From 22f72be2411bb0b98220bc11a5442b533f750791 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 7 Jan 2025 21:08:41 +0800 Subject: [PATCH] test: use internal ports --- src/node/api_clients/rest.py | 5 ++--- src/node/nomos_node.py | 22 +++++++++------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/node/api_clients/rest.py b/src/node/api_clients/rest.py index 512c88a..a899d83 100644 --- a/src/node/api_clients/rest.py +++ b/src/node/api_clients/rest.py @@ -20,7 +20,6 @@ class REST(BaseClient): headers = {"accept": "text/plain"} return self.make_request(method, url, headers=headers, data=payload) - def status(self): - status_response = self.rest_call("get", "cl/status") - logger.debug(f"Status response {status_response}") + def info(self): + status_response = self.rest_call("get", "cryptarchia/info") return status_response.json() diff --git a/src/node/nomos_node.py b/src/node/nomos_node.py index 1a1f301..e4a4a2b 100644 --- a/src/node/nomos_node.py +++ b/src/node/nomos_node.py @@ -53,7 +53,7 @@ class NomosNode: self._external_ports = self._docker_manager.generate_ports(count=number_of_ports) self._udp_port = self._external_ports[0] self._tcp_port = self._external_ports[1] - self._api = REST(self._tcp_port) + self._api = REST(self._internal_ports[1]) logger.debug(f"Internal ports {self._internal_ports}") @@ -85,20 +85,16 @@ class NomosNode: logger.debug(f"Container returned {self._container}") logger.debug(f"Started container from image {self._image_name}. " f"REST: {getattr(self, '_tcp_port', 'N/A')}") - delay(1) - - attached_ip = self._container.attrs["NetworkSettings"]["IPAddress"] - logger.debug(f"Container started with IP {attached_ip}") - # try: - # self.ensure_ready(timeout_duration=wait_for_node_sec) - # except Exception as ex: - # logger.error(f"REST service did not become ready in time: {ex}") - # raise + try: + self.ensure_ready(timeout_duration=wait_for_node_sec) + except Exception as ex: + logger.error(f"REST service did not become ready in time: {ex}") + raise def ensure_ready(self, timeout_duration=10): @retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(0.1), reraise=True) def check_ready(node=self): - node.info_response = node.status() + node.info_response = node.info() logger.info("REST service is ready !!") if self.is_nomos(): @@ -107,5 +103,5 @@ class NomosNode: def is_nomos(self): return "nomos" in self._container_name - def status(self): - return self._api.status() + def info(self): + return self._api.info()