Skip to content
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

APIv2 tests: followup to recent log test #12925

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ podman rm -a -f &>/dev/null

t GET "libpod/containers/json (at start: clean slate)" 200 length=0

# Regression test for #12904
podman run --rm -d --replace --name foo $IMAGE sh -c "echo 123;sleep 42"
t POST "containers/foo/attach?logs=true&stream=false" 200
# Regression test for #12904 (race condition in logging code)
mytext="hi-there-$(random_string 15)"
podman run --rm -d --replace --name foo $IMAGE sh -c "echo $mytext;sleep 42"
# Logs output is prepended by ^A^X
t POST "containers/foo/attach?logs=true&stream=false" 200 \
$'\001\030'$mytext
t POST "containers/foo/kill" 204

podman run -v /tmp:/tmp $IMAGE true
Expand Down Expand Up @@ -236,11 +239,16 @@ t GET containers/$cid/json 200 \
t POST containers/create Image=$IMAGE Entrypoint='["top"]' 201 \
.Id~[0-9a-f]\\{64\\}
cid_top=$(jq -r '.Id' <<<"$output")
# .Network is N/A when rootless
network_expect=
if root; then
network_expect='.NetworkSettings.Networks.podman.NetworkID=podman'
fi
t GET containers/${cid_top}/json 200 \
.Config.Entrypoint[0]="top" \
.Config.Cmd='[]' \
.Path="top" \
.NetworkSettings.Networks.podman.NetworkID=podman
$network_expect
t POST containers/${cid_top}/start 204
# make sure the container is running
t GET containers/${cid_top}/json 200 \
Expand Down Expand Up @@ -364,11 +372,15 @@ t GET containers/$cid/json 200 \
t DELETE containers/$cid?v=true 204

# Test Compat Create with default network mode (#10569)
networkmode=slirp4netns
if root; then
networkmode=bridge
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a bug we should also default to bridge as rootless for the compat API, @mheon WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Luap99 thank you for this. Addressing that is beyond the scope of this PR (and beyond my ability), so I've released the hold. If this situation needs fixing, it should be done in a followup PR.

t POST containers/create Image=$IMAGE HostConfig='{"NetworkMode":"default"}' 201 \
.Id~[0-9a-f]\\{64\\}
cid=$(jq -r '.Id' <<<"$output")
t GET containers/$cid/json 200 \
.HostConfig.NetworkMode="bridge"
.HostConfig.NetworkMode="$networkmode"

t DELETE containers/$cid?v=true 204

Expand Down
11 changes: 9 additions & 2 deletions test/apiv2/test-apiv2
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ echo 0 >$failures_file
# Where the tests live
TESTS_DIR=$(realpath $(dirname $0))

# As of 2021-11 podman has one external helper binary, rootlessport, needed
# for rootless networking.
if [[ -z "$CONTAINERS_HELPER_BINARY_DIR" ]]; then
export CONTAINERS_HELPER_BINARY_DIR=$(realpath ${TESTS_DIR}/../../bin)
fi

# Path to podman binary
PODMAN_BIN=${PODMAN:-${TESTS_DIR}/../../bin/podman}
PODMAN_BIN=${PODMAN:-${CONTAINERS_HELPER_BINARY_DIR}/podman}

# Cleanup handlers
clean_up_server() {
Expand Down Expand Up @@ -289,7 +295,8 @@ function t() {
output="[$(file --brief $WORKDIR/curl.result.out)]"
echo "$output" >>$LOG
elif [[ -e $WORKDIR/curl.result.out ]]; then
output=$(< $WORKDIR/curl.result.out)
# Output from /logs sometimes includes NULs. Strip them.
output=$(tr -d '\0' < $WORKDIR/curl.result.out)

if [[ $content_type =~ application/json ]] && [[ $method != "HEAD" ]]; then
jq . <<<"$output" >>$LOG
Expand Down