spiegel_podman/pkg/domain/infra/abi/play_utils_test.go
Valentin Rothberg 79e21b5b16 kube play: sd-notify integration
Integrate sd-notify policies into `kube play`.  The policies can be
configured for all contianers via the `io.containers.sdnotify`
annotation or for indidivual containers via the
`io.containers.sdnotify/$name` annotation.

The `kube play` process will wait for all containers to be ready by
waiting for the individual `READY=1` messages which are received via
the `pkg/systemd/notifyproxy` proxy mechanism.

Also update the simple "container" sd-notify test as it did not fully
test the expected behavior which became obvious when adding the new
tests.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-08-10 21:12:39 +02:00

38 lines
1.2 KiB
Go

package abi
import (
"testing"
"github.com/containers/podman/v4/libpod/define"
"github.com/stretchr/testify/require"
)
func TestGetSdNotifyMode(t *testing.T) {
tests := []struct {
key, value, name, result string
mustError bool
}{
{sdNotifyAnnotation, define.SdNotifyModeConmon, "", define.SdNotifyModeConmon, false},
{sdNotifyAnnotation + "/container-a", define.SdNotifyModeContainer, "container-a", define.SdNotifyModeContainer, false},
{sdNotifyAnnotation + "/container-b", define.SdNotifyModeIgnore, "container-b", define.SdNotifyModeIgnore, false},
{sdNotifyAnnotation + "/container-c", "", "container-c", "", false},
{sdNotifyAnnotation + "-/wrong-key", "xxx", "wrong-key", "", false},
{sdNotifyAnnotation + "/container-error", "invalid", "container-error", "", true},
}
annotations := make(map[string]string)
// Populate the annotations
for _, test := range tests {
annotations[test.key] = test.value
}
// Run the tests
for _, test := range tests {
result, err := getSdNotifyMode(annotations, test.name)
if test.mustError {
require.Error(t, err, "%v", test)
continue
}
require.NoError(t, err, "%v", test)
require.Equal(t, test.result, result, "%v", test)
}
}