From 4e797c0a7f73d136bae950d4c3818cc1435ffca7 Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Mon, 5 Feb 2024 14:14:52 -0500 Subject: [PATCH] centralize on service_port --- analysisstore/client/commands.py | 4 ++-- analysisstore/ignition.py | 10 +++++----- analysisstore/test/conftest.py | 4 ++-- analysisstore/test/test_client.py | 6 +++--- analysisstore/test/test_conn_pool.py | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/analysisstore/client/commands.py b/analysisstore/client/commands.py index ac355fb..a25cd76 100644 --- a/analysisstore/client/commands.py +++ b/analysisstore/client/commands.py @@ -13,7 +13,7 @@ class AnalysisClient: def __init__(self, config): self.host = config["host"] - self.port = config["port"] + self.service_port = config["service_port"] self._insert_dict = { "analysis_header": self.insert_analysis_header, "analysis_tail": self.insert_analysis_tail, @@ -31,7 +31,7 @@ def __init__(self, config): @property def _host_url(self): """URL to the tornado instance""" - return "http://{}:{}/".format(self.host, self.port) + return "http://{}:{}/".format(self.host, self.service_port) @property def aheader_url(self): diff --git a/analysisstore/ignition.py b/analysisstore/ignition.py index 910a57a..a9a22de 100644 --- a/analysisstore/ignition.py +++ b/analysisstore/ignition.py @@ -35,7 +35,7 @@ def start_server(config=None): for k, v in load_configuration( "analysisstore", "ASST", - ["mongo_uri", "timezone", "database", "port"], + ["mongo_uri", "timezone", "database", "service_port"], allow_missing=True, ).items() if v is not None @@ -54,7 +54,7 @@ def start_server(config=None): ) parser.add_argument( "--service-port", - dest="port", + dest="service_port", type=int, help="port listen to for clients", ) @@ -74,8 +74,8 @@ def start_server(config=None): config["mongo_uri"] = args.mongo_uri if args.timezone is not None: config["timezone"] = args.timezone - if args.port is not None: - config["port"] = args.port + if args.service_port is not None: + config["service_port"] = args.service_port config["testing"] = args.testing config["log_file_prefix"] = args.log_file_prefix if not config: @@ -98,5 +98,5 @@ def start_server(config=None): astore=astore, ) print("Starting Analysisstore service with configuration ", config) - application.listen(config["port"]) + application.listen(config["service_port"]) tornado.ioloop.IOLoop.current().start() diff --git a/analysisstore/test/conftest.py b/analysisstore/test/conftest.py index c82b7a1..a14bdd1 100644 --- a/analysisstore/test/conftest.py +++ b/analysisstore/test/conftest.py @@ -10,7 +10,7 @@ testing_config = dict( timezone="US/Eastern", - port=7601, + service_port=7601, database="astoretest{0}".format(str(uuid.uuid4())), mongo_uri="mongodb://localhost", host="localhost", @@ -42,6 +42,6 @@ def astore_server(): @pytest.fixture(scope="function") def astore_client(): c = AnalysisClient( - {"host": testing_config["host"], "port": testing_config["port"]} + {"host": testing_config["host"], "service_port": testing_config["service_port"]} ) return c diff --git a/analysisstore/test/test_client.py b/analysisstore/test/test_client.py index e4cf615..99c21c3 100644 --- a/analysisstore/test/test_client.py +++ b/analysisstore/test/test_client.py @@ -7,17 +7,17 @@ def test_conn_switch(astore_server, astore_client): - w_conf = dict(host="wrong_host", port=0) + w_conf = dict(host="wrong_host", service_port=0) tmp_conn = AnalysisClient(w_conf) tmp_conn.host == w_conf["host"] - tmp_conn.port == 0 + tmp_conn.service_port == 0 pytest.raises(requests.exceptions.ConnectionError, tmp_conn.connection_status) def test_urls(astore_client): """Catch potentially annoying and difficult to debug typos""" base_test_url = "http://{}:{}/".format( - testing_config["host"], testing_config["port"] + testing_config["host"], testing_config["service_port"] ) astore_client._host_url == base_test_url astore_client.aheader_url == base_test_url + "analysis_header" diff --git a/analysisstore/test/test_conn_pool.py b/analysisstore/test/test_conn_pool.py index 7d18207..c52d201 100644 --- a/analysisstore/test/test_conn_pool.py +++ b/analysisstore/test/test_conn_pool.py @@ -6,7 +6,7 @@ def test_client_badconf(): config = {"host": "localhost"} pytest.raises(KeyError, AnalysisClient, config) - config["port"] = testing_config["port"] + config["service_port"] = testing_config["service_port"] conn = AnalysisClient(config) conn.host == testing_config["host"] - conn.port == testing_config["port"] + conn.service_port == testing_config["service_port"]