From 55803e84a9372a5aa6fd75d7effbb26d965098cc Mon Sep 17 00:00:00 2001 From: Jiaqi Luo <jiaqiluo123+GitHub@gmail.com> Date: Tue, 4 Aug 2020 16:59:44 -0700 Subject: [PATCH] add an environment variable to control whether run tests for RBAC v2 or not --- tests/validation/tests/v3_api/common.py | 5 +++++ tests/validation/tests/v3_api/test_rbac_2.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/validation/tests/v3_api/common.py b/tests/validation/tests/v3_api/common.py index 874d02535..d99498155 100644 --- a/tests/validation/tests/v3_api/common.py +++ b/tests/validation/tests/v3_api/common.py @@ -198,6 +198,11 @@ RANCHER_HOSTNAME_PREFIX = os.environ.get("RANCHER_HOSTNAME_PREFIX", test_run_id) # ----------------------------------------------------------------------------- +# this is used for testing rbac v2 +test_rbac_v2 = os.environ.get("RANCHER_TEST_RBAC_V2", "False") +if_test_rbac_v2 = pytest.mark.skipif(test_rbac_v2 != "True", + reason='test for rbac v2 is skipped') + def is_windows(os_type=TEST_OS): return os_type == "windows" diff --git a/tests/validation/tests/v3_api/test_rbac_2.py b/tests/validation/tests/v3_api/test_rbac_2.py index e3a88b13d..5ed3c1c81 100644 --- a/tests/validation/tests/v3_api/test_rbac_2.py +++ b/tests/validation/tests/v3_api/test_rbac_2.py @@ -5,6 +5,7 @@ from .common import DATA_SUBDIR from .common import get_user_client_and_cluster from .common import test_reader from .common import validate_cluster_role_rbac +from .common import if_test_rbac_v2 @pytest.fixture(scope='module', autouse="True") @@ -13,9 +14,10 @@ def create_project_client(): create_kubeconfig(cluster) +@if_test_rbac_v2 @pytest.mark.parametrize("cluster_role, command, authorization, name", test_reader(os.path.join( DATA_SUBDIR, 'rbac/monitoring/monitoring_rbac.json'))) -def test_monitoring_v2_rbac(cluster_role, command, authorization, name): +def test_monitoring_rbac_v2(cluster_role, command, authorization, name): validate_cluster_role_rbac(cluster_role, command, authorization, name) -- GitLab