From a6500208bdd59c0df2ced2de5a313db17fb36c90 Mon Sep 17 00:00:00 2001 From: GoranP Date: Tue, 25 Jan 2022 14:51:44 +0100 Subject: [PATCH 1/4] adding Dockerfile and instructions how to use cypress with docker --- cypress-studio/Dockerfile | 6 ++++ cypress-studio/README.md | 75 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 cypress-studio/Dockerfile diff --git a/cypress-studio/Dockerfile b/cypress-studio/Dockerfile new file mode 100644 index 0000000..639a6de --- /dev/null +++ b/cypress-studio/Dockerfile @@ -0,0 +1,6 @@ +FROM cypress/included:8.5.0 + +COPY . /cypress-studio +WORKDIR /cypress-studio + +ENTRYPOINT npx cypress run diff --git a/cypress-studio/README.md b/cypress-studio/README.md index b785cc7..018254e 100644 --- a/cypress-studio/README.md +++ b/cypress-studio/README.md @@ -56,6 +56,81 @@ The main goal of this experiment is to share with the community how `Cypress Stu

(back to top)

+ +## How to run tests with docker + +### Prerequisites +Install latest docker engine on local machine following instructions here. + +### How to run cypress tests locally +For executing tests without need to install cypress or nodejs on local machine run following in `cypress-studio` folder: +```sh +docker run -it -v $PWD:/e2e -w /e2e cypress/included:8.5.0 +``` + +### Build docker image with tests +Run following in `cypress-studio`folder: +```sh +docker build -t modus/cypress-studio:latest . +``` + +Run tests locally: +```sh +docker run -it modus/cypress-studio:latest +``` + +### Push image on docker repository + +For push on private repo we have to retag image to point on target docker repository, otherwise default is Dockerhub. + +```sh +docker tag modus/cypress-studio:latest path-to-private-repo.com/repo/cypress-studio:latest +``` +Where `path-to-private-repo.com/repo/cypress-studio:latest`is provate target docker repository. + +Credentials for target docker repository are needed for push. + +Push image with: +```sh +docker push path-to-private-repo.com/repo/cypress-studio:latest +``` + +## Deploy on Kubernetes +### Prerequisites +Docker image is built and pushed in target repository. +Install `kubectl` tool and configure access to kubernete cluster. Installation instructions are here. +Alternativley run on local machine minicube - follow instructions here. + +### Kubernetes YAML example + +Save following YAML as `modus-test-job.yaml` +```YAML +apiVersion: batch/v1 +kind: Job +metadata: + name: modus-cypress-test-job +spec: + template: + spec: + containers: + - name: modus-cypress-test-job + image: path-to-private-repo.com/repo/cypress-studio:latest +``` + +Deploy job on kubernetes: +```sh +kubectl apply -f modus-test-job.yaml +``` + +Find exact name of the job with: +```sh +kubectl get pods +``` + +Using `kubectl logs modus-cypress-test-job-XXX` get logs/results where `modus-cypress-test-job-XXX`is the name of the job. +On development/testing cluster logs could be redirected to central logging system and results could be visible there as well. + + ## Contact From 597a7ecff5c5e517887c5f44fc07f25f2627d49f Mon Sep 17 00:00:00 2001 From: GoranP Date: Tue, 25 Jan 2022 15:48:05 +0100 Subject: [PATCH 2/4] Fixing typos --- cypress-studio/README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cypress-studio/README.md b/cypress-studio/README.md index 018254e..298a7af 100644 --- a/cypress-studio/README.md +++ b/cypress-studio/README.md @@ -60,9 +60,9 @@ The main goal of this experiment is to share with the community how `Cypress Stu ## How to run tests with docker ### Prerequisites -Install latest docker engine on local machine following instructions here. +Install the latest Docker engine on the local machine following instructions here. -### How to run cypress tests locally +### How to run cypress tests on the local machine For executing tests without need to install cypress or nodejs on local machine run following in `cypress-studio` folder: ```sh docker run -it -v $PWD:/e2e -w /e2e cypress/included:8.5.0 @@ -79,16 +79,16 @@ Run tests locally: docker run -it modus/cypress-studio:latest ``` -### Push image on docker repository +### Push image in a docker repository -For push on private repo we have to retag image to point on target docker repository, otherwise default is Dockerhub. +To push the image in a private repo, we have to retag the image to point on the target docker repository. Otherwise, the default is Dockerhub. ```sh docker tag modus/cypress-studio:latest path-to-private-repo.com/repo/cypress-studio:latest ``` Where `path-to-private-repo.com/repo/cypress-studio:latest`is provate target docker repository. -Credentials for target docker repository are needed for push. +Credentials for the target docker repository are needed for the push. Push image with: ```sh @@ -97,9 +97,9 @@ docker push path-to-private-repo.com/repo/cypress-studio:latest ## Deploy on Kubernetes ### Prerequisites -Docker image is built and pushed in target repository. -Install `kubectl` tool and configure access to kubernete cluster. Installation instructions are here. -Alternativley run on local machine minicube - follow instructions here. +Docker image is built and pushed in the target repository. Install `kubectl` tool and configure access to Kubernetes cluster.
+Installation instructions are here.
+Alternatively, run on a local machine mini cube - follow instructions here. ### Kubernetes YAML example @@ -122,13 +122,13 @@ Deploy job on kubernetes: kubectl apply -f modus-test-job.yaml ``` -Find exact name of the job with: +Find exact name of the jobs pod with: ```sh kubectl get pods ``` Using `kubectl logs modus-cypress-test-job-XXX` get logs/results where `modus-cypress-test-job-XXX`is the name of the job. -On development/testing cluster logs could be redirected to central logging system and results could be visible there as well. +On development/testing, cluster logs could be redirected to the central logging system, and results could be visible there. From 3810d98a16f12d36ee789a3fca5ad94437d5650a Mon Sep 17 00:00:00 2001 From: Goran Pizent <2116949+GoranP@users.noreply.github.com> Date: Tue, 25 Jan 2022 15:49:15 +0100 Subject: [PATCH 3/4] Update README.MD --- cypress-studio/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress-studio/README.md b/cypress-studio/README.md index 298a7af..f45848e 100644 --- a/cypress-studio/README.md +++ b/cypress-studio/README.md @@ -97,7 +97,7 @@ docker push path-to-private-repo.com/repo/cypress-studio:latest ## Deploy on Kubernetes ### Prerequisites -Docker image is built and pushed in the target repository. Install `kubectl` tool and configure access to Kubernetes cluster.
+Docker image is built and pushed in the target repository. Install `kubectl` tool and configure access to Kubernetes cluster. Installation instructions are here.
Alternatively, run on a local machine mini cube - follow instructions here. From 7e6a8b972d320eca829aa488e4b4fbb84fc4893c Mon Sep 17 00:00:00 2001 From: GoranP Date: Tue, 1 Feb 2022 09:27:58 +0100 Subject: [PATCH 4/4] QACOE-242 add support for dockerised nightwatch and kubernetes deployment example --- nightwatchJS/Dockerfile | 23 ++++++++++ nightwatchJS/README.md | 77 +++++++++++++++++++++++++++++++++ nightwatchJS/nightwatch.conf.js | 18 +++++++- 3 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 nightwatchJS/Dockerfile diff --git a/nightwatchJS/Dockerfile b/nightwatchJS/Dockerfile new file mode 100644 index 0000000..0d5fb54 --- /dev/null +++ b/nightwatchJS/Dockerfile @@ -0,0 +1,23 @@ +FROM node + +RUN apt update && apt-get clean && apt install -y x11vnc xvfb fluxbox wmctrl wget libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev vim nano + +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \ + && apt-get update && apt-get -y install google-chrome-stable + +COPY . /app +WORKDIR /app + +RUN npm install nightwatch +RUN npm install chromedriver + +RUN useradd app -d /app \ + && mkdir -p /app \ + && chown -v -R app:app /app + +USER app + +EXPOSE 9515 + +ENTRYPOINT npm test \ No newline at end of file diff --git a/nightwatchJS/README.md b/nightwatchJS/README.md index 34fac04..38e44f4 100644 --- a/nightwatchJS/README.md +++ b/nightwatchJS/README.md @@ -154,5 +154,82 @@ OR this command will trigger all tests and its subfolder tests via Chrome browser + +## How to run tests with docker + +### Prerequisites +Install the latest Docker engine on the local machine following instructions here. + +### Build docker image with tests +Run following in `nightwatchJS`folder: +```sh +docker build -t modus/nightwatchjs:latest . +``` + +Run tests locally: +```sh +docker run -it modus/nightwatchjs:latest +``` + + +### Push image to a docker repository + +To push the image to a private repo, we have to retag the image to point on the target docker repository. Otherwise, the default is Dockerhub. + +Push to DockerGub (need credentials for DockerHub) +```sh +docker push modus/nightwatchjs:latest +``` + +Push to private repository: + +```sh +docker tag modus/nightwatchjs:latest path-to-private-repo.com/repo/nightwatchjs:latest +``` +Where `path-to-private-repo.com/repo/nightwatchjs:latest`is private target docker repository. + +Credentials for the target docker repository are needed for the push. + +Push image with: +```sh +docker push path-to-private-repo.com/repo/nightwatchjs:latest +``` + +## Deploy on Kubernetes +### Prerequisites +Docker image is built and pushed in the target repository. Install `kubectl` tool and configure access to Kubernetes cluster.
+Installation instructions are here.
+Alternatively, run on a local machine mini cube - follow instructions here. + +### Kubernetes YAML example + +Save following YAML as `modus-test-job.yaml` +```YAML +apiVersion: batch/v1 +kind: Job +metadata: + name: modus-nightwatch-test-job +spec: + template: + spec: + containers: + - name: modus-nightwatch-test-job + image: modus/nightwatchjs:latest +``` +Previous YAML assume that docker image is pushed on DockerHub. + +Deploy job on kubernetes: +```sh +kubectl apply -f modus-test-job.yaml +``` + +Find exact name of the jobs pod with: +```sh +kubectl get pods +``` + +Using `kubectl logs modus-nightwatch-test-job-XXX` get logs/results where `modus-nightwatch-test-job-XXX`is the name of the job. +On development/testing, cluster logs could be redirected to the central logging system, and results could be visible there. + diff --git a/nightwatchJS/nightwatch.conf.js b/nightwatchJS/nightwatch.conf.js index 7c0a247..ff893f8 100644 --- a/nightwatchJS/nightwatch.conf.js +++ b/nightwatchJS/nightwatch.conf.js @@ -10,8 +10,22 @@ module.exports = { "test_settings" : { "default" : { "desiredCapabilities": { - "browserName": "chrome" + "browserName": "chrome", + "chromeOptions" : { + "args" : ["headless", "no-sandbox", "disable-gpu"] + } } - } + }, + + "chrome" : { + "desiredCapabilities": { + "browserName": "chrome", + "chromeOptions" : { + "args" : ["headless", "no-sandbox", "disable-gpu"] + }, + "javascriptEnabled": true, + "acceptSslCerts": true + } + } }, } \ No newline at end of file