From 82bcf234f44c958a79a2938b29997b39718f3d78 Mon Sep 17 00:00:00 2001 From: Diego MENDEZ <Diego.MENDEZ@ext.ec.europa.eu> Date: Mon, 11 Nov 2024 14:59:25 +0200 Subject: [PATCH] Run some tests just if plugin is installed. --- .gitlab/test.yml | 14 ++++++++++++++ tests/robot/metrics_test.robot | 1 + .../netbox_mac_address_plugin/mac_address.robot | 2 +- tests/robot/plugins_test.robot | 1 + tests/robot/simple_test.robot | 2 +- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.gitlab/test.yml b/.gitlab/test.yml index 585eaed..08c34f2 100644 --- a/.gitlab/test.yml +++ b/.gitlab/test.yml @@ -42,6 +42,13 @@ run-test-job: - python3 -m venv "$CI_PROJECT_DIR/plugins/venv" - source "$CI_PROJECT_DIR/plugins/venv/bin/activate" - pip install -r "$CI_PROJECT_DIR/tests/requirements.e2e.txt" + # Remove some tests if plugins are not installed, to keep CI compatibility with different testing branches. + - for str in {cert,mac,rps}; do + if [[ $(cat requirements.txt | grep -e ${str} | wc -l) == 0 ]]; then + rm -r $CI_PROJECT_DIR/tests/e2e/netbox/netbox_${str}*_plugin; + echo "Removed ${str}'s python tests."; + fi; + done script: - env HOST="${TEST_HOST}" PORT="${TEST_PORT}" API_KEY="$API_KEY" pytest -s --junit-xml=tests-report-netbox-dist-plugin.xml "$CI_PROJECT_DIR/tests/e2e/" after_script: @@ -60,6 +67,13 @@ run-robot-test-job: - python3 -m venv "$CI_PROJECT_DIR/plugins/venv" - source "$CI_PROJECT_DIR/plugins/venv/bin/activate" - docker build -t robotframework:latest ./tests/docker/ + # Remove some tests if plugins are not installed, to keep CI compatibility with different testing branches. + - for str in {mac,}; do + if [[ $(cat requirements.txt | grep -e ${str} | wc -l) == 0 ]]; then + rm -r $CI_PROJECT_DIR/tests/robot/netbox_${str}*_plugin; + echo "Removed ${str}'s robot tests."; + fi; + done script: - docker run --rm -v $CI_PROJECT_DIR:/project --network "host" robotframework:latest bash -c "robot -v HOST:"${TEST_HOST}" -v PORT:"${TEST_PORT}" -v API_TOKEN:"$API_KEY" --outputdir /project/reports /project/tests/robot/" diff --git a/tests/robot/metrics_test.robot b/tests/robot/metrics_test.robot index 6326acb..b028ee6 100644 --- a/tests/robot/metrics_test.robot +++ b/tests/robot/metrics_test.robot @@ -1,4 +1,5 @@ *** Settings *** +Test Tags core Library RequestsLibrary Variables variables.yaml diff --git a/tests/robot/netbox_mac_address_plugin/mac_address.robot b/tests/robot/netbox_mac_address_plugin/mac_address.robot index 6654473..7f90b8d 100644 --- a/tests/robot/netbox_mac_address_plugin/mac_address.robot +++ b/tests/robot/netbox_mac_address_plugin/mac_address.robot @@ -1,5 +1,5 @@ *** Settings *** -Test Tags Docs +Test Tags mac Library RequestsLibrary Library OperatingSystem Library Collections diff --git a/tests/robot/plugins_test.robot b/tests/robot/plugins_test.robot index a30cc99..ab568d9 100644 --- a/tests/robot/plugins_test.robot +++ b/tests/robot/plugins_test.robot @@ -1,4 +1,5 @@ *** Settings *** +Test Tags core Library RequestsLibrary Variables variables.yaml diff --git a/tests/robot/simple_test.robot b/tests/robot/simple_test.robot index efa5c53..a450570 100644 --- a/tests/robot/simple_test.robot +++ b/tests/robot/simple_test.robot @@ -1,5 +1,5 @@ *** Test Cases *** TC01 Pass Test + [tags] testing Pass Execution A Passing Test - \ No newline at end of file -- GitLab