Skip to content

Commit a5b1e13

Browse files
authored
✅ maintenance: fixes random failures to deploy the stack upon integration tests setup (ITISFoundation#2630)
WARNING: this has a test disabled. New PR should re-enable it back
1 parent 3ffc782 commit a5b1e13

File tree

59 files changed

+1242
-701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1242
-701
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,7 @@ jobs:
19051905
path: codeclimate.${{ github.job }}_coverage.json
19061906

19071907
integration-test-director-v2-01:
1908-
timeout-minutes: 30 # if this timeout gets too small, then split the tests
1908+
timeout-minutes: 35 # FIXME: temporary up (PC). if this timeout gets too small, then split the tests
19091909
name: "[int] director-v2 01"
19101910
needs: [build-test-images]
19111911
runs-on: ${{ matrix.os }}
@@ -2198,7 +2198,7 @@ jobs:
21982198
path: codeclimate.${{ github.job }}_coverage.json
21992199

22002200
system-test-public-api:
2201-
timeout-minutes: 20 # if this timeout gets too small, then split the tests
2201+
timeout-minutes: 25 # if this timeout gets too small, then split the tests
22022202
name: "[sys] public api"
22032203
needs: [build-test-images]
22042204
runs-on: ${{ matrix.os }}
@@ -2301,6 +2301,12 @@ jobs:
23012301
run: ./ci/github/system-testing/swarm-deploy.bash install
23022302
- name: test
23032303
run: ./ci/github/system-testing/swarm-deploy.bash test
2304+
- name: upload failed tests logs
2305+
if: failure()
2306+
uses: actions/upload-artifact@v2
2307+
with:
2308+
name: ${{ github.job }}_docker_logs
2309+
path: ./tests/swarm-deploy/test_failures
23042310
- name: cleanup
23052311
if: always()
23062312
run: ./ci/github/system-testing/swarm-deploy.bash clean_up
@@ -2366,24 +2372,24 @@ jobs:
23662372
run: ./ci/github/system-testing/e2e.bash install
23672373
- name: test
23682374
run: ./ci/github/system-testing/e2e.bash test
2369-
- name: recover docker logs
2370-
id: logs_recovery
2371-
if: always()
2375+
- name: dump docker logs
2376+
id: docker_logs_dump
2377+
if: failure()
23722378
run: ./ci/github/system-testing/e2e.bash dump_docker_logs
23732379
- name: upload docker logs
2374-
if: always()
2380+
if: failure()
23752381
uses: actions/upload-artifact@v2
23762382
with:
23772383
name: ${{ github.job }}_docker_logs
2378-
path: simcore_logs
2384+
path: ./tests/e2e/test_failures
23792385
- name: upload screenshots
23802386
if: always()
23812387
uses: actions/upload-artifact@v2
23822388
with:
23832389
name: ${{ github.job }}_screenshots
23842390
path: tests/e2e/screenshots
23852391
- name: upload e2e logs
2386-
if: always()
2392+
if: failure()
23872393
uses: actions/upload-artifact@v2
23882394
with:
23892395
name: ${{ github.job }}_logs

api/tests/test_repo_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# TODO: find json files under services with the word project or similar wildcard??
2424
PROJECTS_PATHS = [
2525
"services/web/server/tests/data/fake-project.json",
26-
"services/web/server/tests/integration/02/workbench_sleeper_payload.json",
26+
"services/web/server/tests/data/workbench_sleeper_payload.json",
2727
"services/web/server/src/simcore_service_webserver/data/fake-template-projects.isan.json",
2828
"services/web/server/src/simcore_service_webserver/data/fake-template-projects.osparc.json",
2929
"services/web/server/src/simcore_service_webserver/data/fake-template-projects.json",

ci/github/system-testing/e2e.bash

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,14 @@ clean_up() {
4848
dump_docker_logs() {
4949
# get docker logs
5050
# NOTE: Timeout avoids issue with dumping logs that hang!
51-
mkdir --parents simcore_logs
52-
(timeout 30 docker service logs --timestamps --tail=300 --details "${SWARM_STACK_NAME:-test}"_webserver >simcore_logs/webserver.log 2>&1) || true
53-
# then the rest (alphabetically)
54-
(timeout 30 docker service logs --timestamps --tail=100 --details "${SWARM_STACK_NAME:-test}"_api-server >simcore_logs/api-server.log 2>&1) || true
55-
(timeout 30 docker service logs --timestamps --tail=200 --details "${SWARM_STACK_NAME:-test}"_catalog >simcore_logs/catalog.log 2>&1) || true
56-
(timeout 30 docker service logs --timestamps --tail=200 --details "${SWARM_STACK_NAME:-test}"_director >simcore_logs/director.log 2>&1) || true
57-
(timeout 30 docker service logs --timestamps --tail=200 --details "${SWARM_STACK_NAME:-test}"_director-v2 >simcore_logs/director-v2.log 2>&1) || true
58-
(timeout 30 docker service logs --timestamps --tail=200 --details "${SWARM_STACK_NAME:-test}"_sidecar >simcore_logs/sidecar.log 2>&1) || true
59-
(timeout 30 docker service logs --timestamps --tail=200 --details "${SWARM_STACK_NAME:-test}"_storage >simcore_logs/storage.log 2>&1) || true
60-
(timeout 30 docker service logs --timestamps --tail=200 --details "${SWARM_STACK_NAME:-test}"_migration >simcore_logs/migration.log 2>&1) || true
61-
(timeout 30 docker service logs --timestamps --tail=200 --details "${SWARM_STACK_NAME:-test}"_postgres >simcore_logs/postgres.log 2>&1) || true
51+
out_dir=tests/e2e/test_failures
52+
mkdir --parents "$out_dir"
53+
54+
for service_id in $(docker service ls -q); do
55+
service_name=$(docker service inspect "$service_id" --format="{{.Spec.Name}}")
56+
echo "Dumping logs for $service_name"
57+
(timeout 30 docker service logs --timestamps --tail=400 --details "$service_id" >"$out_dir/$service_name.log" 2>&1) || true
58+
done
6259
}
6360

6461
# Check if the function exists (bash specific)

ci/github/system-testing/public-api.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ install() {
2828
}
2929

3030
test() {
31+
# WARNING: this test is heavy. Due to limited CI machine power, please do not
32+
# add too much overhead (e.g. low log-level etc)
3133
pytest \
3234
--color=yes \
3335
--cov-report=term-missing \
3436
--keep-docker-up \
37+
--durations=5 \
3538
-v \
3639
tests/public-api
3740
}

ci/github/system-testing/swarm-deploy.bash

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ install() {
2727
}
2828

2929
test() {
30-
pytest --color=yes --cov-report=term-missing -v tests/swarm-deploy --log-level=DEBUG
30+
# WARNING: this test is heavy. Due to limited CI machine power, please do not
31+
# add too much overhead (e.g. low log-level etc)
32+
pytest \
33+
--color=yes \
34+
--cov-report=term-missing \
35+
-v \
36+
--durations=5 \
37+
--log-level=INFO \
38+
tests/swarm-deploy
3139
}
3240

3341
clean_up() {

packages/pytest-simcore/src/pytest_simcore/docker_compose.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
# pylint:disable=unused-argument
33
# pylint:disable=redefined-outer-name
44

5-
""" Fixtures to create docker-compose.yaml configururation files (as in Makefile)
5+
""" Fixtures to create docker-compose.yaml configuration files (as in Makefile)
66
7-
Basically runs `docker-compose config
7+
- Basically runs `docker-compose config
8+
- Services in stack can be selected using 'core_services_selection', 'ops_services_selection' fixtures
89
"""
910

11+
import json
1012
import os
1113
import shutil
1214
import sys
1315
from copy import deepcopy
1416
from pathlib import Path
15-
from pprint import pformat
1617
from typing import Any, Dict, Iterator, List
1718

1819
import pytest
@@ -24,6 +25,7 @@
2425
FIXTURE_CONFIG_CORE_SERVICES_SELECTION,
2526
FIXTURE_CONFIG_OPS_SERVICES_SELECTION,
2627
)
28+
from .helpers.constants import HEADER_STR
2729
from .helpers.utils_docker import get_ip, run_docker_compose_config, save_docker_infos
2830
from .helpers.utils_environs import EnvVarsDict
2931

@@ -143,7 +145,12 @@ def simcore_docker_compose(
143145
env_file_path=env_file_for_testing,
144146
destination_path=temp_folder / "simcore_docker_compose.yml",
145147
)
146-
print("simcore docker-compose:\n%s", pformat(config))
148+
# NOTE: do not add indent. Copy&Paste log into editor instead
149+
print(
150+
HEADER_STR.format("simcore docker-compose"),
151+
json.dumps(config),
152+
HEADER_STR.format("-"),
153+
)
147154
return config
148155

149156

@@ -170,7 +177,12 @@ def ops_docker_compose(
170177
env_file_path=env_file_for_testing,
171178
destination_path=temp_folder / "ops_docker_compose.yml",
172179
)
173-
print("ops docker-compose:\n%s", pformat(config))
180+
# NOTE: do not add indent. Copy&Paste log into editor instead
181+
print(
182+
HEADER_STR.format("ops docker-compose"),
183+
json.dumps(config),
184+
HEADER_STR.format("-"),
185+
)
174186
return config
175187

176188

@@ -239,13 +251,14 @@ def pytest_exception_interact(node, call, report):
239251
@pytest.hookimpl()
240252
def pytest_sessionfinish(session: pytest.Session, exitstatus: ExitCode) -> None:
241253
if exitstatus == ExitCode.TESTS_FAILED:
242-
# get the node root dir (guaranteed to exist)
243254
root_directory: Path = Path(session.fspath)
244255
failed_test_directory = root_directory / "test_failures" / session.name
245256
save_docker_infos(failed_test_directory)
246257

247258

248259
# HELPERS ---------------------------------------------
260+
261+
249262
def _minio_fix(service_environs: Dict) -> Dict:
250263
"""this hack ensures that S3 is accessed from the host at all time, thus pre-signed links work."""
251264
if "S3_ENDPOINT" in service_environs:

packages/pytest-simcore/src/pytest_simcore/docker_registry.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
@pytest.fixture(scope="session")
2323
def docker_registry(keep_docker_up: bool) -> str:
24+
"""sets up and runs a docker registry container locally and returns its URL"""
2425
# run the registry outside of the stack
2526
docker_client = docker.from_env()
2627
# try to login to private registry

0 commit comments

Comments
 (0)