Skip to content

Commit 4391f30

Browse files
committed
test: add busybox image, use it to mostly replace centos image
This is basically the add of BUSYBOX image and then using that instead of centos image. Moving to busybox from centos required a few changed assumptions: * drop -P from grep - busybox's grep did not support -P. instead use posix groups ([:space:]) * don't use long --format for 'stat' - busybox stat didn't like this, so just use '-c'. * mount - /usr/bin/mount -> /bin/mount - busybox image only has /bin, not /usr/bin/mount * /bin/bash - busybox image does not have bin/bash The tests "squashfs empty change no layer" and "tar empty change no layer" do not work with the busybox image. There are layers created, and they have this content: $ tar tvf oci/blobs/sha256/acff571f8cf*b03f45 tar: Removing leading `/' from member names drwxr-xr-x 0/0 0 2023-11-13 14:06 / drwxr-xr-x 0/0 0 2023-11-13 14:06 etc/ ---------- 0/0 0 2023-11-13 14:06 etc/resolv.conf drwxr-xr-x 0/0 0 2023-11-13 14:06 proc/ drwxr-xr-x 0/0 0 2023-11-13 14:06 sys/ The content there are results of stacker. I don't have a good way to avoid them at the moment. I've also left the bom tests in place with the centos image. Those would have had to have been adjusted and probably would not work with busybox at the moment. Signed-off-by: Scott Moser <smoser@brickies.net>
1 parent c75830e commit 4391f30

35 files changed

+225
-214
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ build_stacker = go build -tags "$(BUILD_TAGS) $1" -ldflags "-X main.version=$(VE
2020
STACKER_DOCKER_BASE?=docker://ghcr.io/project-stacker/
2121
# They default to their image name in STACKER_DOCKER_BASE
2222
STACKER_BUILD_BASE_IMAGE?=$(STACKER_DOCKER_BASE)alpine:edge
23+
STACKER_BUILD_BUSYBOX_IMAGE?=$(STACKER_DOCKER_BASE)busybox:latest
2324
STACKER_BUILD_CENTOS_IMAGE?=$(STACKER_DOCKER_BASE)centos:latest
2425
STACKER_BUILD_UBUNTU_IMAGE?=$(STACKER_DOCKER_BASE)ubuntu:latest
25-
STACKER_BUILD_IMAGES = $(STACKER_BUILD_BASE_IMAGE) $(STACKER_BUILD_CENTOS_IMAGE) $(STACKER_BUILD_UBUNTU_IMAGE)
26+
STACKER_BUILD_IMAGES = \
27+
$(STACKER_BUILD_BASE_IMAGE) \
28+
$(STACKER_BUILD_BUSYBOX_IMAGE) \
29+
$(STACKER_BUILD_CENTOS_IMAGE) \
30+
$(STACKER_BUILD_UBUNTU_IMAGE)
31+
2632
LXC_CLONE_URL?=https://github.com/lxc/lxc
2733
LXC_BRANCH?=stable-5.0
2834

@@ -128,6 +134,7 @@ test: stacker $(REGCLIENT) $(SKOPEO) $(ZOT)
128134
LXC_BRANCH=$(LXC_BRANCH) \
129135
LXC_CLONE_URL=$(LXC_CLONE_URL) \
130136
STACKER_BUILD_BASE_IMAGE=$(STACKER_BUILD_BASE_IMAGE) \
137+
STACKER_BUILD_BUSYBOX_IMAGE=$(STACKER_BUILD_BUSYBOX_IMAGE) \
131138
STACKER_BUILD_CENTOS_IMAGE=$(STACKER_BUILD_CENTOS_IMAGE) \
132139
STACKER_BUILD_UBUNTU_IMAGE=$(STACKER_BUILD_UBUNTU_IMAGE) \
133140
./test/main.py \

