Skip to content

Commit

Permalink
fix(ci): run test for preview - WIP
Browse files Browse the repository at this point in the history
Signed-off-by: WrenIX <[email protected]>
  • Loading branch information
wrenix committed Nov 12, 2024
1 parent 1097e47 commit 1d58fc3
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 35 deletions.
55 changes: 55 additions & 0 deletions .github/tests/test_job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
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
- |
set -e
echo "download image:"
curl -s "https://upload.wikimedia.org/wikipedia/commons/d/df/Open_data.png" -o test_upload.png
echo "upload to nextcloud:"
curl \
-s \
-w "%{http_code}" \
-u admin:changeme \
-T test_upload.png \
"http://nextcloud.nextcloud.svc.cluster.local:8080/remote.php/dav/files/admin/test_upload.png"
echo "done"
- name: 10-generate-preview
image: curlimages/curl
command:
- /bin/sh
- -c
- |
apk add file
set -e
echo "fetch preview:"
curl \
-s \
-w "%{http_code}" \
-u admin:changeme \
"http://nextcloud.nextcloud.svc.cluster.local:8080/index.php/core/preview.png?file=test_upload.png&x=128&y=128&mimeFallback=true&a=0" \
-o - | file -
echo "done"
containers:
- name: final
image: curlimages/curl
command:
- /bin/sh
- -c
- |
set -e
echo "All tests run successfull (initContainer in given order)"
restartPolicy: Never
26 changes: 0 additions & 26 deletions .github/tests/test_upload_job.yaml

This file was deleted.

22 changes: 13 additions & 9 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "--create-namespace --values charts/nextcloud/test-values/imaginary.yaml"
test: true

steps:
- name: Checkout
Expand Down Expand Up @@ -142,18 +144,20 @@ 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: |
EXIT=0
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 && \
echo "Here's the logs from the job:" && \
kubectl logs --tail=-1 -f -l batch.kubernetes.io/job-name=create-nextcloud-file && \
echo "Here's the logs from the nextcloud pod:" && \
kubectl logs -l app.kubernetes.io/name=nextcloud
kubectl wait --for=condition=Complete --timeout=2m job/test-nextcloud || EXIT=1
echo "Here's the logs from the job:"
kubectl logs --ignore-errors --prefix --tail=-1 --all-containers=true -l batch.kubernetes.io/job-name=test-nextcloud
echo "Here's the logs from the nextcloud pod:"
kubectl logs --ignore-errors --prefix -l app.kubernetes.io/name=nextcloud
exit $EXIT
summary:
runs-on: ubuntu-latest-low
Expand Down
5 changes: 5 additions & 0 deletions charts/nextcloud/test-values/imaginary.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
fullnameOverride: nextcloud

nextcloud:
host: nextcloud
trustedDomains:
- '*'
defaultConfigs:
imaginary.config.php: true

Expand Down

0 comments on commit 1d58fc3

Please sign in to comment.