@@ -59,7 +59,7 @@ var _ = deploy.Describe("direct-testing", "direct-testing-metrics", "", func(d *
59
59
pods , err := f .ClientSet .CoreV1 ().Pods (d .Namespace ).List (context .Background (), metav1.ListOptions {})
60
60
framework .ExpectNoError (err , "list pods" )
61
61
62
- test := func () {
62
+ test := func (g Gomega ) {
63
63
numPods := 0
64
64
for _ , pod := range pods .Items {
65
65
if pod .Annotations ["pmem-csi.intel.com/scrape" ] != "containers" {
@@ -75,47 +75,38 @@ var _ = deploy.Describe("direct-testing", "direct-testing-metrics", "", func(d *
75
75
76
76
ip := pod .Status .PodIP
77
77
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" )
80
80
81
81
url := fmt .Sprintf ("http://%s.%s:%d/metrics" ,
82
82
pod .Namespace , pod .Name , port .ContainerPort )
83
83
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" )
92
85
data , err := ioutil .ReadAll (resp .Body )
93
- framework . ExpectNoError (err , "read GET response" )
86
+ g . Expect (err ). NotTo ( HaveOccurred () , "read GET response" )
94
87
name := pod .Name + "/" + container .Name
95
88
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 )
98
91
if ! strings .Contains (pod .Name , "controller" ) {
99
92
// 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 )
105
98
}
106
99
} else {
107
- Expect (data ).To (ContainSubstring ("csi_sidecar_operations_seconds " ), name )
100
+ g . Expect (data ).To (ContainSubstring ("csi_sidecar_operations_seconds " ), name )
108
101
}
109
102
}
110
103
}
111
104
}
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" )
113
106
}
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" )
115
108
}
116
- Eventually (func () string {
117
- return strings .Join (InterceptGomegaFailures (test ), "\n " )
118
- }, "10s" , "1s" ).Should (BeEmpty ())
109
+ Eventually (test , "10s" , "1s" ).Should (Succeed ())
119
110
})
120
111
121
112
It ("rejects large headers" , func () {
0 commit comments