Skip to content

Commit 875b8d0

Browse files
[CLIENT-3972] Dev tests: paginated query test case should handle receiving less than all the records when running against a multi-node cluster and the records are unevenly distributed across the nodes / partitions (#992)
1 parent 2e89d02 commit 875b8d0

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

test/new_tests/test_query_pagination.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,25 +130,28 @@ def callback(part_id, input_tuple):
130130
query_obj = self.as_connection.query(self.test_ns, None)
131131
query_obj.paginate()
132132

133-
num_populated_partitions = 4
134-
all_records = (
133+
NUM_PARTITIONS = 4
134+
num_records_from_part_1000_to_1003 = (
135135
self.partition_1000_count
136136
+ self.partition_1001_count
137137
+ self.partition_1002_count
138138
+ self.partition_1003_count
139139
)
140-
self.partition_1000_count / num_populated_partitions
141-
query_obj.max_records = math.ceil(all_records / num_populated_partitions)
140+
avg_records_per_partition = math.ceil(num_records_from_part_1000_to_1003 / NUM_PARTITIONS)
141+
query_obj.max_records = avg_records_per_partition
142142

143-
for i in range(num_populated_partitions):
143+
NUM_ITERATIONS = NUM_PARTITIONS
144+
for _ in range(NUM_ITERATIONS):
144145
query_obj.foreach(
145146
callback,
146147
{
147-
"partition_filter": {"begin": 1000, "count": num_populated_partitions},
148+
"partition_filter": {"begin": 1000, "count": NUM_PARTITIONS},
148149
},
149150
)
150151

151-
assert len(records) == all_records
152+
# Worst case scenario, all the records are in one node
153+
# Best case scenario, we got all the records back
154+
assert NUM_ITERATIONS <= len(records) <= num_records_from_part_1000_to_1003
152155

153156
# NOTE: This could fail if node record counts are small and unbalanced across nodes.
154157
@pytest.mark.xfail(reason="Might fail depending on record count and distribution.")

0 commit comments

Comments
 (0)