mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
fix unit tests using Patch in fake client
This commit is contained in:
parent
8b3b4e4dea
commit
cb9ac04777
@ -496,7 +496,6 @@ func TestStatefulSetControllerGetStatefulSetsForPod(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetPodsForStatefulSetAdopt(t *testing.T) {
|
func TestGetPodsForStatefulSetAdopt(t *testing.T) {
|
||||||
set := newStatefulSet(5)
|
set := newStatefulSet(5)
|
||||||
ssc, spc := newFakeStatefulSetController(set)
|
|
||||||
pod1 := newStatefulSetPod(set, 1)
|
pod1 := newStatefulSetPod(set, 1)
|
||||||
// pod2 is an orphan with matching labels and name.
|
// pod2 is an orphan with matching labels and name.
|
||||||
pod2 := newStatefulSetPod(set, 2)
|
pod2 := newStatefulSetPod(set, 2)
|
||||||
@ -510,6 +509,8 @@ func TestGetPodsForStatefulSetAdopt(t *testing.T) {
|
|||||||
pod4.OwnerReferences = nil
|
pod4.OwnerReferences = nil
|
||||||
pod4.Name = "x" + pod4.Name
|
pod4.Name = "x" + pod4.Name
|
||||||
|
|
||||||
|
ssc, spc := newFakeStatefulSetController(set, pod1, pod2, pod3, pod4)
|
||||||
|
|
||||||
spc.podsIndexer.Add(pod1)
|
spc.podsIndexer.Add(pod1)
|
||||||
spc.podsIndexer.Add(pod2)
|
spc.podsIndexer.Add(pod2)
|
||||||
spc.podsIndexer.Add(pod3)
|
spc.podsIndexer.Add(pod3)
|
||||||
|
@ -879,7 +879,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
|
|||||||
require.True(t, actions[1].Matches("patch", "nodes"))
|
require.True(t, actions[1].Matches("patch", "nodes"))
|
||||||
require.Equal(t, actions[1].GetSubresource(), "status")
|
require.Equal(t, actions[1].GetSubresource(), "status")
|
||||||
|
|
||||||
updatedNode, err := applyNodeStatusPatch(&existingNode, actions[1].(core.PatchActionImpl).GetPatch())
|
updatedNode, err := kubeClient.CoreV1().Nodes().Get(testKubeletHostname, metav1.GetOptions{})
|
||||||
require.NoError(t, err, "can't apply node status patch")
|
require.NoError(t, err, "can't apply node status patch")
|
||||||
|
|
||||||
for i, cond := range updatedNode.Status.Conditions {
|
for i, cond := range updatedNode.Status.Conditions {
|
||||||
@ -891,7 +891,6 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
|
|||||||
|
|
||||||
// Version skew workaround. See: https://github.com/kubernetes/kubernetes/issues/16961
|
// Version skew workaround. See: https://github.com/kubernetes/kubernetes/issues/16961
|
||||||
lastIndex := len(updatedNode.Status.Conditions) - 1
|
lastIndex := len(updatedNode.Status.Conditions) - 1
|
||||||
|
|
||||||
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[lastIndex].Type, "NodeReady should be the last condition")
|
assert.Equal(t, v1.NodeReady, updatedNode.Status.Conditions[lastIndex].Type, "NodeReady should be the last condition")
|
||||||
assert.NotEmpty(t, updatedNode.Status.Conditions[lastIndex].Message)
|
assert.NotEmpty(t, updatedNode.Status.Conditions[lastIndex].Message)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user