From b6fc01e4868497e475b3f04b5763403f7dca3179 Mon Sep 17 00:00:00 2001 From: Thomas Schuetz Date: Mon, 15 May 2023 10:48:55 +0200 Subject: [PATCH] chore: add first e2e tests Signed-off-by: Thomas Schuetz --- .github/workflows/e2e-tests.yaml | 62 +++++++++++++++++++++++++++ .gitignore | 1 + charts/glasskube-operator/Chart.yaml | 4 +- charts/glasskube-operator/values.yaml | 2 +- e2e/Makefile | 3 ++ e2e/kuttl/kuttl-test.yaml | 7 +++ e2e/kuttl/test/00-assert.yaml | 27 ++++++++++++ e2e/kuttl/test/00-install.yaml | 6 +++ 8 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/e2e-tests.yaml create mode 100644 e2e/Makefile create mode 100644 e2e/kuttl/kuttl-test.yaml create mode 100644 e2e/kuttl/test/00-assert.yaml create mode 100644 e2e/kuttl/test/00-install.yaml diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml new file mode 100644 index 00000000..d7bea0d2 --- /dev/null +++ b/.github/workflows/e2e-tests.yaml @@ -0,0 +1,62 @@ +name: Test Scenarios +on: + push: + branches: + - 'main' + pull_request: + branches: + - 'main' + +env: + # renovate: datasource=github-tags depName=kudobuilder/kuttl + KUTTL_VERSION: "v0.15.0" + +defaults: + run: + shell: bash + +jobs: + run-scenarios: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v3 + + - uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4 + with: + python-version: '3.9' + check-latest: true + + - name: Download KUTTL + run: | + curl -fL https://github.com/kudobuilder/kuttl/releases/download/${{ env.KUTTL_VERSION }}/kubectl-kuttl_${KUTTL_VERSION#v}_linux_x86_64 -o kubectl-kuttl + chmod +x kubectl-kuttl + mv kubectl-kuttl /usr/local/bin + + - name: Set up chart-testing + uses: helm/chart-testing-action@e8788873172cb653a90ca2e819d79d65a66d4e76 # v2.4.0 + + - name: Cleanup Chart.lock for test + run: rm charts/glasskube-operator/Chart.lock + + - name: Run chart-testing (lint) + run: ct lint --validate-maintainers=false --check-version-increment=false --chart-dirs charts --target-branch ${{ github.event.repository.default_branch }} --all + + - name: Create kind cluster + uses: helm/kind-action@d8ccf8fb623ce1bb360ae2f45f323d9d5c5e9f00 # v1.5.0 + + - name: Cleanup Chart.lock for test + run: rm charts/glasskube-operator/Chart.lock + + - name: Run chart-testing (install) + run: > + ct install --chart-dirs charts --skip-clean-up --target-branch ${{ github.event.repository.default_branch }} --all + --helm-extra-set-args '--set=cert-manager.enabled=true --set=mariadb-operator.enabled=true --set=cloudnative-pg.enabled=true --set=kube-prometheus-stack.enabled=true' + + - name: Run Tests + working-directory: e2e + run: make test diff --git a/.gitignore b/.gitignore index 38414c9e..01a39496 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.gradle/ /**/build/ /.idea/ +/e2e/kubeconfig /charts/*/charts/ diff --git a/charts/glasskube-operator/Chart.yaml b/charts/glasskube-operator/Chart.yaml index c36f34ae..2dfccdf4 100644 --- a/charts/glasskube-operator/Chart.yaml +++ b/charts/glasskube-operator/Chart.yaml @@ -9,12 +9,12 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: "0.6.3" # x-release-please-version +version: "0.6.3" # x-release-please-version # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.6.3" # x-release-please-version +appVersion: "0.6.3" # x-release-please-version dependencies: - name: cert-manager condition: cert-manager.enabled diff --git a/charts/glasskube-operator/values.yaml b/charts/glasskube-operator/values.yaml index 22bfc7bb..ca8f68c9 100644 --- a/charts/glasskube-operator/values.yaml +++ b/charts/glasskube-operator/values.yaml @@ -5,7 +5,7 @@ operator: image: repository: glasskube/operator - tag: "" # defaults to Chart.appVersion if unspecified + tag: "" # defaults to Chart.appVersion if unspecified replicaCount: 1 resources: limits: diff --git a/e2e/Makefile b/e2e/Makefile new file mode 100644 index 00000000..954cc57b --- /dev/null +++ b/e2e/Makefile @@ -0,0 +1,3 @@ +.PHONY: test +test: + kubectl kuttl test --start-kind=false ./kuttl --config=./kuttl/kuttl-test.yaml diff --git a/e2e/kuttl/kuttl-test.yaml b/e2e/kuttl/kuttl-test.yaml new file mode 100644 index 00000000..887efc5d --- /dev/null +++ b/e2e/kuttl/kuttl-test.yaml @@ -0,0 +1,7 @@ +apiVersion: kuttl.dev/v1 +kind: TestSuite +testDirs: + - ./test +timeout: 400 +skipDelete: true +namespace: default diff --git a/e2e/kuttl/test/00-assert.yaml b/e2e/kuttl/test/00-assert.yaml new file mode 100644 index 00000000..51d0579e --- /dev/null +++ b/e2e/kuttl/test/00-assert.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: matomo-matomo + labels: + app: matomo + app.kubernetes.io/managed-by: glasskube-operator + glasskube.eu/Matomo: matomo +status: + availableReplicas: 1 + readyReplicas: 1 + replicas: 1 + updatedReplicas: 1 + +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: matomo-matomo-mariadb +status: + availableReplicas: 1 + currentReplicas: 1 + readyReplicas: 1 + replicas: 1 + updatedReplicas: 1 + diff --git a/e2e/kuttl/test/00-install.yaml b/e2e/kuttl/test/00-install.yaml new file mode 100644 index 00000000..d1a625e1 --- /dev/null +++ b/e2e/kuttl/test/00-install.yaml @@ -0,0 +1,6 @@ +apiVersion: "glasskube.eu/v1alpha1" +kind: Matomo +metadata: + name: matomo +spec: + host: matomo.minikube