From 1ff2a6b4c151f52862ac8a5443ac9cc3e2fa2231 Mon Sep 17 00:00:00 2001 From: kunal kankriya Date: Wed, 31 Jul 2024 17:28:50 +0530 Subject: [PATCH] test: seperated OpenAPI and GraphQL test --- smoke-test/tests/read_only/test_search.py | 61 +++++++++++++---------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/smoke-test/tests/read_only/test_search.py b/smoke-test/tests/read_only/test_search.py index 82f2c6715b8f4b..3b9635f3da2cd5 100644 --- a/smoke-test/tests/read_only/test_search.py +++ b/smoke-test/tests/read_only/test_search.py @@ -6,10 +6,6 @@ BASE_URL_V3 = f"{get_gms_url()}/openapi/v3" -restli_default_headers = { - "X-RestLi-Protocol-Version": "2.0.0", -} - default_headers = { "Content-Type": "application/json", } @@ -66,16 +62,8 @@ def _get_search_result(frontend_session, entity: str): ("chart", "chart"), ("dataset", "dataset"), ("dashboard", "dashboard"), - ( - # Task - "dataJob", - "dataJob", - ), - ( - # Pipeline - "dataFlow", - "dataFlow", - ), + ("dataJob", "dataJob"), + ("dataFlow", "dataFlow"), ("container", "container"), ("tag", "tag"), ("corpUser", "corpUser"), @@ -85,11 +73,7 @@ def _get_search_result(frontend_session, entity: str): ("mlPrimaryKey", "mlPrimaryKey"), ("corpGroup", "corpGroup"), ("mlFeatureTable", "mlFeatureTable"), - ( - # Term group - "glossaryNode", - "glossaryNode", - ), + ("glossaryNode", "glossaryNode"), ("mlModel", "mlModel"), ], ) @@ -126,13 +110,40 @@ def test_search_works(entity_type, api_name): assert res_data["data"], f"res_data was {res_data}" assert res_data["data"][api_name]["urn"] == first_urn, f"res_data was {res_data}" - print(f"Response entity_type {entity_type}") - print(f"Response first_urn {first_urn}") - if not entity_type or not first_urn: - pytest.skip("No dynamic data available") +@pytest.mark.read_only +@pytest.mark.parametrize( + "entity_type", + [ + "chart", + "dataset", + "dashboard", + "dataJob", + "dataFlow", + "container", + "tag", + "corpUser", + "mlFeature", + "glossaryTerm", + "domain", + "mlPrimaryKey", + "corpGroup", + "mlFeatureTable", + "glossaryNode", + "mlModel", + ], +) +def test_openapi_v3_entity(entity_type): + frontend_session = get_frontend_session() + search_result = _get_search_result(frontend_session, entity_type) + num_entities = search_result["total"] + if num_entities == 0: + print(f"[WARN] No results for {entity_type}") + return + entities = search_result["searchResults"] + + first_urn = entities[0]["entity"]["urn"] - # Fetch actual data from the OpenAPI v3 endpoint session = requests.Session() url = f"{BASE_URL_V3}/entity/{entity_type}/{first_urn}" response = session.get(url, headers=default_headers) @@ -140,10 +151,8 @@ def test_search_works(entity_type, api_name): actual_data = response.json() print(f"Entity Data for URN {first_urn}: {actual_data}") - # Simulated expected data, ideally this should be obtained from a reliable source expected_data = {"urn": first_urn} - # Validate that the data from OpenAPI matches the expected data assert ( actual_data["urn"] == expected_data["urn"] ), f"Mismatch: expected {expected_data}, got {actual_data}"