mirror of
https://github.com/containers/podman.git
synced 2025-12-12 09:50:25 +08:00
Merge pull request #14159 from vrothberg/service-container
play kube: service container
This commit is contained in:
@@ -456,13 +456,12 @@ var _ = Describe("Verify podman containers.conf usage", func() {
|
||||
containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage1\"")
|
||||
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
if IsRemote() {
|
||||
podmanTest.RestartRemoteService()
|
||||
}
|
||||
|
||||
SkipIfRemote("Restarting the system service will fail loading the broken containers.conf")
|
||||
|
||||
session = podmanTest.Podman([]string{"info", "--format", "{{.Store.ImageCopyTmpDir}}"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
Expect(session).Should(Exit(125))
|
||||
Expect(session.Err.Contents()).To(ContainSubstring("invalid image_copy_tmp_dir"))
|
||||
})
|
||||
|
||||
|
||||
@@ -408,19 +408,6 @@ EOF
|
||||
run_podman pod rm test
|
||||
}
|
||||
|
||||
# Wait for the pod (1st arg) to transition into the state (2nd arg)
|
||||
function _ensure_pod_state() {
|
||||
for i in {0..5}; do
|
||||
run_podman pod inspect $1 --format "{{.State}}"
|
||||
if [[ $output == "$2" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
is "$output" "$2" "unexpected pod state"
|
||||
}
|
||||
|
||||
@test "pod exit policies" {
|
||||
# Test setting exit policies
|
||||
run_podman pod create
|
||||
|
||||
@@ -100,6 +100,61 @@ RELABEL="system_u:object_r:container_file_t:s0"
|
||||
run_podman pod rm -t 0 -f test_pod
|
||||
}
|
||||
|
||||
@test "podman play --service-container" {
|
||||
skip_if_remote "service containers only work locally"
|
||||
|
||||
TESTDIR=$PODMAN_TMPDIR/testdir
|
||||
mkdir -p $TESTDIR
|
||||
|
||||
yaml="
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
labels:
|
||||
app: test
|
||||
name: test_pod
|
||||
spec:
|
||||
containers:
|
||||
- command:
|
||||
- top
|
||||
image: $IMAGE
|
||||
name: test
|
||||
resources: {}
|
||||
"
|
||||
|
||||
echo "$yaml" > $PODMAN_TMPDIR/test.yaml
|
||||
run_podman play kube --service-container=true $PODMAN_TMPDIR/test.yaml
|
||||
|
||||
# Make sure that the service container exists and runs.
|
||||
run_podman container inspect "352a88685060-service" --format "{{.State.Running}}"
|
||||
is "$output" "true"
|
||||
|
||||
# Stop the *main* container and make sure that
|
||||
# 1) The pod transitions to Exited
|
||||
# 2) The service container is stopped
|
||||
# #) The service container is marked as an service container
|
||||
run_podman stop test_pod-test
|
||||
_ensure_pod_state test_pod Exited
|
||||
run_podman container inspect "352a88685060-service" --format "{{.State.Running}}"
|
||||
is "$output" "false"
|
||||
run_podman container inspect "352a88685060-service" --format "{{.IsService}}"
|
||||
is "$output" "true"
|
||||
|
||||
# Restart the pod, make sure the service is running again
|
||||
run_podman pod restart test_pod
|
||||
run_podman container inspect "352a88685060-service" --format "{{.State.Running}}"
|
||||
is "$output" "true"
|
||||
|
||||
# Kill the pod and make sure the service is not running
|
||||
run_podman pod kill test_pod
|
||||
run_podman container inspect "352a88685060-service" --format "{{.State.Running}}"
|
||||
is "$output" "false"
|
||||
|
||||
# Remove the pod and make sure the service is removed along with it
|
||||
run_podman pod rm test_pod
|
||||
run_podman 1 container exists "352a88685060-service"
|
||||
}
|
||||
|
||||
@test "podman play --network" {
|
||||
TESTDIR=$PODMAN_TMPDIR/testdir
|
||||
mkdir -p $TESTDIR
|
||||
|
||||
@@ -392,6 +392,19 @@ function pause_image() {
|
||||
echo "localhost/podman-pause:$output"
|
||||
}
|
||||
|
||||
# Wait for the pod (1st arg) to transition into the state (2nd arg)
|
||||
function _ensure_pod_state() {
|
||||
for i in {0..5}; do
|
||||
run_podman pod inspect $1 --format "{{.State}}"
|
||||
if [[ $output == "$2" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
is "$output" "$2" "unexpected pod state"
|
||||
}
|
||||
|
||||
###########################
|
||||
# _add_label_if_missing # make sure skip messages include rootless/remote
|
||||
###########################
|
||||
|
||||
Reference in New Issue
Block a user