From 048ea57f1ae98a586d3642ef85dd2644d46ed2f8 Mon Sep 17 00:00:00 2001 From: Ayoub Mrini Date: Mon, 12 Jun 2023 16:01:56 +0200 Subject: [PATCH] OCPBUGS-13153: Merge TestNodeExporterGenericOptions and TestNodeExporterGoMaxProcs tests Do it in a seperate PR to ease backporitng https://github.com/openshift/cluster-monitoring-operator/pull/1996 as the maxprocs config wasn't present in < 4.14 Signed-off-by: Ayoub Mrini --- test/e2e/node_exporter_test.go | 38 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/test/e2e/node_exporter_test.go b/test/e2e/node_exporter_test.go index e26befec5c..2cda5a3d09 100644 --- a/test/e2e/node_exporter_test.go +++ b/test/e2e/node_exporter_test.go @@ -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 + }, }, } @@ -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 - }, - ) - }) -}