diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 525babc..7542dc7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -86,28 +86,12 @@ jobs: version: v0.14.0 kubectl_version: v1.24.0 - name: Install Helm Chart - run: | - helm install agh-e2e testdata/e2e/agh-e2e -n agh-e2e --create-namespace - kubectl config set-context --current --namespace=agh-e2e + run: ./testdata/e2e/bin/install-chart.sh - name: Wait for sync to finish - run: kubectl wait --for=jsonpath='{.status.phase}'=Succeeded pod/adguardhome-sync --timeout=1m + run: ./testdata/e2e/bin/wait-for-sync.sh - name: Show origin Logs - run: | - echo Pod adguardhome-origin logs - kubectl logs adguardhome-origin + run: ./testdata/e2e/bin/show-origin-logs.sh - name: Show Replica Logs - run: | - for pod in $(kubectl get pods -l bakito.net/adguardhome-sync=replica -o name); do - echo Pod "${pod} logs" - kubectl logs ${pod} - ERRORS=$(kubectl logs ${pod} | grep '\[error\]' | wc -l) - echo "Found ${ERRORS} error(s) in log" - echo "----------------------------------------------" - done + run: ./testdata/e2e/bin/show-replica-logs.sh - name: Show Sync Logs - run: | - echo Pod adguardhome-sync logs - kubectl logs adguardhome-sync - ERRORS=$(kubectl logs adguardhome-sync | grep Error | wc -l) - echo "Found ${ERRORS} error(s) in log"; - if [[ "${ERRORS}" != "0" ]]; then exit 1; fi + run: ./testdata/e2e/bin/show-sync-logs.sh diff --git a/Makefile b/Makefile index 9327544..c74e475 100644 --- a/Makefile +++ b/Makefile @@ -64,5 +64,4 @@ kind-create: kind create cluster kind-test: - helm delete agh-e2e -n agh-e2e - helm install agh-e2e testdata/e2e/agh-e2e -n agh-e2e --create-namespace + @./testdata/e2e/bin/install-chart.sh diff --git a/testdata/e2e/agh-e2e/.helmignore b/testdata/e2e/.helmignore similarity index 100% rename from testdata/e2e/agh-e2e/.helmignore rename to testdata/e2e/.helmignore diff --git a/testdata/e2e/agh-e2e/Chart.yaml b/testdata/e2e/Chart.yaml similarity index 100% rename from testdata/e2e/agh-e2e/Chart.yaml rename to testdata/e2e/Chart.yaml diff --git a/testdata/e2e/bin/install-chart.sh b/testdata/e2e/bin/install-chart.sh new file mode 100755 index 0000000..71b8ed9 --- /dev/null +++ b/testdata/e2e/bin/install-chart.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +kubectl config set-context --current --namespace=agh-e2e + +if [[ $(helm list --no-headers -n agh-e2e | grep agh-e2e | wc -l) == "1" ]]; then + helm delete agh-e2e -n agh-e2e --wait +fi +helm install agh-e2e testdata/e2e -n agh-e2e --create-namespace diff --git a/testdata/e2e/bin/show-origin-logs.sh b/testdata/e2e/bin/show-origin-logs.sh new file mode 100755 index 0000000..b6768c2 --- /dev/null +++ b/testdata/e2e/bin/show-origin-logs.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +echo Pod adguardhome-origin logs +kubectl logs adguardhome-origin diff --git a/testdata/e2e/bin/show-replica-logs.sh b/testdata/e2e/bin/show-replica-logs.sh new file mode 100755 index 0000000..b2dd70d --- /dev/null +++ b/testdata/e2e/bin/show-replica-logs.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +for pod in $(kubectl get pods -l bakito.net/adguardhome-sync=replica -o name); do + echo Pod "${pod} logs" + kubectl logs ${pod} + ERRORS=$(kubectl logs ${pod} | grep '\[error\]' | wc -l) + echo "Found ${ERRORS} error(s) in log" + echo "----------------------------------------------" +done diff --git a/testdata/e2e/bin/show-sync-logs.sh b/testdata/e2e/bin/show-sync-logs.sh new file mode 100755 index 0000000..e0959ac --- /dev/null +++ b/testdata/e2e/bin/show-sync-logs.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +echo Pod adguardhome-sync logs +kubectl logs adguardhome-sync +ERRORS=$(kubectl logs adguardhome-sync | grep Error | wc -l) +echo "Found ${ERRORS} error(s) in log"; +if [[ "${ERRORS}" != "0" ]]; then exit 1; fi diff --git a/testdata/e2e/bin/wait-for-agh-pods.sh b/testdata/e2e/bin/wait-for-agh-pods.sh new file mode 100755 index 0000000..81f9ba6 --- /dev/null +++ b/testdata/e2e/bin/wait-for-agh-pods.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +echo "wait for adguardhome pods" +for pod in $(kubectl get pods -l bakito.net/adguardhome-sync -o name); do + kubectl wait --for condition=Ready ${pod} --timeout=30s +done diff --git a/testdata/e2e/bin/wait-for-sync.sh b/testdata/e2e/bin/wait-for-sync.sh new file mode 100755 index 0000000..5bdfa38 --- /dev/null +++ b/testdata/e2e/bin/wait-for-sync.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +kubectl wait --for=jsonpath='{.status.phase}'=Succeeded pod/adguardhome-sync --timeout=1m diff --git a/testdata/e2e/pod-adguardhome-sync.yaml b/testdata/e2e/pod-adguardhome-sync.yaml deleted file mode 100644 index ec618e9..0000000 --- a/testdata/e2e/pod-adguardhome-sync.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: adguardhome-sync -spec: - containers: - - name: adguardhome-sync - image: ghcr.io/bakito/adguardhome-sync:main - command: - - /opt/go/adguardhome-sync - - run - envFrom: - - configMapRef: - name: sync-conf - restartPolicy: Never diff --git a/testdata/e2e/agh-e2e/templates/configmap-origin.yaml b/testdata/e2e/templates/configmap-origin.yaml similarity index 100% rename from testdata/e2e/agh-e2e/templates/configmap-origin.yaml rename to testdata/e2e/templates/configmap-origin.yaml diff --git a/testdata/e2e/agh-e2e/templates/configmap-sync.yaml b/testdata/e2e/templates/configmap-sync.yaml similarity index 100% rename from testdata/e2e/agh-e2e/templates/configmap-sync.yaml rename to testdata/e2e/templates/configmap-sync.yaml diff --git a/testdata/e2e/agh-e2e/templates/pod-adguardhome-origin.yaml b/testdata/e2e/templates/pod-adguardhome-origin.yaml similarity index 100% rename from testdata/e2e/agh-e2e/templates/pod-adguardhome-origin.yaml rename to testdata/e2e/templates/pod-adguardhome-origin.yaml diff --git a/testdata/e2e/agh-e2e/templates/pod-adguardhome-replica.yaml b/testdata/e2e/templates/pod-adguardhome-replica.yaml similarity index 100% rename from testdata/e2e/agh-e2e/templates/pod-adguardhome-replica.yaml rename to testdata/e2e/templates/pod-adguardhome-replica.yaml diff --git a/testdata/e2e/agh-e2e/templates/pod-adguardhome-sync.yaml b/testdata/e2e/templates/pod-adguardhome-sync.yaml similarity index 69% rename from testdata/e2e/agh-e2e/templates/pod-adguardhome-sync.yaml rename to testdata/e2e/templates/pod-adguardhome-sync.yaml index 44f0954..b725044 100644 --- a/testdata/e2e/agh-e2e/templates/pod-adguardhome-sync.yaml +++ b/testdata/e2e/templates/pod-adguardhome-sync.yaml @@ -12,11 +12,7 @@ spec: - /bin/bash - -c - | - #!/bin/bash - echo "wait for adguardhome pods" - for pod in $(kubectl get pods -l bakito.net/adguardhome-sync -o name); do - kubectl wait --for condition=Ready ${pod} --timeout=30s - done + {{- .Files.Get "bin/wait-for-agh-pods.sh" | nindent 10}} containers: - name: adguardhome-sync image: ghcr.io/bakito/adguardhome-sync:main diff --git a/testdata/e2e/agh-e2e/templates/rbac.yaml b/testdata/e2e/templates/rbac.yaml similarity index 100% rename from testdata/e2e/agh-e2e/templates/rbac.yaml rename to testdata/e2e/templates/rbac.yaml diff --git a/testdata/e2e/agh-e2e/templates/service-origin.yaml b/testdata/e2e/templates/service-origin.yaml similarity index 100% rename from testdata/e2e/agh-e2e/templates/service-origin.yaml rename to testdata/e2e/templates/service-origin.yaml diff --git a/testdata/e2e/agh-e2e/templates/service-replica.yaml b/testdata/e2e/templates/service-replica.yaml similarity index 100% rename from testdata/e2e/agh-e2e/templates/service-replica.yaml rename to testdata/e2e/templates/service-replica.yaml diff --git a/testdata/e2e/agh-e2e/values.yaml b/testdata/e2e/values.yaml similarity index 100% rename from testdata/e2e/agh-e2e/values.yaml rename to testdata/e2e/values.yaml