summaryrefslogtreecommitdiff
path: root/test/system
diff options
context:
space:
mode:
Diffstat (limited to 'test/system')
-rw-r--r--test/system/090-events.bats65
-rw-r--r--test/system/190-run-ipcns.bats70
2 files changed, 135 insertions, 0 deletions
diff --git a/test/system/090-events.bats b/test/system/090-events.bats
index a0b0380a2..cac0a177c 100644
--- a/test/system/090-events.bats
+++ b/test/system/090-events.bats
@@ -129,3 +129,68 @@ EOF
run cat $events_file
is "$output" ".*\"Name\":\"$IMAGE" "test"
}
+
+function _populate_events_file() {
+ # Create 100 duplicate entries to populate the events log file.
+ local events_file=$1
+ truncate --size=0 $events_file
+ for i in {0..99}; do
+ printf '{"Name":"busybox","Status":"pull","Time":"2022-04-06T11:26:42.7236679%02d+02:00","Type":"image","Attributes":null}\n' $i >> $events_file
+ done
+}
+
+@test "events log-file rotation" {
+ skip_if_remote "setting CONTAINERS_CONF logger options does not affect remote client"
+
+ # Make sure that the events log file is (not) rotated depending on the
+ # settings in containers.conf.
+
+ # Config without a limit
+ eventsFile=$PODMAN_TMPDIR/events.txt
+ _populate_events_file $eventsFile
+ containersConf=$PODMAN_TMPDIR/containers.conf
+ cat >$containersConf <<EOF
+[engine]
+events_logger="file"
+events_logfile_path="$eventsFile"
+EOF
+
+ # Create events *without* a limit and make sure that it has not been
+ # rotated/truncated.
+ contentBefore=$(head -n100 $eventsFile)
+ CONTAINERS_CONF=$containersConf run_podman run --rm $IMAGE true
+ contentAfter=$(head -n100 $eventsFile)
+ is "$contentBefore" "$contentAfter" "events file has not been rotated"
+
+ # Repopulate events file
+ rm $eventsFile
+ _populate_events_file $eventsFile
+
+ # Config with a limit
+ rm $containersConf
+ cat >$containersConf <<EOF
+[engine]
+events_logger="file"
+events_logfile_path="$eventsFile"
+# The limit of 4750 is the *exact* half of the inital events file.
+events_logfile_max_size=4750
+EOF
+
+ # Create events *with* a limit and make sure that it has been
+ # rotated/truncated. Once rotated, the events file should only contain the
+ # second half of its previous events plus the new ones.
+ expectedContentAfterTruncation=$PODMAN_TMPDIR/truncated.txt
+
+ run_podman create $IMAGE
+ CONTAINERS_CONF=$containersConf run_podman rm $output
+ tail -n52 $eventsFile >> $expectedContentAfterTruncation
+
+ # Make sure the events file looks as expected.
+ is "$(cat $eventsFile)" "$(cat $expectedContentAfterTruncation)" "events file has been rotated"
+
+ # Make sure that `podman events` can read the file, and that it returns the
+ # same amount of events. We checked the contents before.
+ CONTAINERS_CONF=$containersConf run_podman events --stream=false --since="2022-03-06T11:26:42.723667984+02:00"
+ is "$(wc -l <$eventsFile)" "$(wc -l <<<$output)" "all events are returned"
+ is "${lines[-2]}" ".* log-rotation $eventsFile"
+}
diff --git a/test/system/190-run-ipcns.bats b/test/system/190-run-ipcns.bats
new file mode 100644
index 000000000..9327d8ec7
--- /dev/null
+++ b/test/system/190-run-ipcns.bats
@@ -0,0 +1,70 @@
+#!/usr/bin/env bats -*- bats -*-
+# shellcheck disable=SC2096
+#
+# Tests for podman build
+#
+
+load helpers
+
+@test "podman --ipc=host" {
+ run readlink /proc/self/ns/ipc
+ hostipc=$output
+ run_podman run --rm --ipc=host $IMAGE readlink /proc/self/ns/ipc
+ is "$output" "$hostipc" "HostIPC and container IPC should be same"
+}
+
+@test "podman --ipc=none" {
+ run readlink /proc/self/ns/ipc
+ hostipc=$output
+ run_podman run --rm --ipc=none $IMAGE readlink /proc/self/ns/ipc
+ if [[ $output == "$hostipc" ]]; then
+ die "hostipc and containeripc should be different"
+ fi
+ run_podman 1 run --rm --ipc=none $IMAGE ls /dev/shm
+ is "$output" "ls: /dev/shm: No such file or directory" "Should fail with missing /dev/shm"
+}
+
+@test "podman --ipc=private" {
+ run readlink /proc/self/ns/ipc
+ hostipc=$output
+ run_podman run -d --ipc=private --name test $IMAGE sleep 100
+ if [[ $output == "$hostipc" ]]; then
+ die "hostipc and containeripc should be different"
+ fi
+ run_podman 125 run --ipc=container:test --rm $IMAGE readlink /proc/self/ns/ipc
+ is "$output" ".*is not allowed: non-shareable IPC (hint: use IpcMode:shareable for the donor container)" "Containers should not share private ipc namespace"
+ run_podman stop -t 0 test
+ run_podman rm test
+}
+
+@test "podman --ipc=shareable" {
+ run readlink /proc/self/ns/ipc
+ hostipc=$output
+ run_podman run -d --ipc=shareable --name test $IMAGE sleep 100
+ if [[ $output == "$hostipc" ]]; then
+ die "hostipc and containeripc should be different"
+ fi
+ run_podman run --ipc=container:test --rm $IMAGE readlink /proc/self/ns/ipc
+ if [[ $output == "$hostipc" ]]; then
+ die "hostipc and containeripc should be different"
+ fi
+ run_podman stop -t 0 test
+ run_podman rm test
+}
+
+@test "podman --ipc=container@test" {
+ run readlink /proc/self/ns/ipc
+ hostipc=$output
+ run_podman run -d --name test $IMAGE sleep 100
+ run_podman exec test readlink /proc/self/ns/ipc
+ if [[ $output == "$hostipc" ]]; then
+ die "hostipc and containeripc should be different"
+ fi
+ testipc=$output
+ run_podman run --ipc=container:test --rm $IMAGE readlink /proc/self/ns/ipc
+ is "$output" "$testipc" "Containers should share ipc namespace"
+ run_podman stop -t 0 test
+ run_podman rm test
+}
+
+# vim: filetype=sh