mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
Merge pull request #114760 from TommyStarK/unit-tests/pkg-kubelet-cm-containermap
kubelet/cm/containermap: Improving test coverage
This commit is contained in:
commit
299b72c587
@ -62,26 +62,25 @@ func TestContainerMap(t *testing.T) {
|
|||||||
|
|
||||||
// Remove all entries from the containerMap, checking proper removal of
|
// Remove all entries from the containerMap, checking proper removal of
|
||||||
// each along the way.
|
// each along the way.
|
||||||
for i := range tc.containerNames {
|
cm.Visit(func(podUID string, containerName string, containerID string) {
|
||||||
cm.RemoveByContainerID(tc.containerIDs[i])
|
cm.RemoveByContainerID(containerID)
|
||||||
containerID, err := cm.GetContainerID(tc.podUID, tc.containerNames[i])
|
containerID, err := cm.GetContainerID(podUID, containerName)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("unexpected retrieval of containerID after removal: %v", containerID)
|
t.Errorf("unexpected retrieval of containerID after removal: %v", containerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
cm.Add(tc.podUID, tc.containerNames[i], tc.containerIDs[i])
|
cm.Add(podUID, containerName, containerID)
|
||||||
|
|
||||||
cm.RemoveByContainerRef(tc.podUID, tc.containerNames[i])
|
cm.RemoveByContainerRef(podUID, containerName)
|
||||||
podUID, containerName, err := cm.GetContainerRef(tc.containerIDs[i])
|
id, cn, err := cm.GetContainerRef(containerID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("unexpected retrieval of container reference after removal: (%v, %v)", podUID, containerName)
|
t.Errorf("unexpected retrieval of container reference after removal: (%v, %v)", id, cn)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
// Verify containerMap now empty.
|
// Verify containerMap now empty.
|
||||||
if len(cm) != 0 {
|
if len(cm) != 0 {
|
||||||
t.Errorf("unexpected entries still in containerMap: %v", cm)
|
t.Errorf("unexpected entries still in containerMap: %v", cm)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user