-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13542 from Katka92/che7_dockerfile
Add dockerfile to execute E2E Che 7 typescript tests.
- Loading branch information
Showing
5 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright (c) 2019 Red Hat, Inc. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
|
||
FROM library/centos:centos7 | ||
|
||
ENV LANG=en_US.utf8 \ | ||
DISPLAY=:99 \ | ||
FABRIC8_USER_NAME=fabric8 | ||
|
||
COPY google-chrome.repo /etc/yum.repos.d/google-chrome.repo | ||
|
||
RUN yum install --assumeyes epel-release && \ | ||
yum update --assumeyes && \ | ||
yum install --assumeyes google-chrome-stable && \ | ||
yum install --assumeyes \ | ||
xorg-x11-server-Xvfb \ | ||
git \ | ||
unzip \ | ||
centos-release-scl && \ | ||
yum install --assumeyes nodejs && \ | ||
npm install -g typescript && \ | ||
yum install jq --assumeyes && \ | ||
yum install x11vnc --assumeyes && \ | ||
yum clean all --assumeyes && \ | ||
rm -rf /var/cache/yum && \ | ||
# Get compatible versions of chrome and chromedriver | ||
chrome_version=$(google-chrome --version | grep -oiE "[0-9]*\.[0-9]*\.[0-9]*") && \ | ||
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 | ||
|
||
COPY e2e/package.json e2e/package-lock.json /root/e2e/ | ||
RUN cd /root/e2e && \ | ||
npm --silent i | ||
|
||
COPY e2e /root/e2e | ||
COPY docker-entrypoint.sh /root/ | ||
|
||
WORKDIR /root/ | ||
|
||
ENTRYPOINT ["/root/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# End-to-end typescript tests for Che 7 | ||
|
||
## Table Of Content | ||
|
||
* [Requirements](#requirements) | ||
* [What are these tests meant for](#what-are-these-tests-meant-for) | ||
* [How to run it](#how-to-run-it) | ||
|
||
##Requirements | ||
To run these tests you need to have running Che instance. You can execute tests directly using ` npm ` but if you like to use this Docker image, you need to have | ||
installed Docker on your machine. | ||
|
||
## What are these tests meant for | ||
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 locally you have go to ` dockerfiles ` folder and execute following command: | ||
|
||
``` | ||
./e2e/build.sh | ||
``` | ||
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 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 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 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 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 watch locally using VNC with IP: 172.17.0.2 `. Then you can easily join VNC using this API: ` 172.17.0.2:0 `. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2019 Red Hat, Inc. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
|
||
if [ -z "$TS_SELENIUM_BASE_URL" ]; then | ||
echo "TS_SELENIUM_BASE_URL is not set!"; | ||
exit 1 | ||
fi | ||
|
||
chromedriver & | ||
/usr/bin/Xvfb :1 -screen 0 1920x1080x24 +extension RANDR > /dev/null 2>&1 & | ||
x11vnc -display :1.0 > /dev/null 2>&1 & | ||
export DISPLAY=:1.0 | ||
|
||
hostname=$(hostname -I) | ||
echo "You can watch locally using VNC with IP: $hostname" | ||
|
||
if mount | grep 'local_tests'; then | ||
echo "The local code is mounted. Executing local code." | ||
cd local_tests || exit | ||
npm i | ||
else | ||
echo "Executing e2e tests from an image." | ||
cd e2e || exit | ||
fi | ||
|
||
npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[google-chrome] | ||
name=google-chrome | ||
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch | ||
enabled=1 | ||
gpgcheck=1 | ||
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub |