Skip to content

Commit

Permalink
test: seperated OpenAPI and GraphQL test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunal-kankriya committed Jul 31, 2024
1 parent 99b519a commit 1ff2a6b
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions smoke-test/tests/read_only/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down Expand Up @@ -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"),
Expand All @@ -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"),
],
)
Expand Down Expand Up @@ -126,24 +110,49 @@ 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)
response.raise_for_status()
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}"

0 comments on commit 1ff2a6b

Please sign in to comment.