Skip to content

Commit 2cab753

Browse files
hsheth2ksrinath
authored andcommitted
feat(ci): add pytest hooks for updating golden files (datahub-project#12581)
1 parent 7c5922d commit 2cab753

File tree

28 files changed

+593
-654
lines changed

28 files changed

+593
-654
lines changed

Diff for: .github/workflows/metadata-ingestion.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ concurrency:
2727
jobs:
2828
metadata-ingestion:
2929
runs-on: ubuntu-latest
30-
timeout-minutes: 40
30+
timeout-minutes: 60
3131
env:
3232
DATAHUB_TELEMETRY_ENABLED: false
3333
# TODO: Enable this once the test is fixed.

Diff for: metadata-ingestion-modules/airflow-plugin/tests/conftest.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import pathlib
22
import site
33

4+
from datahub.testing.pytest_hooks import ( # noqa: F401,E402
5+
load_golden_flags,
6+
pytest_addoption,
7+
)
48

5-
def pytest_addoption(parser):
6-
parser.addoption(
7-
"--update-golden-files",
8-
action="store_true",
9-
default=False,
10-
)
11-
12-
9+
# The integration tests run Airflow, with our plugin, in a subprocess.
10+
# To get more accurate coverage, we need to ensure that the coverage
11+
# library is available in the subprocess.
1312
# See https://coverage.readthedocs.io/en/latest/subprocess.html#configuring-python-for-sub-process-measurement
1413
coverage_startup_code = "import coverage; coverage.process_startup()"
1514
site_packages_dir = pathlib.Path(site.getsitepackages()[0])

Diff for: metadata-ingestion-modules/airflow-plugin/tests/integration/test_plugin.py

-9
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
HAS_AIRFLOW_LISTENER_API,
2727
HAS_AIRFLOW_STANDALONE_CMD,
2828
)
29-
from tests.utils import PytestConfig
3029

3130
pytestmark = pytest.mark.integration
3231

@@ -346,18 +345,13 @@ def _run_airflow(
346345

347346

348347
def check_golden_file(
349-
pytestconfig: PytestConfig,
350348
output_path: pathlib.Path,
351349
golden_path: pathlib.Path,
352350
ignore_paths: Sequence[str] = (),
353351
) -> None:
354-
update_golden = pytestconfig.getoption("--update-golden-files")
355-
356352
assert_metadata_files_equal(
357353
output_path=output_path,
358354
golden_path=golden_path,
359-
update_golden=update_golden,
360-
copy_output=False,
361355
ignore_paths=ignore_paths,
362356
ignore_order=True,
363357
)
@@ -434,7 +428,6 @@ class DagTestCase:
434428
],
435429
)
436430
def test_airflow_plugin(
437-
pytestconfig: PytestConfig,
438431
tmp_path: pathlib.Path,
439432
golden_filename: str,
440433
test_case: DagTestCase,
@@ -497,7 +490,6 @@ def test_airflow_plugin(
497490
_sanitize_output_file(airflow_instance.metadata_file)
498491

499492
check_golden_file(
500-
pytestconfig=pytestconfig,
501493
output_path=airflow_instance.metadata_file,
502494
golden_path=golden_path,
503495
ignore_paths=[
@@ -512,7 +504,6 @@ def test_airflow_plugin(
512504
if test_case.multiple_connections:
513505
_sanitize_output_file(airflow_instance.metadata_file2)
514506
check_golden_file(
515-
pytestconfig=pytestconfig,
516507
output_path=airflow_instance.metadata_file2,
517508
golden_path=golden_path,
518509
ignore_paths=[

Diff for: metadata-ingestion-modules/dagster-plugin/build.gradle

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ task lint(type: Exec, dependsOn: installDev) {
5959
"mypy --show-traceback --show-error-codes src/ tests/ examples/"
6060
}
6161
task lintFix(type: Exec, dependsOn: installDev) {
62-
commandLine 'bash', '-x', '-c',
63-
"source ${venv_name}/bin/activate && " +
62+
commandLine 'bash', '-c',
63+
"source ${venv_name}/bin/activate && set -x && " +
6464
"ruff check --fix src/ tests/ examples/ && " +
6565
"ruff format src/ tests/ examples/ "
6666
}
@@ -71,9 +71,9 @@ task installDevTest(type: Exec, dependsOn: [installDev]) {
7171
outputs.dir("${venv_name}")
7272
outputs.file(sentinel_file)
7373
commandLine 'bash', '-c',
74-
"source ${venv_name}/bin/activate && set -x && " +
75-
"${pip_install_command} -e .[dev,integration-tests] ${extra_pip_requirements} && " +
76-
"touch ${sentinel_file}"
74+
"source ${venv_name}/bin/activate && set -x && " +
75+
"${pip_install_command} -e .[dev,integration-tests] ${extra_pip_requirements} && " +
76+
"touch ${sentinel_file}"
7777
}
7878

7979
task testQuick(type: Exec, dependsOn: installDevTest) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from datahub.testing.pytest_hooks import ( # noqa: F401,E402
2+
load_golden_flags,
3+
pytest_addoption,
4+
)

Diff for: metadata-ingestion-modules/dagster-plugin/tests/unit/conftest.py

-21
This file was deleted.

0 commit comments

Comments
 (0)