From 1c88dd2d83acadd14265c45715b4a0bd2f2eb593 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Fri, 10 Nov 2023 19:41:41 +0100 Subject: [PATCH 01/17] - added first version with helm test --- .drone.star | 12 +++++++++++- charts/ocis/ci/deployment-values.yaml | 10 +++++----- .../ocis/templates/tests/test-connection.yaml | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 charts/ocis/templates/tests/test-connection.yaml diff --git a/.drone.star b/.drone.star index 1ad97d6b5..774b5bbad 100644 --- a/.drone.star +++ b/.drone.star @@ -205,7 +205,7 @@ def deployments(ctx): "kind": "pipeline", "type": "docker", "name": "k3d", - "steps": wait(ctx) + install(ctx) + showPodsAfterInstall(ctx), + "steps": wait(ctx) + install(ctx) + showPodsAfterInstall(ctx) + helmtest(ctx), "services": [ { "name": "k3d", @@ -268,3 +268,13 @@ def showPodsAfterInstall(config): "kubectl get ingress", ], }] + +def helmtest(ctx): + return [{ + "name": "helm-test", + "image": "docker.io/owncloudci/alpine", + "commands": [ + "export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", + "helm test --atomic --timeout 5m0s ocis", + ], + }] diff --git a/charts/ocis/ci/deployment-values.yaml b/charts/ocis/ci/deployment-values.yaml index cde53cc3e..42adc4375 100644 --- a/charts/ocis/ci/deployment-values.yaml +++ b/charts/ocis/ci/deployment-values.yaml @@ -1,15 +1,15 @@ --- ingress: enabled: true - ingressClassName: nginx - annotations: - nginx.ingress.kubernetes.io/proxy-body-size: 1024m + #ingressClassName: nginx + #annotations: + # nginx.ingress.kubernetes.io/proxy-body-size: 1024m tls: - secretName: chart-example-tls hosts: - - ocis.owncloud.test + - host.k3d.internal -externalDomain: ocis.owncloud.test +externalDomain: host.k3d.internal logging: level: debug diff --git a/charts/ocis/templates/tests/test-connection.yaml b/charts/ocis/templates/tests/test-connection.yaml new file mode 100644 index 000000000..ca695244d --- /dev/null +++ b/charts/ocis/templates/tests/test-connection.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "ocis-test-connection" + labels: + {{- include "ocis.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + hostAliases: + - ip: "127.0.0.1" + hostnames: + - "host.k3d.internal" + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['https://{{ .Values.externalDomain }}/'] + restartPolicy: Never From 735ec90a80a44aa2d569ef3717f9024ced60cf67 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Fri, 10 Nov 2023 19:48:57 +0100 Subject: [PATCH 02/17] - switch busybox wget to curl - removed hostAliases --- charts/ocis/templates/tests/test-connection.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/charts/ocis/templates/tests/test-connection.yaml b/charts/ocis/templates/tests/test-connection.yaml index ca695244d..e65fa554d 100644 --- a/charts/ocis/templates/tests/test-connection.yaml +++ b/charts/ocis/templates/tests/test-connection.yaml @@ -7,13 +7,9 @@ metadata: annotations: "helm.sh/hook": test spec: - hostAliases: - - ip: "127.0.0.1" - hostnames: - - "host.k3d.internal" containers: - - name: wget - image: busybox - command: ['wget'] - args: ['https://{{ .Values.externalDomain }}/'] + - name: curl + image: curlimages/curl + command: ['curl'] + args: ['-k','https://{{ .Values.externalDomain }}/'] restartPolicy: Never From 1e62b43ed9beecd70a6ef09b3f0c08fbb3056379 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Fri, 10 Nov 2023 19:52:27 +0100 Subject: [PATCH 03/17] - switch to busybox and wget again --- charts/ocis/templates/tests/test-connection.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/ocis/templates/tests/test-connection.yaml b/charts/ocis/templates/tests/test-connection.yaml index e65fa554d..4a31c1cf8 100644 --- a/charts/ocis/templates/tests/test-connection.yaml +++ b/charts/ocis/templates/tests/test-connection.yaml @@ -8,8 +8,8 @@ metadata: "helm.sh/hook": test spec: containers: - - name: curl - image: curlimages/curl - command: ['curl'] - args: ['-k','https://{{ .Values.externalDomain }}/'] + - name: wget + image: {{ .Values.initContainerImage.repository }} + command: ['wget'] + args: ['https://{{ .Values.externalDomain }}/'] restartPolicy: Never From dbb2927c2c6c1aff71f571b2a2cabbf507dfc25b Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Fri, 10 Nov 2023 19:57:19 +0100 Subject: [PATCH 04/17] - use values --- charts/ocis/templates/tests/test-connection.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/ocis/templates/tests/test-connection.yaml b/charts/ocis/templates/tests/test-connection.yaml index 4a31c1cf8..fef2b3a04 100644 --- a/charts/ocis/templates/tests/test-connection.yaml +++ b/charts/ocis/templates/tests/test-connection.yaml @@ -9,7 +9,8 @@ metadata: spec: containers: - name: wget - image: {{ .Values.initContainerImage.repository }} + {{- include "ocis.initContainerImage" $ | nindent 6 }} command: ['wget'] args: ['https://{{ .Values.externalDomain }}/'] + {{- include "ocis.containerSecurityContext" . | nindent 6 }} restartPolicy: Never From e12098cc75bf81d7effb5c2110dc26bafb86bfba Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Fri, 10 Nov 2023 20:02:59 +0100 Subject: [PATCH 05/17] - add resource limitation --- charts/ocis/templates/tests/test-connection.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/ocis/templates/tests/test-connection.yaml b/charts/ocis/templates/tests/test-connection.yaml index fef2b3a04..9ee40b65e 100644 --- a/charts/ocis/templates/tests/test-connection.yaml +++ b/charts/ocis/templates/tests/test-connection.yaml @@ -13,4 +13,5 @@ spec: command: ['wget'] args: ['https://{{ .Values.externalDomain }}/'] {{- include "ocis.containerSecurityContext" . | nindent 6 }} + resources: {{ toYaml .jobResources | nindent 8 }} restartPolicy: Never From 3a0fb1b35e9c8c057d0a59b2f6ee18fd66337aa7 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Fri, 10 Nov 2023 20:08:00 +0100 Subject: [PATCH 06/17] - removed atomic from helm test --- .drone.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.star b/.drone.star index 774b5bbad..e2259d442 100644 --- a/.drone.star +++ b/.drone.star @@ -275,6 +275,6 @@ def helmtest(ctx): "image": "docker.io/owncloudci/alpine", "commands": [ "export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", - "helm test --atomic --timeout 5m0s ocis", + "helm test --timeout 5m0s ocis", ], }] From 1870d38068f6de63c0b1ad6d6acfc7465c35cc57 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Fri, 10 Nov 2023 20:13:37 +0100 Subject: [PATCH 07/17] - add log output to helm test --- .drone.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.star b/.drone.star index e2259d442..f47b7a64d 100644 --- a/.drone.star +++ b/.drone.star @@ -275,6 +275,6 @@ def helmtest(ctx): "image": "docker.io/owncloudci/alpine", "commands": [ "export KUBECONFIG=kubeconfig-$${DRONE_BUILD_NUMBER}.yaml", - "helm test --timeout 5m0s ocis", + "helm test --timeout 5m0s ocis --logs", ], }] From 15eb442a2f984a33fdb0259f33b6b073e316e61f Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Mon, 13 Nov 2023 09:26:50 +0100 Subject: [PATCH 08/17] - test to access k3d --- ci/k3d-drone.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ci/k3d-drone.yaml b/ci/k3d-drone.yaml index 9dbc9cbb9..3507fa150 100644 --- a/ci/k3d-drone.yaml +++ b/ci/k3d-drone.yaml @@ -3,19 +3,19 @@ kind: Simple metadata: name: drone servers: 1 -image: rancher/k3s:v1.25.0-k3s1 +image: rancher/k3s:v1.27.4-k3s1 options: k3s: extraArgs: - arg: --tls-san=k3d nodeFilters: - server:* - - arg: --disable=servicelb + - arg: --disable=metrics-server nodeFilters: - server:* - - arg: --disable=metrics-server + - arg: --port="80:80@loadbalancer" nodeFilters: - server:* - - arg: --disable=traefik + - arg: --port="443:443@loadbalancer" nodeFilters: - - server:* \ No newline at end of file + - server:* From 002f396d148727f61156fd30105eabb9bb5dbe51 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Mon, 13 Nov 2023 09:45:28 +0100 Subject: [PATCH 09/17] - next test --- ci/k3d-drone.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ci/k3d-drone.yaml b/ci/k3d-drone.yaml index 3507fa150..b3d8020e5 100644 --- a/ci/k3d-drone.yaml +++ b/ci/k3d-drone.yaml @@ -1,4 +1,4 @@ -apiVersion: k3d.io/v1alpha4 +apiVersion: k3d.io/v1alpha5 kind: Simple metadata: name: drone @@ -13,9 +13,3 @@ options: - arg: --disable=metrics-server nodeFilters: - server:* - - arg: --port="80:80@loadbalancer" - nodeFilters: - - server:* - - arg: --port="443:443@loadbalancer" - nodeFilters: - - server:* From 1b046477266de52447f1dba316ae752369908a33 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Mon, 13 Nov 2023 09:58:43 +0100 Subject: [PATCH 10/17] - added portforwarding --- ci/k3d-drone.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/k3d-drone.yaml b/ci/k3d-drone.yaml index b3d8020e5..066a32641 100644 --- a/ci/k3d-drone.yaml +++ b/ci/k3d-drone.yaml @@ -4,6 +4,10 @@ metadata: name: drone servers: 1 image: rancher/k3s:v1.27.4-k3s1 +ports: + - port: 443:443 + nodeFilters: + - loadbalancer options: k3s: extraArgs: From 93a71394f575e745e6b71d11e808c8c4ae7f4da0 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Mon, 13 Nov 2023 10:04:05 +0100 Subject: [PATCH 11/17] - disabled wget security check --- charts/ocis/templates/tests/test-connection.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/ocis/templates/tests/test-connection.yaml b/charts/ocis/templates/tests/test-connection.yaml index 9ee40b65e..bb0332853 100644 --- a/charts/ocis/templates/tests/test-connection.yaml +++ b/charts/ocis/templates/tests/test-connection.yaml @@ -11,7 +11,7 @@ spec: - name: wget {{- include "ocis.initContainerImage" $ | nindent 6 }} command: ['wget'] - args: ['https://{{ .Values.externalDomain }}/'] + args: ['--no-check-certificate', 'https://{{ .Values.externalDomain }}/'] {{- include "ocis.containerSecurityContext" . | nindent 6 }} resources: {{ toYaml .jobResources | nindent 8 }} restartPolicy: Never From 55b3920af18b2fa32c6e6cf6579119f5b8396076 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Mon, 13 Nov 2023 10:13:15 +0100 Subject: [PATCH 12/17] - verbose output for wget --- charts/ocis/templates/tests/test-connection.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/ocis/templates/tests/test-connection.yaml b/charts/ocis/templates/tests/test-connection.yaml index bb0332853..c500f1e48 100644 --- a/charts/ocis/templates/tests/test-connection.yaml +++ b/charts/ocis/templates/tests/test-connection.yaml @@ -11,7 +11,7 @@ spec: - name: wget {{- include "ocis.initContainerImage" $ | nindent 6 }} command: ['wget'] - args: ['--no-check-certificate', 'https://{{ .Values.externalDomain }}/'] + args: ['-v','--no-check-certificate','https://{{ .Values.externalDomain }}/'] {{- include "ocis.containerSecurityContext" . | nindent 6 }} resources: {{ toYaml .jobResources | nindent 8 }} restartPolicy: Never From e350f32d768871cd35badbb14345bd56b6aa07c6 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Mon, 13 Nov 2023 10:21:08 +0100 Subject: [PATCH 13/17] - switched to curl again as wget in busybox has no verbose mode --- charts/ocis/templates/tests/test-connection.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/ocis/templates/tests/test-connection.yaml b/charts/ocis/templates/tests/test-connection.yaml index c500f1e48..cf696f34a 100644 --- a/charts/ocis/templates/tests/test-connection.yaml +++ b/charts/ocis/templates/tests/test-connection.yaml @@ -8,10 +8,10 @@ metadata: "helm.sh/hook": test spec: containers: - - name: wget - {{- include "ocis.initContainerImage" $ | nindent 6 }} - command: ['wget'] - args: ['-v','--no-check-certificate','https://{{ .Values.externalDomain }}/'] + - name: curl + image: curlimages/curl:latest + command: ['curl'] + args: ['-v','-k','https://{{ .Values.externalDomain }}/'] {{- include "ocis.containerSecurityContext" . | nindent 6 }} resources: {{ toYaml .jobResources | nindent 8 }} restartPolicy: Never From 62f9c97ecc2e03725d112c3e6d4458e74769dee8 Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Mon, 13 Nov 2023 10:22:34 +0100 Subject: [PATCH 14/17] - added specific tag to curl image --- charts/ocis/templates/tests/test-connection.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/ocis/templates/tests/test-connection.yaml b/charts/ocis/templates/tests/test-connection.yaml index cf696f34a..1e942932d 100644 --- a/charts/ocis/templates/tests/test-connection.yaml +++ b/charts/ocis/templates/tests/test-connection.yaml @@ -9,7 +9,7 @@ metadata: spec: containers: - name: curl - image: curlimages/curl:latest + image: curlimages/curl:8.4.0 command: ['curl'] args: ['-v','-k','https://{{ .Values.externalDomain }}/'] {{- include "ocis.containerSecurityContext" . | nindent 6 }} From 6584063b36d670132bd36a5fec6c39a3881a9e3b Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Wed, 29 Nov 2023 18:26:10 +0100 Subject: [PATCH 15/17] - added e2e tests. 1st version --- charts/ocis/templates/tests/execute-e2e.yaml | 65 ++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 charts/ocis/templates/tests/execute-e2e.yaml diff --git a/charts/ocis/templates/tests/execute-e2e.yaml b/charts/ocis/templates/tests/execute-e2e.yaml new file mode 100644 index 000000000..64fb7c897 --- /dev/null +++ b/charts/ocis/templates/tests/execute-e2e.yaml @@ -0,0 +1,65 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "e2e-tests" + labels: + {{- include "ocis.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + initContainers: + - name: git-checkout + image: owncloudci/nodejs:18 + workingDir: "/tests" + command: ['git'] + args: ['clone','-b','stable-7.1','--single-branch','--no-tags','https://github.com/owncloud/web.git'] + volumeMounts: + - name: test-dir + mountPath: /tests # we mount that volume only to apply fsGroup to that path + - name: install-pnpm + image: owncloudci/nodejs:18 + workingDir: "/tests/web" + command: ['bash'] + args: ['-c','pnpm config set store-dir ./.pnpm-store; pnpm install'] + volumeMounts: + - name: test-dir + mountPath: /tests # we mount that volume only to apply fsGroup to that path + - name: install-chromium + image: owncloudci/nodejs:18 + workingDir: "/tests/web" + command: ['bash'] + args: ['-c','pnpm exec playwright install chromium; pnpm exec playwright install-deps'] + volumeMounts: + - name: test-dir + mountPath: /tests # we mount that volume only to apply fsGroup to that path + + containers: + - name: e2e-tests + image: owncloudci/nodejs:18 + workingDir: "/tests/web" + command: ['pnpm'] + args: ['test:e2e:cucumber','tests/e2e/cucumber/features/*/*[!.oc10].feature'] + {{- include "ocis.containerSecurityContext" . | nindent 6 }} + resources: {{ toYaml .jobResources | nindent 8 }} + env: + - name: "BASE_URL_OCIS" + value: "host.k3d.internal" + - name: "HEADLESS" + value: "true" + - name: "BROWSER" + value: "chromium" + - name: "RETRY" + value: "1" + - name: "WEB_UI_CONFIG_FILE" + value: "/drone/src/tests/config/drone/ocis-config.json" + - name: "LOCAL_UPLOAD_DIR" + value: "/uploads" + volumeMounts: + - name: test-dir + mountPath: /tests # we mount that volume only to apply fsGroup to that path + + restartPolicy: Never + volumes: + - name: test-dir + emptyDir: {} + \ No newline at end of file From 8427ee94fee1606854cd66f85fea726d973328dd Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Wed, 29 Nov 2023 18:33:11 +0100 Subject: [PATCH 16/17] - added containerSecurityContext --- charts/ocis/templates/tests/execute-e2e.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/charts/ocis/templates/tests/execute-e2e.yaml b/charts/ocis/templates/tests/execute-e2e.yaml index 64fb7c897..6846b1fba 100644 --- a/charts/ocis/templates/tests/execute-e2e.yaml +++ b/charts/ocis/templates/tests/execute-e2e.yaml @@ -13,6 +13,7 @@ spec: workingDir: "/tests" command: ['git'] args: ['clone','-b','stable-7.1','--single-branch','--no-tags','https://github.com/owncloud/web.git'] + {{- include "ocis.containerSecurityContext" . | nindent 6 }} volumeMounts: - name: test-dir mountPath: /tests # we mount that volume only to apply fsGroup to that path @@ -21,6 +22,7 @@ spec: workingDir: "/tests/web" command: ['bash'] args: ['-c','pnpm config set store-dir ./.pnpm-store; pnpm install'] + {{- include "ocis.containerSecurityContext" . | nindent 6 }} volumeMounts: - name: test-dir mountPath: /tests # we mount that volume only to apply fsGroup to that path @@ -29,6 +31,7 @@ spec: workingDir: "/tests/web" command: ['bash'] args: ['-c','pnpm exec playwright install chromium; pnpm exec playwright install-deps'] + {{- include "ocis.containerSecurityContext" . | nindent 6 }} volumeMounts: - name: test-dir mountPath: /tests # we mount that volume only to apply fsGroup to that path From 9e5f755c901c99ef87b1dc2f59005d626a56063b Mon Sep 17 00:00:00 2001 From: Dennis Sieben Date: Wed, 29 Nov 2023 18:34:24 +0100 Subject: [PATCH 17/17] - added resource limitations --- charts/ocis/templates/tests/execute-e2e.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/charts/ocis/templates/tests/execute-e2e.yaml b/charts/ocis/templates/tests/execute-e2e.yaml index 6846b1fba..196d129ae 100644 --- a/charts/ocis/templates/tests/execute-e2e.yaml +++ b/charts/ocis/templates/tests/execute-e2e.yaml @@ -14,6 +14,7 @@ spec: command: ['git'] args: ['clone','-b','stable-7.1','--single-branch','--no-tags','https://github.com/owncloud/web.git'] {{- include "ocis.containerSecurityContext" . | nindent 6 }} + resources: {{ toYaml .jobResources | nindent 8 }} volumeMounts: - name: test-dir mountPath: /tests # we mount that volume only to apply fsGroup to that path @@ -23,6 +24,7 @@ spec: command: ['bash'] args: ['-c','pnpm config set store-dir ./.pnpm-store; pnpm install'] {{- include "ocis.containerSecurityContext" . | nindent 6 }} + resources: {{ toYaml .jobResources | nindent 8 }} volumeMounts: - name: test-dir mountPath: /tests # we mount that volume only to apply fsGroup to that path @@ -32,6 +34,7 @@ spec: command: ['bash'] args: ['-c','pnpm exec playwright install chromium; pnpm exec playwright install-deps'] {{- include "ocis.containerSecurityContext" . | nindent 6 }} + resources: {{ toYaml .jobResources | nindent 8 }} volumeMounts: - name: test-dir mountPath: /tests # we mount that volume only to apply fsGroup to that path