Update argoCD test

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau 2021-09-09 13:03:07 +02:00 committed by Sam Alba
parent a73b34d096
commit 2a91ae1d80
5 changed files with 143 additions and 98 deletions

View File

@ -144,13 +144,24 @@ jobs:
- name: Provision Localstack AWS resources - name: Provision Localstack AWS resources
env: env:
AWS_ACCESS_KEY_ID: test AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-2 AWS_DEFAULT_REGION: us-east-2
run: | run: |
aws --endpoint-url=http://localhost:4566 s3 mb s3://dagger-ci aws --endpoint-url=http://localhost:4566 s3 mb s3://dagger-ci
aws --endpoint-url=http://localhost:4566 ecr create-repository --repository-name dagger-ci aws --endpoint-url=http://localhost:4566 ecr create-repository --repository-name dagger-ci
- name: Setup ArgoCD infra
run: |
make install
dagger -w universe -e argocd-infra input text TestKubeconfig -f "$HOME"/.kube/config
dagger -w universe -e dagger-infra up
# Expose Argo API
kubectl port-forward svc/argocd-server -n argocd 8080:443 &
curl localhost:8080
continue-on-error: true
- name: Universe Test - name: Universe Test
run: | run: |
make universe-test make universe-test

View File

@ -2,8 +2,10 @@ plan:
package: ./argocd/tests package: ./argocd/tests
name: argocd name: argocd
inputs: inputs:
TestConfig.argocdConfig.server:
text: localhost:8080
TestConfig.argocdConfig.token: TestConfig.argocdConfig.token:
secret: ENC[AES256_GCM,data:N7hA,iv:7gqCkackbGFXXBmTI+7eKq5OWSWttOt33vr9IwvN6wQ=,tag:yoBj8vEQv3b9lQJg2Ht51w==,type:str] secret: ENC[AES256_GCM,data:TC8wCWyJ+yTkAQXBLLioVDUm4YfkMMgHEzcxyRBr/uwOErEYAWDE539dahcPclQYW/Ds7UVQIv+PMS+43zXSqIv5lde842IhOEIZwemCGnWrGy2yBC566WCYPxU16k76MzslwhJrYGDi4GF4zlIyvtVO6AbviumZqGT+wAq4/Z6KZ2CQTDWNf42ise2orGNsBTj7jqpazLO34A+Wt9USW/cJrSqU+BtAjGkoLZW65iGJ8ui8RdADxw5/A0rkdJaoN4mnSUi7yARpcmTdQBdo33385csTxxqy8oWw7OR4itUfzzWKbOprQph/EeEtxMtPAuHOB/9As/6dvIGcynwxPjw=,iv:xAb0eF1lCmNoaE9Tzfnq2uLB647DK2Cat2BZTPn272s=,tag:D2mfkvEAzVi34y7WYSg7JQ==,type:str]
sops: sops:
kms: [] kms: []
gcp_kms: [] gcp_kms: []
@ -19,8 +21,8 @@ sops:
WG5JdHlKYUlnZnZlMVNIRjczSld5ek0KF0z0UqtoGcYFFeOyMwIDAY1pyKosaOii WG5JdHlKYUlnZnZlMVNIRjczSld5ek0KF0z0UqtoGcYFFeOyMwIDAY1pyKosaOii
IVqsMSYfj4+vz7mRd8HoXoSiSnuc7mLJek/izsdZtYUTfD/QnTC71Q== IVqsMSYfj4+vz7mRd8HoXoSiSnuc7mLJek/izsdZtYUTfD/QnTC71Q==
-----END AGE ENCRYPTED FILE----- -----END AGE ENCRYPTED FILE-----
lastmodified: "2021-08-16T14:41:25Z" lastmodified: "2021-09-09T09:31:30Z"
mac: ENC[AES256_GCM,data:IGmsWqxTDcWRjAgGQbQ5s5Ip1FrTj3ncqpWpdW/HXYp2DqA1SMQ1aH3whJ9JcxlBALWzc0jI4LXuPS+wxy5zrSC/Syp6bt3hYyo7DRsPMpPozm2q26hbGFPDAEXRF5K1+ZHRQ+DnuKecQJuQVz4UNZQg1HTsebnDgZ+D9OHMaek=,iv:AFWorUNhkwxR6R7ilttnJHuWeohsgHsc6NIZPtM3nr4=,tag:kXrm1i09+bvuFAaZqFvNKA==,type:str] mac: ENC[AES256_GCM,data:khUMYQdGj8qwNd7TZa2TPJIeOD9WjOn6LpNhqnZ2VZPOHWzre56MSytBS65h2bqgB5ljaYOM8qR8qc6UzSFhcNOBaAKofOYfuD1Zy6BcjNzNbJ9wvQE9qvT5o25VHsLk+fNhJt04wNdGdWjPuJNJrTTGLj82CXKCUPGyxvV72Pg=,iv:ut+MuwUELE+xu+I1G6NmqFrxu39++2pr96SHShQ5scI=,tag:5Fa6WPRo7R9UN5L7ankYzA==,type:str]
pgp: [] pgp: []
encrypted_suffix: secret encrypted_suffix: secret
version: 3.7.1 version: 3.7.1

