Skip to content

Commit

Permalink
centralize on service_port
Browse files Browse the repository at this point in the history
  • Loading branch information
JunAishima committed Feb 5, 2024
1 parent e516c79 commit 4e797c0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions analysisstore/client/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions analysisstore/ignition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
)
Expand All @@ -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:
Expand All @@ -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()
4 changes: 2 additions & 2 deletions analysisstore/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions analysisstore/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions analysisstore/test/test_conn_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit 4e797c0

Please sign in to comment.