7373 ["datastore.write" , "fce701f6-867094ae" , "0#0" , "kiloBytesPerSecond" ],
7474]
7575
76+ STRING_TABLE_WITH_NEGATIVE_VALUES = [ # only a snippet!
77+ ["datastore.name" , "192.168.99.100:/vmtestnfs1" , "NFS_sgrznac1_Test" , "string" ],
78+ ["datastore.name" , "192.168.99.101:/vmprodnfs1" , "NFS_sgrznac1_Prod" , "string" ],
79+ [
80+ "datastore.name" ,
81+ "192.168.99.99:/VeeamBackup_SGRZVeeam.acp.local" ,
82+ "VeeamBackup_SGRZVeeam.acp.local" ,
83+ "string" ,
84+ ],
85+ ["datastore.name" , "576b8c5e-3d1e6844-ed6c-645106f0c5d0" , "SSD_sgrz3par_vmstore1" , "string" ],
86+ ["datastore.name" , "57e121ef-2bb2dbaa-ad99-645106f0c5d0" , "vsa_vol1" , "string" ],
87+ ["datastore.name" , "5847d774-2bdca236-23df-645106f0c5d0" , "SSD_sgrz3par_vmstore2" , "string" ],
88+ ["datastore.name" , "vvol:bf19e892e24d4f74-9246b507ebac9dec" , "3par VVOL" , "string" ],
89+ ["datastore.read" , "56490e2e-692ac36c" , "0#0" , "kiloBytesPerSecond" ],
90+ ["datastore.read" , "576b8c5e-3d1e6844-ed6c-645106f0c5d0" , "0#0" , "kiloBytesPerSecond" ],
91+ ["datastore.read" , "57e121ef-2bb2dbaa-ad99-645106f0c5d0" , "0#0" , "kiloBytesPerSecond" ],
92+ ["datastore.read" , "5847d774-2bdca236-23df-645106f0c5d0" , "0#0" , "kiloBytesPerSecond" ],
93+ ["datastore.read" , "79d8b527-45291f84" , "13#26" , "kiloBytesPerSecond" ],
94+ ["datastore.read" , "fce701f6-867094ae" , "0#0" , "kiloBytesPerSecond" ],
95+ ["datastore.sizeNormalizedDatastoreLatency" , "56490e2e-692ac36c" , "0#0" , "microsecond" ],
96+ [
97+ "datastore.sizeNormalizedDatastoreLatency" ,
98+ "576b8c5e-3d1e6844-ed6c-645106f0c5d0" ,
99+ "-1#-1" ,
100+ "microsecond" ,
101+ ],
102+ [
103+ "datastore.sizeNormalizedDatastoreLatency" ,
104+ "57e121ef-2bb2dbaa-ad99-645106f0c5d0" ,
105+ "0#0" ,
106+ "microsecond" ,
107+ ],
108+ [
109+ "datastore.sizeNormalizedDatastoreLatency" ,
110+ "5847d774-2bdca236-23df-645106f0c5d0" ,
111+ "0#0" ,
112+ "microsecond" ,
113+ ],
114+ ["datastore.sizeNormalizedDatastoreLatency" , "79d8b527-45291f84" , "0#0" , "microsecond" ],
115+ ["datastore.sizeNormalizedDatastoreLatency" , "fce701f6-867094ae" , "0#0" , "microsecond" ],
116+ ]
117+
76118
77119@pytest .fixture (name = "section" , scope = "module" )
78120def _get_section () -> SectionCounter :
79121 return parse_esx_vsphere_counters (STRING_TABLE )
80122
81123
124+ @pytest .fixture (name = "section_with_negative_values" , scope = "module" )
125+ def _get_section_negative_values () -> SectionCounter :
126+ return parse_esx_vsphere_counters (STRING_TABLE_WITH_NEGATIVE_VALUES )
127+
128+
82129def test_discovery_summary (section : SectionCounter ) -> None :
83130 assert sorted (
84131 discover_esx_vsphere_datastore_io (
@@ -141,6 +188,20 @@ def test_check_summary(section: SectionCounter) -> None:
141188 ]
142189
143190
191+ def test_check_summary_negative_values (section_with_negative_values : SectionCounter ) -> None :
192+ with pytest .raises (ValueError ):
193+ # Because of the negative value in the latency, we expect a ValueError
194+ # from the render.timespan() function
195+ assert (
196+ list (
197+ _check_esx_vsphere_datastore_io (
198+ "SUMMARY" , {}, section_with_negative_values , 1659382581 , {}
199+ )
200+ )
201+ == []
202+ )
203+
204+
144205def test_check_item (section : SectionCounter ) -> None :
145206 assert list (
146207 _check_esx_vsphere_datastore_io (
@@ -162,3 +223,17 @@ def test_check_item(section: SectionCounter) -> None:
162223 Result (state = State .OK , summary = "Latency: 0 seconds" ),
163224 Metric ("disk_latency" , 0.0 ),
164225 ]
226+
227+
228+ def test_check_item_negative_values (section_with_negative_values : SectionCounter ) -> None :
229+ with pytest .raises (ValueError ):
230+ # Because of the negative value in the latency, we expect a ValueError
231+ # from the render.timespan() function
232+ assert (
233+ list (
234+ _check_esx_vsphere_datastore_io (
235+ "SSD_sgrz3par_vmstore1" , {}, section_with_negative_values , 1659382581 , {}
236+ )
237+ )
238+ == []
239+ )
0 commit comments