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

@ -141,16 +141,27 @@ jobs:
run: |
mkdir -p ~/.config/dagger
echo "$DAGGER_AGE_KEY" > ~/.config/dagger/keys.txt
- name: Provision Localstack AWS resources
env:
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-2
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-2
run: |
aws --endpoint-url=http://localhost:4566 s3 mb s3://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
run: |
make universe-test

View File

@ -2,8 +2,10 @@ plan:
package: ./argocd/tests
name: argocd
inputs:
TestConfig.argocdConfig.server:
text: localhost:8080
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:
kms: []
gcp_kms: []
@ -19,8 +21,8 @@ sops:
WG5JdHlKYUlnZnZlMVNIRjczSld5ek0KF0z0UqtoGcYFFeOyMwIDAY1pyKosaOii
IVqsMSYfj4+vz7mRd8HoXoSiSnuc7mLJek/izsdZtYUTfD/QnTC71Q==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-08-16T14:41:25Z"
mac: ENC[AES256_GCM,data:IGmsWqxTDcWRjAgGQbQ5s5Ip1FrTj3ncqpWpdW/HXYp2DqA1SMQ1aH3whJ9JcxlBALWzc0jI4LXuPS+wxy5zrSC/Syp6bt3hYyo7DRsPMpPozm2q26hbGFPDAEXRF5K1+ZHRQ+DnuKecQJuQVz4UNZQg1HTsebnDgZ+D9OHMaek=,iv:AFWorUNhkwxR6R7ilttnJHuWeohsgHsc6NIZPtM3nr4=,tag:kXrm1i09+bvuFAaZqFvNKA==,type:str]
lastmodified: "2021-09-09T09:31:30Z"
mac: ENC[AES256_GCM,data:khUMYQdGj8qwNd7TZa2TPJIeOD9WjOn6LpNhqnZ2VZPOHWzre56MSytBS65h2bqgB5ljaYOM8qR8qc6UzSFhcNOBaAKofOYfuD1Zy6BcjNzNbJ9wvQE9qvT5o25VHsLk+fNhJt04wNdGdWjPuJNJrTTGLj82CXKCUPGyxvV72Pg=,iv:ut+MuwUELE+xu+I1G6NmqFrxu39++2pr96SHShQ5scI=,tag:5Fa6WPRo7R9UN5L7ankYzA==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

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

View File

@ -81,6 +81,17 @@ skip_unless_local_kube() {
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
setup_localstack() {
if [ "$(curl -s http://localhost:4566)" = '{"status": "running"}' ] && \

View File

@ -1,87 +1,87 @@
# Instead of setup, this runs only once
setup_file() {
load 'helpers'
load 'helpers'
setup_localstack
setup_localstack
}
setup() {
load 'helpers'
load 'helpers'
common_setup
common_setup
}
@test "cue-sanity-check" {
dagger -e sanity-check up
dagger -e sanity-check up
}
@test "os" {
dagger -e os up
dagger -e os up
}
@test "go" {
dagger -e go up
dagger -e go up
}
@test "js/yarn" {
dagger -e js-yarn up
dagger -e js-yarn up
}
@test "java/maven" {
dagger -e java-maven up
dagger -e java-maven up
}
@test "alpine" {
dagger -e alpine up
dagger -e alpine up
}
@test "netlify" {
dagger -e netlify up
dagger -e netlify up
}
@test "git" {
# Fetch repo
dagger -e git-repo up
# Fetch repo
dagger -e git-repo up
# Commit & push
dagger -e git-commit up
# Commit & push
dagger -e git-commit up
}
@test "os.#Container" {
dagger -e os-container up
dagger -e os-container up
}
@test "aws: ecr" {
dagger -e aws-ecr up
dagger -e aws-ecr up
}
@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" {
dagger -e aws-s3 up
dagger -e aws-s3 up
}
@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" {
dagger -e aws-eks up
dagger -e aws-eks up
}
@test "docker run: local" {
skip "Not implemented yet + missing inputs leading to failure"
# dagger -e docker-run-local up
skip "Not implemented yet + missing inputs leading to failure"
# dagger -e docker-run-local up
}
@test "docker build" {
dagger -e docker-build up
dagger -e docker-build up
}
@test "docker push and pull" {
@ -96,7 +96,7 @@ setup() {
}
@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" {
@ -106,117 +106,134 @@ setup() {
}
@test "docker command: ssh" {
dagger -e docker-command-ssh up
dagger -e docker-command-ssh up
}
@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" {
run dagger -e docker-command-ssh-wrong-key-passphrase up
assert_failure
run dagger -e docker-command-ssh-wrong-key-passphrase up
assert_failure
}
@test "docker compose" {
dagger -e docker-compose up
dagger -e docker-compose up
}
@test "docker run: ssh" {
dagger -e docker-run-ssh up
dagger -e docker-run-ssh up
}
@test "kubernetes: deployment" {
skip_unless_local_kube
skip_unless_local_kube
# Copy deployment to sandbox
copy_to_sandbox kubernetes-deployment kubernetes
# Copy deployment to sandbox
copy_to_sandbox kubernetes-deployment kubernetes
# Set kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input text TestKubeconfig -f "$HOME"/.kube/config
# Set kubeconfig
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
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input unset TestKubeconfig
# Unset kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input unset TestKubeconfig
}
@test "kubernetes: kustomize" {
dagger -e kubernetes-kustomize up
dagger -e kubernetes-kustomize up
}
@test "kubernetes: helm" {
skip_unless_local_kube
skip_unless_local_kube
# Copy deployment to sandbox
copy_to_sandbox kubernetes-helm kubernetes
# Copy deployment to sandbox
copy_to_sandbox kubernetes-helm kubernetes
# Set kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input text TestKubeconfig -f "$HOME"/.kube/config
# Set kubeconfig
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
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input unset TestKubeconfig
# Unset kubeconfig
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input unset TestKubeconfig
}
@test "google cloud: gcr" {
dagger -e google-gcr up
dagger -e google-gcr up
}
@test "google cloud: gcs" {
dagger -e google-gcs up
dagger -e google-gcs up
}
@test "google cloud: gke" {
dagger -e google-gke up
dagger -e google-gke up
}
@test "google cloud: cloudrun" {
dagger -e google-cloudrun up
dagger -e google-cloudrun up
}
@test "terraform" {
# it must fail because of a missing var
run dagger -e terraform up
assert_failure
# it must fail because of a missing var
run dagger -e terraform up
assert_failure
# Copy deployment to sandbox
copy_to_sandbox terraform terraform
# Copy deployment to sandbox
copy_to_sandbox terraform terraform
# 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 up
assert_success
# 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 up
assert_success
# ensure the tfvar was passed correctly
run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.input.value -f text
assert_success
assert_output "42"
# ensure the tfvar was passed correctly
run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.input.value -f text
assert_success
assert_output "42"
# ensure the random value is always the same
# this proves we're effectively using the s3 backend
run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.random.value -f json
assert_success
assert_output "36"
# ensure the random value is always the same
# this proves we're effectively using the s3 backend
run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.random.value -f json
assert_success
assert_output "36"
# Unset input
run dagger -w "$DAGGER_SANDBOX" -e terraform input unset TestTerraform.apply.tfvars.input
assert_success
# Unset input
run dagger -w "$DAGGER_SANDBOX" -e terraform input unset TestTerraform.apply.tfvars.input
assert_success
}
@test "azure-resourcegroup" {
skip "Azure CI infra not implemented yet - manually tested and working"
#dagger -e azure-resourcegroup up
skip "Azure CI infra not implemented yet - manually tested and working"
#dagger -e azure-resourcegroup up
}
@test "azure-storage" {
skip "Azure CI infra not implemented yet - manually tested and working"
#dagger -e azure-storage up
skip "Azure CI infra not implemented yet - manually tested and working"
#dagger -e azure-storage up
}
@test "argocd" {
skip "ArgoCD CI secrets not yet generated - Infra not implemented yet"
#dagger -e argocd up
skip_unless_local_kube
# 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"
}