diff --git a/docs/ocis/development/testing.md b/docs/ocis/development/testing.md index 7810f1a193f..da6e577ac0a 100644 --- a/docs/ocis/development/testing.md +++ b/docs/ocis/development/testing.md @@ -428,7 +428,7 @@ Test suites that are tagged with `@antivirus` require antivirus service. The ava #### 1. Setup Locally -##### Linux OS user +##### Linux OS User Run the following command to set up calmAV and clamAV daemon @@ -446,7 +446,7 @@ sudo service clamav-daemon status The commands are ubuntu specific and may differ according to your system. You can find information related to installation of clamAV in their official documentation [here](https://docs.clamav.net/manual/Installing/Packages.html). {{< /hint>}} -##### Mac OS user +##### Mac OS User Install ClamAV using [here](https://gist.github.com/mendozao/3ea393b91f23a813650baab9964425b9) Start ClamAV daemon @@ -457,7 +457,7 @@ Start ClamAV daemon #### 2. Setup clamAV With Docker -##### Linux OS user +##### Linux OS User Run `clamAV` through docker @@ -465,7 +465,7 @@ Run `clamAV` through docker docker run -d -p 3310:3310 owncloudci/clamavd ``` -##### Mac OS user +##### Mac OS User ```bash docker run -d -p 3310:3310 -v /your/local/filesystem/path/to/clamav/:/var/lib/clamav mkodockx/docker-clamav:alpine @@ -542,7 +542,7 @@ You can run the second oCIS instance in two ways: From the `Run and Debug` panel of VSCode, select `Fed oCIS Server` and start the debugger. -#### Using env file +#### Using env File ```bash # init oCIS @@ -589,89 +589,126 @@ The sample `fontsMap.json` file is located in `tests/config/drone/fontsMap.json` } ``` -## Running Test on helm setup +## Running Test on Helm Setup -Make sure the following tools are installed: +The following tools must be installed: -Install [k3d](https://k3d.io/stable/#install-script) -Install [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) -Install [helm](https://helm.sh/docs/intro/install/) +* Install [k3d](https://k3d.io/stable/#install-script) +* Install [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) +* Install [helm](https://helm.sh/docs/intro/install/) -Also, clone the [`ocis-charts`](https://github.com/owncloud/ocis-charts/) repository. +Also, clone the [ocis-charts](https://github.com/owncloud/ocis-charts/) repository. -1. Setup Basicauth -Enable basic authentication for the proxy in the ocis-charts repo: -```bash -cd ocis-charts -# Enable basic auth in proxy deployment -sed -i '/- name: PROXY_HTTP_ADDR/i\ - - name: PROXY_ENABLE_BASIC_AUTH\ - value: "true"' ./charts/ocis/templates/proxy/deployment.yaml -# copy authbasic service -cp -r /tests/config/drone/k8s/authbasic ./charts/ocis/templates/ -# change admin password -sed -i '/- name: IDM_ADMIN_PASSWORD/{n;N;N;N;d;}' ./charts/ocis/templates/idm/deployment.yaml -sed -i '/- name: IDM_ADMIN_PASSWORD/a\\n value: "admin"' ./charts/ocis/templates/idm/deployment.yaml -# Update values.yaml -cp /tests/config/drone/k8s/values.yaml charts/charts/ocis/ci/deployment-values.yaml -# Update template values -sed -i '/{{- $_ := set .scope "appNameAuthMachine" "authmachine" -}}/a\ {{- $_ := set .scope "appNameAuthBasic" "authbasic" -}}' ./charts/ocis/templates/_common/_tplvalues.tpl -``` +1. Setup Basicauth\ + Enable basic authentication for the proxy in the `ocis-charts` repo: + ```bash + cd ocis-charts -2. Install charts using k3d + # Enable basic auth in proxy deployment + sed -i '/- name: PROXY_HTTP_ADDR/i \ + - name: PROXY_ENABLE_BASIC_AUTH \ + value: "true"' ./charts/ocis/templates/proxy/deployment.yaml -```bash -k3d cluster create drone --api-port ocis-server:33199 -p '80:80@loadbalancer' -p '443:443@loadbalancer' --k3s-arg '--tls-san=k3d@server:*' --k3s-arg '--disable=metrics-server@server:*' -k3d kubeconfig get drone > kubeconfig.yaml -chmod 0600 kubeconfig.yaml -kubectl create configmap coredns-custom --namespace kube-system --from-literal='rewritehost.override=rewrite name exact ocis-server host.k3d.internal' -kubectl -n kube-system rollout restart deployment coredns -make helm-install-atomic -``` + # copy authbasic service + cp -r /tests/config/drone/k8s/authbasic ./charts/ocis/templates/ -3. Run test -To run test you should set `K8S` to true. -```bash -cd + # change admin password + sed -i '/- name: IDM_ADMIN_PASSWORD/{n;N;N;N;d;}' ./charts/ocis/templates/idm/deployment.yaml + sed -i '/- name: IDM_ADMIN_PASSWORD/a\\n value: "admin"' ./charts/ocis/templates/idm/deployment.yaml -# build and run ocis wrapper -make -C ./tests/ociswrapper -./tests/ociswrapper/bin/ociswrapper serve --url https://ocis-server --admin-username admin --admin-password admin --skip-ocis-run + # Update values.yaml + cp /tests/config/drone/k8s/values.yaml charts/charts/ocis/ci/deployment-values.yaml -K8S=true TEST_SERVER_URL="https://ocis-server" make test-acceptance-api BEHAT_FEATURE=tests/acceptance/features/apiArchiver/downloadById.feature -``` -1. Run Test With ociswrapper -```bash -ociswrapper serve --url https://ocis-server --admin-username admin --admin-password admin --skip-ocis-run -``` -1. Run Antivirus Test -To run clamav service run these commands deploying the helm chart -```bash -cp -r config/drone/k8s/clamav charts/ocis/templates/ -sed -i 's/{{ *\.Values\.features\.virusscan\.infectedFileHandling *| *quote *}}/"delete"/' ocis/templates/antivirus/deployment.yaml -sed -i 's/{{ *\.Values\.features\.virusscan\.infectedFileHandling *| *quote *}}/"delete"/' ocis/templates/antivirus/deployment.yaml -sed -i '/name: ANTIVIRUS_SCANNER_TYPE/{n;s/value: *"icap"/value: "clamav"/}' charts/ocis/templates/antivirus/deployment.yaml -sed -i '/- name: ANTIVIRUS_SCANNER_TYPE/i\ - name: ANTIVIRUS_CLAMAV_SOCKET\n value: "tcp://clamav:3310"' charts/ocis/templates/antivirus/deployment.yaml -``` -1. Run Email Test -To run email service run these commands deploying the helm chart -```bash -cp -r /tests/config/drone/k8s/mailpit charts/ocis/templates/ -``` -After ocis is deployed -```bash -kubectl port-forward svc/mailpit $EMAIL_PORT:8025 -n ocis -``` -1. Run Authapp Test -To run authapp service run these commands deploying the helm chart -```bash -cp -r /tests/config/drone/k8s/mailpit charts/ocis/templates/ -``` -1. Run Tika Test -To run tika service run these commands deploying the helm chart -```bash -cp -r /tests/config/drone/k8s/tika charts/ocis/templates/ -``` + # Update template values + sed -i '/{{- $_ := set .scope "appNameAuthMachine" "authmachine" -}}/a \ + {{- $_ := set .scope "appNameAuthBasic" "authbasic" -}}' \ + ./charts/ocis/templates/_common/_tplvalues.tpl + ``` + +2. Install Charts Using k3d + + ```bash + k3d cluster create drone \ + --api-port ocis-server:33199 \ + -p '80:80@loadbalancer' \ + -p '443:443@loadbalancer' \ + --k3s-arg '--tls-san=k3d@server:*' \ + --k3s-arg '--disable=metrics-server@server:*' + + k3d kubeconfig get drone > kubeconfig.yaml + + chmod 0600 kubeconfig.yaml + + kubectl create configmap coredns-custom \ + --namespace kube-system \ + --from-literal='rewritehost.override=rewrite name exact ocis-server host.k3d.internal' + + kubectl -n kube-system rollout restart deployment coredns + + make helm-install-atomic + ``` + +3. Run Test\ + To run test you should set `K8S` to true: + ```bash + cd + + # build and run ocis wrapper + make -C ./tests/ociswrapper + ./tests/ociswrapper/bin/ociswrapper serve \ + --url https://ocis-server \ + --admin-username admin \ + --admin-password admin \ + --skip-ocis-run + + K8S=true TEST_SERVER_URL="https://ocis-server" \ + make test-acceptance-api BEHAT_FEATURE=tests/acceptance/features/apiArchiver/downloadById.feature + ``` + +4. Run Test With ociswrapper + ```bash + ociswrapper serve \ + --url https://ocis-server \ + --admin-username admin \ + --admin-password admin \ + --skip-ocis-run + ``` + +5. Run Antivirus Test\ + To run the clamav service, run these commands deploying the helm chart: + ```bash + cp -r config/drone/k8s/clamav charts/ocis/templates/ + + sed -i 's/{{ *\.Values\.features\.virusscan\.infectedFileHandling *| *quote *}}/"delete"/' \ + ocis/templates/antivirus/deployment.yaml + + sed -i 's/{{ *\.Values\.features\.virusscan\.infectedFileHandling *| *quote *}}/"delete"/' \ + ocis/templates/antivirus/deployment.yaml + + sed -i '/name: ANTIVIRUS_SCANNER_TYPE/{n;s/value: *"icap"/value: "clamav"/}' \ + charts/ocis/templates/antivirus/deployment.yaml + + sed -i '/- name: ANTIVIRUS_SCANNER_TYPE/i \ + - name: ANTIVIRUS_CLAMAV_SOCKET\n \ + value: "tcp://clamav:3310"' \ + charts/ocis/templates/antivirus/deployment.yaml + ``` + +5. Run Email Test\ + To run the email service, run these commands deploying the helm chart: + ```bash + cp -r /tests/config/drone/k8s/mailpit charts/ocis/templates/ + ``` + After ocis is deployed: + ```bash + kubectl port-forward svc/mailpit $EMAIL_PORT:8025 -n ocis + ``` + +6. Run Tika Test\ + To run the tika service, run these commands deploying the helm chart: + ```bash + cp -r /tests/config/drone/k8s/tika charts/ocis/templates/ + ``` ## Generating Code Coverage Report by Running Acceptance Tests