@@ -131,6 +131,10 @@ func testCollect(t *testing.T) {
131131			urlPath :  "/redfish/v1/Chassis/System.Embedded.1/Blocks/0" ,
132132			filePath : "../testdata/redfish_block.json" ,
133133		},
134+ 		{
135+ 			urlPath :  "/redfish/v1/Chassis/System.Embedded.1/Sensors/Device1" ,
136+ 			filePath : "../testdata/redfish_sensors.json" ,
137+ 		},
134138	}
135139
136140	expectedSet  :=  []* struct  {
@@ -176,17 +180,35 @@ func testCollect(t *testing.T) {
176180			},
177181		},
178182		{
179- 			name :    "hw_last_update" ,
180- 			typ :     prommodel .MetricType_COUNTER ,
181- 			value :  math .NaN (), // don't care 
183+ 			name : "hw_last_update" ,
184+ 			typ :  prommodel .MetricType_COUNTER ,
185+ 			// value:  math.NaN(), // don't care
182186			labels : map [string ]string {},
183187		},
184188		{
185- 			name :    "hw_last_update_duration_minutes" ,
186- 			typ :     prommodel .MetricType_GAUGE ,
187- 			value :  math .NaN (), // don't care 
189+ 			name : "hw_last_update_duration_minutes" ,
190+ 			typ :  prommodel .MetricType_GAUGE ,
191+ 			// value:  math.NaN(), // don't care
188192			labels : map [string ]string {},
189193		},
194+ 		{
195+ 			name :  "hw_chassis_sensors_thresholds_uppercritical_reading" ,
196+ 			typ :   prommodel .MetricType_GAUGE ,
197+ 			value : math .NaN (), // null 
198+ 			labels : map [string ]string {
199+ 				"chassis" : "System.Embedded.1" ,
200+ 				"sensor" :  "Device1" ,
201+ 			},
202+ 		},
203+ 		{
204+ 			name :  "hw_chassis_sensors_thresholds_upperfatal_reading" ,
205+ 			typ :   prommodel .MetricType_GAUGE ,
206+ 			value : 150 ,
207+ 			labels : map [string ]string {
208+ 				"chassis" : "System.Embedded.1" ,
209+ 				"sensor" :  "Device1" ,
210+ 			},
211+ 		},
190212	}
191213
192214	cc , err  :=  clientConfig ()
@@ -254,11 +276,18 @@ func testCollect(t *testing.T) {
254276				default :
255277					t .Fatalf ("unknown type: " )
256278				}
257- 				if  actualMetricName  ==  expected .name  && 
258- 					(math .IsNaN (expected .value ) ||  val  ==  expected .value ) && 
259- 					matchLabels (actualLabels , expected .labels ) {
260- 					expected .matched  =  true 
261- 					continue  ActualLoop
279+ 				if  actualMetricName  ==  expected .name  &&  matchLabels (actualLabels , expected .labels ) {
280+ 					if  actualMetricName  ==  "hw_last_update"  ||  actualMetricName  ==  "hw_last_update_duration_minutes"  {
281+ 						expected .matched  =  true 
282+ 						continue  ActualLoop
283+ 					}
284+ 					if  math .IsNaN (expected .value ) &&  math .IsNaN (val ) {
285+ 						expected .matched  =  true 
286+ 						continue  ActualLoop
287+ 					} else  if  expected .value  ==  val  {
288+ 						expected .matched  =  true 
289+ 						continue  ActualLoop
290+ 					}
262291				}
263292			}
264293			t .Error ("unexpected metric; name:" , actualMetricName , "value:" , actual .GetGauge ().GetValue (), "labels:" , actualLabels )
0 commit comments