Skip to content

Commit e77b521

Browse files
committed
RCBC-543: Add consistency helper for update_collection tests
1 parent 3e56723 commit e77b521

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

test/collection_manager_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ def test_update_collection_history_retention
297297

298298
settings = Management::UpdateCollectionSettings.new(history: true)
299299
@magma_collection_manager.update_collection(scope_name, collection_name, settings)
300+
env.consistency.wait_until_collection_satisfies_predicate(TEST_MAGMA_BUCKET_NAME, scope_name, collection_name) do |c|
301+
c["history"] == true
302+
end
300303

301304
coll = get_collection(scope_name, collection_name, @magma_collection_manager)
302305

@@ -479,6 +482,9 @@ def test_update_collection_max_expiry
479482

480483
settings = Management::UpdateCollectionSettings.new(max_expiry: 1)
481484
@collection_manager.update_collection(scope_name, collection_name, settings)
485+
env.consistency.wait_until_collection_satisfies_predicate(env.bucket, scope_name, collection_name) do |c|
486+
c["maxTTL"] == 1
487+
end
482488

483489
coll_spec = get_collection(scope_name, collection_name)
484490

@@ -529,6 +535,9 @@ def test_update_collection_max_expiry_no_expiry
529535
settings = Management::UpdateCollectionSettings.new(max_expiry: -1)
530536

531537
@collection_manager.update_collection(scope_name, collection_name, settings)
538+
env.consistency.wait_until_collection_satisfies_predicate(env.bucket, scope_name, collection_name) do |c|
539+
c["maxTTL"] == -1
540+
end
532541

533542
coll_spec = get_collection(scope_name, collection_name)
534543

test/utils/consistency_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ def wait_until_collection_dropped(bucket_name, scope_name, collection_name, time
129129
end
130130
end
131131

132+
def wait_until_collection_satisfies_predicate(bucket_name, scope_name, collection_name, timeout: DEFAULT_TIMEOUT_SECS, &blk)
133+
wait_until(timeout,
134+
"Collection `#{collection_name}` in scope `#{scope_name}` & bucket `#{bucket_name}` does not satisfy the predicate at #{blk.source_location.join(':')} in all nodes") do
135+
resource_satisfies_predicate("pools/default/buckets/#{bucket_name}/scopes") do |resp|
136+
resp["scopes"].any? do |scope|
137+
scope["name"] == scope_name && scope["collections"].any? { |c| c["name"] == collection_name && yield(c) }
138+
end
139+
end
140+
end
141+
end
142+
132143
def wait_until_bucket_present_in_indexes(name, timeout: DEFAULT_TIMEOUT_SECS)
133144
wait_until(timeout, "Bucket `#{name}` is not present in the query service in all nodes") do
134145
@query_hosts.all? do |host|

0 commit comments

Comments
 (0)