Skip to content

Commit f801fdd

Browse files
authored
is1594 fix and re-activate e2e testing (#1620)
Solves #1594 and part of #1367 - e2e runs in host ( partially implements #1367). installs/uninstall insecure registry (see e2e.bash ) - e2e flow is reviewed and updated - e2e is reactivated in github actions and removed from travis. Fixes bugs in postgres migration scripts related to unhandled exceptions
1 parent 91d9482 commit f801fdd

28 files changed

+471
-445
lines changed

.github/workflows/ci-testing-deploy.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,6 @@ jobs:
750750
system-test-e2e:
751751
# FIXME: skip the job until make it faster and more reliable
752752
# https://github.com/ITISFoundation/osparc-simcore/issues/1594
753-
if: "false"
754753
name: System-testing e2e
755754
needs: [build-test-images]
756755
runs-on: ${{ matrix.os }}
@@ -797,8 +796,15 @@ jobs:
797796
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
798797
restore-keys: |
799798
${{ runner.os }}-node-
800-
- name: install
801-
run: ./ci/github/system-testing/e2e.bash install
799+
- name: setup images
800+
run: ./ci/github/system-testing/e2e.bash setup_images
801+
- name: setup environment
802+
run: ./ci/github/system-testing/e2e.bash setup_environment
803+
- name: setup registry
804+
run: ./ci/github/system-testing/e2e.bash setup_registry
805+
- name: setup database
806+
timeout-minutes: 2
807+
run: ./ci/github/system-testing/e2e.bash setup_database
802808
- name: test
803809
run: ./ci/github/system-testing/e2e.bash test
804810
- name: recover docker logs
@@ -917,7 +923,7 @@ jobs:
917923
integration-test-sidecar,
918924
integration-test-simcore-sdk,
919925
system-test-swarm-deploy,
920-
#system-test-e2e,
926+
system-test-e2e,
921927
]
922928
runs-on: ubuntu-latest
923929
steps:

.travis.yml

+6-37
Original file line numberDiff line numberDiff line change
@@ -385,43 +385,7 @@ jobs:
385385
after_failure:
386386
- unbuffer bash ci/travis/system-testing/swarm-deploy.bash after_failure
387387

388-
# system testing e2e testing -----------------------------------------------------------------
389-
# https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-on-travis-ci
390-
# FIXME: skip the job until make it faster and more reliable https://github.com/ITISFoundation/osparc-simcore/issues/1594
391-
- if: false
392-
stage: integration-testing / system-testing
393-
name: e2e testing
394-
language: node_js
395-
node_js:
396-
- "10"
397-
sudo: required
398-
services:
399-
- xvfb
400-
addons:
401-
apt:
402-
packages:
403-
- libnss3 # This is required to run new chrome on old trusty
404-
- expect-dev # for unbuffer: brings color back into travis logs
405-
- docker-ce
406-
- python3-venv
407-
notifications:
408-
email: false
409-
cache:
410-
directories:
411-
- node_modules
412-
before_install:
413-
- sudo bash ci/travis/system-testing/e2e.bash before_install
414-
install:
415-
- unbuffer bash ci/travis/system-testing/e2e.bash install
416-
before_script:
417-
- unbuffer bash ci/travis/system-testing/e2e.bash before_script
418-
script:
419-
- unbuffer bash ci/travis/system-testing/e2e.bash script
420-
after_success:
421-
- unbuffer bash ci/travis/system-testing/e2e.bash after_success
422-
after_failure:
423-
- unbuffer bash ci/travis/system-testing/e2e.bash after_failure
424-
388+
# deployment in master environ ----------------------------------------------------------------
425389
- stage: deployment
426390
name: master
427391
if: branch = master
@@ -436,6 +400,8 @@ jobs:
436400
script: unbuffer bash ci/deploy/dockerhub-deploy.bash
437401
on:
438402
branch: master
403+
404+
# deployment to staging environ ----------------------------------------------------------------
439405
- stage: deployment
440406
name: staging
441407
if: branch = staging
@@ -450,6 +416,8 @@ jobs:
450416
script: unbuffer bash ci/deploy/dockerhub-deploy.bash
451417
on:
452418
branch: staging
419+
420+
# deployment to production environ ----------------------------------------------------------------
453421
- stage: deployment
454422
name: production/release
455423
env:
@@ -466,6 +434,7 @@ jobs:
466434
all_branches: true
467435
tags: true
468436
condition: $TRAVIS_TAG =~ ^v[0-9]+.[0-9]+.[0-9]+$
437+
469438
notifications:
470439
email:
471440
on_success: never

