Skip to content

Commit ea4a34b

Browse files
committed
test: switch to new CLI style
This also includes modification of tests to make sure that the default --image tag is latest. Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 731b4c5 commit ea4a34b

File tree

8 files changed

+219
-219
lines changed

8 files changed

+219
-219
lines changed

test/config.bats

Lines changed: 99 additions & 99 deletions
Large diffs are not rendered by default.

test/create.bats

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ function teardown() {
2424
teardown_image
2525
}
2626

27-
@test "umoci create --image [empty]" {
27+
@test "umoci create --layout [empty]" {
2828
# Setup up $NEWIMAGE.
2929
NEWIMAGE=$(mktemp -d --tmpdir="$BATS_TMPDIR" image-XXXXX)
3030
rm -rf "$NEWIMAGE"
3131

3232
# Create a new image with no tags.
33-
umoci create --image "$NEWIMAGE"
33+
umoci create --layout "$NEWIMAGE"
3434
[ "$status" -eq 0 ]
3535
image-verify "$NEWIMAGE"
3636

@@ -51,27 +51,27 @@ function teardown() {
5151
image-verify "$NEWIMAGE"
5252
}
5353

54-
@test "umoci create --image --tag" {
54+
@test "umoci create --layout --tag" {
5555
BUNDLE="$(setup_bundle)"
5656

5757
# Setup up $NEWIMAGE.
5858
export NEWIMAGE=$(mktemp -d --tmpdir="$BATS_TMPDIR" image-XXXXX)
5959
rm -rf "$NEWIMAGE"
6060

6161
# Create a new image with another tag.
62-
umoci create --image "$NEWIMAGE" --tag "latest"
62+
umoci create --layout "$NEWIMAGE" --tag "latest"
6363
[ "$status" -eq 0 ]
6464
# XXX: oci-image-validate doesn't like empty images (without layers)
6565
#image-verify "$NEWIMAGE"
6666

6767
# Modify the config.
68-
umoci config --image "$NEWIMAGE" --from "latest" --tag "latest" --config.user "1234:1332"
68+
umoci config --image "${NEWIMAGE}" --config.user "1234:1332"
6969
[ "$status" -eq 0 ]
7070
# XXX: oci-image-validate doesn't like empty images (without layers)
7171
#image-verify "$NEWIMAGE"
7272

7373
# Unpack the image.
74-
umoci unpack --image "$NEWIMAGE" --from "latest" --bundle "$BUNDLE"
74+
umoci unpack --image "${NEWIMAGE}" --bundle "$BUNDLE"
7575
[ "$status" -eq 0 ]
7676
bundle-verify "$BUNDLE"
7777

@@ -96,7 +96,7 @@ function teardown() {
9696
[[ "$output" == "null" ]]
9797

9898
# Check that the history looks sane.
99-
umoci stat --image "$NEWIMAGE" --tag "latest" --json
99+
umoci stat --image "${NEWIMAGE}" --json
100100
[ "$status" -eq 0 ]
101101
# There should be no non-empty_layers.
102102
[[ "$(echo "$output" | jq -SM '[.history[] | .empty_layer == false] | any')" == "false" ]]

test/gc.bats

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,48 +25,48 @@ function teardown() {
2525
}
2626

2727
@test "umoci gc [consistent]" {
28-
image-verify "$IMAGE"
28+
image-verify "${IMAGE}"
2929

3030
# Initial gc.
31-
umoci gc --image "$IMAGE"
31+
umoci gc --layout "${IMAGE}"
3232
[ "$status" -eq 0 ]
33-
image-verify "$IMAGE"
33+
image-verify "${IMAGE}"
3434

3535
# Check how many blobs there were.
3636
sane_run find "$IMAGE/blobs" -type f
3737
[ "$status" -eq 0 ]
3838
nblobs="${#lines[@]}"
3939

4040
# Redo the gc.
41-
umoci gc --image "$IMAGE"
41+
umoci gc --layout "${IMAGE}"
4242
[ "$status" -eq 0 ]
43-
image-verify "$IMAGE"
43+
image-verify "${IMAGE}"
4444

4545
# Make sure that another gc run does nothing.
4646
sane_run find "$IMAGE/blobs" -type f
4747
[ "$status" -eq 0 ]
4848
[ "${#lines[@]}" -eq "$nblobs" ]
4949

50-
image-verify "$IMAGE"
50+
image-verify "${IMAGE}"
5151
}
5252

5353
@test "umoci gc" {
5454
BUNDLE="$(setup_bundle)"
5555

56-
image-verify "$IMAGE"
56+
image-verify "${IMAGE}"
5757

5858
# Initial gc.
59-
umoci gc --image "$IMAGE"
59+
umoci gc --layout "${IMAGE}"
6060
[ "$status" -eq 0 ]
61-
image-verify "$IMAGE"
61+
image-verify "${IMAGE}"
6262

6363
# Check how many blobs there were.
6464
sane_run find "$IMAGE/blobs" -type f
6565
[ "$status" -eq 0 ]
6666
nblobs="${#lines[@]}"
6767

6868
# Unpack the image.
69-
umoci unpack --image "$IMAGE" --from "$TAG" --bundle "$BUNDLE"
69+
umoci unpack --image "${IMAGE}:${TAG}" --bundle "$BUNDLE"
7070
[ "$status" -eq 0 ]
7171
bundle-verify "$BUNDLE"
7272

@@ -75,9 +75,9 @@ function teardown() {
7575
chmod +w "$BUNDLE/rootfs/etc/." && rm -rf "$BUNDLE/rootfs/etc"
7676

7777
# Repack the image under a new tag.
78-
umoci repack --image "$IMAGE" --bundle "$BUNDLE" --tag "${TAG}-new"
78+
umoci repack --image "${IMAGE}:${TAG}-new" --bundle "$BUNDLE"
7979
[ "$status" -eq 0 ]
80-
image-verify "$IMAGE"
80+
image-verify "${IMAGE}"
8181

8282
# Make sure the number of blobs has changed.
8383
sane_run find "$IMAGE/blobs" -type f
@@ -86,67 +86,67 @@ function teardown() {
8686
nblobs="${#lines[@]}"
8787

8888
# Make sure it is the same after doing a gc, because we used a new tag.
89-
umoci gc --image "$IMAGE"
89+
umoci gc --layout "${IMAGE}"
9090
[ "$status" -eq 0 ]
91-
image-verify "$IMAGE"
91+
image-verify "${IMAGE}"
9292

9393
# Make sure that another gc run does nothing.
9494
sane_run find "$IMAGE/blobs" -type f
9595
[ "$status" -eq 0 ]
9696
[ "${#lines[@]}" -eq "$nblobs" ]
9797

9898
# Delete the old reference.
99-
umoci tag --image "$IMAGE" rm --tag "$TAG"
99+
umoci tag --layout "${IMAGE}" rm --tag "${TAG}"
100100
[ "$status" -eq 0 ]
101-
image-verify "$IMAGE"
101+
image-verify "${IMAGE}"
102102

103103
# Now do a gc which should delete some blobs.
104-
umoci gc --image "$IMAGE"
104+
umoci gc --layout "${IMAGE}"
105105
[ "$status" -eq 0 ]
106-
image-verify "$IMAGE"
106+
image-verify "${IMAGE}"
107107

108108
# Make sure that another gc run does nothing.
109109
sane_run find "$IMAGE/blobs" -type f
110110
[ "$status" -eq 0 ]
111111
[ "${#lines[@]}" -lt "$nblobs" ]
112112

113-
image-verify "$IMAGE"
113+
image-verify "${IMAGE}"
114114
}
115115

116116
@test "umoci gc [empty]" {
117-
image-verify "$IMAGE"
117+
image-verify "${IMAGE}"
118118

119119
# Initial gc.
120-
umoci gc --image "$IMAGE"
120+
umoci gc --layout "${IMAGE}"
121121
[ "$status" -eq 0 ]
122-
image-verify "$IMAGE"
122+
image-verify "${IMAGE}"
123123

124124
# Check how many blobs there were.
125125
sane_run find "$IMAGE/blobs" -type f
126126
[ "$status" -eq 0 ]
127127
[ "${#lines[@]}" -ne 0 ]
128128

129129
# Remove refs.
130-
umoci tag --image "$IMAGE" list
130+
umoci tag --layout "${IMAGE}" list
131131
[ "$status" -eq 0 ]
132132
[ "${#lines[@]}" -gt 0 ]
133-
image-verify "$IMAGE"
133+
image-verify "${IMAGE}"
134134

135135
for line in "${lines[*]}"; do
136-
umoci tag --image "$IMAGE" rm --tag "$(echo "$line" | awk '{ print $1 }')"
136+
umoci tag --layout "${IMAGE}" rm --tag "$(echo "$line" | awk '{ print $1 }')"
137137
[ "$status" -eq 0 ]
138-
image-verify "$IMAGE"
138+
image-verify "${IMAGE}"
139139
done
140140

141141
# Do a gc, which should remove all blobs.
142-
umoci gc --image "$IMAGE"
142+
umoci gc --layout "${IMAGE}"
143143
[ "$status" -eq 0 ]
144-
image-verify "$IMAGE"
144+
image-verify "${IMAGE}"
145145

146146
# Check how many blobs there were.
147147
sane_run find "$IMAGE/blobs" -type f
148148
[ "$status" -eq 0 ]
149149
[ "${#lines[@]}" -eq 0 ]
150150

151-
image-verify "$IMAGE"
151+
image-verify "${IMAGE}"
152152
}

test/pack_mapping.bats

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ function teardown() {
2929
# We do a bunch of remapping tricks, which we can't really do if we're not root.
3030
requires root
3131

32-
image-verify "$IMAGE"
32+
image-verify "${IMAGE}"
3333

3434
BUNDLE_A="$(setup_bundle)"
3535
BUNDLE_B="$(setup_bundle)"
3636

3737
# Unpack the image.
38-
umoci unpack --image "$IMAGE" --from "$TAG" --bundle "$BUNDLE_A" --uid-map "1337:0:65535" --gid-map "8888:0:65535"
38+
umoci unpack --image "${IMAGE}:${TAG}" --bundle "$BUNDLE_A" --uid-map "1337:0:65535" --gid-map "8888:0:65535"
3939
[ "$status" -eq 0 ]
4040
bundle-verify "$BUNDLE_A"
4141

@@ -51,7 +51,7 @@ function teardown() {
5151
done
5252

5353
# Unpack the image with a differen uid and gid mapping.
54-
umoci unpack --image "$IMAGE" --from "$TAG" --bundle "$BUNDLE_B" --uid-map "8080:0:65535" --gid-map "7777:0:65535"
54+
umoci unpack --image "${IMAGE}:${TAG}" --bundle "$BUNDLE_B" --uid-map "8080:0:65535" --gid-map "7777:0:65535"
5555
[ "$status" -eq 0 ]
5656
bundle-verify "$BUNDLE_B"
5757

@@ -66,22 +66,22 @@ function teardown() {
6666
[ "$gid" -ge 7777 ] && [ "$gid" -lt "$((7777 + 65535))" ]
6767
done
6868

69-
image-verify "$IMAGE"
69+
image-verify "${IMAGE}"
7070
}
7171

7272
# FIXME: It would be nice if we implemented this test with a manual chown.
7373
@test "umoci repack [with unpack --uid-map --gid-map]" {
7474
# We do a bunch of remapping tricks, which we can't really do if we're not root.
7575
requires root
7676

77-
image-verify "$IMAGE"
77+
image-verify "${IMAGE}"
7878

7979
BUNDLE_A="$(setup_bundle)"
8080
BUNDLE_B="$(setup_bundle)"
8181
BUNDLE_C="$(setup_bundle)"
8282

8383
# Unpack the image.
84-
umoci unpack --image "$IMAGE" --from "$TAG" --bundle "$BUNDLE_A" --uid-map "1337:0:65535" --gid-map "7331:0:65535"
84+
umoci unpack --image "${IMAGE}:${TAG}" --bundle "$BUNDLE_A" --uid-map "1337:0:65535" --gid-map "7331:0:65535"
8585
[ "$status" -eq 0 ]
8686
bundle-verify "$BUNDLE_A"
8787

@@ -93,12 +93,12 @@ function teardown() {
9393
chown "2000:8000" "$BUNDLE_A/rootfs/new test file "
9494

9595
# Repack the image using the same mapping.
96-
umoci repack --image "$IMAGE" --bundle "$BUNDLE_A" --tag "${TAG}-new"
96+
umoci repack --image "${IMAGE}:${TAG}-new" --bundle "$BUNDLE_A"
9797
[ "$status" -eq 0 ]
98-
image-verify "$IMAGE"
98+
image-verify "${IMAGE}"
9999

100100
# Unpack it again with a different mapping.
101-
umoci unpack --image "$IMAGE" --from "${TAG}-new" --bundle "$BUNDLE_B" --uid-map "4000:0:65535" --gid-map "4000:0:65535"
101+
umoci unpack --image "${IMAGE}:${TAG}-new" --bundle "$BUNDLE_B" --uid-map "4000:0:65535" --gid-map "4000:0:65535"
102102
[ "$status" -eq 0 ]
103103
bundle-verify "$BUNDLE_B"
104104

@@ -108,7 +108,7 @@ function teardown() {
108108
[[ "$output" == "$((2000 - 1337 + 4000)):$((8000 - 7331 + 4000))" ]]
109109

110110
# Redo the unpacking with no mapping.
111-
umoci unpack --image "$IMAGE" --from "${TAG}-new" --bundle "$BUNDLE_C"
111+
umoci unpack --image "${IMAGE}:${TAG}-new" --bundle "$BUNDLE_C"
112112
[ "$status" -eq 0 ]
113113
bundle-verify "$BUNDLE_C"
114114

@@ -117,5 +117,5 @@ function teardown() {
117117
[ "$status" -eq 0 ]
118118
[[ "$output" == "$((2000 - 1337)):$((8000 - 7331))" ]]
119119

120-
image-verify "$IMAGE"
120+
image-verify "${IMAGE}"
121121
}

0 commit comments

Comments
 (0)