From 1ae3454147d51b6f617013c7bb8c4d6489601cae Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Mon, 30 Sep 2024 18:18:01 +0200 Subject: [PATCH] feat(tests): add conditional markers for Byron tests Introduce ORDER5_BYRON and LONG_BYRON markers to conditionally apply pytest marks based on the configuration. This change helps to avoid setting priority for tests when the it is not needed, because the tests run on setup where it is fast to respin the local testnet. Also, add a new "noop" placeholder marker to the pyproject.toml file. --- cardano_node_tests/tests/common.py | 6 ++++++ cardano_node_tests/tests/test_configuration.py | 4 ++-- cardano_node_tests/tests/test_kes.py | 4 ++-- cardano_node_tests/tests/test_pools.py | 4 ++-- pyproject.toml | 1 + 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cardano_node_tests/tests/common.py b/cardano_node_tests/tests/common.py index 6ba3b857e..700399269 100644 --- a/cardano_node_tests/tests/common.py +++ b/cardano_node_tests/tests/common.py @@ -9,6 +9,7 @@ from cardano_node_tests.tests import issues from cardano_node_tests.utils import cluster_nodes from cardano_node_tests.utils import clusterlib_utils +from cardano_node_tests.utils import configuration from cardano_node_tests.utils import pytest_utils from cardano_node_tests.utils.versions import VERSIONS @@ -18,6 +19,11 @@ MAX_INT64 = (2**63) - 1 MAX_UINT64 = (2**64) - 1 +ORDER5_BYRON = ( + pytest.mark.order(5) if "_fast" not in configuration.SCRIPTS_DIRNAME else pytest.mark.noop +) +LONG_BYRON = pytest.mark.long if "_fast" not in configuration.SCRIPTS_DIRNAME else pytest.mark.noop + _BLD_SKIP_REASON = "" if VERSIONS.transaction_era != VERSIONS.cluster_era: diff --git a/cardano_node_tests/tests/test_configuration.py b/cardano_node_tests/tests/test_configuration.py index 7ca3838be..adb4fe105 100644 --- a/cardano_node_tests/tests/test_configuration.py +++ b/cardano_node_tests/tests/test_configuration.py @@ -129,8 +129,8 @@ def check_epoch_length(cluster_obj: clusterlib.ClusterLib) -> None: # It takes long time to setup the cluster instance (when starting from Byron). # We mark the tests as "long" and set the highest priority, so the setup is done at the # beginning of the testrun, instead of needing to respin a cluster that is already running. -@pytest.mark.order(5) -@pytest.mark.long +@common.ORDER5_BYRON +@common.LONG_BYRON class TestBasic: """Basic tests for node configuration.""" diff --git a/cardano_node_tests/tests/test_kes.py b/cardano_node_tests/tests/test_kes.py index 8b246203c..3a6159004 100644 --- a/cardano_node_tests/tests/test_kes.py +++ b/cardano_node_tests/tests/test_kes.py @@ -157,8 +157,8 @@ class TestKES: # It takes long time to setup the cluster instance (when starting from Byron). # We mark the tests as "long" and set the highest priority, so the setup is done at the # beginning of the testrun, instead of needing to respin a cluster that is already running. - @pytest.mark.order(5) - @pytest.mark.long + @common.ORDER5_BYRON + @common.LONG_BYRON def test_expired_kes( self, cluster_kes: clusterlib.ClusterLib, diff --git a/cardano_node_tests/tests/test_pools.py b/cardano_node_tests/tests/test_pools.py index 956743aa3..111697f14 100644 --- a/cardano_node_tests/tests/test_pools.py +++ b/cardano_node_tests/tests/test_pools.py @@ -1776,8 +1776,8 @@ def test_pool_registration_deregistration( # It takes long time to setup the cluster instance (when starting from Byron). # We mark the tests as "long" and set the highest priority, so the setup is done at the # beginning of the testrun, instead of needing to respin a cluster that is already running. -@pytest.mark.order(5) -@pytest.mark.long +@common.ORDER5_BYRON +@common.LONG_BYRON class TestPoolCost: """Tests for stake pool cost.""" diff --git a/pyproject.toml b/pyproject.toml index dfb599d0c..3e759f61a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,4 +136,5 @@ markers = [ "upgrade: test(s) for upgrade testing", "plutus: test(s) for plutus", "disabled: temporarily disabled test(s)", + "noop: placeholder marker", ]