diff --git a/smoke-test/cypress-dev.sh b/smoke-test/cypress-dev.sh index 155f91f95d..f1bb16d2f1 100755 --- a/smoke-test/cypress-dev.sh +++ b/smoke-test/cypress-dev.sh @@ -15,7 +15,6 @@ python -c 'from tests.cypress.integration_test import ingest_data; ingest_data() cd tests/cypress npm install -export CYPRESS_ADMIN_USERNAME=${ADMIN_USERNAME:-datahub} -export CYPRESS_ADMIN_PASSWORD=${ADMIN_PASSWORD:-datahub} +source ./set-cypress-creds.sh npx cypress open \ No newline at end of file diff --git a/smoke-test/set-cypress-creds.sh b/smoke-test/set-cypress-creds.sh new file mode 100644 index 0000000000..0512724e9a --- /dev/null +++ b/smoke-test/set-cypress-creds.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +export CYPRESS_ADMIN_USERNAME=${ADMIN_USERNAME:-datahub} +export CYPRESS_ADMIN_PASSWORD=${ADMIN_PASSWORD:-datahub} \ No newline at end of file diff --git a/smoke-test/smoke.sh b/smoke-test/smoke.sh index a21c734613..1018ee503d 100755 --- a/smoke-test/smoke.sh +++ b/smoke-test/smoke.sh @@ -22,8 +22,7 @@ source venv/bin/activate (cd ..; ./gradlew :smoke-test:yarnInstall) -export CYPRESS_ADMIN_USERNAME=${ADMIN_USERNAME:-datahub} -export CYPRESS_ADMIN_PASSWORD=${ADMIN_PASSWORD:-datahub} +source ./set-cypress-creds.sh if [[ -z "${TEST_STRATEGY}" ]]; then pytest -rP --durations=20 -vv --continue-on-collection-errors --junit-xml=junit.smoke.xml diff --git a/smoke-test/test_e2e.py b/smoke-test/test_e2e.py index dbb04ce652..fa2ae41f70 100644 --- a/smoke-test/test_e2e.py +++ b/smoke-test/test_e2e.py @@ -17,6 +17,7 @@ from tests.utils import ( wait_for_healthcheck_util, get_frontend_session, get_admin_credentials, + get_root_urn, ) bootstrap_sample_data = "../metadata-ingestion/examples/mce_files/bootstrap_mce.json" @@ -120,10 +121,7 @@ def _ensure_dataset_present( @tenacity.retry( stop=tenacity.stop_after_attempt(sleep_times), wait=tenacity.wait_fixed(sleep_sec) ) -def _ensure_group_not_present( - urn: str, - frontend_session -) -> Any: +def _ensure_group_not_present(urn: str, frontend_session) -> Any: json = { "query": """query corpGroup($urn: String!) {\n corpGroup(urn: $urn) {\n @@ -148,7 +146,7 @@ def _ensure_group_not_present( @pytest.mark.dependency(depends=["test_healthchecks"]) def test_ingestion_via_rest(wait_for_healthchecks): ingest_file_via_rest(bootstrap_sample_data) - _ensure_user_present(urn="urn:li:corpuser:datahub") + _ensure_user_present(urn=get_root_urn()) @pytest.mark.dependency(depends=["test_healthchecks"]) @@ -481,7 +479,7 @@ def test_frontend_search_across_entities(frontend_session, query, min_expected_r @pytest.mark.dependency(depends=["test_healthchecks", "test_run_ingestion"]) def test_frontend_user_info(frontend_session): - urn = "urn:li:corpuser:datahub" + urn = get_root_urn() json = { "query": """query corpUser($urn: String!) {\n corpUser(urn: $urn) {\n @@ -570,7 +568,7 @@ def test_ingest_with_system_metadata(): "entity": { "value": { "com.linkedin.metadata.snapshot.CorpUserSnapshot": { - "urn": "urn:li:corpuser:datahub", + "urn": get_root_urn(), "aspects": [ { "com.linkedin.identity.CorpUserInfo": { @@ -603,7 +601,7 @@ def test_ingest_with_blank_system_metadata(): "entity": { "value": { "com.linkedin.metadata.snapshot.CorpUserSnapshot": { - "urn": "urn:li:corpuser:datahub", + "urn": get_root_urn(), "aspects": [ { "com.linkedin.identity.CorpUserInfo": { @@ -633,7 +631,7 @@ def test_ingest_without_system_metadata(): "entity": { "value": { "com.linkedin.metadata.snapshot.CorpUserSnapshot": { - "urn": "urn:li:corpuser:datahub", + "urn": get_root_urn(), "aspects": [ { "com.linkedin.identity.CorpUserInfo": { @@ -731,7 +729,7 @@ def test_frontend_me_query(frontend_session): assert res_data assert res_data["data"] - assert res_data["data"]["me"]["corpUser"]["urn"] == "urn:li:corpuser:datahub" + assert res_data["data"]["me"]["corpUser"]["urn"] == get_root_urn() assert res_data["data"]["me"]["platformPrivileges"]["viewAnalytics"] is True assert res_data["data"]["me"]["platformPrivileges"]["managePolicies"] is True assert res_data["data"]["me"]["platformPrivileges"]["manageUserCredentials"] is True @@ -1140,7 +1138,7 @@ def test_home_page_recommendations(frontend_session): listRecommendations(input: $input) { modules { title } } }""", "variables": { "input": { - "userUrn": "urn:li:corpuser:datahub", + "userUrn": get_root_urn(), "requestContext": {"scenario": "HOME"}, "limit": 5, } @@ -1171,7 +1169,7 @@ def test_search_results_recommendations(frontend_session): listRecommendations(input: $input) { modules { title } } }""", "variables": { "input": { - "userUrn": "urn:li:corpuser:datahub", + "userUrn": get_root_urn(), "requestContext": { "scenario": "SEARCH_RESULTS", "searchRequestContext": {"query": "asdsdsdds", "filters": []}, @@ -1202,7 +1200,7 @@ def test_generate_personal_access_token(frontend_session): "variables": { "input": { "type": "PERSONAL", - "actorUrn": "urn:li:corpuser:datahub", + "actorUrn": get_root_urn(), "duration": "ONE_MONTH", } }, diff --git a/smoke-test/tests/deprecation/deprecation_test.py b/smoke-test/tests/deprecation/deprecation_test.py index ffa2c13196..1149a970aa 100644 --- a/smoke-test/tests/deprecation/deprecation_test.py +++ b/smoke-test/tests/deprecation/deprecation_test.py @@ -1,5 +1,10 @@ import pytest -from tests.utils import delete_urns_from_file, get_frontend_url, ingest_file_via_rest +from tests.utils import ( + delete_urns_from_file, + get_frontend_url, + ingest_file_via_rest, + get_root_urn, +) @pytest.fixture(scope="module", autouse=True) @@ -87,7 +92,7 @@ def test_update_deprecation_all_fields(frontend_session): "deprecated": True, "decommissionTime": 0, "note": "My test note", - "actor": "urn:li:corpuser:datahub", + "actor": get_root_urn(), } @@ -143,6 +148,6 @@ def test_update_deprecation_partial_fields(frontend_session, ingest_cleanup_data assert res_data["data"]["dataset"]["deprecation"] == { "deprecated": False, "note": "", - "actor": "urn:li:corpuser:datahub", + "actor": get_root_urn(), "decommissionTime": None, } diff --git a/smoke-test/tests/policies/test_policies.py b/smoke-test/tests/policies/test_policies.py index c25a96cd27..b709154189 100644 --- a/smoke-test/tests/policies/test_policies.py +++ b/smoke-test/tests/policies/test_policies.py @@ -1,6 +1,12 @@ import pytest import tenacity -from tests.utils import get_frontend_url, wait_for_healthcheck_util, get_frontend_session, get_sleep_info +from tests.utils import ( + get_frontend_url, + wait_for_healthcheck_util, + get_frontend_session, + get_sleep_info, + get_root_urn, +) TEST_POLICY_NAME = "Updated Platform Policy" @@ -25,7 +31,7 @@ def frontend_session(wait_for_healthchecks): @pytest.mark.dependency(depends=["test_healthchecks"]) -@pytest.fixture(scope='class', autouse=True) +@pytest.fixture(scope="class", autouse=True) def test_frontend_list_policies(frontend_session): """Fixture to execute setup before and tear down after all tests are run""" res_data = listPolicies(frontend_session) @@ -73,9 +79,11 @@ def _ensure_policy_present(frontend_session, new_urn): assert res_data["data"]["listPolicies"] # Verify that the updated policy appears in the list and has the appropriate changes - result = list(filter( - lambda x: x["urn"] == new_urn, res_data["data"]["listPolicies"]["policies"] - )) + result = list( + filter( + lambda x: x["urn"] == new_urn, res_data["data"]["listPolicies"]["policies"] + ) + ) print(result) assert len(result) == 1 @@ -99,7 +107,7 @@ def test_frontend_policy_operations(frontend_session): "resources": {"type": "dataset", "allResources": True}, "privileges": ["EDIT_ENTITY_TAGS"], "actors": { - "users": ["urn:li:corpuser:datahub"], + "users": [get_root_urn()], "resourceOwners": False, "allUsers": False, "allGroups": False, @@ -138,7 +146,9 @@ def test_frontend_policy_operations(frontend_session): }, } - response = frontend_session.post(f"{get_frontend_url()}/api/v2/graphql", json=update_json) + response = frontend_session.post( + f"{get_frontend_url()}/api/v2/graphql", json=update_json + ) response.raise_for_status() res_data = response.json() diff --git a/smoke-test/tests/utils.py b/smoke-test/tests/utils.py index 1f59c09569..cf744c3b1d 100644 --- a/smoke-test/tests/utils.py +++ b/smoke-test/tests/utils.py @@ -38,6 +38,10 @@ def get_admin_credentials(): ) +def get_root_urn(): + return "urn:li:corpuser:datahub" + + def get_gms_url(): return os.getenv("DATAHUB_GMS_URL") or "http://localhost:8080"