Skip to content
Prev Previous commit
Next Next commit
add smoke test checks
  • Loading branch information
hsheth2 committed Jun 25, 2021
commit db689c04d6c0f9a3c770a2ca0ba682893799ebb9
59 changes: 55 additions & 4 deletions smoke-test/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
KAFKA_BROKER = "localhost:9092"

bootstrap_sample_data = "../metadata-ingestion/examples/mce_files/bootstrap_mce.json"
usage_sample_data = (
"../metadata-ingestion/tests/integration/bigquery-usage/bigquery_usages_golden.json"
)
bq_sample_data = "./sample_bq_data.json"
restli_default_headers = {
"X-RestLi-Protocol-Version": "2.0.0",
Expand All @@ -30,13 +33,12 @@ def test_healthchecks(wait_for_healthchecks):
pass


@pytest.mark.dependency(depends=["test_healthchecks"])
def test_ingestion_via_rest(wait_for_healthchecks):
def ingest_file(filename: str):
pipeline = Pipeline.create(
{
"source": {
"type": "file",
"config": {"filename": bootstrap_sample_data},
"config": {"filename": filename},
},
"sink": {
"type": "datahub-rest",
Expand All @@ -48,6 +50,16 @@ def test_ingestion_via_rest(wait_for_healthchecks):
pipeline.raise_from_status()


@pytest.mark.dependency(depends=["test_healthchecks"])
def test_ingestion_via_rest(wait_for_healthchecks):
ingest_file(bootstrap_sample_data)


@pytest.mark.dependency(depends=["test_healthchecks"])
def test_ingestion_usage_via_rest(wait_for_healthchecks):
ingest_file(usage_sample_data)


@pytest.mark.dependency(depends=["test_healthchecks"])
def test_ingestion_via_kafka(wait_for_healthchecks):
pipeline = Pipeline.create(
Expand All @@ -74,7 +86,13 @@ def test_ingestion_via_kafka(wait_for_healthchecks):
time.sleep(kafka_post_ingestion_wait_sec)


@pytest.mark.dependency(depends=["test_ingestion_via_rest", "test_ingestion_via_kafka"])
@pytest.mark.dependency(
depends=[
"test_ingestion_via_rest",
"test_ingestion_via_kafka",
"test_ingestion_usage_via_rest",
]
)
def test_run_ingestion(wait_for_healthchecks):
# Dummy test so that future ones can just depend on this one.
pass
Expand Down Expand Up @@ -193,6 +211,39 @@ def test_gms_search_dataset(query, min_expected_results):
assert data["elements"][0]["urn"]


# @pytest.mark.dependency(depends=["test_healthchecks", "test_run_ingestion"])
def test_gms_usage_fetch():
response = requests.post(
f"{GMS_ENDPOINT}/usageStats?action=queryRange",
headers=restli_default_headers,
json={
"resource": "urn:li:dataset:(urn:li:dataPlatform:bigquery,harshal-playground-306419.test_schema.excess_deaths_derived,PROD)",
"duration": "DAY",
"rangeFromEnd": "ALL",
},
)
response.raise_for_status()

data = response.json()["value"]

assert len(data["buckets"]) == 6
assert data["buckets"][0]["metrics"]["topSqlQueries"]

fields = data["aggregations"].pop("fields")
assert len(fields) == 12
assert fields[0]["count"] == 7

users = data["aggregations"].pop("users")
assert len(users) == 2
assert users[0]["count"] == 7

assert data["aggregations"] == {
# "fields" and "users" already popped out
"totalSqlQueries": 7,
"uniqueUserCount": 2,
}


@pytest.fixture(scope="session")
def frontend_session(wait_for_healthchecks):
session = requests.Session()
Expand Down