Merge pull request #6456 from edsantiago/bats

system tests : more tests
This commit is contained in:
OpenShift Merge Robot 2020-06-01 21:11:41 +02:00 committed by GitHub
commit d6bf6b92c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 9 deletions

View File

@ -50,6 +50,7 @@ load helpers
}
# Issue #4785 - piping to exec statement - fixed in #4818
# Issue #5046 - piping to exec truncates results (actually a conmon issue)
@test "podman exec - cat from stdin" {
skip_if_remote
@ -60,6 +61,20 @@ load helpers
run_podman exec -i $cid cat < <(echo $echo_string)
is "$output" "$echo_string" "output read back from 'exec cat'"
# #5046 - large file content gets lost via exec
# Generate a large file with random content; get a hash of its content
local bigfile=${PODMAN_TMPDIR}/bigfile
dd if=/dev/urandom of=$bigfile bs=1024 count=1500
expect=$(sha512sum $bigfile | awk '{print $1}')
# Transfer it to container, via exec, make sure correct #bytes are sent
run_podman exec -i $cid dd of=/tmp/bigfile bs=512 <$bigfile
is "${lines[0]}" "3000+0 records in" "dd: number of records in"
is "${lines[1]}" "3000+0 records out" "dd: number of records out"
# Verify sha. '% *' strips off the path, keeping only the SHA
run_podman exec $cid sha512sum /tmp/bigfile
is "${output% *}" "$expect" "SHA of file in container"
# Clean up
run_podman exec $cid touch /stop
run_podman wait $cid
run_podman rm $cid

View File

@ -56,7 +56,11 @@ function teardown() {
skip_if_remote "podman-pod does not work with podman-remote"
podname=pod$(random_string)
run_podman 1 pod exists $podname
run_podman pod create --infra=true --name=$podname
podid="$output"
run_podman pod exists $podname
run_podman pod exists $podid
# Randomly-assigned port in the 5xxx range
for port in $(shuf -i 5000-5999);do
@ -91,6 +95,10 @@ function teardown() {
# ...then rm the pod, then rmi the pause image so we don't leave strays.
run_podman pod rm $podname
run_podman rmi $pause_iid
# Pod no longer exists
run_podman 1 pod exists $podid
run_podman 1 pod exists $podname
}
# Random byte
@ -131,6 +139,9 @@ function random_ip() {
hostname=$(random_string | tr A-Z a-z).$(random_string | tr A-Z a-z).net
labelname=$(random_string 11)
labelvalue=$(random_string 22)
pod_id_file=${PODMAN_TMPDIR}/pod-id-file
# Create a pod with all the desired options
@ -143,7 +154,8 @@ function random_ip() {
--add-host "$add_host_n:$add_host_ip" \
--dns "$dns_server" \
--dns-search "$dns_search" \
--dns-opt "$dns_opt"
--dns-opt "$dns_opt" \
--label "${labelname}=${labelvalue}"
pod_id="$output"
# Check --pod-id-file
@ -168,18 +180,20 @@ function random_ip() {
is "$output" ".*nameserver $dns_server" "--dns [server] was added"
is "$output" ".*search $dns_search" "--dns-search was added"
is "$output" ".*options $dns_opt" "--dns-opt was added"
}
@test "podman pod inspect - format" {
skip_if_remote "podman-pod does not work with podman-remote"
# pod inspect
run_podman pod inspect --format '{{.Name}}: {{.ID}} : {{.NumContainers}} : {{.Labels}}' mypod
is "$output" "mypod: $pod_id : 1 : map\[${labelname}:${labelvalue}]" \
"pod inspect --format ..."
run_podman pod create --name podtest
podid=$output
# pod ps
run_podman pod ps --format '{{.ID}} {{.Name}} {{.Status}} {{.Labels}}'
is "$output" "${pod_id:0:12} mypod Running map\[${labelname}:${labelvalue}]" "pod ps"
run_podman pod inspect --format '-> {{.Name}}: {{.NumContainers}}' podtest
is "$output" "-> podtest: 1"
run_podman pod ps --no-trunc --filter "label=${labelname}=${labelvalue}" --format '{{.ID}}'
is "$output" "$pod_id" "pod ps --filter label=..."
run_podman pod rm -f podtest
run_podman pod rm -f mypod
}
# vim: filetype=sh

View File

@ -60,4 +60,27 @@ load helpers
run_podman rmi busybox
}
# Issue #5466 - port-forwarding doesn't work with this option and -d
@test "podman networking: port with --userns=keep-id" {
skip_if_remote
# FIXME: randomize port, and create second random host port
myport=54321
# Container will exit as soon as 'nc' receives input
run_podman run -d --userns=keep-id -p 127.0.0.1:$myport:$myport \
$IMAGE nc -l -p $myport
cid="$output"
# emit random string, and check it
teststring=$(random_string 30)
echo "$teststring" | nc 127.0.0.1 $myport
run_podman logs $cid
is "$output" "$teststring" "test string received on container"
# Clean up
run_podman rm $cid
}
# vim: filetype=sh