From dc77117d71f73c7dc721a4cae5748ef54c080780 Mon Sep 17 00:00:00 2001 From: jessebot Date: Wed, 24 Jul 2024 15:42:52 +0200 Subject: [PATCH] add a k8s Job to test uploading a file to nextcloud which should be using S3 Signed-off-by: jessebot --- .github/minio_test_values.yaml | 11 +++++++++++ .github/test_upload_job.yaml | 24 ++++++++++++++++++++++++ .github/workflows/lint-test.yaml | 22 +++++++++++++++++----- 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 .github/test_upload_job.yaml diff --git a/.github/minio_test_values.yaml b/.github/minio_test_values.yaml index ab04ea17..24a5587b 100644 --- a/.github/minio_test_values.yaml +++ b/.github/minio_test_values.yaml @@ -1,15 +1,26 @@ +## minio helm chart values for use in ci tests: +# https://github.com/minio/minio/blob/master/helm/minio/values.yaml + # make service name predictable fullnameOverride: minio ## minio mode, i.e. standalone or distributed mode: standalone +## Configure resource requests and limits +## ref: http://kubernetes.io/docs/user-guide/compute-resources/ +## +resources: + requests: + memory: 1Gi + ## Enable persistence using Persistent Volume Claims ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ ## persistence: enabled: false +# default credentials rootUser: nextcloud rootPassword: rootpass123 diff --git a/.github/test_upload_job.yaml b/.github/test_upload_job.yaml new file mode 100644 index 00000000..c0c38cf6 --- /dev/null +++ b/.github/test_upload_job.yaml @@ -0,0 +1,24 @@ +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: create-nextcloud-file +spec: + template: + metadata: + name: create-nextcloud-file + spec: + containers: + - name: create-nextcloud-file + image: alpine + command: + - | + /bin/sh + -c + echo "testing123" > test_upload.txt && \ + curl \ + -u nextcloud:changeme \ + -T test_upload.txt \ + "https://nextcloud.nextcloud.cluster.local.svc/nextcloud/remote.php/dav/files/nextcloud/test_upload.txt" && \ + echo "success" + restartPolicy: Never diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index dad5d392..45824f22 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -85,7 +85,7 @@ jobs: # test the helm chart with s3 as the primary storage - name: S3 Enabled as Primary Storage # we need to skip the clean up so we can test adding a file - helm_args: '--skip-clean-up --helm-extra-set-args "--set=nextcloud.objectStore.s3.enabled=true --set-nextcloud.objectStore.s3.accessKey=nextcloud --set-nextcloud.objectStore.s3.secretKey=rootpass123 --set-nextcloud.objectStore.s3.host=minio.minio.cluster.local.svc --set-nextcloud.objectStore.s3.port=9000 --set-nextcloud.objectStore.s3.bucket=nextcloud" && echo "Success 🎉"' + helm_args: '--namespace nextcloud --skip-clean-up --helm-extra-set-args "--set=nextcloud.objectStore.s3.enabled=true --set-nextcloud.objectStore.s3.accessKey=nextcloud --set-nextcloud.objectStore.s3.secretKey=rootpass123 --set-nextcloud.objectStore.s3.host=minio.minio.cluster.local.svc --set-nextcloud.objectStore.s3.port=9000 --set-nextcloud.objectStore.s3.bucket=nextcloud" && echo "Success 🎉"' steps: - name: Checkout @@ -119,24 +119,36 @@ jobs: - name: Install MinIO for testing S3 as Primary Storage if: matrix.test_cases.name == 'S3 Enabled as Primary Storage' - # installs minio community helm chart here: https://github.com/minio/minio/tree/master/helm/minio + # installs minio community helm chart here: + # https://github.com/minio/minio/tree/master/helm/minio run: | - helm repo add minio https://charts.min.io/ + helm repo add minio https://charts.min.io/ && \ helm install minio \ --namespace minio \ --create-namespace \ + --wait \ + --wait-for-jobs \ + --timeout 2m0s \ --values .github/minio_test_values.yaml \ - minio/minio + minio/minio && \ + kubectl create namespace nextcloud - name: Run chart-testing (install ${{ matrix.test_cases.name }}) id: install 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' + # applies a kubernetes job that uploads a file and then checks log of finished pod + run: | + kubectl apply -f ./.github/test_upload_job.yaml --wait=true && \ + kubectl logs batch.kubernetes.io/job-name=test-file-upload + summary: runs-on: ubuntu-latest-low needs: [changes, test] if: always() steps: - name: Summary - run: if ${{ needs.changes.outputs.src != 'false' && needs.run-tests.result != 'success' }}; then exit 1; fi + run: if ${{ needs.changes.outputs.src != 'false' && needs.test.result != 'success' }}; then exit 1; fi