.vscode/launch.template.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// This is a template. Clone and replace extension ".template.json" by ".json"
12
{
23
// Use IntelliSense to learn about possible attributes.
34
// Hover to view descriptions of existing attributes.

.vscode/settings.template.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// This is a template. Clone and replace extension ".template.json" by ".json"
12
{
23
"editor.tabSize": 2,
34
"editor.insertSpaces": true,
@@ -34,4 +35,4 @@
3435
"shellcheck.run": "onSave",
3536
"shellcheck.enableQuickFix": true,
3637
"python.formatting.provider": "black"
37-
}
38+
}

ci/github/system-testing/e2e.bash

+149-49
Original file line numberDiff line numberDiff line change
@@ -11,69 +11,169 @@ export DOCKER_IMAGE_TAG
1111
SWARM_STACK_NAME=e2e_test_stack
1212
export SWARM_STACK_NAME
1313

14+
install_insecure_registry() {
15+
# Create .env and append extra variables
16+
if [[ -f .env ]]; then
17+
cp .env .env.bak
18+
fi
19+
20+
make .env
21+
{
22+
# disable email verification
23+
echo WEBSERVER_LOGIN_REGISTRATION_INVITATION_REQUIRED=0
24+
echo WEBSERVER_LOGIN_REGISTRATION_CONFIRMATION_REQUIRED=0
25+
# set max number of CPUs sidecar
26+
echo SERVICES_MAX_NANO_CPUS=2000000000
27+
# set up insecure internal registry
28+
echo REGISTRY_AUTH=False
29+
echo REGISTRY_SSL=False
30+
echo REGISTRY_URL=registry:5000
31+
# disable registry caching to ensure services are fetched
32+
echo DIRECTOR_REGISTRY_CACHING=False
33+
} >>.env
34+
35+
# prepare insecure registry access for docker engine
36+
echo "------------------- adding host name to the insecure registry "
37+
if [[ -f /etc/hosts ]]; then
38+
cp /etc/hosts .hosts.bak
39+
fi
40+
sudo bash -c "echo '127.0.0.1 registry' >> /etc/hosts"
41+
42+
echo "------------------- adding insecure registry into docker daemon "
43+
if [[ -f /etc/docker/daemon.json ]]; then
44+
cp /etc/docker/daemon.json .daemon.bak
45+
fi
46+
sudo bash -c "echo '{\"insecure-registries\": [\"registry:5000\"]}' >> /etc/docker/daemon.json"
47+
48+
echo "------------------ restarting daemon [takes some time]"
49+
sudo service docker restart
50+
}
51+
52+
uninstall_insecure_registry() {
53+
echo "------------------ reverting .env"
54+
if [[ -f .env.bak ]]; then
55+
mv .env.bak .env
56+
fi
57+
58+
echo "------------------ reverting /etc/hosts"
59+
if [[ -f .hosts.bak ]]; then
60+
sudo mv .hosts.bak /etc/hosts
61+
fi
62+
63+
if [[ -f .daemon.bak ]]; then
64+
echo "------------------ reverting /etc/docker/daemon.json"
65+
sudo mv .daemon.bak /etc/docker/daemon.json
66+
echo "------------------ restarting daemon [takes some time]"
67+
sudo service docker restart
68+
fi
69+
}
70+
71+
setup_images() {
72+
echo "--------------- getting simcore docker images..."
73+
make pull-version || ( (make pull-cache || true) && make build-x tag-version)
74+
make info-images
75+
76+
# configure simcore for testing with a private registry
77+
install_insecure_registry
78+
79+
# start simcore and set log-level
80+
export LOG_LEVEL=WARNING
81+
make up-version
82+
}
83+
84+
setup_environment() {
85+
86+
echo "--------------- installing environment ..."
87+
/bin/bash -c 'sudo apt install -y postgresql-client'
88+
89+
echo "-------------- installing test framework..."
90+
# create a python venv and activate
91+
make .venv
92+
# shellcheck disable=SC1091
93+
source .venv/bin/activate
94+
95+
bash ci/helpers/ensure_python_pip.bash
96+
pushd tests/e2e
97+
make install
98+
popd
99+
}
100+
101+
setup_registry() {
102+
# shellcheck disable=SC1091
103+
source .venv/bin/activate
104+
pushd tests/e2e
105+
echo "--------------- deploying the registry..."
106+
make registry-up
107+
echo "--------------- waiting for all services to be up..."
108+
make wait-for-services
109+
echo "--------------- transfering the images to the local registry..."
110+
make transfer-images-to-registry
111+
popd
112+
}
113+
114+
setup_database() {
115+
# shellcheck disable=SC1091
116+
source .venv/bin/activate
117+
pushd tests/e2e
118+
echo "--------------- injecting templates in postgres db..."
119+
120+
# Checks that pg is up and running
121+
IMAGE_NAME="$(docker image ls --filter 'reference=postgres*' --format "{{.Repository}}:{{.Tag}}" | tail -1)"
122+
docker ps --filter "ancestor=$IMAGE_NAME"
123+
docker inspect "$(docker ps --filter "ancestor=$IMAGE_NAME" -q)"
124+
125+
# Cleaning up volumes
126+
docker volume prune --force
127+
128+
# migrates tables
129+
make pg-db-tables
130+
131+
# Injects project template
132+
make inject-templates-in-db
133+
popd
134+
}
135+
14136
install() {
15-
echo "--------------- installing psql client..."
16-
/bin/bash -c 'sudo apt install -y postgresql-client'
17-
echo "--------------- getting simcore docker images..."
18-
make pull-version || ( (make pull-cache || true) && make build-x tag-version)
19-
make info-images
20-
21-
# configure simcore for testing with a private registry
22-
bash tests/e2e/scripts/setup_env_insecure_registry.bash
23-
24-
# start simcore and set log-level
25-
export LOG_LEVEL=WARNING; make up-version
26-
27-
echo "-------------- installing test framework..."
28-
# create a python venv and activate
29-
make .venv
30-
# shellcheck disable=SC1091
31-
source .venv/bin/activate
32-
bash ci/helpers/ensure_python_pip.bash
33-
pushd tests/e2e;
34-
make install
35-
echo "--------------- deploying the registry..."
36-
make registry-up
37-
echo "--------------- waiting for all services to be up..."
38-
make wait-for-services
39-
echo "--------------- transfering the images to the local registry..."
40-
make transfer-images-to-registry
41-
echo "--------------- injecting templates in postgres db..."
42-
make pg-db-tables
43-
make inject-templates-in-db
44-
popd
137+
## shortcut
138+
setup_images
139+
setup_environment
140+
setup_registry
141+
setup_database
45142
}
46143

