mirror of
https://github.com/logos-messaging/logos-messaging-interop-tests.git
synced 2026-01-03 06:23:12 +00:00
chore: store time filter fixes (#106)
* chore: store time filter fixes * adjustments
This commit is contained in:
parent
b3b902ae1c
commit
914de83ec2
@ -14,6 +14,7 @@ class MessageRpcResponse:
|
||||
ephemeral: Optional[bool]
|
||||
meta: Optional[str]
|
||||
proof: Optional[str] = field(default_factory=dict)
|
||||
rateLimitProof: Optional[str] = field(default_factory=dict)
|
||||
rate_limit_proof: Optional[dict] = field(default_factory=dict)
|
||||
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ def set_allure_env_variables():
|
||||
outfile.write(f"{attribute_name}={attribute_value}\n")
|
||||
|
||||
|
||||
@pytest.fixture(scope="class", autouse=False)
|
||||
@pytest.fixture(scope="function", autouse=False)
|
||||
def start_postgres_container():
|
||||
pg_container = start_postgres()
|
||||
yield
|
||||
|
||||
@ -15,7 +15,6 @@ class TestExternalDb(StepsStore):
|
||||
self.setup_first_store_node(store="false", relay="true")
|
||||
self.subscribe_to_pubsub_topics_via_relay()
|
||||
|
||||
@pytest.mark.dependency(name="test_on_empty_postgress_db")
|
||||
@pytest.mark.timeout(60)
|
||||
def test_on_empty_postgress_db(self):
|
||||
message = self.create_message()
|
||||
@ -23,8 +22,11 @@ class TestExternalDb(StepsStore):
|
||||
self.check_published_message_is_stored(page_size=5, ascending="true")
|
||||
assert len(self.store_response.messages) >= 1
|
||||
|
||||
@pytest.mark.dependency(depends=["test_on_empty_postgress_db"])
|
||||
def test_on_postgress_db_with_one_message(self):
|
||||
self.test_on_empty_postgress_db()
|
||||
self.setup_first_publishing_node(store="true", relay="true", store_message_db_url=self.postgress_url)
|
||||
self.setup_first_store_node(store="false", relay="true")
|
||||
self.subscribe_to_pubsub_topics_via_relay()
|
||||
message = self.create_message()
|
||||
self.publish_message(message=message)
|
||||
self.check_published_message_is_stored(page_size=5, ascending="true")
|
||||
|
||||
@ -90,21 +90,22 @@ class TestTimeFilter(StepsStore):
|
||||
assert not store_response.messages, "Message count mismatch"
|
||||
|
||||
def test_time_filter_start_time_equals_end_time(self):
|
||||
message_hash_list = {"nwaku": [], "gowaku": []}
|
||||
ts_pass = self.get_time_list_pass()
|
||||
for timestamp in ts_pass:
|
||||
message = self.create_message(timestamp=timestamp["value"])
|
||||
self.publish_message(message=message)
|
||||
message_hash_list["nwaku"].append(self.compute_message_hash(self.test_pubsub_topic, message, hash_type="hex"))
|
||||
message_hash_list["gowaku"].append(self.compute_message_hash(self.test_pubsub_topic, message, hash_type="base64"))
|
||||
for node in self.store_nodes:
|
||||
try:
|
||||
self.get_messages_from_store(
|
||||
node,
|
||||
page_size=20,
|
||||
start_time=ts_pass[0]["value"],
|
||||
end_time=ts_pass[0]["value"],
|
||||
)
|
||||
raise Exception(f"Request for stored messages with start_time==end_time is successful")
|
||||
except Exception as ex:
|
||||
assert "INVALID_QUERY: startTime should be before endTime" in str(ex)
|
||||
store_response = self.get_messages_from_store(
|
||||
node,
|
||||
page_size=20,
|
||||
start_time=ts_pass[0]["value"],
|
||||
end_time=ts_pass[0]["value"],
|
||||
)
|
||||
assert len(store_response.messages) == 1, "Message count mismatch"
|
||||
assert store_response.message_hash(0) == message_hash_list[node.type()][0], "Incorrect messaged filtered based on time"
|
||||
|
||||
@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku")
|
||||
def test_time_filter_start_time_after_end_time(self):
|
||||
@ -116,18 +117,15 @@ class TestTimeFilter(StepsStore):
|
||||
self.publish_message(message=message)
|
||||
logger.debug(f"inquering stored messages with start time {start_time} after end time {end_time}")
|
||||
for node in self.store_nodes:
|
||||
try:
|
||||
self.get_messages_from_store(
|
||||
node,
|
||||
page_size=20,
|
||||
start_time=start_time,
|
||||
end_time=end_time,
|
||||
)
|
||||
raise Exception(f"Request for stored messages with start_time==end_time is successful")
|
||||
except Exception as ex:
|
||||
assert "INVALID_QUERY: startTime should be before endTime" in str(ex)
|
||||
store_response = self.get_messages_from_store(
|
||||
node,
|
||||
page_size=20,
|
||||
start_time=start_time,
|
||||
end_time=end_time,
|
||||
)
|
||||
logger.debug(f"response for wrong time message is {store_response.response}")
|
||||
assert len(store_response.messages) == 0, "got messages with start time after end time !"
|
||||
|
||||
@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku")
|
||||
def test_time_filter_negative_start_time(self):
|
||||
ts_pass = self.get_time_list_pass()
|
||||
for timestamp in ts_pass:
|
||||
@ -140,7 +138,6 @@ class TestTimeFilter(StepsStore):
|
||||
logger.debug(f"number of messages stored for " f"start time = {start_time} is {len(store_response.messages)}")
|
||||
assert len(store_response.messages) == 6, "number of messages retrieved doesn't match time filter "
|
||||
|
||||
@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku")
|
||||
def test_time_filter_zero_start_time(self):
|
||||
ts_pass = self.get_time_list_pass()
|
||||
for timestamp in ts_pass:
|
||||
@ -206,13 +203,10 @@ class TestTimeFilter(StepsStore):
|
||||
end_time = int((datetime.now() + timedelta(days=8000)).timestamp() * 1e9)
|
||||
logger.debug(f"inquering stored messages with start time {start_time} after end time {end_time}")
|
||||
for node in self.store_nodes:
|
||||
try:
|
||||
self.get_messages_from_store(node, page_size=20, start_time=start_time, end_time=end_time, include_data=True)
|
||||
raise Exception(f"Request for stored messages with invalid end_time {end_time} is successful")
|
||||
except Exception as ex:
|
||||
assert "INVALID_QUERY: time range should be smaller than one day in nanos" in str(ex)
|
||||
store_response = self.get_messages_from_store(node, page_size=20, start_time=start_time, end_time=end_time, include_data=True)
|
||||
logger.debug(f"number of messages stored for start time {start_time} and " f"end time = {end_time} is {len(store_response.messages)}")
|
||||
assert len(store_response.messages) == 6, "number of messages retrieved doesn't match time filter "
|
||||
|
||||
@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku")
|
||||
def test_time_filter_small_timestamp(self):
|
||||
ts_pass = self.get_time_list_pass()
|
||||
start_time = ts_pass[0]["value"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user