status-cli-tests/tests/test_fetch_community.py

44 lines
1.6 KiB
Python
Raw Permalink Normal View History

2024-07-10 13:59:42 +00:00
from time import sleep
import pytest
from src.libs.common import delay
from src.steps.common import StepsCommon
from datetime import datetime
@pytest.mark.usefixtures("start_1_node")
class TestFetchCommunity(StepsCommon):
2024-09-11 10:00:42 +00:00
@pytest.mark.flaky(reruns=2)
2024-07-10 13:59:42 +00:00
def test_fetch_community_baseline(self):
2024-09-23 07:57:07 +00:00
if not self.community_nodes:
2024-07-10 13:59:42 +00:00
self.setup_community_nodes()
failed_community_fetches = []
for community_node in self.community_nodes:
community_id = community_node["community_id"]
response = self.first_node.fetch_community(community_id)
try:
assert response["result"]["id"] == community_id
except Exception as ex:
failed_community_fetches.append((community_id, str(ex)))
if failed_community_fetches:
formatted_missing_requests = [f",Community ID: {cid}, Error: {er}" for cid, er in failed_community_fetches]
raise AssertionError(
f"{len(failed_community_fetches)} community fetches out of {len(self.community_nodes)}: " + "\n".join(formatted_missing_requests)
)
def test_fetch_community_with_latency(self):
self.setup_community_nodes()
with self.add_latency():
self.test_fetch_community_baseline()
def test_fetch_community_with_packet_loss(self):
self.setup_community_nodes()
with self.add_packet_loss():
self.test_fetch_community_baseline()
def test_fetch_community_with_low_bandwith(self):
self.setup_community_nodes()
with self.add_low_bandwith():
self.test_fetch_community_baseline()