Skip to content

Commit

Permalink
Adding e2e test support for monitoring deployments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Q-Lee committed Mar 22, 2016
1 parent 0c22277 commit 81ba98a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/e2e/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
}
Expand Down

0 comments on commit 81ba98a

Please sign in to comment.