Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lookml): Fixing lookml integration test. #3405

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
view: fragment_derived_view
{ derived_table:
{
sql: date DATE encode ZSTD,
platform VARCHAR(20) encode ZSTD AS aliased_platform,
country VARCHAR(20) encode ZSTD
;;
}
}
50 changes: 25 additions & 25 deletions metadata-ingestion/tests/integration/lookml/test_lookml.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def test_lookml_ingest(pytestconfig, tmp_path, mock_time):
pipeline.pretty_print_summary()
pipeline.raise_from_status(raise_warnings=True)

# mce_helpers.check_golden_file(
# pytestconfig,
# output_path=tmp_path / mce_out_file,
# golden_path=test_resources_dir / mce_out_file,
# )
mce_helpers.check_golden_file(
pytestconfig,
output_path=tmp_path / mce_out_file,
golden_path=test_resources_dir / mce_out_file,
)


@freeze_time(FROZEN_TIME)
Expand Down Expand Up @@ -96,11 +96,11 @@ def test_lookml_ingest_offline(pytestconfig, tmp_path, mock_time):
pipeline.pretty_print_summary()
pipeline.raise_from_status(raise_warnings=True)

# mce_helpers.check_golden_file(
# pytestconfig,
# output_path=tmp_path / mce_out,
# golden_path=test_resources_dir / mce_out,
# )
mce_helpers.check_golden_file(
pytestconfig,
output_path=tmp_path / mce_out,
golden_path=test_resources_dir / mce_out,
)


@freeze_time(FROZEN_TIME)
Expand Down Expand Up @@ -175,11 +175,11 @@ def ingestion_test(
pipeline.pretty_print_summary()
pipeline.raise_from_status(raise_warnings=True)

# mce_helpers.check_golden_file(
# pytestconfig,
# output_path=tmp_path / mce_out_file,
# golden_path=test_resources_dir / mce_out_file,
# )
mce_helpers.check_golden_file(
pytestconfig,
output_path=tmp_path / mce_out_file,
golden_path=test_resources_dir / mce_out_file,
)


@freeze_time(FROZEN_TIME)
Expand Down Expand Up @@ -224,11 +224,11 @@ def test_lookml_bad_sql_parser(pytestconfig, tmp_path, mock_time):
except PipelineExecutionError:
pass

# mce_helpers.check_golden_file(
# pytestconfig,
# output_path=tmp_path / mce_out,
# golden_path=test_resources_dir / mce_out,
# )
mce_helpers.check_golden_file(
pytestconfig,
output_path=tmp_path / mce_out,
golden_path=test_resources_dir / mce_out,
)


@freeze_time(FROZEN_TIME)
Expand Down Expand Up @@ -268,8 +268,8 @@ def test_lookml_github_info(pytestconfig, tmp_path, mock_time):
pipeline.pretty_print_summary()
pipeline.raise_from_status(raise_warnings=True)

# mce_helpers.check_golden_file(
# pytestconfig,
# output_path=tmp_path / mce_out,
# golden_path=test_resources_dir / mce_out,
# )
mce_helpers.check_golden_file(
pytestconfig,
output_path=tmp_path / mce_out,
golden_path=test_resources_dir / mce_out,
)
26 changes: 1 addition & 25 deletions metadata-ingestion/tests/test_helpers/mce_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import pprint
import shutil
from typing import Any, List, Optional, Union
from typing import List, Optional, Union

import deepdiff

Expand Down Expand Up @@ -37,24 +37,6 @@ def assert_mces_equal(
assert not diff, f"MCEs differ\n{pprint.pformat(diff)}"


def mce_mcp_key_extractor(x: Any) -> Any:
"""A key extractor for MCE / MCP records to help with sorting"""
try:
if "proposedSnapshot" in x: # MCE
for k in x["proposedSnapshot"]:
if k.endswith("Snapshot"):
return x["proposedSnapshot"][k]["urn"]
elif "entityUrn" in x: # MCP
return x["entityUrn"]
elif "resource" in x: # legacy Usage event
return x["resource"]
else: # something else, unlikely this will end well
return x
except Exception as e:
print(x)
raise e


def check_golden_file(
pytestconfig: PytestConfig,
output_path: Union[str, os.PathLike],
Expand All @@ -80,12 +62,6 @@ def check_golden_file(
golden = load_json_file(golden_path)

try:
# Do a stable sort of the output and the golden lists to eliminate spurious diffs
if isinstance(output, list):
output = sorted(output, key=mce_mcp_key_extractor)
if isinstance(golden, list):
golden = sorted(golden, key=mce_mcp_key_extractor)

assert_mces_equal(output, golden, ignore_paths)

except AssertionError as e:
Expand Down