47144
test() {
48-
pushd tests/e2e; make test; popd
145+
pushd tests/e2e
146+
make test
147+
popd
49148

50149
}
51150

52151
recover_artifacts() {
53-
# all screenshots are in tests/e2e/screenshots if any
54-
55-
# get docker logs.
56-
# WARNING: dumping long logs might take hours!!
57-
mkdir simcore_logs
58-
(docker service logs --timestamps --tail=300 --details simcore_webserver > simcore_logs/webserver.log 2>&1) || true
59-
(docker service logs --timestamps --tail=200 --details simcore_director > simcore_logs/director.log 2>&1) || true
60-
(docker service logs --timestamps --tail=200 --details simcore_storage > simcore_logs/storage.log 2>&1) || true
61-
(docker service logs --timestamps --tail=200 --details simcore_sidecar > simcore_logs/sidecar.log 2>&1) || true
62-
(docker service logs --timestamps --tail=200 --details simcore_catalog > simcore_logs/catalog.log 2>&1) || true
152+
# all screenshots are in tests/e2e/screenshots if any
153+
154+
# get docker logs.
155+
# WARNING: dumping long logs might take hours!!
156+
mkdir simcore_logs
157+
(docker service logs --timestamps --tail=300 --details simcore_webserver >simcore_logs/webserver.log 2>&1) || true
158+
(docker service logs --timestamps --tail=200 --details simcore_director >simcore_logs/director.log 2>&1) || true
159+
(docker service logs --timestamps --tail=200 --details simcore_storage >simcore_logs/storage.log 2>&1) || true
160+
(docker service logs --timestamps --tail=200 --details simcore_sidecar >simcore_logs/sidecar.log 2>&1) || true
161+
(docker service logs --timestamps --tail=200 --details simcore_catalog >simcore_logs/catalog.log 2>&1) || true
63162
}
64163

