forked from containers/storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnames.bats
722 lines (636 loc) · 22.1 KB
/
names.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
#!/usr/bin/env bats
load helpers
# Helper function to scan the list of names of an item for a particular value.
check-for-name() {
name="$1"
shift
run storage --debug=false get-names "$@"
[ "$status" -eq 0 ]
[[ "$output" =~ "$name" ]]
}
@test "names at creation: layers" {
# Create a layer with no name.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
lowerlayer=$output
# Verify that the layer exists and can be found by ID.
run storage exists -l $lowerlayer
[ "$status" -eq 0 ]
# Verify that these three names don't appear to be assigned.
run storage exists -l no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -l foolayer
[ "$status" -ne 0 ]
run storage exists -l barlayer
[ "$status" -ne 0 ]
# Create a new layer and give it two of the above-mentioned names.
run storage --debug=false create-layer -n foolayer -n barlayer $lowerlayer
[ "$status" -eq 0 ]
[ "$output" != "" ]
upperlayer=${output%% *}
# Verify that the new layer exists and can be found by its ID.
run storage exists -l $upperlayer
[ "$status" -eq 0 ]
# Verify that two of the names we checked earlier are now assigned, and to the new layer.
run storage exists -l no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -l foolayer
[ "$status" -eq 0 ]
run storage exists -l barlayer
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $upperlayer
[ "$status" -ne 0 ]
run check-for-name foolayer $upperlayer
[ "$status" -eq 0 ]
run check-for-name barlayer $upperlayer
[ "$status" -eq 0 ]
}
@test "add-names: layers" {
# Create a layer with no name.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
lowerlayer=$output
# Verify that we can find the layer by its ID.
run storage exists -l $lowerlayer
[ "$status" -eq 0 ]
# Check that these three names are not currently assigned.
run storage exists -l no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -l foolayer
[ "$status" -ne 0 ]
run storage exists -l barlayer
[ "$status" -ne 0 ]
# Create a new layer with names.
run storage --debug=false create-layer -n foolayer -n barlayer $lowerlayer
[ "$status" -eq 0 ]
[ "$output" != "" ]
upperlayer=${output%% *}
# Add names to the new layer.
run storage add-names -n newlayer -n otherlayer $upperlayer
[ "$status" -eq 0 ]
# Verify that we can find the new layer by its ID.
run storage exists -l $upperlayer
[ "$status" -eq 0 ]
# Verify that the name we didn't assign is still unassigned, and that the two names we
# started with, along with the two we added, are assigned, to the new layer.
run storage exists -l no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -l foolayer
[ "$status" -eq 0 ]
run storage exists -l barlayer
[ "$status" -eq 0 ]
run storage exists -l newlayer
[ "$status" -eq 0 ]
run storage exists -l otherlayer
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $upperlayer
[ "$status" -ne 0 ]
run check-for-name foolayer $upperlayer
[ "$status" -eq 0 ]
run check-for-name barlayer $upperlayer
[ "$status" -eq 0 ]
run check-for-name newlayer $upperlayer
[ "$status" -eq 0 ]
run check-for-name otherlayer $upperlayer
[ "$status" -eq 0 ]
}
@test "set-names: layers" {
# Create a layer with no name.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
lowerlayer=$output
# Verify that we can find the layer by its ID.
run storage exists -l $lowerlayer
[ "$status" -eq 0 ]
# Check that these three names are not currently assigned.
run storage exists -l no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -l foolayer
[ "$status" -ne 0 ]
run storage exists -l barlayer
[ "$status" -ne 0 ]
# Create a new layer with two names.
run storage --debug=false create-layer -n foolayer -n barlayer $lowerlayer
[ "$status" -eq 0 ]
[ "$output" != "" ]
upperlayer=${output%% *}
# Assign a list of two names to the layer, which should remove its other names.
run storage set-names -n newlayer -n otherlayer $upperlayer
[ "$status" -eq 0 ]
# Check that the old names are not assigned at all, but the new names are, to it.
run storage exists -l $upperlayer
[ "$status" -eq 0 ]
run storage exists -l no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -l foolayer
[ "$status" -ne 0 ]
run storage exists -l barlayer
[ "$status" -ne 0 ]
run storage exists -l newlayer
[ "$status" -eq 0 ]
run storage exists -l otherlayer
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $upperlayer
[ "$status" -ne 0 ]
run check-for-name foolayer $upperlayer
[ "$status" -ne 0 ]
run check-for-name barlayer $upperlayer
[ "$status" -ne 0 ]
run check-for-name newlayer $upperlayer
[ "$status" -eq 0 ]
run check-for-name otherlayer $upperlayer
[ "$status" -eq 0 ]
}
@test "move-names: layers" {
# Create a layer with no name.
run storage --debug=false create-layer -n foolayer -n barlayer
[ "$status" -eq 0 ]
[ "$output" != "" ]
lowerlayer=${output%% *}
# Verify that we can find the layer by its ID.
run storage exists -l $lowerlayer
[ "$status" -eq 0 ]
# Check that these three names are not currently assigned.
run storage exists -l no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -l foolayer
[ "$status" -eq 0 ]
run storage exists -l barlayer
[ "$status" -eq 0 ]
# Create another layer with no names.
run storage --debug=false create-layer $lowerlayer
[ "$status" -eq 0 ]
upperlayer=${output%% *}
# Set names on that new layer, which should remove the names from the old one.
run storage set-names -n foolayer -n barlayer $upperlayer
[ "$status" -eq 0 ]
# Verify that we can find the layer by its ID, and that the two names exist.
run storage exists -l $upperlayer
[ "$status" -eq 0 ]
run storage exists -l no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -l foolayer
[ "$status" -eq 0 ]
run storage exists -l barlayer
[ "$status" -eq 0 ]
# Check that the names are attached to the new layer and not the old one.
run check-for-name foolayer $lowerlayer
[ "$status" -ne 0 ]
run check-for-name barlayer $lowerlayer
[ "$status" -ne 0 ]
run check-for-name foolayer $upperlayer
[ "$status" -eq 0 ]
run check-for-name barlayer $upperlayer
[ "$status" -eq 0 ]
}
@test "names at creation: images" {
# Create a layer.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer=$output
# Create an image with names that uses that layer.
run storage --debug=false create-image -n fooimage -n barimage $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
image=${output%% *}
# Check that we can find that image by ID and by its names.
run storage exists -i $image
[ "$status" -eq 0 ]
run storage exists -i no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -i fooimage
[ "$status" -eq 0 ]
run storage exists -i barimage
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $image
[ "$status" -ne 0 ]
run check-for-name fooimage $image
[ "$status" -eq 0 ]
run check-for-name barimage $image
[ "$status" -eq 0 ]
}
@test "add-names: images" {
# Create a layer.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer=$output
# Create an image with names that uses that layer.
run storage --debug=false create-image -n fooimage -n barimage $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
image=${output%% *}
# Check that we can find that image by ID and by its names.
run storage exists -i $image
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $image
[ "$status" -ne 0 ]
run check-for-name fooimage $image
[ "$status" -eq 0 ]
run check-for-name barimage $image
[ "$status" -eq 0 ]
# Add two names to the image.
run storage add-names -n newimage -n otherimage $image
[ "$status" -eq 0 ]
# Check that all of the names are now assigned.
run storage exists -i no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -i fooimage
[ "$status" -eq 0 ]
run storage exists -i barimage
[ "$status" -eq 0 ]
run storage exists -i newimage
[ "$status" -eq 0 ]
run storage exists -i otherimage
[ "$status" -eq 0 ]
# Check that all of the names are now assigned to this image.
run check-for-name no-such-thing-as-this-name $image
[ "$status" -ne 0 ]
run check-for-name fooimage $image
[ "$status" -eq 0 ]
run check-for-name barimage $image
[ "$status" -eq 0 ]
run check-for-name newimage $image
[ "$status" -eq 0 ]
run check-for-name otherimage $image
[ "$status" -eq 0 ]
}
@test "set-names: images" {
# Create a layer.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer=$output
# Create an image with names that uses that layer.
run storage --debug=false create-image -n fooimage -n barimage $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
image=${output%% *}
# Check that we can find that image by ID and by its names.
run storage exists -i $image
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $image
[ "$status" -ne 0 ]
run check-for-name fooimage $image
[ "$status" -eq 0 ]
run check-for-name barimage $image
[ "$status" -eq 0 ]
# Set the names for the image to two new names.
run storage set-names -n newimage -n otherimage $image
[ "$status" -eq 0 ]
# Check that the two new names are the only ones assigned.
run storage exists -i no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -i fooimage
[ "$status" -ne 0 ]
run storage exists -i barimage
[ "$status" -ne 0 ]
run storage exists -i newimage
[ "$status" -eq 0 ]
run storage exists -i otherimage
[ "$status" -eq 0 ]
# Check that the two new names are the only ones on this image.
run check-for-name no-such-thing-as-this-name $image
[ "$status" -ne 0 ]
run check-for-name fooimage $image
[ "$status" -ne 0 ]
run check-for-name barimage $image
[ "$status" -ne 0 ]
run check-for-name newimage $image
[ "$status" -eq 0 ]
run check-for-name otherimage $image
[ "$status" -eq 0 ]
}
@test "move-names: images" {
# Create a layer.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer=$output
# Create an image with names that uses that layer.
run storage --debug=false create-image -n fooimage -n barimage $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
firstimage=${output%% *}
# Create another image with no names.
run storage --debug=false create-image $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
image=${output%% *}
# Check that we can find the first image by ID and by its names.
run storage exists -i $firstimage
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $firstimage
[ "$status" -ne 0 ]
run check-for-name fooimage $firstimage
[ "$status" -eq 0 ]
run check-for-name barimage $firstimage
[ "$status" -eq 0 ]
# Set a name list on the new image that includes the names of the old one.
run storage set-names -n fooimage -n barimage -n newimage -n otherimage $image
[ "$status" -eq 0 ]
# Check that all of the names are assigned.
run storage exists -i no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -i fooimage
[ "$status" -eq 0 ]
run storage exists -i barimage
[ "$status" -eq 0 ]
run storage exists -i newimage
[ "$status" -eq 0 ]
run storage exists -i otherimage
[ "$status" -eq 0 ]
# Check that all of the names are assigned to the new image.
run check-for-name no-such-thing-as-this-name $image
[ "$status" -ne 0 ]
run check-for-name fooimage $image
[ "$status" -eq 0 ]
run check-for-name barimage $image
[ "$status" -eq 0 ]
run check-for-name newimage $image
[ "$status" -eq 0 ]
run check-for-name otherimage $image
[ "$status" -eq 0 ]
}
@test "add-names: ro-images" {
case "$STORAGE_DRIVER" in
overlay*|vfs)
;;
*)
skip "not supported by driver $STORAGE_DRIVER"
;;
esac
mkdir ${TESTDIR}/{ro-root,ro-runroot}
# Create a layer.
run storage --debug=false --graph ${TESTDIR}/ro-root --run ${TESTDIR}/ro-runroot create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer=$output
# Create an image with names that uses that layer.
run storage --debug=false --graph ${TESTDIR}/ro-root --run ${TESTDIR}/ro-runroot create-image -n fooimage -n barimage $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
image=${output%% *}
storage --debug=false --graph ${TESTDIR}/ro-root --run ${TESTDIR}/ro-runroot shutdown
# Check that we can find the image by ID and by its names.
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i $image
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i fooimage
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i barimage
[ "$status" -eq 0 ]
# Add a pair of names to the image.
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root add-names -n newimage -n otherimage $image
echo "add-names:" "$output"
[ "$status" -eq 0 ]
# Check that all of the names are resolveable.
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root images
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i $image
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i fooimage
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i barimage
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i newimage
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i otherimage
[ "$status" -eq 0 ]
}
@test "remove-names: ro-images" {
case "$STORAGE_DRIVER" in
overlay*|vfs)
;;
*)
skip "not supported by driver $STORAGE_DRIVER"
;;
esac
mkdir ${TESTDIR}/{ro-root,ro-runroot}
# Create a layer.
run storage --debug=false --graph ${TESTDIR}/ro-root --run ${TESTDIR}/ro-runroot create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer=$output
# Create an image with names that uses that layer.
run storage --debug=false --graph ${TESTDIR}/ro-root --run ${TESTDIR}/ro-runroot create-image -n fooimage -n barimage -n newimage -n otherimage $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
image=${output%% *}
storage --debug=false --graph ${TESTDIR}/ro-root --run ${TESTDIR}/ro-runroot shutdown
# Check that we can find the image by ID and by its names.
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i $image
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i fooimage
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i barimage
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i newimage
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i otherimage
[ "$status" -eq 0 ]
# Remove one of the names from the image.
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root remove-names -n newimage $image
echo "remove-names:" "$output"
[ "$status" -eq 0 ]
# Check that all of the names are still resolveable, except for the one we removed.
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i $image
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i fooimage
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i barimage
[ "$status" -eq 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i newimage
[ "$status" -ne 0 ]
run storage --storage-opt ${STORAGE_DRIVER}.imagestore=${TESTDIR}/ro-root exists -i otherimage
[ "$status" -eq 0 ]
}
@test "names at creation: containers" {
# Create a layer.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer=$output
# Create an image that uses that layer.
run storage --debug=false create-image $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
image=${output%% *}
# Create a container with two names, based on that image.
run storage --debug=false create-container -n foocontainer -n barcontainer $image
[ "$status" -eq 0 ]
[ "$output" != "" ]
container=${output%% *}
# Check that we can find the container using either its ID or names.
run storage exists -c $container
[ "$status" -eq 0 ]
run storage exists -c no-such-thing-as-this-name
[ "$status" -ne 0 ]
run storage exists -c foocontainer
[ "$status" -eq 0 ]
run storage exists -c barcontainer
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $container
[ "$status" -ne 0 ]
run check-for-name foocontainer $container
[ "$status" -eq 0 ]
run check-for-name barcontainer $container
[ "$status" -eq 0 ]
}
@test "add-names: containers" {
# Create a layer.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer=$output
# Create an image that uses that layer.
run storage --debug=false create-image -n fooimage -n barimage $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
image=${output%% *}
# Create a container with two names, based on that image.
run storage --debug=false create-container -n foocontainer -n barcontainer $image
[ "$status" -eq 0 ]
[ "$output" != "" ]
container=${output%% *}
# Check that we can find the container using either its ID or names.
run storage exists -c $container
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $container
[ "$status" -ne 0 ]
run check-for-name foocontainer $container
[ "$status" -eq 0 ]
run check-for-name barcontainer $container
[ "$status" -eq 0 ]
# Add two names to the container.
run storage add-names -n newcontainer -n othercontainer $container
[ "$status" -eq 0 ]
# Verify that all of those names are assigned to the container.
run storage exists -c $container
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $container
[ "$status" -ne 0 ]
run check-for-name foocontainer $container
[ "$status" -eq 0 ]
run check-for-name barcontainer $container
[ "$status" -eq 0 ]
run check-for-name newcontainer $container
[ "$status" -eq 0 ]
run check-for-name othercontainer $container
[ "$status" -eq 0 ]
}
@test "set-names: containers" {
# Create a layer.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer=$output
# Create an image that uses that layer.
run storage --debug=false create-image -n fooimage -n barimage $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
image=${output%% *}
# Create a container with two names, based on that image.
run storage --debug=false create-container -n foocontainer -n barcontainer $image
[ "$status" -eq 0 ]
[ "$output" != "" ]
container=${output%% *}
# Check that we can find the container using either its ID or names.
run storage exists -c $container
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $container
[ "$status" -ne 0 ]
run check-for-name foocontainer $container
[ "$status" -eq 0 ]
run check-for-name barcontainer $container
[ "$status" -eq 0 ]
# Set the list of names for the container to just these two values.
run storage set-names -n newcontainer -n othercontainer $container
[ "$status" -eq 0 ]
# Check that these are the only two names attached to the container.
run storage exists -c $container
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $container
[ "$status" -ne 0 ]
run check-for-name foocontainer $container
[ "$status" -ne 0 ]
run check-for-name barcontainer $container
[ "$status" -ne 0 ]
run check-for-name newcontainer $container
[ "$status" -eq 0 ]
run check-for-name othercontainer $container
[ "$status" -eq 0 ]
}
@test "move-names: containers" {
# Create a layer.
run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer=$output
# Create an image that uses that layer.
run storage --debug=false create-image -n fooimage -n barimage $layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
image=${output%% *}
# Create a container with two names, based on that image.
run storage --debug=false create-container -n foocontainer -n barcontainer $image
[ "$status" -eq 0 ]
[ "$output" != "" ]
firstcontainer=${output%% *}
# Create another container with two different names, based on that image.
run storage --debug=false create-container -n newcontainer -n othercontainer $image
[ "$status" -eq 0 ]
[ "$output" != "" ]
container=${output%% *}
# Check that we can access both containers by ID, and that they have the right names.
run storage exists -c $firstcontainer
[ "$status" -eq 0 ]
run storage exists -c $container
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $firstcontainer
[ "$status" -ne 0 ]
run check-for-name foocontainer $firstcontainer
[ "$status" -eq 0 ]
run check-for-name barcontainer $firstcontainer
[ "$status" -eq 0 ]
run check-for-name newcontainer $firstcontainer
[ "$status" -ne 0 ]
run check-for-name othercontainer $firstcontainer
[ "$status" -ne 0 ]
run check-for-name foocontainer $container
[ "$status" -ne 0 ]
run check-for-name barcontainer $container
[ "$status" -ne 0 ]
run check-for-name newcontainer $container
[ "$status" -eq 0 ]
run check-for-name othercontainer $container
[ "$status" -eq 0 ]
# Set the names on the new container to the names we gave the old one.
run storage set-names -n foocontainer -n barcontainer $container
[ "$status" -eq 0 ]
# Check that the containers can still be found, and that the names are correctly set.
run storage exists -c $firstcontainer
[ "$status" -eq 0 ]
run storage exists -c $container
[ "$status" -eq 0 ]
run check-for-name no-such-thing-as-this-name $container
[ "$status" -ne 0 ]
run check-for-name foocontainer $firstcontainer
[ "$status" -ne 0 ]
run check-for-name barcontainer $firstcontainer
[ "$status" -ne 0 ]
run check-for-name newcontainer $firstcontainer
[ "$status" -ne 0 ]
run check-for-name othercontainer $firstcontainer
[ "$status" -ne 0 ]
run check-for-name foocontainer $container
[ "$status" -eq 0 ]
run check-for-name barcontainer $container
[ "$status" -eq 0 ]
run check-for-name newcontainer $container
[ "$status" -ne 0 ]
run check-for-name othercontainer $container
[ "$status" -ne 0 ]
}