mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Adding e2e test support for monitoring deployments.
This commit is contained in:
parent
0c22277020
commit
81ba98ae5d
@ -102,14 +102,19 @@ func verifyExpectedRcsExistAndGetExpectedPods(c *client.Client) ([]string, error
|
|||||||
for _, rcLabel := range rcLabels {
|
for _, rcLabel := range rcLabels {
|
||||||
selector := labels.Set{"k8s-app": rcLabel}.AsSelector()
|
selector := labels.Set{"k8s-app": rcLabel}.AsSelector()
|
||||||
options := api.ListOptions{LabelSelector: selector}
|
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)
|
rcList, err := c.ReplicationControllers(api.NamespaceSystem).List(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(rcList.Items) != 1 {
|
if (len(rcList.Items) + len(deploymentList.Items)) != 1 {
|
||||||
return nil, fmt.Errorf("expected to find one replica for RC with label %s but got %d",
|
return nil, fmt.Errorf("expected to find one replica for RC or deployment with label %s but got %d",
|
||||||
rcLabel, len(rcList.Items))
|
rcLabel, len(rcList.Items))
|
||||||
}
|
}
|
||||||
|
// Check all the replication controllers.
|
||||||
for _, rc := range rcList.Items {
|
for _, rc := range rcList.Items {
|
||||||
selector := labels.Set(rc.Spec.Selector).AsSelector()
|
selector := labels.Set(rc.Spec.Selector).AsSelector()
|
||||||
options := api.ListOptions{LabelSelector: selector}
|
options := api.ListOptions{LabelSelector: selector}
|
||||||
@ -124,6 +129,21 @@ func verifyExpectedRcsExistAndGetExpectedPods(c *client.Client) ([]string, error
|
|||||||
expectedPods = append(expectedPods, string(pod.UID))
|
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
|
return expectedPods, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user