diff --git a/pyproject.toml b/pyproject.toml index 438e20a3..60f9ed89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -240,6 +240,8 @@ markers = [ "examples", "influxdb", "mongodb", + "python", + "shell", "slow", ] diff --git a/tests/cluster/test_examples.sh b/tests/cluster/test_examples.sh index 23f5d951..55696bf8 100644 --- a/tests/cluster/test_examples.sh +++ b/tests/cluster/test_examples.sh @@ -9,6 +9,10 @@ test_cloud_cluster() { source examples/shell/cloud_cluster.sh } +test_cloud_import() { + source examples/shell/cloud_import.sh +} + # Load shUnit2. HERE="$(dirname "$(realpath "$0")")" . ${HERE}/../util/shunit2 diff --git a/tests/cluster/test_examples.py b/tests/cluster/test_examples_python.py similarity index 71% rename from tests/cluster/test_examples.py rename to tests/cluster/test_examples_python.py index 10f5f118..0f321932 100644 --- a/tests/cluster/test_examples.py +++ b/tests/cluster/test_examples_python.py @@ -1,6 +1,5 @@ # Copyright (c) 2023, Crate.io Inc. # Distributed under the terms of the AGPLv3 license, see LICENSE. -import subprocess from pathlib import Path import pytest @@ -9,6 +8,9 @@ import cratedb_toolkit +pytestmark = pytest.mark.python + + ROOT = Path(__file__).parent.parent.parent @@ -36,44 +38,6 @@ def test_example_cloud_cluster_exists_python(mocker, mock_cloud_cluster_exists): main() -def test_example_cloud_cluster_exists_shell(mocker, mock_cloud_cluster_exists, capfd): - """ - Verify that the program `examples/shell/cloud_cluster.sh` works. - In this case, the `ctk` command is mocked completely, so this is nothing serious. - """ - - cratedb_toolkit.configure( - settings_accept_env=True, - ) - - mocker.patch.dict( - "os.environ", - { - "CRATEDB_CLOUD_SUBSCRIPTION_ID": "f33a2f55-17d1-4f21-8130-b6595d7c52db", - "CRATEDB_CLOUD_CLUSTER_NAME": "testcluster", - "CRATEDB_USERNAME": "crate", - }, - ) - - script = ROOT / "tests" / "cluster" / "test_examples.sh" - subprocess.check_call(["bash", script]) # noqa: S603, S607 - - out, err = capfd.readouterr() - - assert "cluster start" in out - assert "shell --command" in out - - """ - assert "Mont Blanc massif" in out - assert "Monte Rosa Alps" in out - assert "Deploying/starting/resuming CrateDB Cloud Cluster: id=None, name=plotz" in err - assert "Cluster information: name=plotz, url=https://plotz.aks1.westeurope.azure.cratedb.net:4200" in err - assert "Successfully acquired cluster" in err - assert "CONNECT OK" in err - assert "SELECT 2 rows in set (0.000 sec)" in err - """ - - @responses.activate def test_example_cloud_cluster_with_deploy(mocker, mock_cloud_cluster_deploy): """ diff --git a/tests/cluster/test_examples_shell.py b/tests/cluster/test_examples_shell.py new file mode 100644 index 00000000..25ffc59e --- /dev/null +++ b/tests/cluster/test_examples_shell.py @@ -0,0 +1,48 @@ +import subprocess +from pathlib import Path + +import pytest + +import cratedb_toolkit + +ROOT = Path(__file__).parent.parent.parent + +pytestmark = pytest.mark.shell + + +def test_example_cloud_cluster_exists_shell(mocker, mock_cloud_cluster_exists, capfd): + """ + Verify that the program `examples/shell/cloud_cluster.sh` works. + In this case, the `ctk` command is mocked completely, so this is nothing serious. + """ + + cratedb_toolkit.configure( + settings_accept_env=True, + ) + + mocker.patch.dict( + "os.environ", + { + "CRATEDB_CLOUD_SUBSCRIPTION_ID": "f33a2f55-17d1-4f21-8130-b6595d7c52db", + "CRATEDB_CLOUD_CLUSTER_NAME": "testcluster", + "CRATEDB_USERNAME": "crate", + }, + ) + + script = ROOT / "tests" / "cluster" / "test_examples.sh" + subprocess.check_call(["bash", script]) # noqa: S603, S607 + + out, err = capfd.readouterr() + + assert "cluster start" in out + assert "shell --command" in out + + """ + assert "Mont Blanc massif" in out + assert "Monte Rosa Alps" in out + assert "Deploying/starting/resuming CrateDB Cloud Cluster: id=None, name=plotz" in err + assert "Cluster information: name=plotz, url=https://plotz.aks1.westeurope.azure.cratedb.net:4200" in err + assert "Successfully acquired cluster" in err + assert "CONNECT OK" in err + assert "SELECT 2 rows in set (0.000 sec)" in err + """