Fix Table field comparison in SNMP collector table tests (#20871)
Co-authored-by: ilyam8 <22274335+ilyam8@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ilyam8 <ilya@netdata.cloud>
Copilot committed
Aug 22, 2025 at 11:25 UTC
d1fc90c103b820897cdca5a6dc6e79228a424b98
1 file changed
+196
-7
src/go/plugin/go.d/collector/snmp/ddsnmp/ddsnmpcollector/collector_table_test.go
+196
-7
@@ -72,6 +72,7 @@ func TestTableCollector_Collect(t *testing.T) {
72
Tags: map[string]string{"interface": "eth0"},
73
MetricType: "rate",
74
IsTable: true,
75
+ Table: "ifTable",
76
},
77
{
78
Name: "ifInOctets",
@@ -79,6 +80,7 @@ func TestTableCollector_Collect(t *testing.T) {
80
Tags: map[string]string{"interface": "eth1"},
81
MetricType: "rate",
82
IsTable: true,
83
+ Table: "ifTable",
84
},
85
},
86
expectedError: false,
@@ -142,6 +144,7 @@ func TestTableCollector_Collect(t *testing.T) {
144
Tags: map[string]string{"interface": "eth0"},
145
MetricType: "rate",
146
IsTable: true,
147
+ Table: "ifTable",
148
},
149
{
150
Name: "ifOutOctets",
@@ -149,6 +152,7 @@ func TestTableCollector_Collect(t *testing.T) {
152
Tags: map[string]string{"interface": "eth0"},
153
MetricType: "rate",
154
IsTable: true,
155
+ Table: "ifTable",
156
},
157
{
158
Name: "ifOperStatus",
@@ -156,6 +160,7 @@ func TestTableCollector_Collect(t *testing.T) {
160
Tags: map[string]string{"interface": "eth0"},
161
MetricType: "gauge",
162
IsTable: true,
163
+ Table: "ifTable",
164
},
165
// Row 2
166
{
@@ -164,6 +169,7 @@ func TestTableCollector_Collect(t *testing.T) {
169
Tags: map[string]string{"interface": "eth1"},
170
MetricType: "rate",
171
IsTable: true,
172
+ Table: "ifTable",
173
},
174
{
175
Name: "ifOutOctets",
@@ -171,6 +177,7 @@ func TestTableCollector_Collect(t *testing.T) {
177
Tags: map[string]string{"interface": "eth1"},
178
MetricType: "rate",
179
IsTable: true,
180
+ Table: "ifTable",
181
},
182
{
183
Name: "ifOperStatus",
@@ -178,6 +185,7 @@ func TestTableCollector_Collect(t *testing.T) {
185
Tags: map[string]string{"interface": "eth1"},
186
MetricType: "gauge",
187
IsTable: true,
188
+ Table: "ifTable",
189
},
190
},
191
expectedError: false,
@@ -287,6 +295,8 @@ func TestTableCollector_Collect(t *testing.T) {
295
Tags: map[string]string{"interface": "eth0"},
296
MetricType: "rate",
297
IsTable: true,
298
+
299
+ Table: "ifTable",
300
},
301
},
302
expectedError: false,
@@ -351,6 +361,7 @@ func TestTableCollector_Collect(t *testing.T) {
361
Tags: map[string]string{"interface": "eth0"},
362
MetricType: "rate",
363
IsTable: true,
364
+ Table: "ifTable",
365
},
366
{
367
Name: "ipSystemStatsHCInReceives",
@@ -358,6 +369,7 @@ func TestTableCollector_Collect(t *testing.T) {
369
Tags: nil,
370
MetricType: "rate",
371
IsTable: true,
372
+ Table: "ipSystemStatsTable",
373
},
374
{
375
Name: "ipSystemStatsHCInReceives",
@@ -365,6 +377,7 @@ func TestTableCollector_Collect(t *testing.T) {
377
Tags: nil,
378
MetricType: "rate",
379
IsTable: true,
380
+ Table: "ipSystemStatsTable",
381
},
382
},
383
expectedError: false,
@@ -425,6 +438,8 @@ func TestTableCollector_Collect(t *testing.T) {
438
Tags: map[string]string{"interface": "eth0"},
439
MetricType: "rate",
440
IsTable: true,
441
+
442
+ Table: "ifTable",
443
},
444
{
445
Name: "ifOutOctets",
@@ -432,6 +447,8 @@ func TestTableCollector_Collect(t *testing.T) {
447
Tags: map[string]string{"interface": "eth0"},
448
MetricType: "rate",
449
IsTable: true,
450
+
451
+ Table: "ifTable",
452
},
453
// Row 2 - only ifInOctets
454
{
@@ -440,6 +457,8 @@ func TestTableCollector_Collect(t *testing.T) {
457
Tags: map[string]string{"interface": "eth1"},
458
MetricType: "rate",
459
IsTable: true,
460
+
461
+ Table: "ifTable",
462
},
463
// Row 3 - both metrics but no tag
464
{
@@ -448,6 +467,8 @@ func TestTableCollector_Collect(t *testing.T) {
467
Tags: nil,
468
MetricType: "rate",
469
IsTable: true,
470
+
471
+ Table: "ifTable",
472
},
473
{
474
Name: "ifOutOctets",
@@ -455,6 +476,8 @@ func TestTableCollector_Collect(t *testing.T) {
476
Tags: nil,
477
MetricType: "rate",
478
IsTable: true,
479
+
480
+ Table: "ifTable",
481
},
482
},
483
expectedError: false,
@@ -530,6 +553,8 @@ func TestTableCollector_Collect(t *testing.T) {
553
Tags: nil,
554
MetricType: "rate",
555
IsTable: true,
556
+
557
+ Table: "ifTable",
558
},
559
},
560
expectedError: false,
@@ -593,6 +618,7 @@ func TestTableCollector_Collect(t *testing.T) {
618
Tags: map[string]string{"interface": "lo0", "if_type": "softwareLoopback"},
619
MetricType: "rate",
620
IsTable: true,
621
+ Table: "ifTable",
622
},
623
{
624
Name: "ifInErrors",
@@ -600,6 +626,7 @@ func TestTableCollector_Collect(t *testing.T) {
626
Tags: map[string]string{"interface": "eth0", "if_type": "ethernetCsmacd"},
627
MetricType: "rate",
628
IsTable: true,
629
+ Table: "ifTable",
630
},
631
},
632
expectedError: false,
@@ -649,6 +676,8 @@ func TestTableCollector_Collect(t *testing.T) {
676
Tags: map[string]string{"interface": "eth0"},
677
MetricType: "rate",
678
IsTable: true,
679
+
680
+ Table: "ifTable",
681
},
682
{
683
Name: "ifInErrors",
@@ -656,6 +685,8 @@ func TestTableCollector_Collect(t *testing.T) {
685
Tags: map[string]string{"interface": "lo0"},
686
MetricType: "rate",
687
IsTable: true,
688
+
689
+ Table: "ifTable",
690
},
691
},
692
expectedError: false,
@@ -727,6 +758,8 @@ func TestTableCollector_Collect(t *testing.T) {
758
},
759
MetricType: "rate",
760
IsTable: true,
761
+
762
+ Table: "ifTable",
763
},
764
},
765
expectedError: false,
@@ -781,6 +814,7 @@ func TestTableCollector_Collect(t *testing.T) {
814
Tags: map[string]string{"interface": "eth0"},
815
MetricType: "rate",
816
IsTable: true,
817
+ Table: "ifTable",
818
},
819
},
820
expectedError: false,
@@ -838,6 +872,8 @@ func TestTableCollector_Collect(t *testing.T) {
872
},
873
MetricType: "rate",
874
IsTable: true,
875
+
876
+ Table: "ifTable",
877
},
878
{
879
Name: "ifInOctets",
@@ -849,6 +885,8 @@ func TestTableCollector_Collect(t *testing.T) {
885
},
886
MetricType: "rate",
887
IsTable: true,
888
+
889
+ Table: "ifTable",
890
},
891
},
892
expectedError: false,
@@ -896,6 +934,7 @@ func TestTableCollector_Collect(t *testing.T) {
934
Tags: map[string]string{"mac_address": "00:50:56:AB:CD:EF"},
935
MetricType: "rate",
936
IsTable: true,
937
+ Table: "devTable",
938
},
939
},
940
expectedError: false,
@@ -943,6 +982,8 @@ func TestTableCollector_Collect(t *testing.T) {
982
Tags: map[string]string{"ip_address": "192.168.1.1"},
983
MetricType: "gauge",
984
IsTable: true,
985
+
986
+ Table: "ipAddrTable",
987
},
988
},
989
expectedError: false,
@@ -1005,6 +1046,8 @@ func TestTableCollector_Collect(t *testing.T) {
1046
Tags: map[string]string{"interface": "eth0", "if_type": "ethernet"},
1047
MetricType: "rate",
1048
IsTable: true,
1049
+
1050
+ Table: "ifTable",
1051
},
1052
},
1053
expectedError: false,
@@ -1063,6 +1106,8 @@ func TestTableCollector_Collect(t *testing.T) {
1106
Tags: map[string]string{"interface": "tunnel0", "if_type": "131"}, // Raw value when no mapping
1107
MetricType: "rate",
1108
IsTable: true,
1109
+
1110
+ Table: "ifTable",
1111
},
1112
},
1113
expectedError: false,
@@ -1109,6 +1154,8 @@ func TestTableCollector_Collect(t *testing.T) {
1154
Tags: map[string]string{"interface": ""}, // Empty tag value
1155
MetricType: "rate",
1156
IsTable: true,
1157
+
1158
+ Table: "ifTable",
1159
},
1160
},
1161
expectedError: false,
@@ -1169,6 +1216,8 @@ func TestTableCollector_Collect(t *testing.T) {
1216
Tags: map[string]string{"interface": "eth0"},
1217
MetricType: "rate",
1218
IsTable: true,
1219
+
1220
+ Table: "ifTable",
1221
},
1222
{
1223
Name: "ifOutOctets",
@@ -1176,6 +1225,8 @@ func TestTableCollector_Collect(t *testing.T) {
1225
Tags: map[string]string{"interface": "eth0"},
1226
MetricType: "rate",
1227
IsTable: true,
1228
+
1229
+ Table: "ifTable",
1230
},
1231
// Row 2 - only ifInOctets
1232
{
@@ -1184,6 +1235,8 @@ func TestTableCollector_Collect(t *testing.T) {
1235
Tags: map[string]string{"interface": "eth1"},
1236
MetricType: "rate",
1237
IsTable: true,
1238
+
1239
+ Table: "ifTable",
1240
},
1241
// Row 3 - both metrics but no tag
1242
{
@@ -1192,6 +1245,8 @@ func TestTableCollector_Collect(t *testing.T) {
1245
Tags: nil,
1246
MetricType: "rate",
1247
IsTable: true,
1248
+
1249
+ Table: "ifTable",
1250
},
1251
{
1252
Name: "ifOutOctets",
@@ -1199,6 +1254,8 @@ func TestTableCollector_Collect(t *testing.T) {
1254
Tags: nil,
1255
MetricType: "rate",
1256
IsTable: true,
1257
+
1258
+ Table: "ifTable",
1259
},
1260
},
1261
expectedError: false,
@@ -1246,6 +1303,7 @@ func TestTableCollector_Collect(t *testing.T) {
1303
Tags: map[string]string{"cpu_id": "1"},
1304
MetricType: "gauge",
1305
IsTable: true,
1306
+ Table: "cpmCPUTotalTable",
1307
},
1308
},
1309
expectedError: false,
@@ -1301,6 +1359,7 @@ func TestTableCollector_Collect(t *testing.T) {
1359
Tags: map[string]string{"interface": "eth0"},
1360
MetricType: "gauge",
1361
IsTable: true,
1362
+ Table: "ifTable",
1363
MultiValue: map[string]int64{
1364
"up": 1,
1365
"down": 0,
@@ -1315,6 +1374,7 @@ func TestTableCollector_Collect(t *testing.T) {
1374
Tags: map[string]string{"interface": "eth1"},
1375
MetricType: "gauge",
1376
IsTable: true,
1377
+ Table: "ifTable",
1378
MultiValue: map[string]int64{
1379
"up": 0,
1380
"down": 1,
@@ -1376,6 +1436,7 @@ func TestTableCollector_Collect(t *testing.T) {
1436
Tags: map[string]string{"fan_name": "Fan1"},
1437
MetricType: "gauge",
1438
IsTable: true,
1439
+ Table: "fanTable",
1440
MultiValue: map[string]int64{
1441
"normal": 1,
1442
"warning": 0,
@@ -1388,6 +1449,7 @@ func TestTableCollector_Collect(t *testing.T) {
1449
Tags: map[string]string{"fan_name": "Fan2"},
1450
MetricType: "gauge",
1451
IsTable: true,
1452
+ Table: "fanTable",
1453
MultiValue: map[string]int64{
1454
"normal": 0,
1455
"warning": 0,
@@ -1446,6 +1508,7 @@ func TestTableCollector_Collect(t *testing.T) {
1508
Tags: map[string]string{"pool_name": "Processor"},
1509
MetricType: "gauge",
1510
IsTable: true,
1511
+ Table: "cempMemPoolTable",
1512
},
1513
{
1514
Name: "cempMemPoolFree",
@@ -1453,6 +1516,7 @@ func TestTableCollector_Collect(t *testing.T) {
1516
Tags: map[string]string{"pool_name": "Processor"},
1517
MetricType: "gauge",
1518
IsTable: true,
1519
+ Table: "cempMemPoolTable",
1520
},
1521
},
1522
expectedError: false,
@@ -1507,6 +1571,7 @@ func TestTableCollector_Collect(t *testing.T) {
1571
Tags: map[string]string{"phase": "L1"},
1572
MetricType: "gauge",
1573
IsTable: true,
1574
+ Table: "upsPhaseInputTable",
1575
},
1576
{
1577
Name: "upsPhaseInputCurrent",
@@ -1514,6 +1579,7 @@ func TestTableCollector_Collect(t *testing.T) {
1579
Tags: map[string]string{"phase": "4"}, // Raw value when no mapping
1580
MetricType: "gauge",
1581
IsTable: true,
1582
+ Table: "upsPhaseInputTable",
1583
},
1584
},
1585
expectedError: false,
@@ -1568,6 +1634,7 @@ func TestTableCollector_Collect(t *testing.T) {
1634
Tags: map[string]string{"node_name": "node1"},
1635
MetricType: "gauge",
1636
IsTable: true,
1637
+ Table: "nodeTable",
1638
MultiValue: map[string]int64{
1639
"OK": 1,
1640
"ATTN": 0,
@@ -1581,6 +1648,7 @@ func TestTableCollector_Collect(t *testing.T) {
1648
Tags: map[string]string{"node_name": "node2"},
1649
MetricType: "gauge",
1650
IsTable: true,
1651
+ Table: "nodeTable",
1652
MultiValue: map[string]int64{
1653
"OK": 0,
1654
"ATTN": 0,
@@ -1639,6 +1707,7 @@ func TestTableCollector_Collect(t *testing.T) {
1707
Tags: map[string]string{"cpu_index": "1"},
1708
MetricType: "gauge",
1709
IsTable: true,
1710
+ Table: "cpmCPULoadTable",
1711
},
1712
{
1713
Name: "cpmCPULoadAvg5min",
@@ -1646,6 +1715,7 @@ func TestTableCollector_Collect(t *testing.T) {
1715
Tags: map[string]string{"cpu_index": "1"},
1716
MetricType: "gauge",
1717
IsTable: true,
1718
+ Table: "cpmCPULoadTable",
1719
},
1720
},
1721
expectedError: false,
@@ -1687,6 +1757,8 @@ func TestTableCollector_Collect(t *testing.T) {
1757
Tags: nil,
1758
MetricType: "rate",
1759
IsTable: true,
1760
+
1761
+ Table: "ifTable",
1762
},
1763
// ifDescr metric is skipped because string can't be converted to int64
1764
},
@@ -1754,6 +1826,8 @@ func TestTableCollector_Collect(t *testing.T) {
1826
Tags: map[string]string{"interface": "GigabitEthernet0/0"},
1827
MetricType: "rate",
1828
IsTable: true,
1829
+
1830
+ Table: "ifTable",
1831
},
1832
{
1833
Name: "ifInErrors",
@@ -1761,6 +1835,8 @@ func TestTableCollector_Collect(t *testing.T) {
1835
Tags: map[string]string{"interface": "GigabitEthernet0/1"},
1836
MetricType: "rate",
1837
IsTable: true,
1838
+
1839
+ Table: "ifTable",
1840
},
1841
},
1842
expectedError: false,
@@ -1827,6 +1903,8 @@ func TestTableCollector_Collect(t *testing.T) {
1903
Tags: map[string]string{"interface": "GigabitEthernet0/0"},
1904
MetricType: "rate",
1905
IsTable: true,
1906
+
1907
+ Table: "ifTable",
1908
},
1909
{
1910
Name: "ifInErrors",
@@ -1834,6 +1912,8 @@ func TestTableCollector_Collect(t *testing.T) {
1912
Tags: map[string]string{"interface": "GigabitEthernet0/1"},
1913
MetricType: "rate",
1914
IsTable: true,
1915
+
1916
+ Table: "ifTable",
1917
},
1918
{
1919
Name: "ifInErrors",
@@ -1841,6 +1921,8 @@ func TestTableCollector_Collect(t *testing.T) {
1921
Tags: nil, // No cross-table tag found for index 3
1922
MetricType: "rate",
1923
IsTable: true,
1924
+
1925
+ Table: "ifTable",
1926
},
1927
},
1928
expectedError: false,
@@ -1930,6 +2012,8 @@ func TestTableCollector_Collect(t *testing.T) {
2012
},
2013
MetricType: "rate",
2014
IsTable: true,
2015
+
2016
+ Table: "ifTable",
2017
},
2018
},
2019
expectedError: false,
@@ -1994,6 +2078,7 @@ func TestTableCollector_Collect(t *testing.T) {
2078
Tags: map[string]string{"interface_clean": "GigabitEthernet0"},
2079
MetricType: "rate",
2080
IsTable: true,
2081
+ Table: "ifTable",
2082
},
2083
},
2084
expectedError: false,
@@ -2088,11 +2173,13 @@ func TestTableCollector_Collect(t *testing.T) {
2173
},
2174
MetricType: ddprofiledefinition.ProfileMetricTypeRate,
2175
IsTable: true,
2176
+ Table: "cieIfInterfaceTable",
2177
},
2178
{
2179
Name: "ifType",
2180
MetricType: "gauge",
2181
IsTable: true,
2182
+ Table: "ifTable",
2183
Tags: nil,
2184
Value: 6,
2185
},
@@ -2164,6 +2251,8 @@ func TestTableCollector_Collect(t *testing.T) {
2251
Tags: map[string]string{"pdu_name": "PDU-A1"},
2252
MetricType: "gauge",
2253
IsTable: true,
2254
+
2255
+ Table: "cpiPduBranchTable",
2256
},
2257
},
2258
expectedError: false,
@@ -2237,6 +2326,8 @@ func TestTableCollector_Collect(t *testing.T) {
2326
Tags: map[string]string{"device_name": "Device-123"},
2327
MetricType: "gauge",
2328
IsTable: true,
2329
+
2330
+ Table: "customTable",
2331
},
2332
},
2333
expectedError: false,
@@ -2306,6 +2397,8 @@ func TestTableCollector_Collect(t *testing.T) {
2397
Tags: nil, // No tag because index transform failed
2398
MetricType: "gauge",
2399
IsTable: true,
2400
+
2401
+ Table: "customTable",
2402
},
2403
},
2404
expectedError: false,
@@ -2359,6 +2452,8 @@ func TestTableCollector_Collect(t *testing.T) {
2452
Tags: map[string]string{"ent_descr": "Power Supply 1"},
2453
MetricType: "gauge",
2454
IsTable: true,
2455
+
2456
+ Table: "panEntityFRUModuleTable",
2457
},
2458
{
2459
Name: "panEntryFRUModulePowerUsed",
@@ -2366,6 +2461,8 @@ func TestTableCollector_Collect(t *testing.T) {
2461
Tags: map[string]string{"ent_descr": "Power Supply 2"},
2462
MetricType: "gauge",
2463
IsTable: true,
2464
+
2465
+ Table: "panEntityFRUModuleTable",
2466
},
2467
},
2468
expectedError: false,
@@ -2437,6 +2534,8 @@ func TestTableCollector_Collect(t *testing.T) {
2534
},
2535
MetricType: "gauge",
2536
IsTable: true,
2537
+
2538
+ Table: "panEntityFRUModuleTable",
2539
},
2540
{
2541
Name: "panEntryFRUModulePowerUsed",
@@ -2447,6 +2546,8 @@ func TestTableCollector_Collect(t *testing.T) {
2546
},
2547
MetricType: "gauge",
2548
IsTable: true,
2549
+
2550
+ Table: "panEntityFRUModuleTable",
2551
},
2552
},
2553
expectedError: false,
@@ -2513,6 +2614,8 @@ func TestTableCollector_Collect(t *testing.T) {
2614
Tags: map[string]string{"interface": "GigabitEthernet0/0"}, // Uses ifName (cross-table)
2615
MetricType: "rate",
2616
IsTable: true,
2617
+
2618
+ Table: "ifTable",
2619
},
2620
{
2621
Name: "ifInErrors",
@@ -2520,6 +2623,8 @@ func TestTableCollector_Collect(t *testing.T) {
2623
Tags: map[string]string{"interface": "GigabitEthernet0/1"}, // Uses ifName (cross-table)
2624
MetricType: "rate",
2625
IsTable: true,
2626
+
2627
+ Table: "ifTable",
2628
},
2629
{
2630
Name: "ifInErrors",
@@ -2527,6 +2632,8 @@ func TestTableCollector_Collect(t *testing.T) {
2632
Tags: map[string]string{"interface": "eth2-description"}, // Falls back to ifDescr (same-table)
2633
MetricType: "rate",
2634
IsTable: true,
2635
+
2636
+ Table: "ifTable",
2637
},
2638
},
2639
expectedError: false,
@@ -2603,6 +2710,8 @@ func TestTableCollector_Collect(t *testing.T) {
2710
},
2711
MetricType: "rate",
2712
IsTable: true,
2713
+
2714
+ Table: "ifTable",
2715
},
2716
{
2717
Name: "ifInOctets",
@@ -2613,6 +2722,8 @@ func TestTableCollector_Collect(t *testing.T) {
2722
},
2723
MetricType: "rate",
2724
IsTable: true,
2725
+
2726
+ Table: "ifTable",
2727
},
2728
},
2729
expectedError: false,
@@ -2677,6 +2788,8 @@ func TestTableCollector_Collect(t *testing.T) {
2788
Tags: map[string]string{"interface": "eth0-description"}, // Uses ifDescr (first in order)
2789
MetricType: "rate",
2790
IsTable: true,
2791
+
2792
+ Table: "ifTable",
2793
},
2794
{
2795
Name: "ifInOctets",
@@ -2684,6 +2797,8 @@ func TestTableCollector_Collect(t *testing.T) {
2797
Tags: map[string]string{"interface": "GigE0/1"}, // Falls back to ifName when ifDescr is empty
2798
MetricType: "rate",
2799
IsTable: true,
2800
+
2801
+ Table: "ifTable",
2802
},
2803
},
2804
expectedError: false,
@@ -2756,6 +2871,8 @@ func TestTableCollector_Collect(t *testing.T) {
2871
Tags: map[string]string{"interface_name": "GigE0/0"}, // Uses ifName
2872
MetricType: "rate",
2873
IsTable: true,
2874
+
2875
+ Table: "ifTable",
2876
},
2877
{
2878
Name: "ifInOctets",
@@ -2763,6 +2880,8 @@ func TestTableCollector_Collect(t *testing.T) {
2880
Tags: map[string]string{"interface_name": "eth1"}, // Falls back to ifDescr
2881
MetricType: "rate",
2882
IsTable: true,
2883
+
2884
+ Table: "ifTable",
2885
},
2886
{
2887
Name: "ifInOctets",
@@ -2770,6 +2889,8 @@ func TestTableCollector_Collect(t *testing.T) {
2889
Tags: map[string]string{"interface_name": "3"}, // Falls back to index
2890
MetricType: "rate",
2891
IsTable: true,
2892
+
2893
+ Table: "ifTable",
2894
},
2895
},
2896
expectedError: false,
@@ -2814,6 +2935,8 @@ func TestTableCollector_Collect(t *testing.T) {
2935
Tags: map[string]string{"ip_version": "1"},
2936
MetricType: "rate",
2937
IsTable: true,
2938
+
2939
+ Table: "ipSystemStatsTable",
2940
},
2941
{
2942
Name: "ipSystemStatsHCInReceives",
@@ -2821,6 +2944,8 @@ func TestTableCollector_Collect(t *testing.T) {
2944
Tags: map[string]string{"ip_version": "2"},
2945
MetricType: "rate",
2946
IsTable: true,
2947
+
2948
+ Table: "ipSystemStatsTable",
2949
},
2950
},
2951
expectedError: false,
@@ -2868,6 +2993,7 @@ func TestTableCollector_Collect(t *testing.T) {
2993
Tags: map[string]string{"service_type": "20", "stat_type": "2"},
2994
MetricType: "rate",
2995
IsTable: true,
2996
+ Table: "cfwConnectionStatTable",
2997
},
2998
{
2999
Name: "cfwConnectionStatValue",
@@ -2875,6 +3001,7 @@ func TestTableCollector_Collect(t *testing.T) {
3001
Tags: map[string]string{"service_type": "21", "stat_type": "3"},
3002
MetricType: "rate",
3003
IsTable: true,
3004
+ Table: "cfwConnectionStatTable",
3005
},
3006
},
3007
expectedError: false,
@@ -2923,6 +3050,8 @@ func TestTableCollector_Collect(t *testing.T) {
3050
Tags: map[string]string{"ip_version": "ipv4"},
3051
MetricType: "rate",
3052
IsTable: true,
3053
+
3054
+ Table: "ipSystemStatsTable",
3055
},
3056
{
3057
Name: "ipSystemStatsHCInReceives",
@@ -2930,6 +3059,8 @@ func TestTableCollector_Collect(t *testing.T) {
3059
Tags: map[string]string{"ip_version": "ipv6"},
3060
MetricType: "rate",
3061
IsTable: true,
3062
+
3063
+ Table: "ipSystemStatsTable",
3064
},
3065
{
3066
Name: "ipSystemStatsHCInReceives",
@@ -2937,6 +3068,8 @@ func TestTableCollector_Collect(t *testing.T) {
3068
Tags: map[string]string{"ip_version": "0"}, // No mapping for 0
3069
MetricType: "rate",
3070
IsTable: true,
3071
+
3072
+ Table: "ipSystemStatsTable",
3073
},
3074
},
3075
expectedError: false,
@@ -2984,6 +3117,8 @@ func TestTableCollector_Collect(t *testing.T) {
3117
Tags: map[string]string{"interface_index": "1"}, // No sub_interface tag
3118
MetricType: "rate",
3119
IsTable: true,
3120
+
3121
+ Table: "ifTable",
3122
},
3123
{
3124
Name: "ifInOctets",
@@ -2991,6 +3126,8 @@ func TestTableCollector_Collect(t *testing.T) {
3126
Tags: map[string]string{"interface_index": "2", "sub_interface": "3"},
3127
MetricType: "rate",
3128
IsTable: true,
3129
+
3130
+ Table: "ifTable",
3131
},
3132
},
3133
expectedError: false,
@@ -3035,6 +3172,7 @@ func TestTableCollector_Collect(t *testing.T) {
3172
Tags: map[string]string{"index1": "192", "index2": "168"},
3173
MetricType: "gauge",
3174
IsTable: true,
3175
+ Table: "ipMRouteTable",
3176
},
3177
},
3178
expectedError: false,
@@ -3094,6 +3232,8 @@ func TestTableCollector_Collect(t *testing.T) {
3232
},
3233
MetricType: "gauge",
3234
IsTable: true,
3235
+
3236
+ Table: "customTable",
3237
},
3238
},
3239
expectedError: false,
@@ -3140,6 +3280,8 @@ func TestTableCollector_Collect(t *testing.T) {
3280
Tags: map[string]string{"interface_index": "1"}, // No invalid_tag
3281
MetricType: "rate",
3282
IsTable: true,
3283
+
3284
+ Table: "ifTable",
3285
},
3286
},
3287
expectedError: false,
@@ -3186,6 +3328,8 @@ func TestTableCollector_Collect(t *testing.T) {
3328
Tags: map[string]string{"interface_index": "5"}, // No impossible_tag
3329
MetricType: "rate",
3330
IsTable: true,
3331
+
3332
+ Table: "ifTable",
3333
},
3334
},
3335
expectedError: false,
@@ -3261,6 +3405,8 @@ func TestTableCollector_Collect(t *testing.T) {
3405
Family: "Health/Temperature",
3406
MetricType: "gauge",
3407
IsTable: true,
3408
+
3409
+ Table: "mtxrHlTable",
3410
},
3411
{
3412
Name: "mtxrHlSensorValue_voltage",
@@ -3270,6 +3416,7 @@ func TestTableCollector_Collect(t *testing.T) {
3416
Family: "Health/Power",
3417
MetricType: "gauge",
3418
IsTable: true,
3419
+ Table: "mtxrHlTable",
3420
},
3421
},
3422
expectedError: false,
@@ -3353,6 +3500,7 @@ func TestTableCollector_Collect(t *testing.T) {
3500
Family: "Health/Temperature",
3501
MetricType: "gauge",
3502
IsTable: true,
3503
+ Table: "mtxrHlTable",
3504
},
3505
{
3506
Name: "mtxrHlSensorValue_sensor_status",
@@ -3361,6 +3509,7 @@ func TestTableCollector_Collect(t *testing.T) {
3509
Family: "Health/Status",
3510
MetricType: "gauge",
3511
IsTable: true,
3512
+ Table: "mtxrHlTable",
3513
MultiValue: map[string]int64{
3514
"not_ok": 0,
3515
"ok": 1,
@@ -3374,6 +3523,7 @@ func TestTableCollector_Collect(t *testing.T) {
3523
Family: "Health/Power",
3524
MetricType: "gauge",
3525
IsTable: true,
3526
+ Table: "mtxrHlTable",
3527
},
3528
},
3529
expectedError: false,
@@ -3439,6 +3589,8 @@ func TestTableCollector_Collect(t *testing.T) {
3589
Description: "Traffic on eth0 interface",
3590
MetricType: "rate",
3591
IsTable: true,
3592
+
3593
+ Table: "ifTable",
3594
},
3595
{
3596
Name: "ifInOctets",
@@ -3448,6 +3600,8 @@ func TestTableCollector_Collect(t *testing.T) {
3600
Description: "Traffic on lo0 interface",
3601
MetricType: "rate",
3602
IsTable: true,
3603
+
3604
+ Table: "ifTable",
3605
},
3606
{
3607
Name: "ifInOctets",
@@ -3457,6 +3611,8 @@ func TestTableCollector_Collect(t *testing.T) {
3611
Description: "Traffic on tun0 interface",
3612
MetricType: "rate",
3613
IsTable: true,
3614
+
3615
+ Table: "ifTable",
3616
},
3617
},
3618
expectedError: false,
@@ -3516,6 +3672,7 @@ func TestTableCollector_Collect(t *testing.T) {
3672
Tags: map[string]string{"interface": "eth0"},
3673
MetricType: "gauge",
3674
IsTable: true,
3675
+ Table: "ifTable",
3676
MultiValue: map[string]int64{
3677
"down": 0,
3678
"up": 1,
@@ -3527,6 +3684,7 @@ func TestTableCollector_Collect(t *testing.T) {
3684
Tags: map[string]string{"interface": "eth1"},
3685
MetricType: "gauge",
3686
IsTable: true,
3687
+ Table: "ifTable",
3688
MultiValue: map[string]int64{
3689
"down": 1,
3690
"up": 0,
@@ -3538,6 +3696,7 @@ func TestTableCollector_Collect(t *testing.T) {
3696
Tags: map[string]string{"interface": "eth2"},
3697
MetricType: "gauge",
3698
IsTable: true,
3699
+ Table: "ifTable",
3700
MultiValue: map[string]int64{
3701
"down": 1,
3702
"up": 0,
@@ -3607,6 +3766,8 @@ func TestTableCollector_Collect(t *testing.T) {
3766
Family: "Storage/FileSystem",
3767
MetricType: "gauge",
3768
IsTable: true,
3769
+
3770
+ Table: "hrStorageTable",
3771
},
3772
{
3773
Name: "filesystem_size",
@@ -3615,6 +3776,8 @@ func TestTableCollector_Collect(t *testing.T) {
3776
Family: "Storage/FileSystem",
3777
MetricType: "gauge",
3778
IsTable: true,
3779
+
3780
+ Table: "hrStorageTable",
3781
},
3782
{
3783
Name: "memory_size",
@@ -3623,6 +3786,8 @@ func TestTableCollector_Collect(t *testing.T) {
3786
Family: "Storage/Memory",
3787
MetricType: "gauge",
3788
IsTable: true,
3789
+
3790
+ Table: "hrStorageTable",
3791
},
3792
{
3793
Name: "hrStorageSize",
@@ -3631,6 +3796,8 @@ func TestTableCollector_Collect(t *testing.T) {
3796
Family: "Storage/Other",
3797
MetricType: "gauge",
3798
IsTable: true,
3799
+
3800
+ Table: "hrStorageTable",
3801
},
3802
},
3803
expectedError: false,
@@ -3658,11 +3825,6 @@ func TestTableCollector_Collect(t *testing.T) {
3825
3826
result, err := collector.Collect(tc.profile)
3827
3661
- // TODO: the Table field is now compared as part of the metric; ensure expectedResult includes correct Table values
3662
- for i := range result {
3663
- result[i].Table = ""
3664
- }
3665
-
3828
if tc.expectedError {
3829
assert.Error(t, err)
3830
if tc.errorContains != "" {
@@ -3848,6 +4010,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4010
Tags: map[string]string{"interface": "eth0"},
4011
MetricType: "rate",
4012
IsTable: true,
4013
+
4014
+ Table: "ifTable",
4015
},
4016
{
4017
Name: "ifOutOctets",
@@ -3855,6 +4019,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4019
Tags: map[string]string{"interface": "eth0"},
4020
MetricType: "rate",
4021
IsTable: true,
4022
+
4023
+ Table: "ifTable",
4024
},
4025
{
4026
Name: "ifInOctets",
@@ -3862,6 +4028,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4028
Tags: map[string]string{"interface": "eth1"},
4029
MetricType: "rate",
4030
IsTable: true,
4031
+
4032
+ Table: "ifTable",
4033
},
4034
{
4035
Name: "ifOutOctets",
@@ -3869,6 +4037,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4037
Tags: map[string]string{"interface": "eth1"},
4038
MetricType: "rate",
4039
IsTable: true,
4040
+
4041
+ Table: "ifTable",
4042
},
4043
},
4044
},
@@ -3982,6 +4152,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4152
Tags: map[string]string{"interface": "eth0"},
4153
MetricType: "rate",
4154
IsTable: true,
4155
+
4156
+ Table: "ifTable",
4157
},
4158
{
4159
Name: "ifInOctets",
@@ -3989,6 +4161,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4161
Tags: map[string]string{"interface": "eth1"},
4162
MetricType: "rate",
4163
IsTable: true,
4164
+
4165
+ Table: "ifTable",
4166
},
4167
},
4168
},
@@ -4150,6 +4324,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4324
Tags: map[string]string{"interface": "eth0"},
4325
MetricType: "rate",
4326
IsTable: true,
4327
+
4328
+ Table: "ifTable",
4329
},
4330
{
4331
Name: "ifOutOctets",
@@ -4157,6 +4333,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4333
Tags: map[string]string{"interface": "eth0"},
4334
MetricType: "rate",
4335
IsTable: true,
4336
+
4337
+ Table: "ifTable",
4338
},
4339
// From second config
4340
{
@@ -4165,6 +4343,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4343
Tags: map[string]string{"interface": "eth0"},
4344
MetricType: "rate",
4345
IsTable: true,
4346
+
4347
+ Table: "ifTable",
4348
},
4349
{
4350
Name: "ifOutErrors",
@@ -4172,6 +4352,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4352
Tags: map[string]string{"interface": "eth0"},
4353
MetricType: "rate",
4354
IsTable: true,
4355
+
4356
+ Table: "ifTable",
4357
},
4358
},
4359
},
@@ -4274,6 +4456,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4456
Tags: map[string]string{"ent_descr": "Power Supply 1"},
4457
MetricType: "gauge",
4458
IsTable: true,
4459
+
4460
+ Table: "panEntityFRUModuleTable",
4461
},
4462
{
4463
Name: "panEntryFRUModulePowerUsed",
@@ -4281,6 +4465,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4465
Tags: map[string]string{"ent_descr": "Power Supply 2"},
4466
MetricType: "gauge",
4467
IsTable: true,
4468
+
4469
+ Table: "panEntityFRUModuleTable",
4470
},
4471
},
4472
},
@@ -4392,6 +4578,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4578
},
4579
MetricType: "gauge",
4580
IsTable: true,
4581
+
4582
+ Table: "panEntityFRUModuleTable",
4583
},
4584
{
4585
Name: "panEntryFRUModulePowerUsed",
@@ -4402,6 +4590,8 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4590
},
4591
MetricType: "gauge",
4592
IsTable: true,
4593
+
4594
+ Table: "panEntityFRUModuleTable",
4595
},
4596
},
4597
},
@@ -4453,8 +4643,7 @@ func TestCollector_Collect_TableCaching(t *testing.T) {
4643
for _, profile := range result {
4644
for i := range profile.Metrics {
4645
profile.Metrics[i].Profile = nil
4456
- // TODO: the Table field is now compared as part of the metric; ensure expectedResult includes correct Table values
4457
- profile.Metrics[i].Table = ""
4646
+
4647
}
4648
}
4649