From bfc9d9642b27e9d32c008137d2cf89e7109a8322 Mon Sep 17 00:00:00 2001 From: Kyle Robbertze Date: Mon, 4 Apr 2022 14:14:03 +0200 Subject: [PATCH] feat: support testing statefulset --- tests.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests.go b/tests.go index e3eda8a..3252da8 100644 --- a/tests.go +++ b/tests.go @@ -30,6 +30,21 @@ func TestDeploy(client kubernetes.Interface, ns string, deploymentName string, t TestPodsByLabels(client, deploymentName, ns, labelMap, t) } +func TestStatefulSet(client kubernetes.Interface, ns string, name string, t *console.TestResults) { + if client == nil { + t.Failf(name, "failed to get kubernetes client") + return + } + + statefulset, err := client.AppsV1().StatefulSets(ns).Get(context.TODO(), name, metav1.GetOptions{}) + if errors.IsNotFound(err) { + t.Failf(name, "statefulset not found") + return + } + labelMap, _ := metav1.LabelSelectorAsMap(statefulset.Spec.Selector) + TestPodsByLabels(client, name, ns, labelMap, t) +} + func TestDaemonSet(client kubernetes.Interface, ns string, name string, t *console.TestResults) { testName := name if client == nil {