Skip to content

Commit b5f5dd6

Browse files
Merge pull request #1515 from awgreene/robust-webhook-selector-test
Bug 1833426: Update Webhook E2E Namespace Labels
2 parents d23b7ab + 61d94e2 commit b5f5dd6

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

test/e2e/webhook_e2e_test.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,42 @@ var _ = Describe("CSVs with a Webhook", func() {
3131
var crc versioned.Interface
3232
var namespace *corev1.Namespace
3333
var nsCleanupFunc cleanupFunc
34+
var nsLabels map[string]string
3435
BeforeEach(func() {
3536
c = newKubeClient(GinkgoT())
3637
crc = newCRClient(GinkgoT())
37-
namespace, nsCleanupFunc = newNamespace(GinkgoT(), c, genName("webhook-test-"))
38+
nsLabels = map[string]string{
39+
"foo": "bar",
40+
}
41+
namespace = &corev1.Namespace{
42+
ObjectMeta: metav1.ObjectMeta{
43+
Name: genName("webhook-test-"),
44+
Labels: nsLabels,
45+
},
46+
}
47+
48+
var err error
49+
namespace, err = c.KubernetesInterface().CoreV1().Namespaces().Create(context.TODO(), namespace, metav1.CreateOptions{})
50+
Expect(err).Should(BeNil())
51+
Expect(namespace).ShouldNot(BeNil())
52+
53+
nsCleanupFunc = func() {
54+
err := c.KubernetesInterface().CoreV1().Namespaces().Delete(context.TODO(), namespace.GetName(), metav1.DeleteOptions{})
55+
Expect(err).Should(BeNil())
56+
}
3857
})
3958
AfterEach(func() {
4059
if nsCleanupFunc != nil {
4160
nsCleanupFunc()
4261
}
4362
})
4463
When("Installed in an OperatorGroup that defines a selector", func() {
45-
var nsLabels map[string]string
4664
var cleanupCSV cleanupFunc
4765
var ogSelector *metav1.LabelSelector
4866
BeforeEach(func() {
49-
nsLabels = map[string]string{
50-
"foo": "bar",
51-
}
5267
ogSelector = &metav1.LabelSelector{
5368
MatchLabels: nsLabels,
5469
}
55-
// Add a label to the namespace
56-
Eventually(func() error {
57-
var err error
58-
namespace, err = c.KubernetesInterface().CoreV1().Namespaces().Get(context.TODO(), namespace.Name, metav1.GetOptions{})
59-
if err != nil {
60-
return err
61-
}
62-
63-
if namespace.GetLabels() == nil {
64-
namespace.SetLabels(map[string]string{})
65-
}
66-
namespace.Labels["foo"] = "bar"
67-
68-
c.KubernetesInterface().CoreV1().Namespaces().Update(context.TODO(), namespace, metav1.UpdateOptions{})
69-
return err
70-
}, time.Minute, 5*time.Second).Should(Succeed())
7170

7271
og := newOperatorGroup(namespace.Name, genName("selector-og-"), nil, ogSelector, nil, false)
7372
_, err := crc.OperatorsV1().OperatorGroups(namespace.Name).Create(context.TODO(), og, metav1.CreateOptions{})

0 commit comments

Comments
 (0)