View File

@ -1,19 +1,18 @@
package app package argocd
import ( import (
"alpha.dagger.io/argocd"
"alpha.dagger.io/dagger" "alpha.dagger.io/dagger"
"alpha.dagger.io/os" "alpha.dagger.io/os"
) )
TestConfig: argocdConfig: argocd.#Config & { TestConfig: argocdConfig: #Config & {
version: "v2.0.5" version: dagger.#Input & {*"v2.0.5" | string}
server: "dagger-example-argocd-server.tld" server: dagger.#Input & {*"dagger-example-argocd-server.tld" | string}
token: dagger.#Secret & dagger.#Input token: dagger.#Input & {dagger.#Secret}
} }
TestArgoCD2: os.#Container & { TestArgoCD: os.#Container & {
image: argocd.#CLI & { image: #CLI & {
config: TestConfig.argocdConfig config: TestConfig.argocdConfig
} }
always: true always: true
@ -22,3 +21,8 @@ TestArgoCD2: os.#Container & {
"""# """#
env: VERSION: TestConfig.argocdConfig.version env: VERSION: TestConfig.argocdConfig.version
} }
TestArgoCDStatus: #Status & {
config: TestConfig.argocdConfig
name: "test"
}

View File

@ -81,6 +81,17 @@ skip_unless_local_kube() {
fi fi
} }
# Check if there is a local endpoint.
#
# This is necessary to do test with endpoint.
# Usage:
# skip_unless_endpoint_available "localhost:8080"
skip_unless_endpoint_available() {
local endpoint="$1"
curl "$endpoint"
}
# Cleanup local Localstack instances # Cleanup local Localstack instances
setup_localstack() { setup_localstack() {
if [ "$(curl -s http://localhost:4566)" = '{"status": "running"}' ] && \ if [ "$(curl -s http://localhost:4566)" = '{"status": "running"}' ] && \

View File

@ -1,87 +1,87 @@
# Instead of setup, this runs only once # Instead of setup, this runs only once
setup_file() { setup_file() {
load 'helpers' load 'helpers'
setup_localstack setup_localstack
} }
setup() { setup() {
load 'helpers' load 'helpers'
common_setup common_setup
} }
@test "cue-sanity-check" { @test "cue-sanity-check" {
dagger -e sanity-check up dagger -e sanity-check up
} }
@test "os" { @test "os" {
dagger -e os up dagger -e os up
} }
@test "go" { @test "go" {
dagger -e go up dagger -e go up
} }
@test "js/yarn" { @test "js/yarn" {
dagger -e js-yarn up dagger -e js-yarn up
} }
@test "java/maven" { @test "java/maven" {
dagger -e java-maven up dagger -e java-maven up
} }
@test "alpine" { @test "alpine" {
dagger -e alpine up dagger -e alpine up
} }
@test "netlify" { @test "netlify" {
dagger -e netlify up dagger -e netlify up
} }
@test "git" { @test "git" {
# Fetch repo # Fetch repo
dagger -e git-repo up dagger -e git-repo up
# Commit & push # Commit & push
dagger -e git-commit up dagger -e git-commit up
} }
@test "os.#Container" { @test "os.#Container" {
dagger -e os-container up dagger -e os-container up
} }
@test "aws: ecr" { @test "aws: ecr" {
dagger -e aws-ecr up dagger -e aws-ecr up
} }
@test "aws: ecr/localstack" { @test "aws: ecr/localstack" {
skip_unless_local_localstack skip_unless_local_localstack
dagger -e aws-ecr-localstack up dagger -e aws-ecr-localstack up
} }
@test "aws: s3" { @test "aws: s3" {
dagger -e aws-s3 up dagger -e aws-s3 up
} }
@test "aws: s3/localstack" { @test "aws: s3/localstack" {
skip_unless_local_localstack skip_unless_local_localstack
dagger -e aws-s3-localstack up dagger -e aws-s3-localstack up
} }
@test "aws: eks" { @test "aws: eks" {
dagger -e aws-eks up dagger -e aws-eks up
} }
@test "docker run: local" { @test "docker run: local" {
skip "Not implemented yet + missing inputs leading to failure" skip "Not implemented yet + missing inputs leading to failure"
# dagger -e docker-run-local up # dagger -e docker-run-local up
} }
@test "docker build" { @test "docker build" {
dagger -e docker-build up dagger -e docker-build up
} }
@test "docker push and pull" { @test "docker push and pull" {
@ -96,7 +96,7 @@ setup() {
} }
@test "docker push: multi registry" { @test "docker push: multi registry" {
run dagger -e docker-push-multi-registry up run dagger -e docker-push-multi-registry up
} }
@test "docker push: invalid credential" { @test "docker push: invalid credential" {
@ -106,117 +106,134 @@ setup() {
} }
@test "docker command: ssh" { @test "docker command: ssh" {
dagger -e docker-command-ssh up dagger -e docker-command-ssh up
} }
@test "docker command: ssh with key passphrase" { @test "docker command: ssh with key passphrase" {
dagger -e docker-command-ssh-key-passphrase up dagger -e docker-command-ssh-key-passphrase up
} }
@test "docker command: ssh with wrong key passphrase" { @test "docker command: ssh with wrong key passphrase" {
run dagger -e docker-command-ssh-wrong-key-passphrase up run dagger -e docker-command-ssh-wrong-key-passphrase up
assert_failure assert_failure
} }
@test "docker compose" { @test "docker compose" {
dagger -e docker-compose up dagger -e docker-compose up
} }
@test "docker run: ssh" { @test "docker run: ssh" {
dagger -e docker-run-ssh up dagger -e docker-run-ssh up
} }
@test "kubernetes: deployment" { @test "kubernetes: deployment" {
skip_unless_local_kube skip_unless_local_kube
# Copy deployment to sandbox # Copy deployment to sandbox
copy_to_sandbox kubernetes-deployment kubernetes copy_to_sandbox kubernetes-deployment kubernetes
# Set kubeconfig # Set kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input text TestKubeconfig -f "$HOME"/.kube/config dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input text TestKubeconfig -f "$HOME"/.kube/config
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment up dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment up
# Unset kubeconfig # Unset kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input unset TestKubeconfig dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input unset TestKubeconfig
} }
@test "kubernetes: kustomize" { @test "kubernetes: kustomize" {
dagger -e kubernetes-kustomize up dagger -e kubernetes-kustomize up
} }
@test "kubernetes: helm" { @test "kubernetes: helm" {
skip_unless_local_kube skip_unless_local_kube
# Copy deployment to sandbox # Copy deployment to sandbox
copy_to_sandbox kubernetes-helm kubernetes copy_to_sandbox kubernetes-helm kubernetes
# Set kubeconfig # Set kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input text TestKubeconfig -f "$HOME"/.kube/config dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input text TestKubeconfig -f "$HOME"/.kube/config
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm up dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm up
# Unset kubeconfig # Unset kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input unset TestKubeconfig dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input unset TestKubeconfig
} }
@test "google cloud: gcr" { @test "google cloud: gcr" {
dagger -e google-gcr up dagger -e google-gcr up
} }
@test "google cloud: gcs" { @test "google cloud: gcs" {
dagger -e google-gcs up dagger -e google-gcs up
} }
@test "google cloud: gke" { @test "google cloud: gke" {
dagger -e google-gke up dagger -e google-gke up
} }
@test "google cloud: cloudrun" { @test "google cloud: cloudrun" {
dagger -e google-cloudrun up dagger -e google-cloudrun up
} }
@test "terraform" { @test "terraform" {
# it must fail because of a missing var # it must fail because of a missing var
run dagger -e terraform up run dagger -e terraform up
assert_failure assert_failure
# Copy deployment to sandbox # Copy deployment to sandbox
copy_to_sandbox terraform terraform copy_to_sandbox terraform terraform
# Add the var and try again # Add the var and try again
run dagger -w "$DAGGER_SANDBOX" -e terraform input text TestTerraform.apply.tfvars.input "42" run dagger -w "$DAGGER_SANDBOX" -e terraform input text TestTerraform.apply.tfvars.input "42"
run dagger -w "$DAGGER_SANDBOX" -e terraform up run dagger -w "$DAGGER_SANDBOX" -e terraform up
assert_success assert_success
# ensure the tfvar was passed correctly # ensure the tfvar was passed correctly
run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.input.value -f text run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.input.value -f text
assert_success assert_success
assert_output "42" assert_output "42"
# ensure the random value is always the same # ensure the random value is always the same
# this proves we're effectively using the s3 backend # this proves we're effectively using the s3 backend
run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.random.value -f json run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.random.value -f json
assert_success assert_success
assert_output "36" assert_output "36"
# Unset input # Unset input
run dagger -w "$DAGGER_SANDBOX" -e terraform input unset TestTerraform.apply.tfvars.input run dagger -w "$DAGGER_SANDBOX" -e terraform input unset TestTerraform.apply.tfvars.input
assert_success assert_success
} }
@test "azure-resourcegroup" { @test "azure-resourcegroup" {
skip "Azure CI infra not implemented yet - manually tested and working" skip "Azure CI infra not implemented yet - manually tested and working"
#dagger -e azure-resourcegroup up #dagger -e azure-resourcegroup up
} }
@test "azure-storage" { @test "azure-storage" {
skip "Azure CI infra not implemented yet - manually tested and working" skip "Azure CI infra not implemented yet - manually tested and working"
#dagger -e azure-storage up #dagger -e azure-storage up
} }
@test "argocd" { @test "argocd" {
skip "ArgoCD CI secrets not yet generated - Infra not implemented yet" skip_unless_local_kube
#dagger -e argocd up
# Deploy argoCD infra
# dagger -e argocd-infra input text TestKubeconfig -f "$HOME"/.kube/config
#dagger -e argocd-infra up
# pid=$!
curl localhost:8080
# Kill Pid
#check_pid=$(pgrep "$pid")
#if [ "$pid" -eq "$check_pid" ]; then
# kill "$pid"
#fi
# skip "ArgoCD CI secrets not yet generated - Infra not implemented yet"
# dagger -e argocd input secret TestConfig.argocdConfig.token "$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d && echo)"
# dagger -e argocd up
# Kill forward
# >&2 echo "kill pid"
} }