diff --git a/dockerfiles/e2e/Dockerfile b/dockerfiles/e2e/Dockerfile index 255e81c4102b..a6c3202a222f 100644 --- a/dockerfiles/e2e/Dockerfile +++ b/dockerfiles/e2e/Dockerfile @@ -11,6 +11,7 @@ ENV LANG=en_US.utf8 \ FABRIC8_USER_NAME=fabric8 COPY google-chrome.repo /etc/yum.repos.d/google-chrome.repo +COPY e2e /root/e2e RUN yum install --assumeyes epel-release && \ yum update --assumeyes && \ yum install --assumeyes google-chrome-stable && \ @@ -30,15 +31,8 @@ RUN yum install --assumeyes epel-release && \ chromedriver_version=$(curl -s -g https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${chrome_version}) && \ $(curl -sS -g https://chromedriver.storage.googleapis.com/${chromedriver_version}/chromedriver_linux64.zip > chromedriver_linux64.zip) && \ unzip chromedriver_linux64.zip && mv chromedriver /usr/bin/chromedriver && chmod +x /usr/bin/chromedriver && rm chromedriver_linux64.zip && \ - # Clone e2e from eclipse/che repo. - cd root && \ - git init && \ - git remote add upstream https://github.com/eclipse/che.git && \ - git config core.sparsecheckout true && \ - echo "e2e/*" >> .git/info/sparse-checkout && \ - git pull --depth=1 upstream master && \ # Download all dependencies for e2e tests - cd e2e && \ + cd /root/e2e && \ npm --silent i WORKDIR /root/ diff --git a/dockerfiles/e2e/README.md b/dockerfiles/e2e/README.md index f4c7d7be2f76..56974904435f 100644 --- a/dockerfiles/e2e/README.md +++ b/dockerfiles/e2e/README.md @@ -14,35 +14,34 @@ installed Docker on your machine. These tests serves for testing Che 7 happy path. You can see description about these tests here: https://github.com/eclipse/che/tree/master/e2e. ## How to run it -The easiest way is to run them via Docker. To build&run locally you have go to this folder and execute following command: +The easiest way is to run them via Docker. To build locally you have go to ` dockerfiles ` folder and execute following command: ``` -docker build -t che7_tests . +./e2e/build.sh ``` -This command builds docker -image named ` che7_tests `. -Once image is build, you can run the tests inside this docker image. You have to set URL of running Che and increase shared memory size (low shared memory makes chrome driver crash). +This command builds docker image named ` eclipse/che-e2e:nightly `. This image is build nightly and pushed to registry, so you don't have to build that image locally. +You can run the tests inside this docker image. You have to set URL of running Che and increase shared memory size (low shared memory makes chrome driver crash). ``` -docker run --shm-size=256m -e THEIA_SELENIUM_BASE_URL=$URL che7_tests +docker run --shm-size=256m -e THEIA_SELENIUM_BASE_URL=$URL eclipse/che-e2e:nightly ``` If you want to gather screenshots of fallen tests, you have to mount a volume to the docker file. Create a folder, when you want to have the screenshots saved. Then run a command: ``` -docker run --shm-size=256m -v /full/path/to/your/folder:/root/e2e/report:Z -e THEIA_SELENIUM_BASE_URL=$URL che7_tests +docker run --shm-size=256m -v /full/path/to/your/folder:/root/e2e/report:Z -e THEIA_SELENIUM_BASE_URL=$URL eclipse/che-e2e:nightly ``` ###Debugging ####Running own code -If you have done some changes locally and you want to test them, you can mount your code directly to the Docker. If you do so, your mounted code will be executed instead of the code from master. +If you have done some changes locally and you want to test them, you can mount your code directly to the Docker. If you do so, your mounted code will be executed instead of the code that is already in an image. ``` -docker run --shm-size=256m -v /full/path/to/your/e2e/folder:/root/local_tests:Z -e THEIA_SELENIUM_BASE_URL=$URL che7_tests +docker run --shm-size=256m -v /full/path/to/your/e2e/folder:/root/local_tests:Z -e THEIA_SELENIUM_BASE_URL=$URL eclipse/che-e2e:nightly ``` NOTE: If you want to run your own code and gather screenshots, you have to change the mount from ` /root/e2e/report:Z ` to ` /root/local_tests/report:Z `. ####Watching Chrome -If you want to see what is going on in chrome inside a docker, you can use VNC. When running a docker, you can see API where you can connect. This API is on the first line of output and can look like that: ` You can wath localy using VNC with IP: 172.17.0.2 `. Then you can easily join VNC using this API: ` 172.17.0.2:0 `. \ No newline at end of file +If you want to see what is going on in chrome inside a docker, you can use VNC. When running a docker, you can see API where you can connect. This API is on the first line of output and can look like that: ` You can watch locally using VNC with IP: 172.17.0.2 `. Then you can easily join VNC using this API: ` 172.17.0.2:0 `. diff --git a/dockerfiles/e2e/build.sh b/dockerfiles/e2e/build.sh new file mode 100755 index 000000000000..012be060af83 --- /dev/null +++ b/dockerfiles/e2e/build.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright (c) 2017 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# + +base_dir=$(cd "$(dirname "$0")"; pwd) +. "${base_dir}"/../build.include + +E2E_DIR="${base_dir}/../../e2e" +LOCAL_E2E_DIR="${base_dir}/e2e" + +if [ -d $LOCAL_E2E_DIR ]; then + rm -rf $LOCAL_E2E_DIR +fi + +echo "Copying source code ${E2E_DIR} --> ${LOCAL_E2E_DIR}" +cp -r "${E2E_DIR}" "${LOCAL_E2E_DIR}" + +init --name:e2e "$@" +build + +# cleanup +rm -rf $LOCAL_E2E_DIR diff --git a/dockerfiles/e2e/docker-entrypoint.sh b/dockerfiles/e2e/docker-entrypoint.sh index 542e8fd38392..1623129c994c 100755 --- a/dockerfiles/e2e/docker-entrypoint.sh +++ b/dockerfiles/e2e/docker-entrypoint.sh @@ -11,14 +11,14 @@ x11vnc -display :1.0 > /dev/null 2>&1 & export DISPLAY=:1.0 hostname=$(hostname -I) -echo "You can wath localy using VNC with IP: $hostname" +echo "You can watch locally using VNC with IP: $hostname" if mount | grep 'local_tests'; then - echo "The local scripts are mounted. Executing local scripts." + echo "The local code is mounted. Executing local code." cd local_tests npm i else - echo "Executing e2e tests from master branch." + echo "Executing e2e tests from an image." cd e2e fi