From f135a527b16b8689c5f1269408092b578377836f Mon Sep 17 00:00:00 2001 From: Pavel Perestoronin Date: Wed, 10 Jul 2024 14:01:46 +0200 Subject: [PATCH] FIX: test environment cannot connect to ES --- tests/test_elasticsearch.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_elasticsearch.py b/tests/test_elasticsearch.py index 54ef10f..b02003f 100644 --- a/tests/test_elasticsearch.py +++ b/tests/test_elasticsearch.py @@ -11,9 +11,16 @@ from time_execution import settings from time_execution.backends.elasticsearch import ElasticsearchBackend -# This variable is set by tox-docker. See https://tox-docker.readthedocs.io/en/latest/#configuration -ELASTICSEARCH_HOST = os.getenv("ELASTICSEARCH_HOST", "localhost") -ELASTICSEARCH_URI = f"http://{ELASTICSEARCH_HOST}:9200" +# These variables are set by tox-docker. See https://tox-docker.readthedocs.io/en/latest/#configuration +ELASTICSEARCH_HOST = os.getenv("ELASTICSEARCH_HOST") +if not ELASTICSEARCH_HOST: + raise RuntimeError("`ELASTICSEARCH_HOST` is not set") + +ELASTICSEARCH_PORT = os.getenv("ELASTICSEARCH_9200_TCP_PORT") +if not ELASTICSEARCH_PORT: + raise RuntimeError("`ELASTICSEARCH_9200_TCP_PORT` is not set") + +ELASTICSEARCH_URI = f"http://{ELASTICSEARCH_HOST}:{ELASTICSEARCH_PORT}" class TestConnectionErrors(TestBaseBackend):