summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/apiv2/python/rest_api/test_v2_0_0_system.py13
-rw-r--r--test/buildah-bud/buildah-tests.diff18
-rw-r--r--test/e2e/run_cgroup_parent_test.go32
-rw-r--r--test/system/500-networking.bats119
4 files changed, 107 insertions, 75 deletions
diff --git a/test/apiv2/python/rest_api/test_v2_0_0_system.py b/test/apiv2/python/rest_api/test_v2_0_0_system.py
index 8171abb84..1140d09cf 100644
--- a/test/apiv2/python/rest_api/test_v2_0_0_system.py
+++ b/test/apiv2/python/rest_api/test_v2_0_0_system.py
@@ -30,13 +30,12 @@ class SystemTestCase(APITestCase):
# Actor.ID is uppercase for compatibility
self.assertIn("ID", obj["Actor"])
# Verify 1.22+ deprecated variants are present if current originals are
- if (obj["Actor"]["ID"]):
- self.assertEqual(obj["Actor"]["ID"], obj["id"])
- if (obj["Action"]):
- self.assertEqual(obj["Action"], obj["status"])
- if (obj["Actor"].get("Attributes") and obj["Actor"]["Attributes"].get("image")):
- self.assertEqual(obj["Actor"]["Attributes"]["image"], obj["from"])
-
+ if obj["Actor"]["ID"]:
+ self.assertEqual(obj["Actor"]["ID"], obj["id"])
+ if obj["Action"]:
+ self.assertEqual(obj["Action"], obj["status"])
+ if obj["Actor"].get("Attributes") and obj["Actor"]["Attributes"].get("image"):
+ self.assertEqual(obj["Actor"]["Attributes"]["image"], obj["from"])
def test_ping(self):
required_headers = (
diff --git a/test/buildah-bud/buildah-tests.diff b/test/buildah-bud/buildah-tests.diff
index 66d470648..bb28e11c9 100644
--- a/test/buildah-bud/buildah-tests.diff
+++ b/test/buildah-bud/buildah-tests.diff
@@ -1,4 +1,4 @@
-From d684753d6f00ee95720d8fb2e09c7ac19b37b01e Mon Sep 17 00:00:00 2001
+From 5baab334cac9853c1d4bae9466d46dbbe5ff7158 Mon Sep 17 00:00:00 2001
From: Ed Santiago <santiago@redhat.com>
Date: Tue, 9 Feb 2021 17:28:05 -0700
Subject: [PATCH] tweaks for running buildah tests under podman
@@ -9,10 +9,10 @@ Signed-off-by: Ed Santiago <santiago@redhat.com>
1 file changed, 67 insertions(+), 4 deletions(-)
diff --git a/tests/helpers.bash b/tests/helpers.bash
-index 11deb367..44c71dad 100644
+index 166316d5..775d7c9b 100644
--- a/tests/helpers.bash
+++ b/tests/helpers.bash
-@@ -34,6 +34,23 @@ function setup() {
+@@ -43,6 +43,23 @@ EOF
ROOTDIR_OPTS="--root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${STORAGE_DRIVER}"
BUILDAH_REGISTRY_OPTS="--registries-conf ${TESTSDIR}/registries.conf --registries-conf-dir ${TESTDIR}/registries.d --short-name-alias-conf ${TESTDIR}/cache/shortnames.conf"
PODMAN_REGISTRY_OPTS="--registries-conf ${TESTSDIR}/registries.conf"
@@ -36,8 +36,8 @@ index 11deb367..44c71dad 100644
}
function starthttpd() {
-@@ -57,6 +74,12 @@ function stophttpd() {
- function teardown() {
+@@ -84,6 +101,12 @@ function teardown(){
+ function teardown_tests() {
stophttpd
+ if [[ -n "$PODMAN_SERVER_PID" ]]; then
@@ -49,7 +49,7 @@ index 11deb367..44c71dad 100644
# Workaround for #1991 - buildah + overlayfs leaks mount points.
# Many tests leave behind /var/tmp/.../root/overlay and sub-mounts;
# let's find those and clean them up, otherwise 'rm -rf' fails.
-@@ -129,7 +152,13 @@ function copy() {
+@@ -156,7 +179,13 @@ function copy() {
}
function podman() {
@@ -64,7 +64,7 @@ index 11deb367..44c71dad 100644
}
#################
-@@ -164,15 +193,40 @@ function run_buildah() {
+@@ -191,15 +220,40 @@ function run_buildah() {
--retry) retry=3; shift;; # retry network flakes
esac
@@ -108,7 +108,7 @@ index 11deb367..44c71dad 100644
# without "quotes", multiple lines are glommed together into one
if [ -n "$output" ]; then
echo "$output"
-@@ -396,3 +450,12 @@ function skip_if_no_docker() {
+@@ -477,3 +531,12 @@ function skip_if_no_docker() {
skip "this test needs actual docker, not podman-docker"
fi
}
@@ -122,5 +122,5 @@ index 11deb367..44c71dad 100644
+ fi
+}
--
-2.31.1
+2.25.1
diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go
index 82b6c3057..e0e1d4b1d 100644
--- a/test/e2e/run_cgroup_parent_test.go
+++ b/test/e2e/run_cgroup_parent_test.go
@@ -13,6 +13,8 @@ import (
. "github.com/onsi/gomega/gexec"
)
+const cgroupRoot = "/sys/fs/cgroup"
+
var _ = Describe("Podman run with --cgroup-parent", func() {
var (
tempdir string
@@ -64,7 +66,6 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
})
Specify("always honor --cgroup-parent", func() {
- Skip("https://github.com/containers/podman/issues/11165")
SkipIfCgroupV1("test not supported in cgroups v1")
if Containerized() || podmanTest.CgroupManager == "cgroupfs" {
Skip("Requires Systemd cgroup manager support")
@@ -78,36 +79,31 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
Expect(run).Should(Exit(0))
cid := run.OutputToString()
- exec := podmanTest.Podman([]string{"exec", cid, "cat", "/proc/self/cgroup"})
+ exec := podmanTest.Podman([]string{"exec", cid, "cat", "/proc/1/cgroup"})
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
containerCgroup := strings.TrimRight(strings.Replace(exec.OutputToString(), "0::", "", -1), "\n")
- content, err := ioutil.ReadFile(filepath.Join("/sys/fs/cgroup", containerCgroup, "cgroup.procs"))
- Expect(err).To(BeNil())
-
// Move the container process to a sub cgroup
- subCgroupPath := filepath.Join(filepath.Join("/sys/fs/cgroup", containerCgroup, "old-container"))
-
- err = os.MkdirAll(subCgroupPath, 0755)
+ content, err := ioutil.ReadFile(filepath.Join(cgroupRoot, containerCgroup, "cgroup.procs"))
Expect(err).To(BeNil())
-
- err = ioutil.WriteFile(filepath.Join(subCgroupPath, "cgroup.procs"), content, 0644)
+ oldSubCgroupPath := filepath.Join(filepath.Join(cgroupRoot, containerCgroup, "old-container"))
+ err = os.MkdirAll(oldSubCgroupPath, 0755)
+ Expect(err).To(BeNil())
+ err = ioutil.WriteFile(filepath.Join(oldSubCgroupPath, "cgroup.procs"), content, 0644)
Expect(err).To(BeNil())
- cgroup := filepath.Dir(containerCgroup)
+ newCgroup := fmt.Sprintf("%s/new-container", containerCgroup)
+ err = os.MkdirAll(filepath.Join(cgroupRoot, newCgroup), 0755)
+ Expect(err).To(BeNil())
- run = podmanTest.Podman([]string{"--cgroup-manager=cgroupfs", "run", "-d", fmt.Sprintf("--cgroup-parent=%s", cgroup), fedoraMinimal, "sleep", "100"})
+ run = podmanTest.Podman([]string{"--cgroup-manager=cgroupfs", "run", "--rm", "--cgroupns=host", fmt.Sprintf("--cgroup-parent=%s", newCgroup), fedoraMinimal, "cat", "/proc/self/cgroup"})
run.WaitWithDefaultTimeout()
Expect(run).Should(Exit(0))
+ cgroupEffective := strings.TrimRight(strings.Replace(run.OutputToString(), "0::", "", -1), "\n")
- exec = podmanTest.Podman([]string{"exec", cid, "cat", "/proc/self/cgroup"})
- exec.WaitWithDefaultTimeout()
- Expect(exec).Should(Exit(0))
- cgroupEffective := filepath.Dir(strings.TrimRight(strings.Replace(exec.OutputToString(), "0::", "", -1), "\n"))
-
- Expect(cgroupEffective).To(Equal(cgroup))
+ Expect(newCgroup).To(Equal(filepath.Dir(cgroupEffective)))
})
Specify("valid --cgroup-parent using slice", func() {
diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats
index ad5891dd9..bdedfae19 100644
--- a/test/system/500-networking.bats
+++ b/test/system/500-networking.bats
@@ -32,7 +32,6 @@ load helpers
# Bind-mount this file with a different name to a container running httpd
run_podman run -d --name myweb -p "$HOST_PORT:80" \
- --restart always \
-v $INDEX1:/var/www/index.txt:Z \
-w /var/www \
$IMAGE /bin/busybox-extras httpd -f -p 80
@@ -67,46 +66,6 @@ load helpers
run_podman 125 port myweb 99/tcp
is "$output" 'Error: failed to find published port "99/tcp"'
- # Tests #10310: podman will restart slirp4netns on container restart
- run_podman container inspect --format "{{.State.Pid}}" $cid
- pid=$output
-
- # Kill the process; podman restart policy will bring up a new container.
- # -9 is crucial: busybox httpd ignores all other signals.
- kill -9 $pid
- # Wait for process to exit
- retries=30
- while kill -0 $pid; do
- sleep 0.5
- retries=$((retries - 1))
- if [[ $retries -eq 0 ]]; then
- die "Process $pid (container $cid) refused to die"
- fi
- done
-
- # Wait for container to restart
- retries=20
- while :;do
- run_podman container inspect --format "{{.State.Pid}}" myweb
- # pid is 0 as long as the container is not running
- if [[ $output -ne 0 ]]; then
- if [[ $output == $pid ]]; then
- die "This should never happen! Restarted container has same PID ($output) as killed one!"
- fi
- break
- fi
- sleep 0.5
- retries=$((retries - 1))
- if [[ $retries -eq 0 ]]; then
- die "Timed out waiting for container to restart"
- fi
- done
-
- # Verify http contents again: curl from localhost
- # Use retry since it can take a moment until the new container is ready
- run curl --retry 2 -s $SERVER/index.txt
- is "$output" "$random_1" "curl 127.0.0.1:/index.txt after restart"
-
# Clean up
run_podman stop -t 1 myweb
run_podman rm myweb
@@ -476,4 +435,82 @@ load helpers
run_podman network rm -f $netname $netname2
}
+@test "podman network after restart" {
+ random_1=$(random_string 30)
+
+ HOST_PORT=$(random_free_port)
+ SERVER=http://127.0.0.1:$HOST_PORT
+
+ # Create a test file with random content
+ INDEX1=$PODMAN_TMPDIR/hello.txt
+ echo $random_1 > $INDEX1
+
+ local netname=testnet-$(random_string 10)
+ run_podman network create $netname
+ is "$output" ".*/cni/net.d/$netname.conflist" "output of 'network create'"
+
+ for network in "slirp4netns" "$netname"; do
+ # Start container with the restart always policy
+ run_podman run -d --name myweb -p "$HOST_PORT:80" \
+ --restart always \
+ --network $network \
+ -v $INDEX1:/var/www/index.txt:Z \
+ -w /var/www \
+ $IMAGE /bin/busybox-extras httpd -f -p 80
+ cid=$output
+
+ # Tests #10310: podman will restart slirp4netns on container restart
+ run_podman container inspect --format "{{.State.Pid}}" $cid
+ pid=$output
+
+ # Kill the process; podman restart policy will bring up a new container.
+ # -9 is crucial: busybox httpd ignores all other signals.
+ kill -9 $pid
+ # Wait for process to exit
+ retries=30
+ while kill -0 $pid; do
+ sleep 0.5
+ retries=$((retries - 1))
+ if [[ $retries -eq 0 ]]; then
+ die "Process $pid (container $cid) refused to die"
+ fi
+ done
+
+ # Wait for container to restart
+ retries=20
+ while :;do
+ run_podman container inspect --format "{{.State.Pid}}" $cid
+ # pid is 0 as long as the container is not running
+ if [[ $output -ne 0 ]]; then
+ if [[ $output == $pid ]]; then
+ die "This should never happen! Restarted container has same PID ($output) as killed one!"
+ fi
+ break
+ fi
+ sleep 0.5
+ retries=$((retries - 1))
+ if [[ $retries -eq 0 ]]; then
+ die "Timed out waiting for container to restart"
+ fi
+ done
+
+ # Verify http contents again: curl from localhost
+ # Use retry since it can take a moment until the new container is ready
+ run curl --retry 2 -s $SERVER/index.txt
+ is "$output" "$random_1" "curl 127.0.0.1:/index.txt after auto restart"
+
+ run_podman restart $cid
+ # Verify http contents again: curl from localhost
+ # Use retry since it can take a moment until the new container is ready
+ run curl --retry 2 -s $SERVER/index.txt
+ is "$output" "$random_1" "curl 127.0.0.1:/index.txt after podman restart"
+
+ run_podman stop -t 0 $cid
+ run_podman rm -f $cid
+ done
+
+ # Cleanup network
+ run_podman network rm $netname
+}
+
# vim: filetype=sh