65164
clean_up() {
66-
echo "--------------- listing services running..."
67-
docker service ls
68-
echo "--------------- listing images available..."
69-
docker images
70-
echo "--------------- switching off..."
71-
make leave
165+
echo "--------------- listing services running..."
166+
docker service ls
167+
echo "--------------- listing images available..."
168+
docker images
169+
echo "--------------- switching off..."
170+
make leave
171+
echo "--------------- uninstalling insecure registry"
172+
uninstall_insecure_registry
72173
}
73174

74175
# Check if the function exists (bash specific)
75-
if declare -f "$1" > /dev/null
76-
then
176+
if declare -f "$1" >/dev/null; then
77177
# call arguments verbatim
78178
"$@"
79179
else

ci/helpers/build_docker_image_tag.bash

+13-12
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,24 @@
1111
set -euo pipefail
1212
IFS=$'\n\t'
1313

14+
default_image_tag="github"
1415

1516
if [ -v TRAVIS ] && [ "$TRAVIS" = "true" ]; then
16-
# travis here
17-
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
18-
image_tag="${TRAVIS_BRANCH}-travis"
19-
else
20-
# this is a pull request, let's use the name of the originating branch instead of a boring master
21-
image_tag="${TRAVIS_PULL_REQUEST_BRANCH}-travis"
22-
fi
17+
# travis here
18+
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
19+
image_tag="${TRAVIS_BRANCH}-travis"
20+
else
21+
# this is a pull request, let's use the name of the originating branch instead of a boring master
22+
image_tag="${TRAVIS_PULL_REQUEST_BRANCH}-travis"
23+
fi
2324
elif [ -v GITHUB_ACTIONS ] && [ "$GITHUB_ACTIONS" = "true" ]; then
24-
# github here
25-
image_tag="${GITHUB_REF##*/}-github"
25+
# github here
26+
image_tag="${GITHUB_REF##*/}-github"
2627
else
27-
# no CI here so let's use the git name directly
28-
image_tag=$(git rev-parse --abbrev-ref HEAD)
28+
# no CI here so let's use the git name directly
29+
image_tag="$(git rev-parse --abbrev-ref HEAD)-$default_image_tag"
2930
fi
3031

31-
slugified_name=$(exec ci/helpers/slugify_name.bash "$image_tag")
32+
slugified_name="$(exec ci/helpers/slugify_name.bash "$image_tag")"
3233

3334
echo "$slugified_name-testbuild-latest"

0 commit comments

Comments
 (0)