diff --git a/src/env_vars.py b/src/env_vars.py index 5f8c290c..ad4100fb 100644 --- a/src/env_vars.py +++ b/src/env_vars.py @@ -19,9 +19,9 @@ def get_env_var(var_name, default=None): # Configuration constants. Need to be upercase to appear in reports -NUM_MESSAGES = get_env_var("NUM_MESSAGES", 50) -PRIVATE_GROUPS = get_env_var("NUM_MESSAGES", 50) -NUM_CONTACT_REQUESTS = get_env_var("NUM_CONTACT_REQUESTS", 10) +NUM_MESSAGES = get_env_var("NUM_MESSAGES", 25) +PRIVATE_GROUPS = get_env_var("NUM_MESSAGES", 25) +NUM_CONTACT_REQUESTS = get_env_var("NUM_CONTACT_REQUESTS", 5) DELAY_BETWEEN_MESSAGES = get_env_var("DELAY_BETWEEN_MESSAGES", 1) RUNNING_IN_CI = get_env_var("CI") API_REQUEST_TIMEOUT = get_env_var("API_REQUEST_TIMEOUT", 10) diff --git a/src/node/rpc_client.py b/src/node/rpc_client.py index aba5d8c0..83bea69a 100644 --- a/src/node/rpc_client.py +++ b/src/node/rpc_client.py @@ -19,7 +19,19 @@ class StatusNodeRPC: params = [] payload = {"jsonrpc": "2.0", "method": method, "params": params, "id": 1} logger.debug(f"Node: {self.node_name} sends request at address: {self.base_url} with payload: {json.dumps(payload)}") - response = requests.post(self.base_url, headers={"Content-Type": "application/json"}, data=json.dumps(payload), timeout=timeout) - logger.debug(f"Received response: {response.text}") - assert "result" in response.json() - return response.json() + + try: + response = requests.post(self.base_url, headers={"Content-Type": "application/json"}, data=json.dumps(payload), timeout=timeout) + logger.debug(f"Received response: {response.text}") + response.raise_for_status() + assert "result" in response.json(), "Response does not contain 'result' key." + return response.json() + + except requests.exceptions.ReadTimeout: + error_message = f"Request to {self.base_url} usig method {method} timed out after {timeout} seconds. Node: {self.node_name}" + logger.error(error_message) + raise RuntimeError(error_message) + + except requests.exceptions.RequestException as e: + logger.error(f"An error occurred: {str(e)}") + raise diff --git a/tests/test_community_messages.py b/tests/test_community_messages.py index ab97f670..c22c6c85 100644 --- a/tests/test_community_messages.py +++ b/tests/test_community_messages.py @@ -7,6 +7,7 @@ from src.steps.common import StepsCommon @pytest.mark.usefixtures("start_1_node") class TestCommunityMessages(StepsCommon): + @pytest.mark.flaky(reruns=2) def test_community_messages_baseline(self): try: self.community_nodes @@ -67,6 +68,7 @@ class TestCommunityMessages(StepsCommon): with self.add_low_bandwith(): self.test_community_messages_baseline() + @pytest.mark.flaky(reruns=2) def test_community_messages_with_node_pause_10_seconds(self): self.setup_community_nodes(node_limit=1) self.join_created_communities() @@ -79,6 +81,7 @@ class TestCommunityMessages(StepsCommon): delay(10) assert community_node.wait_for_logs([message]) + @pytest.mark.flaky(reruns=2) def test_community_messages_with_node_pause_30_seconds(self): self.setup_community_nodes(node_limit=1) self.join_created_communities() diff --git a/tests/test_fetch_community.py b/tests/test_fetch_community.py index e7a0f0ec..64d9dd4c 100644 --- a/tests/test_fetch_community.py +++ b/tests/test_fetch_community.py @@ -7,6 +7,7 @@ from datetime import datetime @pytest.mark.usefixtures("start_1_node") class TestFetchCommunity(StepsCommon): + @pytest.mark.flaky(reruns=2) def test_fetch_community_baseline(self): try: self.community_nodes diff --git a/tests/test_join_community.py b/tests/test_join_community.py index 110c7820..4ee8b7d9 100644 --- a/tests/test_join_community.py +++ b/tests/test_join_community.py @@ -7,6 +7,7 @@ from datetime import datetime @pytest.mark.usefixtures("start_1_node") class TestJoinCommunity(StepsCommon): + @pytest.mark.flaky(reruns=2) def test_join_community_baseline(self): try: self.community_nodes @@ -65,6 +66,7 @@ class TestJoinCommunity(StepsCommon): with self.add_low_bandwith(): self.test_join_community_baseline() + @pytest.mark.flaky(reruns=2) def test_join_community_with_node_pause(self): self.setup_community_nodes(node_limit=1) community_id = self.community_nodes[0]["community_id"] diff --git a/tests/test_leave_community.py b/tests/test_leave_community.py index af914731..09d6ccc1 100644 --- a/tests/test_leave_community.py +++ b/tests/test_leave_community.py @@ -6,6 +6,7 @@ from datetime import datetime @pytest.mark.usefixtures("start_1_node") class TestLeaveCommunity(StepsCommon): + @pytest.mark.flaky(reruns=2) def test_leave_community_baseline(self): try: self.community_nodes