2021-04-01 12:15:05 -07:00
|
|
|
import pytest
|
2021-02-18 14:47:49 -08:00
|
|
|
from click.testing import CliRunner
|
2021-02-11 12:53:44 -08:00
|
|
|
|
2021-02-18 14:47:49 -08:00
|
|
|
from datahub.entrypoints import datahub
|
2021-04-13 17:30:24 -07:00
|
|
|
from tests.test_helpers import fs_helpers, mce_helpers
|
|
|
|
from tests.test_helpers.docker_helpers import wait_for_port
|
2021-02-09 01:02:05 -08:00
|
|
|
|
2021-02-11 12:24:20 -08:00
|
|
|
|
2021-07-14 20:02:48 -07:00
|
|
|
@pytest.mark.integration
|
2021-04-13 17:30:24 -07:00
|
|
|
def test_mysql_ingest(docker_compose_runner, pytestconfig, tmp_path, mock_time):
|
2021-02-18 14:47:49 -08:00
|
|
|
test_resources_dir = pytestconfig.rootpath / "tests/integration/mysql"
|
2021-02-09 01:02:05 -08:00
|
|
|
|
2021-04-13 17:30:24 -07:00
|
|
|
with docker_compose_runner(
|
|
|
|
test_resources_dir / "docker-compose.yml", "mysql"
|
|
|
|
) as docker_services:
|
|
|
|
wait_for_port(docker_services, "testmysql", 3306)
|
2021-02-18 14:47:49 -08:00
|
|
|
|
2021-04-13 17:30:24 -07:00
|
|
|
# Run the metadata ingestion pipeline.
|
|
|
|
runner = CliRunner()
|
|
|
|
with fs_helpers.isolated_filesystem(tmp_path):
|
|
|
|
config_file = (test_resources_dir / "mysql_to_file.yml").resolve()
|
|
|
|
result = runner.invoke(datahub, ["ingest", "-c", f"{config_file}"])
|
|
|
|
assert result.exit_code == 0
|
2021-02-18 14:47:49 -08:00
|
|
|
|
2021-06-30 16:53:20 -07:00
|
|
|
# Verify the output.
|
|
|
|
mce_helpers.check_golden_file(
|
|
|
|
pytestconfig,
|
|
|
|
output_path="mysql_mces.json",
|
|
|
|
golden_path=test_resources_dir / "mysql_mces_golden.json",
|
|
|
|
)
|