diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/apiv2/20-containers.at | 47 | ||||
-rwxr-xr-x | test/apiv2/test-apiv2 | 11 | ||||
-rw-r--r-- | test/python/docker/__init__.py | 21 | ||||
-rw-r--r-- | test/python/docker/compat/test_system.py | 5 |
4 files changed, 70 insertions, 14 deletions
diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at index 72003984f..45c040fbc 100644 --- a/test/apiv2/20-containers.at +++ b/test/apiv2/20-containers.at @@ -18,6 +18,14 @@ podman rm -a -f &>/dev/null t GET "libpod/containers/json (at start: clean slate)" 200 length=0 +# 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 t GET libpod/containers/json 200 length=0 @@ -231,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 \ @@ -359,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 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 @@ -403,3 +420,29 @@ t GET containers/$cid/json 200 \ .HostConfig.Binds[0]~/tmp:/mnt:.* \ t DELETE containers/$cid?v=true 204 + +# test apiv2 create/commit +t POST containers/create \ + Image=$IMAGE \ + Entrypoint='["echo"]' \ + Cmd='["param1","param2"]' \ + 201 \ + .Id~[0-9a-f]\\{64\\} +cid=$(jq -r '.Id' <<<"$output") + +# No such container +t POST "commit?container=nonesuch" 404 + +cparam="repo=newrepo&tag=v3&comment=abcd&author=eric" +cparam="$cparam&format=docker&changes=CMD=/bin/bar,EXPOSE=9090" +t POST "commit?container=${cid:0:12}&$cparam" 201 \ + .Id~[0-9a-f]\\{64\\} +iid=$(jq -r '.Id' <<<"$output") +t GET images/$iid/json 200 \ + .RepoTags[0]=docker.io/library/newrepo:v3 \ + .Config.ExposedPorts~.*"9090/tcp" \ + .Config.Cmd~.*"/bin/bar" \ + .Comment="abcd" + +t DELETE containers/$cid 204 +t DELETE images/docker.io/library/newrepo:v3?force=false 200 diff --git a/test/apiv2/test-apiv2 b/test/apiv2/test-apiv2 index 19e8c12d0..56280f04e 100755 --- a/test/apiv2/test-apiv2 +++ b/test/apiv2/test-apiv2 @@ -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() { @@ -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 diff --git a/test/python/docker/__init__.py b/test/python/docker/__init__.py index 80fc2a133..816667b82 100644 --- a/test/python/docker/__init__.py +++ b/test/python/docker/__init__.py @@ -42,16 +42,19 @@ class Podman(object): os.environ["CONTAINERS_REGISTRIES_CONF"] = os.path.join( self.anchor_directory, "registry.conf" ) - p = configparser.ConfigParser() - p.read_dict( - { - "registries.search": {"registries": "['quay.io', 'docker.io']"}, - "registries.insecure": {"registries": "[]"}, - "registries.block": {"registries": "[]"}, - } - ) + conf = """unqualified-search-registries = ["docker.io", "quay.io"] + +[[registry]] +location="localhost:5000" +insecure=true + +[[registry.mirror]] +location = "mirror.localhost:5000" + +""" + with open(os.environ["CONTAINERS_REGISTRIES_CONF"], "w") as w: - p.write(w) + w.write(conf) os.environ["CNI_CONFIG_PATH"] = os.path.join( self.anchor_directory, "cni", "net.d" diff --git a/test/python/docker/compat/test_system.py b/test/python/docker/compat/test_system.py index 131b18991..a928de0ee 100644 --- a/test/python/docker/compat/test_system.py +++ b/test/python/docker/compat/test_system.py @@ -54,7 +54,10 @@ class TestSystem(unittest.TestCase): return super().tearDownClass() def test_Info(self): - self.assertIsNotNone(self.client.info()) + info = self.client.info() + self.assertIsNotNone(info) + self.assertEqual(info["RegistryConfig"]["IndexConfigs"]["localhost:5000"]["Secure"], False) + self.assertEqual(info["RegistryConfig"]["IndexConfigs"]["localhost:5000"]["Mirrors"], ["mirror.localhost:5000"]) def test_info_container_details(self): info = self.client.info() |