From 676e7a2236a25c9b05fd8f34b09f3176a09e6d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Je=C5=99=C3=A1bek=20=28Jiri=20Jerabek=29?= Date: Thu, 22 Aug 2024 13:13:39 +0200 Subject: [PATCH] Try to parallelize rbac roles tests (#2237) * fix typo * enable other envs * test with include * rework rbac-parallel * fix typo * fix RBAC_PARALLEL_GROUP * fix linter No-Issue --- .github/workflows/ci_oci-env-integration.yml | 9 ++++++++- Makefile | 4 ++++ .../actions/rbac-parallel.py | 20 +++++++++++++++++++ .../tests/integration/api/test_rbac_roles.py | 4 ++++ galaxy_ng/tests/integration/conftest.py | 2 ++ 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 dev/oci_env_integration/actions/rbac-parallel.py diff --git a/.github/workflows/ci_oci-env-integration.yml b/.github/workflows/ci_oci-env-integration.yml index 22a168384d..45e6d3b654 100644 --- a/.github/workflows/ci_oci-env-integration.yml +++ b/.github/workflows/ci_oci-env-integration.yml @@ -18,7 +18,9 @@ jobs: - TEST_PROFILE: ldap - TEST_PROFILE: keycloak - TEST_PROFILE: standalone - - TEST_PROFILE: rbac + # - TEST_PROFILE: rbac + - TEST_PROFILE: rbac_parallel_group_1 + - TEST_PROFILE: rbac_parallel_group_2 - TEST_PROFILE: certified-sync - TEST_PROFILE: insights - TEST_PROFILE: iqe_rbac @@ -59,4 +61,9 @@ jobs: mkdir $OCI_ENV_PATH/db_backup/ - name: run integration tests + if: ${{ !startsWith(matrix.env.TEST_PROFILE, 'rbac_parallel_group') }} run: make gh-action/${{ matrix.env.TEST_PROFILE }} + + - name: run parallel rbac integration tests + if: ${{ startsWith(matrix.env.TEST_PROFILE, 'rbac_parallel_group') }} + run: make gh-action/rbac-parallel RBAC_PARALLEL_GROUP=${{ matrix.env.TEST_PROFILE }} diff --git a/Makefile b/Makefile index 87c73e29d7..17895a704b 100644 --- a/Makefile +++ b/Makefile @@ -130,6 +130,10 @@ gh-action/keycloak: gh-action/rbac: python3 dev/oci_env_integration/actions/rbac.py +.PHONY: gh-action/rbac-parallel +gh-action/rbac-parallel: + python3 dev/oci_env_integration/actions/rbac-parallel.py $${RBAC_PARALLEL_GROUP} + .PHONY: gh-action/insights gh-action/insights: python3 dev/oci_env_integration/actions/insights.py diff --git a/dev/oci_env_integration/actions/rbac-parallel.py b/dev/oci_env_integration/actions/rbac-parallel.py new file mode 100644 index 0000000000..f5dcee52cc --- /dev/null +++ b/dev/oci_env_integration/actions/rbac-parallel.py @@ -0,0 +1,20 @@ +import action_lib +import sys + +rbac_parallel_group = None + +rbac_parallel_group = sys.argv[1] if len(sys.argv) == 2 else None +rbac_marker = rbac_parallel_group if rbac_parallel_group else "rbac_roles" + +pytest_flags = "-m {0}".format(rbac_marker) + +env = action_lib.OCIEnvIntegrationTest( + envs=[ + { + "env_file": "standalone.compose.env", + "run_tests": True, + "db_restore": None, + "pytest_flags": pytest_flags + } + ] +) diff --git a/galaxy_ng/tests/integration/api/test_rbac_roles.py b/galaxy_ng/tests/integration/api/test_rbac_roles.py index f139ee1ff1..e1c85e708a 100644 --- a/galaxy_ng/tests/integration/api/test_rbac_roles.py +++ b/galaxy_ng/tests/integration/api/test_rbac_roles.py @@ -651,6 +651,7 @@ def _get_reusable_extras(gc): @pytest.mark.rbac_roles +@pytest.mark.rbac_parallel_group_1 @pytest.mark.parametrize("role", ROLES_TO_TEST) def test_global_role_actions(role, subtests, galaxy_client): USERNAME = f"{NAMESPACE}_user_{gen_string()}" @@ -675,6 +676,7 @@ def test_global_role_actions(role, subtests, galaxy_client): @pytest.mark.rbac_roles +@pytest.mark.rbac_parallel_group_2 @pytest.mark.parametrize("role", OBJECT_ROLES_TO_TEST) def test_object_role_actions(role, subtests, galaxy_client): USERNAME = f"{NAMESPACE}_user_{gen_string()}" @@ -733,6 +735,7 @@ def _apply_roles(): @pytest.mark.rbac_roles +@pytest.mark.rbac_parallel_group_2 def test_role_actions_for_admin(subtests, galaxy_client): gc = galaxy_client("admin", ignore_cache=True) extra = _get_reusable_extras(gc) @@ -745,6 +748,7 @@ def test_role_actions_for_admin(subtests, galaxy_client): @pytest.mark.rbac_roles +@pytest.mark.rbac_parallel_group_2 def test_all_actions_are_tested(): """ Ensures that all of the actions defined in ROLES_TO_TEST and OBJECT_ROLES_TO_TEST diff --git a/galaxy_ng/tests/integration/conftest.py b/galaxy_ng/tests/integration/conftest.py index 522394c098..4da3d882c0 100755 --- a/galaxy_ng/tests/integration/conftest.py +++ b/galaxy_ng/tests/integration/conftest.py @@ -68,6 +68,8 @@ ldap: tests related to the ldap integration role: Related to RBAC Roles rbac_roles: Tests checking Role permissions +rbac_parallel_group_1: Parallelized rbac tests group 1 +rbac_parallel_group_2: Parallelized rbac tests group 2 group: Related to Groups slow_in_cloud: tests that take too long to be run against stage max_hub_version: This marker takes an argument that indicates the maximum hub version