@@ -20,19 +20,21 @@ var (
2020 dataConfigJSON , _ = os .ReadFile ("testdata/config.json" )
2121 dataConfigYAML , _ = os .ReadFile ("testdata/config.yaml" )
2222
23- dataBBUInfoOld , _ = os .ReadFile ("testdata/mega-bbu-info-old.txt" )
24- dataBBUInfoRecent , _ = os .ReadFile ("testdata/mega-bbu-info-recent.txt" )
25- dataPhysDrivesInfo , _ = os .ReadFile ("testdata/mega-phys-drives-info.txt" )
23+ dataBBUInfoOld , _ = os .ReadFile ("testdata/mega-bbu-info-old.txt" )
24+ dataBBUInfoRecent , _ = os .ReadFile ("testdata/mega-bbu-info-recent.txt" )
25+ dataPhysDrivesInfo , _ = os .ReadFile ("testdata/mega-phys-drives-info.txt" )
26+ dataPhysDrivesInfoNoDrives , _ = os .ReadFile ("testdata/mega-phys-drives-info-no-drives.txt" )
2627)
2728
2829func Test_testDataIsValid (t * testing.T ) {
2930 for name , data := range map [string ][]byte {
3031 "dataConfigJSON" : dataConfigJSON ,
3132 "dataConfigYAML" : dataConfigYAML ,
3233
33- "dataBBUInfoOld" : dataBBUInfoOld ,
34- "dataBBUInfoRecent" : dataBBUInfoRecent ,
35- "dataPhysDrivesInfo" : dataPhysDrivesInfo ,
34+ "dataBBUInfoOld" : dataBBUInfoOld ,
35+ "dataBBUInfoRecent" : dataBBUInfoRecent ,
36+ "dataPhysDrivesInfo" : dataPhysDrivesInfo ,
37+ "dataPhysDrivesInfoNoDrives" : dataPhysDrivesInfoNoDrives ,
3638 } {
3739 require .NotNil (t , data , name )
3840 }
@@ -216,6 +218,17 @@ func TestCollector_Collect(t *testing.T) {
216218 "phys_drive_5002538c4002e713_predictive_failure_count" : 0 ,
217219 },
218220 },
221+ "adapter with disconnected drives" : {
222+ prepareMock : prepareMockNoDrives ,
223+ wantCharts : len (bbuChartsTmpl ) * 1 ,
224+ wantMetrics : map [string ]int64 {
225+ "bbu_adapter_0_absolute_state_of_charge" : 63 ,
226+ "bbu_adapter_0_capacity_degradation_perc" : 10 ,
227+ "bbu_adapter_0_cycle_count" : 4 ,
228+ "bbu_adapter_0_relative_state_of_charge" : 71 ,
229+ "bbu_adapter_0_temperature" : 33 ,
230+ },
231+ },
219232 "err on exec" : {
220233 prepareMock : prepareMockErr ,
221234 wantMetrics : nil ,
@@ -254,6 +267,13 @@ func prepareMockOK() *mockMegaCliExec {
254267 }
255268}
256269
270+ func prepareMockNoDrives () * mockMegaCliExec {
271+ return & mockMegaCliExec {
272+ physDrivesInfoData : dataPhysDrivesInfoNoDrives ,
273+ bbuInfoData : dataBBUInfoRecent ,
274+ }
275+ }
276+
257277func prepareMockOldBbuOK () * mockMegaCliExec {
258278 return & mockMegaCliExec {
259279 physDrivesInfoData : dataPhysDrivesInfo ,
0 commit comments