From 81ba98ae5d7fe46fa5c0fd01066efa01f604e4e9 Mon Sep 17 00:00:00 2001 From: Quintin Lee Date: Thu, 17 Mar 2016 17:10:46 -0700 Subject: [PATCH] Adding e2e test support for monitoring deployments. --- test/e2e/monitoring.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/e2e/monitoring.go b/test/e2e/monitoring.go index f206d7b7f2a34..6d119547f81e8 100644 --- a/test/e2e/monitoring.go +++ b/test/e2e/monitoring.go @@ -102,14 +102,19 @@ func verifyExpectedRcsExistAndGetExpectedPods(c *client.Client) ([]string, error for _, rcLabel := range rcLabels { selector := labels.Set{"k8s-app": rcLabel}.AsSelector() options := api.ListOptions{LabelSelector: selector} + deploymentList, err := c.Deployments(api.NamespaceSystem).List(options) + if err != nil { + return nil, err + } rcList, err := c.ReplicationControllers(api.NamespaceSystem).List(options) if err != nil { return nil, err } - if len(rcList.Items) != 1 { - return nil, fmt.Errorf("expected to find one replica for RC with label %s but got %d", + if (len(rcList.Items) + len(deploymentList.Items)) != 1 { + return nil, fmt.Errorf("expected to find one replica for RC or deployment with label %s but got %d", rcLabel, len(rcList.Items)) } + // Check all the replication controllers. for _, rc := range rcList.Items { selector := labels.Set(rc.Spec.Selector).AsSelector() options := api.ListOptions{LabelSelector: selector} @@ -124,6 +129,21 @@ func verifyExpectedRcsExistAndGetExpectedPods(c *client.Client) ([]string, error expectedPods = append(expectedPods, string(pod.UID)) } } + // Do the same for all deployments. + for _, rc := range deploymentList.Items { + selector := labels.Set(rc.Spec.Selector.MatchLabels).AsSelector() + options := api.ListOptions{LabelSelector: selector} + podList, err := c.Pods(api.NamespaceSystem).List(options) + if err != nil { + return nil, err + } + for _, pod := range podList.Items { + if pod.DeletionTimestamp != nil { + continue + } + expectedPods = append(expectedPods, string(pod.UID)) + } + } } return expectedPods, nil }