diff --git a/stack/docker-compose.base-with-services.yml b/stack/docker-compose.base-with-services.yml deleted file mode 100644 index 9074a8e7..00000000 --- a/stack/docker-compose.base-with-services.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -version: '3.4' - -services: - - aiidalab: - image: ${REGISTRY:-}${BASE_WITH_SERVICES_IMAGE:-aiidalab/base-with-services}:${VERSION:-newly-build} - environment: - TZ: Europe/Zurich - DOCKER_STACKS_JUPYTER_CMD: notebook - SETUP_DEFAULT_AIIDA_PROFILE: 'true' - AIIDALAB_DEFAULT_APPS: '' - volumes: - - aiidalab-home-folder:/home/jovyan - ports: - - "0.0.0.0:${AIIDALAB_PORT:-}:8888" - -volumes: - aiidalab-home-folder: diff --git a/stack/docker-compose.base.yml b/stack/docker-compose.base.yml deleted file mode 100644 index 3888e526..00000000 --- a/stack/docker-compose.base.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -version: '3.4' - -services: - - database: - image: postgres:12.3 - environment: - POSTGRES_USER: pguser - POSTGRES_PASSWORD: password - volumes: - - aiida-postgres-db:/var/lib/postgresql/data - healthcheck: - test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER}"] - interval: 5s - timeout: 5s - retries: 10 - - messaging: - image: rabbitmq:3.8.3-management - environment: - RABBITMQ_DEFAULT_USER: guest - RABBITMQ_DEFAULT_PASS: guest - volumes: - - aiida-rmq-data:/var/lib/rabbitmq/ - - aiidalab: - image: ${REGISTRY:-}${BASE_IMAGE:-aiidalab/base}:${VERSION:-newly-build} - environment: - RMQHOST: messaging - TZ: Europe/Zurich - DOCKER_STACKS_JUPYTER_CMD: notebook - SETUP_DEFAULT_AIIDA_PROFILE: 'true' - AIIDALAB_DEFAULT_APPS: '' - volumes: - - aiidalab-home-folder:/home/jovyan - depends_on: - database: - condition: service_healthy - messaging: - condition: service_started - ports: - - "0.0.0.0:${AIIDALAB_PORT:-}:8888" - -volumes: - aiida-postgres-db: - aiida-rmq-data: - aiidalab-home-folder: diff --git a/tests/conftest.py b/tests/conftest.py index e8cf4799..636a3829 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,7 +20,7 @@ def pytest_addoption(parser): parser.addoption( "--variant", action="store", - default="base", + default="lab", help="Variant (image name) of the docker-compose file to use.", ) diff --git a/tests/test-base-with-services.py b/tests/test-base-with-services.py deleted file mode 100644 index 38f6b18a..00000000 --- a/tests/test-base-with-services.py +++ /dev/null @@ -1,21 +0,0 @@ -"""Services related tests.""" -import json -from packaging.version import parse - - -def test_correct_pgsql_version_installed(aiidalab_exec, pgsql_version): - info = json.loads( - aiidalab_exec( - "mamba list -n aiida-core-services --json --full-name postgresql" - ).decode() - )[0] - assert info["name"] == "postgresql" - assert parse(info["version"]).major == parse(pgsql_version).major - - -def test_rabbitmq_can_start(aiidalab_exec): - """Test the rabbitmq-server can start, the output should be empty if - the command is successful.""" - output = aiidalab_exec("mamba run -n aiida-core-services rabbitmq-server -detached") - - assert output == b"" diff --git a/tests/test-base.py b/tests/test-base.py deleted file mode 100644 index 963fadcf..00000000 --- a/tests/test-base.py +++ /dev/null @@ -1,53 +0,0 @@ -"""This module contains tests for the base image, which are AiiDA and package management related tests.""" -import pytest -import json -from packaging.version import parse - - -@pytest.mark.parametrize("incompatible_version", ["1.6.3"]) -def test_prevent_pip_install_of_incompatible_aiida_version( - aiidalab_exec, nb_user, aiida_version, incompatible_version -): - package_manager = "pip" - assert parse(aiida_version) != parse(incompatible_version) - # Expected to succeed: - aiidalab_exec( - f"{package_manager} install aiida-core=={aiida_version}", user=nb_user - ) - with pytest.raises(Exception): - aiidalab_exec( - f"{package_manager} install aiida-core=={incompatible_version}", - user=nb_user, - ) - - -def test_correct_python_version_installed(aiidalab_exec, python_version): - info = json.loads(aiidalab_exec("mamba list --json --full-name python").decode())[0] - assert info["name"] == "python" - assert parse(info["version"]) == parse(python_version) - - -def test_create_conda_environment(aiidalab_exec, nb_user): - output = aiidalab_exec("conda create -y -n tmp", user=nb_user).decode().strip() - assert "conda activate tmp" in output - # New conda environments should be created in ~/.conda/envs/ - output = aiidalab_exec("conda env list", user=nb_user).decode().strip() - assert f"/home/{nb_user}/.conda/envs/tmp" in output - - -def test_pip_check(aiidalab_exec): - aiidalab_exec("pip check") - - -def test_correct_aiida_version_installed(aiidalab_exec, aiida_version): - info = json.loads( - aiidalab_exec("mamba list --json --full-name aiida-core").decode() - )[0] - assert info["name"] == "aiida-core" - assert parse(info["version"]) == parse(aiida_version) - - -def test_path_local_pip(aiidalab_exec, nb_user): - """test that the pip local bin path ~/.local/bin is added to PATH""" - output = aiidalab_exec("bash -c 'echo \"${PATH}\"'", user=nb_user).decode() - assert f"/home/{nb_user}/.local/bin" in output diff --git a/tests/test-common.py b/tests/test-common.py index a5ce02b8..29daf6a8 100644 --- a/tests/test-common.py +++ b/tests/test-common.py @@ -1,5 +1,57 @@ -"""Tests for all images, which are docker/docker-compose related tests.""" +"""Tests for all images, which are docker/docker-compose related and AiiDA/package management related tests.""" import requests +import pytest +import json +from packaging.version import parse + + +@pytest.mark.parametrize("incompatible_version", ["1.6.3"]) +def test_prevent_pip_install_of_incompatible_aiida_version( + aiidalab_exec, nb_user, aiida_version, incompatible_version +): + package_manager = "pip" + assert parse(aiida_version) != parse(incompatible_version) + # Expected to succeed: + aiidalab_exec( + f"{package_manager} install aiida-core=={aiida_version}", user=nb_user + ) + with pytest.raises(Exception): + aiidalab_exec( + f"{package_manager} install aiida-core=={incompatible_version}", + user=nb_user, + ) + + +def test_correct_python_version_installed(aiidalab_exec, python_version): + info = json.loads(aiidalab_exec("mamba list --json --full-name python").decode())[0] + assert info["name"] == "python" + assert parse(info["version"]) == parse(python_version) + + +def test_create_conda_environment(aiidalab_exec, nb_user): + output = aiidalab_exec("conda create -y -n tmp", user=nb_user).decode().strip() + assert "conda activate tmp" in output + # New conda environments should be created in ~/.conda/envs/ + output = aiidalab_exec("conda env list", user=nb_user).decode().strip() + assert f"/home/{nb_user}/.conda/envs/tmp" in output + + +def test_pip_check(aiidalab_exec): + aiidalab_exec("pip check") + + +def test_correct_aiida_version_installed(aiidalab_exec, aiida_version): + info = json.loads( + aiidalab_exec("mamba list --json --full-name aiida-core").decode() + )[0] + assert info["name"] == "aiida-core" + assert parse(info["version"]) == parse(aiida_version) + + +def test_path_local_pip(aiidalab_exec, nb_user): + """test that the pip local bin path ~/.local/bin is added to PATH""" + output = aiidalab_exec("bash -c 'echo \"${PATH}\"'", user=nb_user).decode() + assert f"/home/{nb_user}/.local/bin" in output def test_notebook_service_available(notebook_service): diff --git a/tests/test-full-stack.py b/tests/test-full-stack.py index a0d7f828..933c55ef 100644 --- a/tests/test-full-stack.py +++ b/tests/test-full-stack.py @@ -1,5 +1,27 @@ +"""Services related test and package integration tests by installing apps from app store.""" import pytest +import json +from packaging.version import parse + + +def test_correct_pgsql_version_installed(aiidalab_exec, pgsql_version): + info = json.loads( + aiidalab_exec( + "mamba list -n aiida-core-services --json --full-name postgresql" + ).decode() + )[0] + assert info["name"] == "postgresql" + assert parse(info["version"]).major == parse(pgsql_version).major + + +def test_rabbitmq_can_start(aiidalab_exec): + """Test the rabbitmq-server can start, the output should be empty if + the command is successful.""" + output = aiidalab_exec("mamba run -n aiida-core-services rabbitmq-server -detached") + + assert output == b"" + @pytest.fixture(scope="function") def generate_aiidalab_install_output(aiidalab_exec, nb_user):