-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test to cover parallel execution and networking #2570
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
####### | ||
# See if we want to stop on errors and/or install and then remove Docker. | ||
####### | ||
HOST_PORT="${HOST_PORT:-8080}" | ||
showerror=0 | ||
installdocker=0 | ||
usedocker=1 | ||
|
@@ -78,7 +79,99 @@ echo $image | |
######## | ||
# Run container and display contents in /etc | ||
######## | ||
podman run $image ls -alF /etc | ||
podman run --rm $image ls -alF /etc | ||
|
||
######## | ||
# Test networking, bind mounting a file, stdin/stdout redirect | ||
######## | ||
echo "Testing networking: ..." | ||
port_test_failed=0 | ||
txt1="Hello, Podman" | ||
echo "$txt1" > /tmp/hello.txt | ||
podman run -d --name myweb -p "$HOST_PORT:80" -w /var/www -v /tmp/hello.txt:/var/www/index.txt busybox httpd -f -p 80 | ||
echo "$txt1" | podman exec -i myweb sh -c "cat > /var/www/index2.txt" | ||
txt2=$( podman exec myweb cat /var/www/index2.txt ) | ||
[ "x$txt1" == "x$txt2" ] && echo "PASS1" || { echo "FAIL1"; port_test_failed=1; } | ||
txt2=$( podman run --rm --net host busybox wget -qO - http://localhost:$HOST_PORT/index.txt ) | ||
[ "x$txt1" == "x$txt2" ] && echo "PASS2" || { echo "FAIL2"; port_test_failed=1; } | ||
txt2=$( podman run --rm --net host busybox wget -qO - http://localhost:$HOST_PORT/index2.txt ) | ||
[ "x$txt1" == "x$txt2" ] && echo "PASS3" || { echo "FAIL3"; port_test_failed=1; } | ||
# podman run --rm --net container:myweb --add-host myweb:127.0.0.1 busybox wget -qO - http://myweb/index.txt | ||
rm /tmp/hello.txt | ||
podman stop myweb | ||
podman rm myweb | ||
[ "0$port_test_failed" -eq 1 ] && [ "0$showerror" -eq 1 ] && { | ||
echo "networking test failed"; | ||
exit -1; | ||
} | ||
|
||
|
||
######## | ||
# pull and run many containers in parallel, test locks ..etc. | ||
######## | ||
prun_test_failed=0 | ||
podman rmi docker.io/library/busybox:latest > /dev/null || : | ||
for i in `seq 10` | ||
do ( podman run -d --name b$i docker.io/library/busybox:latest busybox httpd -f -p 80 )& | ||
done | ||
echo -e "\nwaiting for creation...\n" | ||
wait | ||
echo -e "\ndone\n" | ||
# assert we have 10 running containers | ||
count=$( podman ps -q | wc -l ) | ||
[ "x$count" == "x10" ] && echo "PASS" || { echo "FAIL, expecting 10 found $count"; prun_test_failed=1; } | ||
[ "0$prun_test_failed" -eq 1 ] && [ "0$showerror" -eq 1 ] && { | ||
echo "was expecting 10 running containers"; | ||
exit -1; | ||
} | ||
|
||
prun_test_failed=0 | ||
for i in `seq 10`; do ( podman stop -t=1 b$i; podman rm b$i )& done | ||
echo -e "\nwaiting for deletion...\n" | ||
wait | ||
echo -e "\ndone\n" | ||
# assert we have 0 running containers | ||
count=$( podman ps -q | wc -l ) | ||
[ "x$count" == "x0" ] && echo "PASS" || { echo "FAIL, expecting 0 found $count"; prun_test_failed=1; } | ||
[ "0$prun_test_failed" -eq 1 ] && [ "0$showerror" -eq 1 ] && { | ||
echo "was expecting 0 running containers"; | ||
exit -1; | ||
} | ||
|
||
|
||
|
||
######## | ||
# run many containers in parallel for an existing image, test locks ..etc. | ||
######## | ||
prun_test_failed=0 | ||
podman pull docker.io/library/busybox:latest > /dev/null || : | ||
for i in `seq 10` | ||
do ( podman run -d --name c$i docker.io/library/busybox:latest busybox httpd -f -p 80 )& | ||
done | ||
echo -e "\nwaiting for creation...\n" | ||
wait | ||
echo -e "\ndone\n" | ||
# assert we have 10 running containers | ||
count=$( podman ps -q | wc -l ) | ||
[ "x$count" == "x10" ] && echo "PASS" || { echo "FAIL, expecting 10 found $count"; prun_test_failed=1; } | ||
[ "0$prun_test_failed" -eq 1 ] && [ "0$showerror" -eq 1 ] && { | ||
echo "was expecting 10 running containers"; | ||
exit -1; | ||
} | ||
|
||
|
||
for i in `seq 10`; do ( podman stop -t=1 c$i; podman rm c$i )& done | ||
echo -e "\nwaiting for deletion...\n" | ||
wait | ||
echo -e "\ndone\n" | ||
# assert we have 0 running containers | ||
count=$( podman ps -q | wc -l ) | ||
[ "x$count" == "x0" ] && echo "PASS" || { echo "FAIL, expecting 0 found $count"; prun_test_failed=1; } | ||
[ "0$prun_test_failed" -eq 1 ] && [ "0$showerror" -eq 1 ] && { | ||
echo "was expecting 0 running containers"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @muayyad-alsadi it's much happier now. Thanks for the changes. If not, no worries. I'd a thought today to add color to the error lines. I can make the change myself when I go through that exercise. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add those when I revisit it to add the commented out tests about |
||
exit -1; | ||
} | ||
|
||
|
||
######## | ||
# Run Java in the container - should ERROR but never stop | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the @haircommander fix worked, we can have