From c3ac2ef5b602f9284be821f17e796087eb4f0085 Mon Sep 17 00:00:00 2001 From: Rafael Acevedo Date: Tue, 8 Oct 2019 20:50:56 -0300 Subject: [PATCH] test sset list with pods not in sset --- pkg/controller/elasticsearch/sset/list_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/controller/elasticsearch/sset/list_test.go b/pkg/controller/elasticsearch/sset/list_test.go index 5e5c4880a9..cfe657a711 100644 --- a/pkg/controller/elasticsearch/sset/list_test.go +++ b/pkg/controller/elasticsearch/sset/list_test.go @@ -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) {