Skip to content

Commit

Permalink
Try to parallelize rbac roles tests (#2237)
Browse files Browse the repository at this point in the history
* fix typo
* enable other envs
* test with include
* rework rbac-parallel
* fix typo
* fix RBAC_PARALLEL_GROUP
* fix linter
No-Issue
  • Loading branch information
jerabekjiri authored Aug 22, 2024
1 parent 1ded60e commit 676e7a2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/ci_oci-env-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions dev/oci_env_integration/actions/rbac-parallel.py
Original file line number Diff line number Diff line change
@@ -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
}
]
)
4 changes: 4 additions & 0 deletions galaxy_ng/tests/integration/api/test_rbac_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}"
Expand All @@ -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()}"
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions galaxy_ng/tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 676e7a2

Please sign in to comment.