@@ -59,7 +59,7 @@ var _ = deploy.Describe("direct-testing", "direct-testing-metrics", "", func(d *
5959 pods , err := f .ClientSet .CoreV1 ().Pods (d .Namespace ).List (context .Background (), metav1.ListOptions {})
6060 framework .ExpectNoError (err , "list pods" )
6161
62- test := func () {
62+ test := func (g Gomega ) {
6363 numPods := 0
6464 for _ , pod := range pods .Items {
6565 if pod .Annotations ["pmem-csi.intel.com/scrape" ] != "containers" {
@@ -75,47 +75,38 @@ var _ = deploy.Describe("direct-testing", "direct-testing-metrics", "", func(d *
7575
7676 ip := pod .Status .PodIP
7777 portNum := port .ContainerPort
78- Expect (ip ).ToNot (BeEmpty (), "have pod IP" )
79- Expect (portNum ).ToNot (Equal (0 ), "have container port" )
78+ g . Expect (ip ).ToNot (BeEmpty (), "have pod IP" )
79+ g . Expect (portNum ).ToNot (Equal (0 ), "have container port" )
8080
8181 url := fmt .Sprintf ("http://%s.%s:%d/metrics" ,
8282 pod .Namespace , pod .Name , port .ContainerPort )
8383 resp , err := client .Get (url )
84- framework .ExpectNoError (err , "GET failed" )
85- // When wrapped with InterceptGomegaFailures, err == nil doesn't
86- // cause the function to abort. We have to do that ourselves before
87- // using resp to avoid a panic.
88- // https://github.com/onsi/gomega/issues/198#issuecomment-856630787
89- if err != nil {
90- return
91- }
84+ g .Expect (err ).NotTo (HaveOccurred (), "GET failed" )
9285 data , err := ioutil .ReadAll (resp .Body )
93- framework . ExpectNoError (err , "read GET response" )
86+ g . Expect (err ). NotTo ( HaveOccurred () , "read GET response" )
9487 name := pod .Name + "/" + container .Name
9588 if strings .HasPrefix (container .Name , "pmem" ) {
96- Expect (data ).To (ContainSubstring ("go_threads " ), name )
97- Expect (data ).To (ContainSubstring ("process_open_fds " ), name )
89+ g . Expect (data ).To (ContainSubstring ("go_threads " ), name )
90+ g . Expect (data ).To (ContainSubstring ("process_open_fds " ), name )
9891 if ! strings .Contains (pod .Name , "controller" ) {
9992 // Only the node driver implements CSI and manages volumes.
100- Expect (data ).To (ContainSubstring ("csi_plugin_operations_seconds " ), name )
101- Expect (data ).To (ContainSubstring ("pmem_amount_available " ), name )
102- Expect (data ).To (ContainSubstring ("pmem_amount_managed " ), name )
103- Expect (data ).To (ContainSubstring ("pmem_amount_max_volume_size " ), name )
104- Expect (data ).To (ContainSubstring ("pmem_amount_total " ), name )
93+ g . Expect (data ).To (ContainSubstring ("csi_plugin_operations_seconds " ), name )
94+ g . Expect (data ).To (ContainSubstring ("pmem_amount_available " ), name )
95+ g . Expect (data ).To (ContainSubstring ("pmem_amount_managed " ), name )
96+ g . Expect (data ).To (ContainSubstring ("pmem_amount_max_volume_size " ), name )
97+ g . Expect (data ).To (ContainSubstring ("pmem_amount_total " ), name )
10598 }
10699 } else {
107- Expect (data ).To (ContainSubstring ("csi_sidecar_operations_seconds " ), name )
100+ g . Expect (data ).To (ContainSubstring ("csi_sidecar_operations_seconds " ), name )
108101 }
109102 }
110103 }
111104 }
112- Expect (numPorts ).NotTo (Equal (0 ), "at least one container should have a 'metrics' port" )
105+ g . Expect (numPorts ).NotTo (Equal (0 ), "at least one container should have a 'metrics' port" )
113106 }
114- Expect (numPods ).NotTo (Equal (0 ), "at least one container should have a 'metrics' port" )
107+ g . Expect (numPods ).NotTo (Equal (0 ), "at least one container should have a 'metrics' port" )
115108 }
116- Eventually (func () string {
117- return strings .Join (InterceptGomegaFailures (test ), "\n " )
118- }, "10s" , "1s" ).Should (BeEmpty ())
109+ Eventually (test , "10s" , "1s" ).Should (Succeed ())
119110 })
120111
121112 It ("rejects large headers" , func () {
0 commit comments