Skip to content

Commit

Permalink
test sset list with pods not in sset
Browse files Browse the repository at this point in the history
  • Loading branch information
racevedoo committed Oct 9, 2019
1 parent e184b62 commit c3ac2ef
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pkg/controller/elasticsearch/sset/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,20 @@ func TestStatefulSetList_GetExistingPods(t *testing.T) {
},
},
}
client := k8s.WrapClient(fake.NewFakeClient(&pod1, &pod2))
// pod not belonging to the sset
podNotInSset := corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-not-in-sset",
Labels: map[string]string{
label.StatefulSetNameLabelName: "different-sset",
},
},
}
client := k8s.WrapClient(fake.NewFakeClient(&pod1, &pod2, &podNotInSset))
pods, err := StatefulSetList{ssetv7}.GetActualPods(client)
require.NoError(t, err)
require.Equal(t, []corev1.Pod{pod1, pod2}, pods)
// TODO: test with an additional pod that does not belong to the sset and
// check it is not returned.
// This cannot be done currently since the fake client does not support label list options.
// See https://github.com/kubernetes-sigs/controller-runtime/pull/311
require.NotContains(t, pods, podNotInSset)
}

func TestStatefulSetList_PodReconciliationDone(t *testing.T) {
Expand Down

0 comments on commit c3ac2ef

Please sign in to comment.