Skip to content

Commit 73d539f

Browse files
committed
Skip content validation for sampling scan tests when using default collection
The default collection can contain documents inserted by other tests, so the content is not always as expected. Change-Id: I4b0ad0ac786358b291ef3b9a8c55097fc671455d Reviewed-on: https://review.couchbase.org/c/couchbase-python-client/+/208445 Reviewed-by: Jared Casey <jared.casey@couchbase.com> Tested-by: Build Bot <build@couchbase.com>
1 parent ad2d70e commit 73d539f

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

couchbase/tests/kv_range_scan_t.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def _purge_temp_docs(self, cb_env, test_ids):
9696
except DocumentNotFoundException:
9797
pass
9898

99-
def _validate_result(self, result, expected_count=0, ids_only=False, return_rows=False, from_sample=False):
99+
def _validate_result(self, result, expected_count=0, ids_only=False, return_rows=False, from_sample=False,
100+
skip_content_validation=False):
100101
assert isinstance(result, ScanResultIterable)
101102
rows = []
102103
for r in result:
@@ -113,7 +114,8 @@ def _validate_result(self, result, expected_count=0, ids_only=False, return_rows
113114
assert r.id is not None
114115
content = r.content_as[dict]
115116
assert content is not None
116-
assert content == {'id': r.id}
117+
if not skip_content_validation:
118+
assert content == {'id': r.id}
117119
rows.append(r)
118120

119121
if from_sample is True:
@@ -179,7 +181,8 @@ def test_sampling_scan(self, cb_env, test_mutation_state):
179181
res = cb_env.collection.scan(scan_type, ScanOptions(timeout=timedelta(seconds=10),
180182
ids_only=False,
181183
consistent_with=test_mutation_state))
182-
self._validate_result(res, limit, ids_only=False, return_rows=False, from_sample=True)
184+
self._validate_result(res, limit, ids_only=False, return_rows=False, from_sample=True,
185+
skip_content_validation=(not cb_env.use_named_collections))
183186

184187
@pytest.mark.usefixtures('check_range_scan_supported')
185188
def test_sampling_scan_with_seed(self, cb_env, test_ids, test_mutation_state):
@@ -188,7 +191,8 @@ def test_sampling_scan_with_seed(self, cb_env, test_ids, test_mutation_state):
188191
res = cb_env.collection.scan(scan_type, ScanOptions(timeout=timedelta(seconds=10),
189192
ids_only=True,
190193
consistent_with=test_mutation_state))
191-
rows = self._validate_result(res, limit, ids_only=True, return_rows=True, from_sample=True)
194+
rows = self._validate_result(res, limit, ids_only=True, return_rows=True, from_sample=True,
195+
skip_content_validation=(not cb_env.use_named_collections))
192196
result_ids = []
193197
for r in rows:
194198
result_ids.append(r.id)
@@ -197,7 +201,8 @@ def test_sampling_scan_with_seed(self, cb_env, test_ids, test_mutation_state):
197201
res = cb_env.collection.scan(scan_type, ScanOptions(timeout=timedelta(seconds=10),
198202
ids_only=True,
199203
consistent_with=test_mutation_state))
200-
rows = self._validate_result(res, limit, ids_only=True, return_rows=True, from_sample=True)
204+
rows = self._validate_result(res, limit, ids_only=True, return_rows=True, from_sample=True,
205+
skip_content_validation=(not cb_env.use_named_collections))
201206
compare_ids = list(map(lambda r: r.id, rows))
202207
assert result_ids == compare_ids
203208

@@ -279,7 +284,7 @@ def test_sampling_scan_with_batch_byte_limit(self, cb_env, test_id, test_mutatio
279284
ScanOptions(timeout=timedelta(seconds=10),
280285
batch_byte_limit=batch_byte_limit,
281286
consistent_with=test_mutation_state))
282-
self._validate_result(res, 100, from_sample=True)
287+
self._validate_result(res, 100, from_sample=True, skip_content_validation=(not cb_env.use_named_collections))
283288

284289
@pytest.mark.usefixtures('check_range_scan_supported')
285290
@pytest.mark.parametrize('batch_item_limit', [0, 1, 25, 100])
@@ -289,7 +294,7 @@ def test_sampling_scan_with_batch_item_limit(self, cb_env, test_id, test_mutatio
289294
ScanOptions(timeout=timedelta(seconds=10),
290295
batch_item_limit=batch_item_limit,
291296
consistent_with=test_mutation_state))
292-
self._validate_result(res, 100, from_sample=True)
297+
self._validate_result(res, 100, from_sample=True, skip_content_validation=(not cb_env.use_named_collections))
293298

294299
@pytest.mark.usefixtures('check_range_scan_supported')
295300
@pytest.mark.parametrize('concurrency', [1, 2, 4, 16, 64, 128])
@@ -299,7 +304,7 @@ def test_sampling_scan_with_concurrency(self, cb_env, test_id, test_mutation_sta
299304
ScanOptions(timeout=timedelta(seconds=10),
300305
concurrency=concurrency,
301306
consistent_with=test_mutation_state))
302-
self._validate_result(res, 100, from_sample=True)
307+
self._validate_result(res, 100, from_sample=True, skip_content_validation=(not cb_env.use_named_collections))
303308

304309
@pytest.mark.usefixtures('check_range_scan_supported')
305310
def test_range_scan_with_zero_concurrency(self, cb_env, test_id, test_mutation_state):

tests/environments/test_environment.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ def use_scope_search_mgmt(self) -> bool:
217217
def use_scope_eventing_mgmt(self) -> bool:
218218
return self._use_scope_eventing_mgmt
219219

220+
@property
221+
def use_named_collections(self) -> bool:
222+
return self._use_named_collections
223+
220224
@property
221225
def vixm(self) -> Optional[Any]:
222226
"""Returns the default ViewIndexManager"""

0 commit comments

Comments
 (0)