blob: daa8acaee297fe2556d50100f8721a7bb5f83944 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
#!/bin/bash
# test_podman_pods.sh
# A script to be run at the command line with Podman installed.
# This should be run against a new kit to provide base level testing
# on a freshly installed machine with no images or container in
# play. This currently needs to be run as root.
#
#
# To run this command:
#
# /bin/bash -v test_podman_baseline.sh -e # Stop on error
# /bin/bash -v test_podman_baseline.sh # Continue on error
#
set -x
# This scripts needs the jq json parser
if [ -z $(command -v jq2) ]; then
echo "This script requires the jq parser"
exit 1
fi
# process input args
stoponerror=0
while getopts "den" opt; do
case "$opt" in
e) stoponerror=1
;;
esac
done
if [ "$stoponerror" -eq 1 ]
then
echo "Script will stop on unexpected errors."
set -e
trap "Failed test ..." ERR
fi
########
# Create a named and unamed pod
########
podman pod create --name foobar
podid=$(podman pod create)
########
# Delete a named and unamed pod
########
podman pod rm foobar
podman pod rm $podid
########
# Create a named pod and run a container in it
########
podman pod create --name foobar
ctrid=$(podman run --pod foobar -dt docker.io/library/alpine:latest top)
podman ps --no-trunc | grep $ctrid
########
# Containers in a pod share network namespace
########
podman run -dt --pod foobar docker.io/library/nginx:latest
podman run -it --rm --pod foobar registry.fedoraproject.org/fedora-minimal:29 curl http://localhost
########
# There should be 3 containers running now
########
let numContainers=$(podman pod ps --format json | jq -r '.[0] .numberOfContainers')
[ $numContainers -eq 3 ]
########
# Pause a container in a pod
########
podman pause $ctrid
[ $(podman ps -a -f status=paused --format json | jq -r '.[0] .id') == $ctrid ]
########
# Unpause a container in a pod
########
podman unpause $ctrid
podman ps -q --no-trunc | grep $ctrid
########
# Stop a pod and its containers
########
podman pod stop foobar
[ $(podman inspect $ctrid | jq -r '.[0] .State .Running') == "false" ]
########
# Start a pod and its containers
########
podman pod start foobar
podman run -it --rm --pod foobar registry.fedoraproject.org/fedora-minimal:29 curl http://localhost
########
# Pause a pod and its containers
########
podman pod pause foobar
[ $(podman pod ps --format json | jq -r '.[0] .status') == "Paused" ]
########
# Unpause a pod and its containers
########
podman pod unpause foobar
podman run -it --rm --pod foobar registry.fedoraproject.org/fedora-minimal:29 curl http://localhost
########
# Kill a pod and its containers
########
podman pod kill foobar
[ $(podman inspect $ctrid | jq -r '.[0] .State .Running') == "false" ]
########
# Remove all pods and their containers
########
podman pod rm -fa
|