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..f45848e 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 the latest Docker engine on the local machine following instructions here. + +### 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 +``` + +### 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 in a docker repository + +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 the target docker repository are needed for the 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 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-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 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 the central logging system, and results could be visible there. + + ## Contact 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