Skip to content

Commit

Permalink
Fix MetricsGrabber test: only check for the master pods if the master…
Browse files Browse the repository at this point in the history
… node is registered
  • Loading branch information
dashpole committed Feb 10, 2021
1 parent dcec526 commit 0272980
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions test/e2e/instrumentation/monitoring/metrics_grabber.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,25 @@ var _ = instrumentation.SIGDescribe("MetricsGrabber", func() {
f := framework.NewDefaultFramework("metrics-grabber")
var c, ec clientset.Interface
var grabber *e2emetrics.Grabber
var masterRegistered bool
ginkgo.BeforeEach(func() {
var err error
c = f.ClientSet
ec = f.KubemarkExternalClusterClientSet
// Check if master Node is registered
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
framework.ExpectNoError(err)
for _, node := range nodes.Items {
if strings.HasSuffix(node.Name, "master") {
masterRegistered = true
}
}
gomega.Eventually(func() error {
grabber, err = e2emetrics.NewMetricsGrabber(c, ec, true, true, true, true, true)
if err != nil {
return fmt.Errorf("failed to create metrics grabber: %v", err)
}
if !grabber.HasControlPlanePods() {
if masterRegistered && !grabber.HasControlPlanePods() {
return fmt.Errorf("unable to get find control plane pods")
}
return nil
Expand All @@ -72,16 +80,6 @@ var _ = instrumentation.SIGDescribe("MetricsGrabber", func() {

ginkgo.It("should grab all metrics from a Scheduler.", func() {
ginkgo.By("Proxying to Pod through the API server")
// Check if master Node is registered
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
framework.ExpectNoError(err)

var masterRegistered = false
for _, node := range nodes.Items {
if strings.HasSuffix(node.Name, "master") {
masterRegistered = true
}
}
if !masterRegistered {
framework.Logf("Master is node api.Registry. Skipping testing Scheduler metrics.")
return
Expand All @@ -93,16 +91,6 @@ var _ = instrumentation.SIGDescribe("MetricsGrabber", func() {

ginkgo.It("should grab all metrics from a ControllerManager.", func() {
ginkgo.By("Proxying to Pod through the API server")
// Check if master Node is registered
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
framework.ExpectNoError(err)

var masterRegistered = false
for _, node := range nodes.Items {
if strings.HasSuffix(node.Name, "master") {
masterRegistered = true
}
}
if !masterRegistered {
framework.Logf("Master is node api.Registry. Skipping testing ControllerManager metrics.")
return
Expand Down

0 comments on commit 0272980

Please sign in to comment.