@@ -29,8 +29,9 @@ def create_magma_bucket
29
29
s . ram_quota_mb = 1024
30
30
end
31
31
)
32
- begin
33
- end
32
+
33
+ env . consistency . wait_until_bucket_present ( TEST_MAGMA_BUCKET_NAME )
34
+
34
35
retry_for_duration ( expected_errors : [ Error ::BucketNotFound ] ) do
35
36
@magma_bucket = @cluster . bucket ( TEST_MAGMA_BUCKET_NAME )
36
37
end
@@ -57,6 +58,8 @@ def get_collection(scope_name, collection_name, mgr = nil)
57
58
end
58
59
59
60
def setup
61
+ skip ( "#{ name } : The server does not support collections" ) unless env . server_version . supports_collections?
62
+
60
63
connect
61
64
@used_scopes = [ ]
62
65
@bucket = @cluster . bucket ( env . bucket )
@@ -86,6 +89,7 @@ def teardown
86
89
def test_create_scope
87
90
scope_name = get_scope_name
88
91
@collection_manager . create_scope ( scope_name )
92
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
89
93
scope = get_scope ( scope_name )
90
94
91
95
refute_nil scope
@@ -94,11 +98,13 @@ def test_create_scope
94
98
def test_drop_scope
95
99
scope_name = get_scope_name
96
100
@collection_manager . create_scope ( scope_name )
101
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
97
102
scope = get_scope ( scope_name )
98
103
99
104
refute_nil scope
100
105
101
106
@collection_manager . drop_scope ( scope_name )
107
+ env . consistency . wait_until_scope_dropped ( env . bucket , scope_name )
102
108
scope = get_scope ( scope_name )
103
109
104
110
assert_nil scope
@@ -108,8 +114,11 @@ def test_create_collection
108
114
coll_names = %w[ coll-1 coll-2 coll-3 ]
109
115
scope_name = get_scope_name
110
116
@collection_manager . create_scope ( scope_name )
117
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
118
+
111
119
coll_names . each do |coll_name |
112
120
@collection_manager . create_collection ( scope_name , coll_name )
121
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , coll_name )
113
122
end
114
123
scope = get_scope ( scope_name )
115
124
@@ -121,15 +130,20 @@ def test_drop_collection
121
130
coll_names = %w[ coll-1 coll-2 coll-3 ]
122
131
scope_name = get_scope_name
123
132
@collection_manager . create_scope ( scope_name )
133
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
134
+
124
135
coll_names . each do |coll_name |
125
136
@collection_manager . create_collection ( scope_name , coll_name )
137
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , coll_name )
126
138
end
127
139
scope = get_scope ( scope_name )
128
140
129
141
refute_nil scope
130
142
assert_equal coll_names . sort , scope . collections . map ( &:name ) . sort
131
143
132
144
@collection_manager . drop_collection ( scope_name , 'coll-1' )
145
+ env . consistency . wait_until_collection_dropped ( env . bucket , scope_name , 'coll-1' )
146
+
133
147
scope = get_scope ( scope_name )
134
148
135
149
refute_includes scope . collections . map ( &:name ) , 'coll-1'
@@ -139,7 +153,10 @@ def test_create_collection_already_exists
139
153
coll_name = 'coll-1'
140
154
scope_name = get_scope_name
141
155
@collection_manager . create_scope ( scope_name )
156
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
157
+
142
158
@collection_manager . create_collection ( scope_name , coll_name )
159
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , coll_name )
143
160
144
161
refute_nil get_collection ( scope_name , coll_name )
145
162
@@ -170,6 +187,7 @@ def test_create_collection_scope_does_not_exist
170
187
def test_create_scope_already_exists
171
188
scope_name = get_scope_name
172
189
@collection_manager . create_scope ( scope_name )
190
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
173
191
174
192
refute_nil get_scope ( scope_name )
175
193
@@ -190,6 +208,7 @@ def test_drop_collection_does_not_exist
190
208
scope_name = get_scope_name
191
209
coll_name = 'does-not-exist'
192
210
@collection_manager . create_scope ( scope_name )
211
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
193
212
194
213
refute_nil get_scope ( scope_name )
195
214
@@ -216,12 +235,14 @@ def test_create_collection_history_retention
216
235
scope_name = get_scope_name
217
236
collection_name = 'test-coll'
218
237
@magma_collection_manager . create_scope ( scope_name )
238
+ env . consistency . wait_until_scope_present ( TEST_MAGMA_BUCKET_NAME , scope_name )
219
239
scope = get_scope ( scope_name , @magma_collection_manager )
220
240
221
241
assert scope
222
242
223
243
settings = Management ::CreateCollectionSettings . new ( history : true )
224
244
@magma_collection_manager . create_collection ( scope_name , collection_name , settings )
245
+ env . consistency . wait_until_collection_present ( TEST_MAGMA_BUCKET_NAME , scope_name , collection_name )
225
246
226
247
coll = get_collection ( scope_name , collection_name , @magma_collection_manager )
227
248
@@ -239,12 +260,15 @@ def test_update_collection_history_retention
239
260
scope_name = get_scope_name
240
261
collection_name = 'test-coll'
241
262
@magma_collection_manager . create_scope ( scope_name )
263
+ env . consistency . wait_until_scope_present ( TEST_MAGMA_BUCKET_NAME , scope_name )
264
+
242
265
scope = get_scope ( scope_name , @magma_collection_manager )
243
266
244
267
assert scope
245
268
246
269
settings = Management ::CreateCollectionSettings . new ( history : false )
247
270
@magma_collection_manager . create_collection ( scope_name , collection_name , settings )
271
+ env . consistency . wait_until_collection_present ( TEST_MAGMA_BUCKET_NAME , scope_name , collection_name )
248
272
249
273
coll = get_collection ( scope_name , collection_name , @magma_collection_manager )
250
274
@@ -268,6 +292,8 @@ def test_create_collection_history_retention_unsupported
268
292
scope_name = get_scope_name
269
293
collection_name = 'test-coll'
270
294
@collection_manager . create_scope ( scope_name )
295
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
296
+
271
297
scope = get_scope ( scope_name )
272
298
273
299
assert scope
@@ -287,6 +313,8 @@ def test_update_collection_history_retention_unsupported
287
313
scope_name = get_scope_name
288
314
collection_name = 'test-coll'
289
315
@collection_manager . create_scope ( scope_name )
316
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
317
+
290
318
scope = get_scope ( scope_name )
291
319
292
320
assert scope
@@ -309,12 +337,14 @@ def test_create_collection_max_expiry
309
337
scope_name = get_scope_name
310
338
collection_name = 'testcoll'
311
339
@collection_manager . create_scope ( scope_name )
340
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
312
341
scope = get_scope ( scope_name )
313
342
314
343
assert scope
315
344
316
345
settings = Management ::CreateCollectionSettings . new ( max_expiry : 5 )
317
346
@collection_manager . create_collection ( scope_name , collection_name , settings )
347
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , collection_name )
318
348
319
349
coll_spec = get_collection ( scope_name , collection_name )
320
350
@@ -348,13 +378,15 @@ def test_create_collection_max_expiry_no_expiry
348
378
scope_name = get_scope_name
349
379
collection_name = 'testcoll'
350
380
@collection_manager . create_scope ( scope_name )
381
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
351
382
scope = get_scope ( scope_name )
352
383
353
384
assert scope
354
385
355
386
settings = Management ::CreateCollectionSettings . new ( max_expiry : -1 )
356
387
357
388
@collection_manager . create_collection ( scope_name , collection_name , settings )
389
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , collection_name )
358
390
359
391
coll_spec = get_collection ( scope_name , collection_name )
360
392
@@ -369,6 +401,7 @@ def test_create_collection_max_expiry_no_expiry_not_supported
369
401
scope_name = get_scope_name
370
402
collection_name = 'testcoll'
371
403
@collection_manager . create_scope ( scope_name )
404
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
372
405
scope = get_scope ( scope_name )
373
406
374
407
assert scope
@@ -384,6 +417,7 @@ def test_create_collection_max_expiry_invalid
384
417
scope_name = get_scope_name
385
418
collection_name = 'testcoll'
386
419
@collection_manager . create_scope ( scope_name )
420
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
387
421
scope = get_scope ( scope_name )
388
422
389
423
assert scope
@@ -404,12 +438,14 @@ def test_update_collection_max_expiry
404
438
scope_name = get_scope_name
405
439
collection_name = 'test-coll'
406
440
@collection_manager . create_scope ( scope_name )
441
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
407
442
scope = get_scope ( scope_name )
408
443
409
444
assert scope
410
445
411
446
settings = Management ::CreateCollectionSettings . new ( max_expiry : 600 )
412
447
@collection_manager . create_collection ( scope_name , collection_name , settings )
448
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , collection_name )
413
449
414
450
coll_spec = get_collection ( scope_name , collection_name )
415
451
@@ -451,12 +487,14 @@ def test_update_collection_max_expiry_no_expiry
451
487
scope_name = get_scope_name
452
488
collection_name = 'testcoll'
453
489
@collection_manager . create_scope ( scope_name )
490
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
454
491
scope = get_scope ( scope_name )
455
492
456
493
assert scope
457
494
458
495
settings = Management ::CreateCollectionSettings . new ( max_expiry : 600 )
459
496
@collection_manager . create_collection ( scope_name , collection_name , settings )
497
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , collection_name )
460
498
461
499
coll_spec = get_collection ( scope_name , collection_name )
462
500
@@ -475,18 +513,23 @@ def test_update_collection_max_expiry_no_expiry
475
513
476
514
def test_update_collection_max_expiry_no_expiry_not_supported
477
515
skip ( "#{ name } : CAVES does not support update_collection" ) if use_caves?
516
+ unless env . server_version . supports_update_collection_max_expiry?
517
+ skip ( "#{ name } : The server does not support update_collection with max_expiry" )
518
+ end
478
519
skip ( "#{ name } : The #{ Couchbase ::Protostellar ::NAME } protocol does not support update_collection" ) if env . protostellar?
479
520
skip ( "#{ name } : The server supports setting max_expiry to -1" ) if env . server_version . supports_collection_max_expiry_set_to_no_expiry?
480
521
481
522
scope_name = get_scope_name
482
523
collection_name = 'testcoll'
483
524
@collection_manager . create_scope ( scope_name )
525
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
484
526
scope = get_scope ( scope_name )
485
527
486
528
assert scope
487
529
488
530
settings = Management ::CreateCollectionSettings . new ( max_expiry : 600 )
489
531
@collection_manager . create_collection ( scope_name , collection_name , settings )
532
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , collection_name )
490
533
491
534
coll_spec = get_collection ( scope_name , collection_name )
492
535
@@ -507,12 +550,14 @@ def test_update_collection_max_expiry_invalid
507
550
scope_name = get_scope_name
508
551
collection_name = 'testcoll'
509
552
@collection_manager . create_scope ( scope_name )
553
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
510
554
scope = get_scope ( scope_name )
511
555
512
556
assert scope
513
557
514
558
settings = Management ::CreateCollectionSettings . new ( max_expiry : 600 )
515
559
@collection_manager . create_collection ( scope_name , collection_name , settings )
560
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , collection_name )
516
561
517
562
coll_spec = get_collection ( scope_name , collection_name )
518
563
@@ -535,6 +580,7 @@ def test_update_collection_does_not_exist
535
580
scope_name = get_scope_name
536
581
coll_name = 'does-not-exist'
537
582
@collection_manager . create_scope ( scope_name )
583
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
538
584
539
585
refute_nil get_scope ( scope_name )
540
586
@@ -565,13 +611,16 @@ def test_create_collection_deprecated
565
611
scope_name = get_scope_name
566
612
coll_name = 'coll-1'
567
613
@collection_manager . create_scope ( scope_name )
614
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
615
+
568
616
@collection_manager . create_collection (
569
617
Management ::CollectionSpec . new do |spec |
570
618
spec . name = coll_name
571
619
spec . scope_name = scope_name
572
620
end ,
573
621
Management ::Options ::Collection ::CreateCollection . new ( timeout : 80_000 )
574
622
)
623
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , coll_name )
575
624
576
625
refute_nil get_collection ( scope_name , coll_name )
577
626
end
@@ -580,12 +629,15 @@ def test_drop_collection_deprecated
580
629
scope_name = get_scope_name
581
630
coll_name = 'coll-1'
582
631
@collection_manager . create_scope ( scope_name )
632
+ env . consistency . wait_until_scope_present ( env . bucket , scope_name )
633
+
583
634
@collection_manager . create_collection (
584
635
Management ::CollectionSpec . new do |spec |
585
636
spec . name = coll_name
586
637
spec . scope_name = scope_name
587
638
end
588
639
)
640
+ env . consistency . wait_until_collection_present ( env . bucket , scope_name , coll_name )
589
641
590
642
refute_nil get_collection ( scope_name , coll_name )
591
643
@@ -596,6 +648,7 @@ def test_drop_collection_deprecated
596
648
end ,
597
649
Management ::Options ::Collection ::DropCollection . new ( timeout : 80_000 )
598
650
)
651
+ env . consistency . wait_until_collection_dropped ( env . bucket , scope_name , coll_name )
599
652
600
653
assert_nil get_collection ( scope_name , coll_name )
601
654
end
0 commit comments