Skip to content

Commit b0e974e

Browse files
authored
Merge pull request kubernetes#92239 from matthyx/more-tests
Add tests covering startup probe without readiness
2 parents 67afc8e + 681202a commit b0e974e

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

pkg/kubelet/prober/prober_manager_test.go

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,20 @@ func TestUpdatePodStatus(t *testing.T) {
256256
Running: &v1.ContainerStateRunning{},
257257
},
258258
}
259+
notStartedNoReadiness := v1.ContainerStatus{
260+
Name: "not_started_container_no_readiness",
261+
ContainerID: "test://not_started_container_no_readiness_id",
262+
State: v1.ContainerState{
263+
Running: &v1.ContainerStateRunning{},
264+
},
265+
}
266+
startedNoReadiness := v1.ContainerStatus{
267+
Name: "started_container_no_readiness",
268+
ContainerID: "test://started_container_no_readiness_id",
269+
State: v1.ContainerState{
270+
Running: &v1.ContainerStateRunning{},
271+
},
272+
}
259273
terminated := v1.ContainerStatus{
260274
Name: "terminated_container",
261275
ContainerID: "test://terminated_container_id",
@@ -266,7 +280,7 @@ func TestUpdatePodStatus(t *testing.T) {
266280
podStatus := v1.PodStatus{
267281
Phase: v1.PodRunning,
268282
ContainerStatuses: []v1.ContainerStatus{
269-
unprobed, probedReady, probedPending, probedUnready, terminated,
283+
unprobed, probedReady, probedPending, probedUnready, notStartedNoReadiness, startedNoReadiness, terminated,
270284
},
271285
}
272286

@@ -275,24 +289,29 @@ func TestUpdatePodStatus(t *testing.T) {
275289

276290
// Setup probe "workers" and cached results.
277291
m.workers = map[probeKey]*worker{
278-
{testPodUID, unprobed.Name, liveness}: {},
279-
{testPodUID, probedReady.Name, readiness}: {},
280-
{testPodUID, probedPending.Name, readiness}: {},
281-
{testPodUID, probedUnready.Name, readiness}: {},
282-
{testPodUID, terminated.Name, readiness}: {},
292+
{testPodUID, unprobed.Name, liveness}: {},
293+
{testPodUID, probedReady.Name, readiness}: {},
294+
{testPodUID, probedPending.Name, readiness}: {},
295+
{testPodUID, probedUnready.Name, readiness}: {},
296+
{testPodUID, notStartedNoReadiness.Name, startup}: {},
297+
{testPodUID, startedNoReadiness.Name, startup}: {},
298+
{testPodUID, terminated.Name, readiness}: {},
283299
}
284300
m.readinessManager.Set(kubecontainer.ParseContainerID(probedReady.ContainerID), results.Success, &v1.Pod{})
285301
m.readinessManager.Set(kubecontainer.ParseContainerID(probedUnready.ContainerID), results.Failure, &v1.Pod{})
302+
m.startupManager.Set(kubecontainer.ParseContainerID(startedNoReadiness.ContainerID), results.Success, &v1.Pod{})
286303
m.readinessManager.Set(kubecontainer.ParseContainerID(terminated.ContainerID), results.Success, &v1.Pod{})
287304

288305
m.UpdatePodStatus(testPodUID, &podStatus)
289306

290307
expectedReadiness := map[probeKey]bool{
291-
{testPodUID, unprobed.Name, readiness}: true,
292-
{testPodUID, probedReady.Name, readiness}: true,
293-
{testPodUID, probedPending.Name, readiness}: false,
294-
{testPodUID, probedUnready.Name, readiness}: false,
295-
{testPodUID, terminated.Name, readiness}: false,
308+
{testPodUID, unprobed.Name, readiness}: true,
309+
{testPodUID, probedReady.Name, readiness}: true,
310+
{testPodUID, probedPending.Name, readiness}: false,
311+
{testPodUID, probedUnready.Name, readiness}: false,
312+
{testPodUID, notStartedNoReadiness.Name, readiness}: false,
313+
{testPodUID, startedNoReadiness.Name, readiness}: true,
314+
{testPodUID, terminated.Name, readiness}: false,
296315
}
297316
for _, c := range podStatus.ContainerStatuses {
298317
expected, ok := expectedReadiness[probeKey{testPodUID, c.Name, readiness}]

0 commit comments

Comments
 (0)