Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
calico-host-endpoint-controller: Add test
Browse files Browse the repository at this point in the history
This adds test to check annotation for respective pod that correct
annotation value is applied for "kubernetes.io/psp".

Signed-off-by: knrt10 <kautilya@kinvolk.io>
  • Loading branch information
knrt10 committed Dec 23, 2020
1 parent 86681ae commit ec26c47
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/platform/packet/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,22 @@ func TestWhenBGPIsNotDisabledInConfigurationServersHasBGPSessionCreated(t *testi
t.Fatalf("Worker pool with BGP not disabled should have at least one BGP session")
}
}

func TestAnnotationForCalicoHostEndpointController(t *testing.T) {
client := testutil.CreateKubeClient(t)
labelSelector := "app=calico-hostendpoint-controller"
expectedAnnotation := "calico-hostendpoint-controller-psp"

pods, err := client.CoreV1().Pods("kube-system").List(context.Background(), metav1.ListOptions{
LabelSelector: labelSelector,
})
if err != nil {
t.Fatalf("Listing pods with label %q: %v", labelSelector, err)
}

for _, v := range pods.Items {
if v.Annotations["kubernetes.io/psp"] != expectedAnnotation {
t.Fatalf("Pod: %s annotation expected: %s got: %s", v.Name, expectedAnnotation, v.Annotations["kubernetes.io/psp"])
}
}
}

0 comments on commit ec26c47

Please sign in to comment.