From 68a5034df685701af8c6c0ae0186c83327e32536 Mon Sep 17 00:00:00 2001 From: WrenIX Date: Mon, 4 Nov 2024 19:21:19 +0100 Subject: [PATCH] fix(ci): run test for preview - WIP Signed-off-by: WrenIX --- .github/tests/test_job.yaml | 38 +++++++++++++++++++++ .github/tests/test_upload_job.yaml | 26 -------------- .github/workflows/lint-test.yaml | 14 ++++---- charts/nextcloud/test-values/imaginary.yaml | 2 ++ 4 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 .github/tests/test_job.yaml delete mode 100644 .github/tests/test_upload_job.yaml diff --git a/.github/tests/test_job.yaml b/.github/tests/test_job.yaml new file mode 100644 index 00000000..ea830396 --- /dev/null +++ b/.github/tests/test_job.yaml @@ -0,0 +1,38 @@ +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: test-nextcloud + namespace: nextcloud +spec: + template: + metadata: + name: test-nextcloud + spec: + initContainers: + - name: 05-create-nextcloud-file + image: curlimages/curl + command: + - /bin/sh + - -c + - | + curl "https://upload.wikimedia.org/wikipedia/commons/c/cc/Open_Data_stickers.jpg" > test_upload.jpg && \ + curl \ + -w "%{http_code}" \ + -u admin:changeme \ + -T test_upload.jpg \ + "http://nextcloud.nextcloud.svc.cluster.local:8080/remote.php/dav/files/admin/test_upload.jpg" && \ + echo -e "\nTried to uploaded a file, test_upload.jpg, to Nextcloud." + - name: 10-generate-preview + image: curlimages/curl + command: + - /bin/sh + - -c + - | + curl \ + -w "%{http_code}" \ + -u admin:changeme \ + "http://nextcloud.nextcloud.svc.cluster.local:8080/index.php/core/preview.png?file=test_upload.jpg&x=128&y=128&mimeFallback=true&a=0" \ + -o - | grep -c PNG && \ + echo -e "\nTried to get preview." + restartPolicy: Never diff --git a/.github/tests/test_upload_job.yaml b/.github/tests/test_upload_job.yaml deleted file mode 100644 index ec9b9a17..00000000 --- a/.github/tests/test_upload_job.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: create-nextcloud-file - namespace: nextcloud -spec: - template: - metadata: - name: create-nextcloud-file - spec: - containers: - - name: create-nextcloud-file - image: curlimages/curl - command: - - /bin/sh - - -c - - | - echo "testing123" > test_upload.txt && \ - curl \ - -w "%{http_code}" \ - -u admin:changeme \ - -T test_upload.txt \ - "http://nextcloud.nextcloud.svc.cluster.local:8080/remote.php/dav/files/admin/test_upload.txt" && \ - echo -e "\nTried to uploaded a file, test_upload.txt, to Nextcloud." - restartPolicy: Never diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index a5601351..d119adce 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -87,10 +87,12 @@ jobs: # we need to skip the clean up so we can test adding a file helm_args: | --namespace nextcloud --skip-clean-up --helm-extra-set-args "--set=fullnameOverride=nextcloud --set=nextcloud.objectStore.s3.enabled=true --set=nextcloud.objectStore.s3.accessKey=nextcloud --set=nextcloud.objectStore.s3.secretKey=rootpass123 --set=nextcloud.objectStore.s3.host=minio.nextcloud.svc.cluster.local --set=nextcloud.objectStore.s3.port=9000 --set=nextcloud.objectStore.s3.ssl=false --set=nextcloud.objectStore.s3.bucket=nextcloud --set=nextcloud.objectStore.s3.usePathStyle=true --set=image.flavor=fpm --set=nginx.enabled=true --set=nextcloud.host=nextcloud --set=nextcloud.trustedDomains[0]='*'" + test: true # test the helm chart with imaginary - name: Imaginary Enabled - helm_args: --helm-extra-set-args "--values charts/nextcloud/test-values/imaginary.yaml" + helm_args: --namespace nextcloud --skip-clean-up --helm-extra-set-args "--values charts/nextcloud/test-values/imaginary.yaml" + test: true steps: - name: Checkout @@ -142,16 +144,16 @@ jobs: if: steps.list-changed.outputs.changed == 'true' run: ct install --target-branch ${{ github.event.repository.default_branch }} ${{ matrix.test_cases.helm_args }} - - name: Try adding a file to Nextcloud - if: matrix.test_cases.name == 'S3 Enabled as Primary Storage' + - name: Run test for Nextcloud + if: matrix.test_cases.test # applies a kubernetes job that uploads a file and then checks log of finished pod run: | kubectl config set-context --current --namespace=nextcloud && \ - kubectl apply -f ./.github/tests/test_upload_job.yaml --wait=true && \ + kubectl apply -f ./.github/tests/test_job.yaml --wait=true && \ sleep 2 && \ - kubectl wait --for=condition=Complete --timeout=2m job/create-nextcloud-file && \ + kubectl wait --for=condition=Complete --timeout=2m job/test-nextcloud && \ echo "Here's the logs from the job:" && \ - kubectl logs --tail=-1 -f -l batch.kubernetes.io/job-name=create-nextcloud-file && \ + kubectl logs --tail=-1 -f -l batch.kubernetes.io/job-name=test-nextcloud && \ echo "Here's the logs from the nextcloud pod:" && \ kubectl logs -l app.kubernetes.io/name=nextcloud diff --git a/charts/nextcloud/test-values/imaginary.yaml b/charts/nextcloud/test-values/imaginary.yaml index 389a1580..028d3af4 100644 --- a/charts/nextcloud/test-values/imaginary.yaml +++ b/charts/nextcloud/test-values/imaginary.yaml @@ -1,3 +1,5 @@ +fullnameOverride: nextcloud + nextcloud: defaultConfigs: imaginary.config.php: true