test/annotations-namespace.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function teardown() {
1313
thing:
1414
from:
1515
type: oci
16-
url: $CENTOS_OCI
16+
url: $BUSYBOX_OCI
1717
run: ls
1818
EOF
1919
stacker build --annotations-namespace=namespace.example
@@ -28,7 +28,7 @@ EOF
2828
thing:
2929
from:
3030
type: oci
31-
url: $CENTOS_OCI
31+
url: $BUSYBOX_OCI
3232
run: ls
3333
EOF
3434
stacker build

test/annotations.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function teardown() {
1313
thing:
1414
from:
1515
type: oci
16-
url: $CENTOS_OCI
16+
url: $BUSYBOX_OCI
1717
run: ls
1818
annotations:
1919
a.b.c.key: val

test/args.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function teardown() {
1313
parent:
1414
from:
1515
type: oci
16-
url: $CENTOS_OCI
16+
url: $BUSYBOX_OCI
1717
child:
1818
from:
1919
type: built

test/asterisk.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function teardown() {
1313
a:
1414
from:
1515
type: oci
16-
url: $CENTOS_OCI
16+
url: $BUSYBOX_OCI
1717
run: |
1818
mkdir /mybin
1919
cp /bin/* /mybin

test/atomfs.bats

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function basic_test() {
1616
test:
1717
from:
1818
type: oci
19-
url: $CENTOS_OCI
19+
url: $BUSYBOX_OCI
2020
run: |
2121
touch /hello
2222
EOF
@@ -48,7 +48,7 @@ EOF
4848
base:
4949
from:
5050
type: oci
51-
url: $CENTOS_OCI
51+
url: $BUSYBOX_OCI
5252
run: touch /base
5353
a:
5454
from:
@@ -105,7 +105,7 @@ EOF
105105

106106
# c should still be ok
107107
[ -f c/c ]
108-
[ -f c/sbin/init ]
108+
[ -f c/bin/sh ]
109109
stacker internal-go atomfs umount c
110110

111111
# c's last layer shouldn't exist any more, since it is unique
@@ -121,7 +121,7 @@ EOF
121121
test:
122122
from:
123123
type: oci
124-
url: $CENTOS_OCI
124+
url: $BUSYBOX_OCI
125125
run: |
126126
touch /hello
127127
EOF

test/basic.bats

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ function teardown() {
1010

1111
@test "multiple stacker builds in a row" {
1212
cat > stacker.yaml <<EOF
13-
centos:
13+
busybox:
1414
from:
1515
type: oci
16-
url: $CENTOS_OCI
16+
url: $BUSYBOX_OCI
1717
import: import
1818
EOF
1919
echo 1 > import
@@ -28,10 +28,10 @@ EOF
2828

2929
@test "basic workings" {
3030
cat > stacker.yaml <<EOF
31-
centos:
31+
busybox:
3232
from:
3333
type: tar
34-
url: .stacker/layer-bases/centos.tar
34+
url: .stacker/layer-bases/busybox.tar
3535
import:
3636
- ./stacker.yaml
3737
- https://www.cisco.com/favicon.ico
@@ -53,7 +53,7 @@ centos:
5353
layer1:
5454
from:
5555
type: built
56-
tag: centos
56+
tag: busybox
5757
run:
5858
- rm /favicon.ico
5959
EOF
@@ -62,29 +62,29 @@ EOF
6262
chmod +x executable
6363
mkdir -p .stacker/layer-bases
6464
chmod 777 .stacker/layer-bases
65-
image_copy oci:$CENTOS_OCI oci:.stacker/layer-bases/oci:centos
66-
umoci unpack --image .stacker/layer-bases/oci:centos dest
67-
tar caf .stacker/layer-bases/centos.tar -C dest/rootfs .
65+
image_copy oci:$BUSYBOX_OCI oci:.stacker/layer-bases/oci:busybox
66+
umoci unpack --image .stacker/layer-bases/oci:busybox dest
67+
tar caf .stacker/layer-bases/busybox.tar -C dest/rootfs .
6868
rm -rf dest
6969

7070
stacker build --substitute "FAVICON=favicon.ico"
7171
[ "$status" -eq 0 ]
7272

7373
# did we really download the image to the right place?
74-
[ -f .stacker/layer-bases/centos.tar ]
74+
[ -f .stacker/layer-bases/busybox.tar ]
7575

7676
# did run actually copy the favicon to the right place?
77-
stacker grab centos:/favicon.ico
78-
[ "$(sha .stacker/imports/centos/favicon.ico)" == "$(sha favicon.ico)" ]
77+
stacker grab busybox:/favicon.ico
78+
[ "$(sha .stacker/imports/busybox/favicon.ico)" == "$(sha favicon.ico)" ]
7979

8080
[ ! -f roots/layer1/rootfs/favicon.ico ] || [ ! -f roots/layer1/overlay/favicon.ico ]
8181

8282
rm executable
83-
stacker grab centos:/usr/bin/executable
83+
stacker grab busybox:/usr/bin/executable
8484
[ "$(stat --format="%a" executable)" = "755" ]
8585

8686
# did we do a copy correctly?
87-
[ "$(sha .stacker/imports/centos/stacker.yaml)" == "$(sha ./stacker.yaml)" ]
87+
[ "$(sha .stacker/imports/busybox/stacker.yaml)" == "$(sha ./stacker.yaml)" ]
8888

8989
# check OCI image generation
9090
manifest=$(cat oci/index.json | jq -r .manifests[0].digest | cut -f2 -d:)
@@ -140,15 +140,15 @@ EOF
140140

141141
@test "stacker.yaml without imports can run" {
142142
cat > stacker.yaml <<EOF
143-
centos:
143+
busybox:
144144
from:
145145
type: oci
146-
url: $CENTOS_OCI
146+
url: $BUSYBOX_OCI
147147
run: |
148148
touch /foo
149149
EOF
150150
stacker build
151-
umoci unpack --image oci:centos dest
151+
umoci unpack --image oci:busybox dest
152152
[ -f dest/rootfs/foo ]
153153
}
154154

@@ -162,25 +162,25 @@ EOF
162162
@test "use colons in roots-dir path name should fail" {
163163
local tmpd=$(pwd)
164164
cat > stacker.yaml <<EOF
165-
centos:
165+
busybox:
166166
from:
167167
type: oci
168-
url: $CENTOS_OCI
168+
url: $BUSYBOX_OCI
169169
run: |
170170
touch /foo
171171
EOF
172172
bad_stacker --roots-dir $tmpd/with:colon build
173173
[ "$status" -eq 1 ]
174174
echo $output | grep "forbidden"
175-
}
175+
}
176176

177177
@test "use colons in layer name should fail" {
178178
local tmpd=$(pwd)
179179
cat > stacker.yaml <<EOF
180-
centos:with:colon:
180+
busybox:with:colon:
181181
from:
182182
type: oci
183-
url: $CENTOS_OCI
183+
url: $BUSYBOX_OCI
184184
run: |
185185
touch /foo
186186
EOF
@@ -194,10 +194,10 @@ EOF
194194
FAVICON: favicon.ico
195195
EOF
196196
cat > stacker.yaml <<EOF
197-
centos:
197+
busybox:
198198
from:
199199
type: tar
200-
url: .stacker/layer-bases/centos.tar
200+
url: .stacker/layer-bases/busybox.tar
201201
import:
202202
- ./stacker.yaml
203203
- https://www.cisco.com/favicon.ico
@@ -219,7 +219,7 @@ centos:
219219
layer1:
220220
from:
221221
type: built
222-
tag: centos
222+
tag: busybox
223223
run:
224224
- rm /favicon.ico
225225
EOF
@@ -228,29 +228,29 @@ EOF
228228
chmod +x executable
229229
mkdir -p .stacker/layer-bases
230230
chmod 777 .stacker/layer-bases
231-
image_copy oci:$CENTOS_OCI oci:.stacker/layer-bases/oci:centos
232-
umoci unpack --image .stacker/layer-bases/oci:centos dest
233-
tar caf .stacker/layer-bases/centos.tar -C dest/rootfs .
231+
image_copy oci:$BUSYBOX_OCI oci:.stacker/layer-bases/oci:busybox
232+
umoci unpack --image .stacker/layer-bases/oci:busybox dest
233+
tar caf .stacker/layer-bases/busybox.tar -C dest/rootfs .
234234
rm -rf dest
235235

236236
stacker build --substitute-file subs.yaml
237237
[ "$status" -eq 0 ]
238238

239239
# did we really download the image to the right place?
240-
[ -f .stacker/layer-bases/centos.tar ]
240+
[ -f .stacker/layer-bases/busybox.tar ]
241241

242242
# did run actually copy the favicon to the right place?
243-
stacker grab centos:/favicon.ico
244-
[ "$(sha .stacker/imports/centos/favicon.ico)" == "$(sha favicon.ico)" ]
243+
stacker grab busybox:/favicon.ico
244+
[ "$(sha .stacker/imports/busybox/favicon.ico)" == "$(sha favicon.ico)" ]
245245

246246
[ ! -f roots/layer1/rootfs/favicon.ico ] || [ ! -f roots/layer1/overlay/favicon.ico ]
247247

248248
rm executable
249-
stacker grab centos:/usr/bin/executable
249+
stacker grab busybox:/usr/bin/executable
250250
[ "$(stat --format="%a" executable)" = "755" ]
251251

252252
# did we do a copy correctly?
253-
[ "$(sha .stacker/imports/centos/stacker.yaml)" == "$(sha ./stacker.yaml)" ]
253+
[ "$(sha .stacker/imports/busybox/stacker.yaml)" == "$(sha ./stacker.yaml)" ]
254254

255255
# check OCI image generation
256256
manifest=$(cat oci/index.json | jq -r .manifests[0].digest | cut -f2 -d:)

test/binds.bats

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function teardown() {
1313
bind-test:
1414
from:
1515
type: oci
16-
url: ${{CENTOS_OCI}}
16+
url: ${{BUSYBOX_OCI}}
1717
binds:
1818
- ${{bind_path}} -> /root/tree1/foo
1919
run: |
@@ -29,7 +29,7 @@ EOF
2929

3030
bind_path=$(realpath tree1/foo)
3131

32-
out=$(stacker build --substitute bind_path=${bind_path} --substitute CENTOS_OCI=$CENTOS_OCI)
32+
out=$(stacker build --substitute bind_path=${bind_path} --substitute BUSYBOX_OCI=$BUSYBOX_OCI)
3333

3434
[[ "${out}" =~ ^(.*filesystem bind-test built successfully)$ ]]
3535

@@ -41,7 +41,7 @@ EOF
4141
bind-test:
4242
from:
4343
type: oci
44-
url: ${{CENTOS_OCI}}
44+
url: ${{BUSYBOX_OCI}}
4545
binds:
4646
- source: ${{bind_path1}}
4747
dest: /root/tree1/foo
@@ -65,7 +65,7 @@ EOF
6565
out=$(stacker build \
6666
"--substitute=bind_path1=${bind_path1}" \
6767
"--substitute=bind_path2=${bind_path2}" \
68-
"--substitute=CENTOS_OCI=$CENTOS_OCI" ) || {
68+
"--substitute=BUSYBOX_OCI=$BUSYBOX_OCI" ) || {
6969
printf "%s\n" "$out" 1>&2
7070
exit 1
7171
}

test/broken-link.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function teardown() {
1414
broken_link:
1515
from:
1616
type: oci
17-
url: $CENTOS_OCI
17+
url: $BUSYBOX_OCI
1818
import:
1919
- dir
2020
run: cp -a /stacker/imports/dir/testln /testln

0 commit comments

Comments
 (0)