-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- hosts: remote | ||
become: yes | ||
pre_tasks: | ||
- name: install tests | ||
ansible.builtin.copy: | ||
src: tests | ||
dest: /opt | ||
owner: root | ||
group: root | ||
roles: | ||
- test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# bats file_tags=host01 | ||
|
||
setup() { | ||
BATS_LIB_PATH=/usr/local/lib/node_modules | ||
bats_load_library bats-support | ||
bats_load_library bats-assert | ||
bats_require_minimum_version 1.5.0 | ||
} | ||
|
||
@test 'available commands' { | ||
run -0 which docker | ||
run -0 which skopeo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# bats file_tags=host01 | ||
|
||
setup() { | ||
BATS_LIB_PATH=/usr/local/lib/node_modules | ||
bats_load_library bats-support | ||
bats_load_library bats-assert | ||
bats_require_minimum_version 1.5.0 | ||
} | ||
|
||
@test 'build docker image' { | ||
run -0 /bin/bash -c '\ | ||
cd /opt/hello | ||
docker build -t hello .' | ||
run -0 docker images | ||
assert_output --partial 'hello' | ||
docker run --name hello -d -p 8080:80 hello | ||
retry -d 1 -t 30 -- curl http://localhost:8080/ | ||
run -0 curl http://localhost:8080/ | ||
assert_output --partial 'Hello World!' | ||
} | ||
|
||
teardown() { | ||
docker rm --force hello | ||
docker rmi --force hello | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# bats file_tags=host01 | ||
|
||
setup() { | ||
BATS_LIB_PATH=/usr/local/lib/node_modules | ||
bats_load_library bats-support | ||
bats_load_library bats-assert | ||
bats_require_minimum_version 1.5.0 | ||
} | ||
|
||
@test 'nginx' { | ||
docker pull nginx | ||
run -0 docker images | ||
assert_output --partial 'nginx' | ||
docker run --name nginx -d nginx | ||
run -0 docker exec nginx /bin/sh -c 'ldd $(which nginx)' | ||
assert_output --partial 'libc' | ||
JQ_QUERY='.[0].SizeRw' | ||
run -0 /bin/bash -c "docker inspect -s nginx | jq ${JQ_QUERY}" | ||
assert_output --regexp '^[0-9]+$' | ||
JQ_QUERY='.[0].GraphDriver.Data.MergedDir' | ||
ROOT=$(docker inspect nginx | jq -r "${JQ_QUERY}") | ||
ls ${ROOT} | ||
run -0 mount | ||
assert_output --partial 'merged' | ||
} | ||
|
||
teardown() { | ||
docker rm --force nginx | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# bats file_tags=host01 | ||
|
||
setup() { | ||
BATS_LIB_PATH=/usr/local/lib/node_modules | ||
bats_load_library bats-support | ||
bats_load_library bats-assert | ||
bats_require_minimum_version 1.5.0 | ||
} | ||
|
||
@test 'overlay filesystem' { | ||
mkdir /tmp/{lower,upper,work,mount} | ||
echo "hello1" > /tmp/lower/hello1 | ||
echo "hello2" > /tmp/upper/hello2 | ||
mount -t overlay -o rw,lowerdir=/tmp/lower,upperdir=/tmp/upper,workdir=/tmp/work overlay /tmp/mount | ||
run -0 cat /tmp/mount/hello1 | ||
assert_output --partial 'hello1' | ||
run -0 cat /tmp/mount/hello2 | ||
assert_output --partial 'hello2' | ||
echo "hello3" > /tmp/mount/hello3 | ||
run -0 ls /tmp/lower | ||
refute_output --partial 'hello3' | ||
run -0 ls /tmp/upper | ||
assert_output --partial 'hello3' | ||
} | ||
|
||
teardown() { | ||
umount -f /tmp/mount | ||
rm -fr /tmp/{lower,upper,work,mount} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# bats file_tags=host01 | ||
|
||
setup() { | ||
BATS_LIB_PATH=/usr/local/lib/node_modules | ||
bats_load_library bats-support | ||
bats_load_library bats-assert | ||
bats_require_minimum_version 1.5.0 | ||
} | ||
|
||
@test 'local registry' { | ||
docker pull busybox | ||
docker tag busybox registry.local/busybox | ||
docker push registry.local/busybox | ||
docker pull registry.local/busybox | ||
} | ||
|
||
teardown() { | ||
docker rmi --force busybox | ||
docker rmi --force registry.local/busybox | ||
} |