Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test sset list with pods not in sset #1936

Merged
merged 1 commit into from
Oct 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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