chore: store fixes (#101)

* chore: store fixes

* chore: store fixes
This commit is contained in:
fbarbu15 2025-01-31 09:18:38 +02:00 committed by GitHub
parent 12a9ec96ca
commit 247db73d75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 23 deletions

View File

@ -21,11 +21,11 @@ class TestExternalDb(StepsStore):
message = self.create_message()
self.publish_message(message=message)
self.check_published_message_is_stored(page_size=5, ascending="true")
assert len(self.store_response.messages) == 1
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):
message = self.create_message()
self.publish_message(message=message)
self.check_published_message_is_stored(page_size=5, ascending="true")
assert len(self.store_response.messages) == 2
assert len(self.store_response.messages) >= 2

View File

@ -97,14 +97,16 @@ class TestTimeFilter(StepsStore):
self.publish_message(message=message)
message_hash_list.append(self.compute_message_hash(self.test_pubsub_topic, message))
for node in self.store_nodes:
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[0], "Incorrect messaged filtered based on time"
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)
@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,15 +118,18 @@ 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:
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 !"
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)
@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:
@ -137,6 +142,7 @@ 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:
@ -147,7 +153,6 @@ class TestTimeFilter(StepsStore):
for node in self.store_nodes:
store_response = self.get_messages_from_store(node, page_size=20, start_time=start_time, include_data=True)
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")
@ -175,7 +180,7 @@ class TestTimeFilter(StepsStore):
try:
for node in self.store_nodes:
store_response = self.get_messages_from_store(node, page_size=20, start_time=start_time, include_data=True)
raise Exception(f" request for stored messages with invalid start time {start_time} is successful")
raise Exception(f"Request for stored messages with invalid start time {start_time} is successful")
except Exception as e:
logger.debug(f"invalid start_time cause error {e}")
assert e.args[0].find("Bad Request for url"), "url with wrong start_time is accepted"
@ -203,9 +208,11 @@ 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:
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 "
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)
@pytest.mark.skipif("go-waku" in (NODE_1 + NODE_2), reason="Test works only with nwaku")
def test_time_filter_small_timestamp(self):