mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-25 22:39:38 +00:00
fix container lifecycle e2e tests
This commit is contained in:
@@ -48,6 +48,8 @@ type execCommand struct {
|
||||
// ContainerName is the name of the container to append the log. If empty,
|
||||
// the name specified in ExecCommand will be used.
|
||||
ContainerName string
|
||||
// LoopPeriod is the time interval for executing the loop.
|
||||
LoopPeriod float32
|
||||
}
|
||||
|
||||
// ExecCommand returns the command to execute in the container that implements
|
||||
@@ -88,8 +90,13 @@ func ExecCommand(name string, c execCommand) []string {
|
||||
if c.Delay != 0 {
|
||||
fmt.Fprint(&cmd, sleepCommand(c.Delay))
|
||||
}
|
||||
|
||||
loopPeriod := float32(1)
|
||||
if c.LoopPeriod != 0 {
|
||||
loopPeriod = c.LoopPeriod
|
||||
}
|
||||
if c.LoopForever {
|
||||
fmt.Fprintf(&cmd, "while true; do echo %s '%s Looping' | tee -a %s >> /proc/1/fd/1 ; sleep 1 ; done; ", timeCmd, name, containerLog)
|
||||
fmt.Fprintf(&cmd, "while true; do echo %s '%s Looping' | tee -a %s >> /proc/1/fd/1 ; sleep %f ; done; ", timeCmd, name, containerLog, loopPeriod)
|
||||
}
|
||||
fmt.Fprintf(&cmd, "echo %s '%s Exiting' | tee -a %s >> /proc/1/fd/1; ", timeCmd, name, containerLog)
|
||||
fmt.Fprintf(&cmd, "exit %d", c.ExitCode)
|
||||
|
||||
@@ -3178,6 +3178,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
|
||||
ExitCode: 0,
|
||||
ContainerName: containerName,
|
||||
LoopForever: true,
|
||||
LoopPeriod: 0.2,
|
||||
}),
|
||||
},
|
||||
},
|
||||
@@ -3280,7 +3281,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
|
||||
ps3Last, err := results.TimeOfLastLoop(prefixedName(PreStopPrefix, restartableInit3))
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
const simulToleration = 500 // milliseconds
|
||||
const simulToleration = 1000 // milliseconds
|
||||
// should all end together since they loop infinitely and exceed their grace period
|
||||
gomega.Expect(ps1Last-ps2Last).To(gomega.BeNumerically("~", 0, simulToleration),
|
||||
fmt.Sprintf("expected PostStart 1 & PostStart 2 to be killed at the same time, got %s", results))
|
||||
@@ -3290,7 +3291,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
|
||||
fmt.Sprintf("expected PostStart 2 & PostStart 3 to be killed at the same time, got %s", results))
|
||||
|
||||
// 30 seconds + 2 second minimum grace for the SIGKILL
|
||||
const lifetimeToleration = 1000 // milliseconds
|
||||
const lifetimeToleration = 1500 // milliseconds
|
||||
gomega.Expect(ps1Last-ps1).To(gomega.BeNumerically("~", 32000, lifetimeToleration),
|
||||
fmt.Sprintf("expected PostStart 1 to live for ~32 seconds, got %s", results))
|
||||
gomega.Expect(ps2Last-ps2).To(gomega.BeNumerically("~", 32000, lifetimeToleration),
|
||||
|
||||
Reference in New Issue
Block a user