From 72f155882c95f21573b31a613edf066bdb55f630 Mon Sep 17 00:00:00 2001 From: Achal Shah Date: Sun, 17 Apr 2022 23:18:53 -0700 Subject: [PATCH] fix: Teardown trino container correctly after tests (#2562) Signed-off-by: Achal Shah --- Makefile | 2 +- sdk/python/tests/conftest.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4d961a0472..4804271dff 100644 --- a/Makefile +++ b/Makefile @@ -147,7 +147,7 @@ install-go-ci-dependencies: go install github.com/go-python/gopy install-protoc-dependencies: - pip install grpcio-tools==1.34.0 + pip install grpcio-tools==1.44.0 compile-protos-go: install-go-proto-dependencies install-protoc-dependencies cd sdk/python && python setup.py build_go_protos diff --git a/sdk/python/tests/conftest.py b/sdk/python/tests/conftest.py index c72a3af754..2ff97649d6 100644 --- a/sdk/python/tests/conftest.py +++ b/sdk/python/tests/conftest.py @@ -195,15 +195,24 @@ def teardown(cls): cls.container.stop() +@pytest.fixture(scope="session") +def trino_fixture(request): + def teardown(): + TrinoContainerSingleton.teardown() + + request.addfinalizer(teardown) + return TrinoContainerSingleton + + @pytest.fixture( params=FULL_REPO_CONFIGS, scope="session", ids=[str(c) for c in FULL_REPO_CONFIGS] ) -def environment(request, worker_id: str): +def environment(request, worker_id: str, trino_fixture): if "TrinoSourceCreator" in request.param.offline_store_creator.__name__: e = construct_test_environment( request.param, worker_id=worker_id, - offline_container=TrinoContainerSingleton.get_singleton(), + offline_container=trino_fixture.get_singleton(), ) else: e = construct_test_environment(request.param, worker_id=worker_id)