Skip to content

Commit

Permalink
OCPBUGS-13153: Merge TestNodeExporterGenericOptions and TestNodeExpor…
Browse files Browse the repository at this point in the history
…terGoMaxProcs tests

Do it in a seperate PR to ease backporitng
openshift#1996
as the maxprocs config wasn't present in < 4.14

Signed-off-by: Ayoub Mrini <amrini@redhat.com>
  • Loading branch information
machine424 committed Jun 12, 2023
1 parent d4f5ba5 commit 048ea57
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions test/e2e/node_exporter_test.go
Expand Up @@ -221,19 +221,31 @@ func TestNodeExporterGenericOptions(t *testing.T) {
}

tests := []struct {
name string
config string
argsPresent []string
name string
config string
verifyGoMaxProcs func(float64) error
}{
{
name: "default config",
config: "",
verifyGoMaxProcs: func(maxProcs float64) error {
if maxProcs > 4 {
return fmt.Errorf("GOMAXPROCS should be limited to 4")
}
return nil
},
},
{
name: "maxprocs = 1",
config: `
nodeExporter:
maxProcs: 1`,
verifyGoMaxProcs: func(maxProcs float64) error {
if maxProcs != 1 {
return fmt.Errorf("GOMAXPROCS should be set to 1 as in the configuration")
}
return nil
},
},
}

Expand All @@ -253,21 +265,13 @@ nodeExporter:
},
)
}

f.PrometheusK8sClient.WaitForQueryReturn(
t, 5*time.Minute, `max(go_sched_gomaxprocs_threads{job="node-exporter"})`,
test.verifyGoMaxProcs,
)

})
}

}

func TestNodeExporterGoMaxProcs(t *testing.T) {
t.Run("limited GOMAXPROCS", func(st *testing.T) {
f.PrometheusK8sClient.WaitForQueryReturn(
t, 5*time.Minute, `max(go_sched_gomaxprocs_threads{job="node-exporter"})`,
func(v float64) error {
if v > 4 {
return fmt.Errorf(`expecting max(go_sched_gomaxprocs_threads{job="node-exporter"}) <= 4 but got %v.`, v)
}
return nil
},
)
})
}

0 comments on commit 048ea57

Please sign in to comment.