From 1395d4eea367c5c95912a028ecec2146b001afb3 Mon Sep 17 00:00:00 2001 From: aya Date: Wed, 25 Dec 2024 16:06:01 +0200 Subject: [PATCH] Create new test file for test_get_multiple_2000_store_messages --- .github/workflows/test_common.yml | 4 ++-- tests/store/test_cursor.py | 16 ---------------- tests/store/test_cursor_many_msgs.py | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 tests/store/test_cursor_many_msgs.py diff --git a/.github/workflows/test_common.yml b/.github/workflows/test_common.yml index 9ef04795..3fc6272b 100644 --- a/.github/workflows/test_common.yml +++ b/.github/workflows/test_common.yml @@ -57,11 +57,11 @@ jobs: - name: Run tests run: | if [ "${{ matrix.shard }}" == 7 ]; then - pytest --reruns 2 -k "test_get_multiple_2000_store_messages" -n 1 --maxfail=1 + pytest --reruns 2 --dist=loadgroup tests/store/test_cursor_many_msgs.py -n 1 --maxfail=1 elif [ "${{ matrix.shard }}" == 1 ]; then pytest --dist=loadgroup tests/relay/test_rln.py -n 1 elif [ "${{ matrix.shard }}" != 1 ]; then - pytest --dist=loadgroup --ignore=test_get_multiple_2000_store_messages --ignore=tests/relay/test_rln.py --reruns 2 -n=4 --shard-id=${{ matrix.shard }} --num-shards=13 --alluredir=allure-results + pytest --dist=loadgroup --ignore=tests/relay/test_rln.py --ignore=tests/store/test_cursor_many_msgs.py --reruns 2 -n=4 --shard-id=${{ matrix.shard }} --num-shards=13 --alluredir=allure-results fi diff --git a/tests/store/test_cursor.py b/tests/store/test_cursor.py index ef28f9bb..4e3820dd 100644 --- a/tests/store/test_cursor.py +++ b/tests/store/test_cursor.py @@ -10,22 +10,6 @@ from src.steps.store import StepsStore class TestCursor(StepsStore): # we implicitly test the reusabilty of the cursor for multiple nodes - def test_get_multiple_2000_store_messages(self): - expected_message_hash_list = [] - for i in range(2000): - message = self.create_message(payload=to_base64(f"Message_{i}")) - self.publish_message(message=message) - expected_message_hash_list.append(self.compute_message_hash(self.test_pubsub_topic, message)) - store_response = StoreResponse({"paginationCursor": "", "pagination_cursor": ""}, self.store_node1) - response_message_hash_list = [] - while store_response.pagination_cursor is not None: - cursor = store_response.pagination_cursor - store_response = self.get_messages_from_store(self.store_node1, page_size=100, cursor=cursor) - for index in range(len(store_response.messages)): - response_message_hash_list.append(store_response.message_hash(index)) - assert len(expected_message_hash_list) == len(response_message_hash_list), "Message count mismatch" - assert expected_message_hash_list == response_message_hash_list, "Message hash mismatch" - @pytest.mark.parametrize("cursor_index, message_count", [[2, 4], [3, 20], [10, 40], [19, 20], [19, 50], [110, 120]]) def test_different_cursor_and_indexes(self, cursor_index, message_count): message_hash_list = [] diff --git a/tests/store/test_cursor_many_msgs.py b/tests/store/test_cursor_many_msgs.py new file mode 100644 index 00000000..b34fdaa7 --- /dev/null +++ b/tests/store/test_cursor_many_msgs.py @@ -0,0 +1,27 @@ +import pytest +from src.env_vars import NODE_1, NODE_2 +from src.libs.common import to_base64 +from src.node.store_response import StoreResponse +from src.steps.store import StepsStore + + +@pytest.mark.xfail("go-waku" in NODE_2, reason="Bug reported: https://github.com/waku-org/go-waku/issues/1109") +@pytest.mark.usefixtures("node_setup") +class TestCursorManyMessages(StepsStore): + # we implicitly test the reusabilty of the cursor for multiple nodes + + def test_get_multiple_2000_store_messages(self): + expected_message_hash_list = [] + for i in range(2000): + message = self.create_message(payload=to_base64(f"Message_{i}")) + self.publish_message(message=message) + expected_message_hash_list.append(self.compute_message_hash(self.test_pubsub_topic, message)) + store_response = StoreResponse({"paginationCursor": "", "pagination_cursor": ""}, self.store_node1) + response_message_hash_list = [] + while store_response.pagination_cursor is not None: + cursor = store_response.pagination_cursor + store_response = self.get_messages_from_store(self.store_node1, page_size=100, cursor=cursor) + for index in range(len(store_response.messages)): + response_message_hash_list.append(store_response.message_hash(index)) + assert len(expected_message_hash_list) == len(response_message_hash_list), "Message count mismatch" + assert expected_message_hash_list == response_message_hash_list, "Message hash mismatch"