mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #92239 from matthyx/more-tests
Add tests covering startup probe without readiness
This commit is contained in:
commit
b0e974e1aa
@ -256,6 +256,20 @@ func TestUpdatePodStatus(t *testing.T) {
|
||||
Running: &v1.ContainerStateRunning{},
|
||||
},
|
||||
}
|
||||
notStartedNoReadiness := v1.ContainerStatus{
|
||||
Name: "not_started_container_no_readiness",
|
||||
ContainerID: "test://not_started_container_no_readiness_id",
|
||||
State: v1.ContainerState{
|
||||
Running: &v1.ContainerStateRunning{},
|
||||
},
|
||||
}
|
||||
startedNoReadiness := v1.ContainerStatus{
|
||||
Name: "started_container_no_readiness",
|
||||
ContainerID: "test://started_container_no_readiness_id",
|
||||
State: v1.ContainerState{
|
||||
Running: &v1.ContainerStateRunning{},
|
||||
},
|
||||
}
|
||||
terminated := v1.ContainerStatus{
|
||||
Name: "terminated_container",
|
||||
ContainerID: "test://terminated_container_id",
|
||||
@ -266,7 +280,7 @@ func TestUpdatePodStatus(t *testing.T) {
|
||||
podStatus := v1.PodStatus{
|
||||
Phase: v1.PodRunning,
|
||||
ContainerStatuses: []v1.ContainerStatus{
|
||||
unprobed, probedReady, probedPending, probedUnready, terminated,
|
||||
unprobed, probedReady, probedPending, probedUnready, notStartedNoReadiness, startedNoReadiness, terminated,
|
||||
},
|
||||
}
|
||||
|
||||
@ -275,24 +289,29 @@ func TestUpdatePodStatus(t *testing.T) {
|
||||
|
||||
// Setup probe "workers" and cached results.
|
||||
m.workers = map[probeKey]*worker{
|
||||
{testPodUID, unprobed.Name, liveness}: {},
|
||||
{testPodUID, probedReady.Name, readiness}: {},
|
||||
{testPodUID, probedPending.Name, readiness}: {},
|
||||
{testPodUID, probedUnready.Name, readiness}: {},
|
||||
{testPodUID, terminated.Name, readiness}: {},
|
||||
{testPodUID, unprobed.Name, liveness}: {},
|
||||
{testPodUID, probedReady.Name, readiness}: {},
|
||||
{testPodUID, probedPending.Name, readiness}: {},
|
||||
{testPodUID, probedUnready.Name, readiness}: {},
|
||||
{testPodUID, notStartedNoReadiness.Name, startup}: {},
|
||||
{testPodUID, startedNoReadiness.Name, startup}: {},
|
||||
{testPodUID, terminated.Name, readiness}: {},
|
||||
}
|
||||
m.readinessManager.Set(kubecontainer.ParseContainerID(probedReady.ContainerID), results.Success, &v1.Pod{})
|
||||
m.readinessManager.Set(kubecontainer.ParseContainerID(probedUnready.ContainerID), results.Failure, &v1.Pod{})
|
||||
m.startupManager.Set(kubecontainer.ParseContainerID(startedNoReadiness.ContainerID), results.Success, &v1.Pod{})
|
||||
m.readinessManager.Set(kubecontainer.ParseContainerID(terminated.ContainerID), results.Success, &v1.Pod{})
|
||||
|
||||
m.UpdatePodStatus(testPodUID, &podStatus)
|
||||
|
||||
expectedReadiness := map[probeKey]bool{
|
||||
{testPodUID, unprobed.Name, readiness}: true,
|
||||
{testPodUID, probedReady.Name, readiness}: true,
|
||||
{testPodUID, probedPending.Name, readiness}: false,
|
||||
{testPodUID, probedUnready.Name, readiness}: false,
|
||||
{testPodUID, terminated.Name, readiness}: false,
|
||||
{testPodUID, unprobed.Name, readiness}: true,
|
||||
{testPodUID, probedReady.Name, readiness}: true,
|
||||
{testPodUID, probedPending.Name, readiness}: false,
|
||||
{testPodUID, probedUnready.Name, readiness}: false,
|
||||
{testPodUID, notStartedNoReadiness.Name, readiness}: false,
|
||||
{testPodUID, startedNoReadiness.Name, readiness}: true,
|
||||
{testPodUID, terminated.Name, readiness}: false,
|
||||
}
|
||||
for _, c := range podStatus.ContainerStatuses {
|
||||
expected, ok := expectedReadiness[probeKey{testPodUID, c.Name, readiness}]
|
||||
|
Loading…
Reference in New Issue
Block a user