Skip to content

Commit b56d30e

Browse files
committed
fix flaky test: Subpath Container restart should verify that container can restart successfully after configmaps modified
Signed-off-by: carlory <[email protected]>
1 parent c2529e8 commit b56d30e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

test/e2e/framework/pod/utils.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,20 @@ import (
3131
"k8s.io/utils/pointer"
3232
)
3333

34+
// This command runs an infinite loop, sleeping for 1 second in each iteration.
35+
// It sets up a trap to exit gracefully when a TERM signal is received.
36+
//
37+
// This is useful for testing scenarios where the container is terminated
38+
// with a zero exit code.
3439
const InfiniteSleepCommand = "trap exit TERM; while true; do sleep 1; done"
3540

41+
// This command will cause the shell to remain in a sleep state indefinitely,
42+
// and it won't exit unless it receives a KILL signal.
43+
//
44+
// This is useful for testing scenarios where the container is terminated
45+
// with a non-zero exit code.
46+
const InfiniteSleepCommandWithoutGracefulShutdown = "sleep infinity"
47+
3648
// GenerateScriptCmd generates the corresponding command lines to execute a command.
3749
func GenerateScriptCmd(command string) []string {
3850
return []string{"/bin/sh", "-c", command}

test/e2e/storage/testsuites/subpath.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,10 @@ func testPodContainerRestartWithHooks(ctx context.Context, f *framework.Framewor
793793
pod.Spec.RestartPolicy = v1.RestartPolicyOnFailure
794794

795795
pod.Spec.Containers[0].Image = e2epod.GetDefaultTestImage()
796-
pod.Spec.Containers[0].Command = e2epod.GenerateScriptCmd(e2epod.InfiniteSleepCommand)
796+
pod.Spec.Containers[0].Command = e2epod.GenerateScriptCmd(e2epod.InfiniteSleepCommandWithoutGracefulShutdown)
797797
pod.Spec.Containers[0].Args = nil
798798
pod.Spec.Containers[1].Image = e2epod.GetDefaultTestImage()
799-
pod.Spec.Containers[1].Command = e2epod.GenerateScriptCmd(e2epod.InfiniteSleepCommand)
799+
pod.Spec.Containers[1].Command = e2epod.GenerateScriptCmd(e2epod.InfiniteSleepCommandWithoutGracefulShutdown)
800800
pod.Spec.Containers[1].Args = nil
801801
hooks.AddLivenessProbe(pod, probeFilePath)
802802

0 commit comments

Comments
 (0)