提交 0263834f 编写于 作者: X xiadanni

tests:remove images after building and add isulad output

Signed-off-by: Nxiadanni <xiadanni1@huawei.com>
上级 fe87cff1
...@@ -45,31 +45,39 @@ function start_isula_builder() { ...@@ -45,31 +45,39 @@ function start_isula_builder() {
# test build image without output # test build image without output
function test_build_without_output() { function test_build_without_output() {
tmpiidfile=$(mktemp -t iid.XXX)
if ! isula-build ctr-img build > /tmp/buildlog-client 2>&1; then if ! isula-build ctr-img build --iidfile "$tmpiidfile" > /tmp/buildlog-client 2>&1; then
echo "FAIL" echo "FAIL"
echo "LOG DIR:/tmp/buildlog-client and /tmp/buildlog-daemon (build without output)" echo "LOG DIR:/tmp/buildlog-client and /tmp/buildlog-daemon (build without output)"
kill -9 "${pidofbuilder}" kill -9 "${pidofbuilder}"
exit 1 exit 1
fi fi
image_clean
} }
# test build image with docker-archive output # test build image with docker-archive output
function test_build_with_docker_archive_output() { function test_build_with_docker_archive_output() {
if ! isula-build ctr-img build --output=docker-archive:/tmp/"${image_name}".tar > /tmp/buildlog-client 2>&1; then tmpiidfile=$(mktemp -t iid.XXX)
if ! isula-build ctr-img build --iidfile "$tmpiidfile" --output=docker-archive:/tmp/"${image_name}".tar > /tmp/buildlog-client 2>&1; then
echo "FAIL" echo "FAIL"
echo "LOG DIR:/tmp/buildlog-client and /tmp/buildlog-daemon (build with docker-archive output)" echo "LOG DIR:/tmp/buildlog-client and /tmp/buildlog-daemon (build with docker-archive output)"
kill -9 "${pidofbuilder}" kill -9 "${pidofbuilder}"
exit 1 exit 1
else else
rm -f /tmp/"${dockerfiledir}".tar rm -f /tmp/"${image_name}".tar
fi fi
image_clean
} }
# test build image with docker-daemon output
function test_build_with_docker_daemon_output() { function test_build_with_docker_daemon_output() {
# test build image with docker-daemon output systemctl status docker > /dev/null 2>&1
if ! isula-build ctr-img build --output=docker-daemon:isula/"${image_name}":latest > /tmp/buildlog-client 2>&1; then if [ $? -ne 0 ]; then
return 0
fi
tmpiidfile=$(mktemp -t iid.XXX)
if ! isula-build ctr-img build --iidfile "$tmpiidfile" --output=docker-daemon:isula/"${image_name}":latest > /tmp/buildlog-client 2>&1; then
echo "FAIL" echo "FAIL"
echo "LOG DIR:/tmp/buildlog-client and /tmp/buildlog-daemon (build with docker-daemon output)" echo "LOG DIR:/tmp/buildlog-client and /tmp/buildlog-daemon (build with docker-daemon output)"
kill -9 "${pidofbuilder}" kill -9 "${pidofbuilder}"
...@@ -77,6 +85,32 @@ function test_build_with_docker_daemon_output() { ...@@ -77,6 +85,32 @@ function test_build_with_docker_daemon_output() {
else else
docker rmi isula/"${image_name}" > /dev/null 2>&1 docker rmi isula/"${image_name}" > /dev/null 2>&1
fi fi
image_clean
}
# test build image with isulad output
function test_build_with_isulad_output() {
systemctl status isulad > /dev/null 2>&1
if [ $? -ne 0 ]; then
return 0
fi
tmpiidfile=$(mktemp -t iid.XXX)
if ! isula-build ctr-img build --iidfile "$tmpiidfile" --output=isulad:isula/"${image_name}":latest > /tmp/buildlog-client 2>&1; then
echo "FAIL"
echo "LOG DIR:/tmp/buildlog-client and /tmp/buildlog-daemon (build with isulad output)"
kill -9 "${pidofbuilder}"
exit 1
else
isula rmi isula/"${image_name}" > /dev/null 2>&1
fi
image_clean
}
function image_clean() {
imageID=$(cat "$tmpiidfile")
isula-build ctr-img rm "$imageID" > /dev/null
rm -f "$tmpiidfile"
} }
# start build images tests # start build images tests
...@@ -92,6 +126,7 @@ function tests() { ...@@ -92,6 +126,7 @@ function tests() {
test_build_without_output test_build_without_output
test_build_with_docker_archive_output test_build_with_docker_archive_output
test_build_with_docker_daemon_output test_build_with_docker_daemon_output
test_build_with_isulad_output
echo "PASS" echo "PASS"
popd > /dev/null 2>&1 || exit 1 popd > /dev/null 2>&1 || exit 1
...@@ -104,7 +139,6 @@ function cleanup() { ...@@ -104,7 +139,6 @@ function cleanup() {
rm -f /tmp/buildlog-* rm -f /tmp/buildlog-*
} }
function main() { function main() {
pre_check pre_check
start_isula_builder start_isula_builder
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册