Skip to content

Commit 030174b

Browse files
authored
[SNMP] Update tests with new device_id and device_ip tags (#17428)
* Update tests with new device_id and device_ip tags * Fix autodiscovery test * Lint
1 parent 2b043dd commit 030174b

File tree

147 files changed

+480
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+480
-33
lines changed

snmp/tests/test_e2e_core.py

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ def test_e2e_user_profiles(dd_agent_check):
8888
'ups_name:testIdentName',
8989
'device_namespace:default',
9090
]
91-
tags = profile_tags + ["snmp_device:{}".format(device_ip)]
91+
tags = profile_tags + [
92+
"snmp_device:{}".format(device_ip),
93+
"device_ip:{}".format(device_ip),
94+
"device_id:default:{}".format(device_ip),
95+
]
9296

9397
aggregator.assert_metric('snmp.upsAdvBatteryNumOfBattPacks', metric_type=aggregator.GAUGE, tags=tags, count=2)
9498
aggregator.assert_metric(
@@ -116,6 +120,8 @@ def test_e2e_user_profiles(dd_agent_check):
116120
'sys_object_id': '1.3.6.1.4.1.318.1.999',
117121
'tags': [
118122
'device_namespace:default',
123+
"device_id:default:" + device_ip,
124+
"device_ip:" + device_ip,
119125
'firmware_version:2.0.3-test',
120126
'model:APC Smart-UPS 600',
121127
'serial_num:test_serial',
@@ -146,7 +152,11 @@ def test_e2e_user_profiles_that_extend_profile_with_same_name(dd_agent_check):
146152
'snmp_profile:palo-alto',
147153
'device_namespace:default',
148154
]
149-
tags = profile_tags + ["snmp_device:{}".format(device_ip)]
155+
tags = profile_tags + [
156+
"snmp_device:{}".format(device_ip),
157+
"device_ip:{}".format(device_ip),
158+
"device_id:default:{}".format(device_ip),
159+
]
150160

151161
aggregator.assert_metric('snmp.panSessionUtilization', metric_type=aggregator.GAUGE, tags=tags, count=2)
152162
aggregator.assert_metric('snmp.panSessionUtilization_user', metric_type=aggregator.GAUGE, tags=tags, count=2)
@@ -166,6 +176,8 @@ def test_e2e_user_profiles_that_extend_profile_with_same_name(dd_agent_check):
166176
'sys_object_id': '1.3.6.1.4.1.25461.2.3.18',
167177
'tags': [
168178
'device_namespace:default',
179+
"device_id:default:" + device_ip,
180+
"device_ip:" + device_ip,
169181
'snmp_device:' + device_ip,
170182
'snmp_profile:palo-alto',
171183
],
@@ -190,7 +202,13 @@ def assert_apc_ups_metrics(dd_agent_check, config):
190202
'device_vendor:apc',
191203
'device_namespace:default',
192204
]
193-
tags = profile_tags + ["snmp_device:{}".format(instance['ip_address'])]
205+
device_ip = instance['ip_address']
206+
207+
tags = profile_tags + [
208+
"snmp_device:{}".format(device_ip),
209+
"device_ip:{}".format(device_ip),
210+
"device_id:default:{}".format(device_ip),
211+
]
194212

195213
common.assert_common_metrics(aggregator, tags, is_e2e=True, loader='core')
196214
aggregator.assert_metric(
@@ -237,7 +255,13 @@ def test_e2e_memory_cpu_f5_big_ip(dd_agent_check):
237255
'snmp_host:f5-big-ip-adc-good-byol-1-vm.c.datadog-integrations-lab.internal',
238256
'snmp_profile:f5-big-ip',
239257
]
240-
tags += ['snmp_device:{}'.format(instance['ip_address'])]
258+
device_ip = instance['ip_address']
259+
260+
tags += [
261+
"snmp_device:{}".format(device_ip),
262+
"device_ip:{}".format(device_ip),
263+
"device_id:default:{}".format(device_ip),
264+
]
241265

242266
common.assert_common_metrics(aggregator, tags, is_e2e=True, loader='core')
243267

@@ -283,6 +307,8 @@ def test_e2e_core_discovery(dd_agent_check):
283307
# autodiscovery
284308
'autodiscovery_subnet:' + network,
285309
'snmp_device:' + ip_address,
310+
"device_ip:" + ip_address,
311+
"device_id:default:" + ip_address,
286312
]
287313

288314
tags_with_loader = tags + ['loader:core']
@@ -356,6 +382,7 @@ def test_e2e_regex_match(dd_agent_check):
356382
]
357383
config['init_config']['loader'] = 'core'
358384
aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True)
385+
device_ip = instance['ip_address']
359386

360387
# raw sysName: 41ba948911b9
361388
aggregator.assert_metric(
@@ -366,7 +393,9 @@ def test_e2e_regex_match(dd_agent_check):
366393
'letter1:4',
367394
'letter2:1',
368395
'loader:core',
369-
'snmp_device:' + instance['ip_address'],
396+
'snmp_device:' + device_ip,
397+
'device_ip:' + device_ip,
398+
'device_id:default:' + device_ip,
370399
'device_namespace:default',
371400
],
372401
)
@@ -391,6 +420,8 @@ def test_e2e_meraki_cloud_controller(dd_agent_check):
391420
'device_vendor:meraki',
392421
'device_namespace:default',
393422
'snmp_device:' + ip_address,
423+
"device_ip:" + ip_address,
424+
"device_id:default:" + ip_address,
394425
]
395426

396427
common.assert_common_metrics(aggregator, tags=common_tags, is_e2e=True, loader='core')
@@ -485,8 +516,14 @@ def test_e2e_core_detect_metrics_using_apc_ups_metrics(dd_agent_check):
485516
# metric_tags from _base.yaml
486517
'snmp_host:APC_UPS_NAME',
487518
]
519+
device_ip = instance['ip_address']
488520

489-
tags = global_metric_tags + ['device_namespace:default', "snmp_device:{}".format(instance['ip_address'])]
521+
tags = global_metric_tags + [
522+
'device_namespace:default',
523+
"snmp_device:{}".format(device_ip),
524+
"device_ip:{}".format(device_ip),
525+
"device_id:default:{}".format(device_ip),
526+
]
490527

491528
common.assert_common_metrics(aggregator, tags, is_e2e=True, loader='core')
492529

@@ -534,12 +571,15 @@ def test_e2e_core_cisco_csr(dd_agent_check):
534571
config['init_config']['loader'] = 'core'
535572
instance = config['instances'][0]
536573
aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True)
574+
device_ip = instance['ip_address']
537575

538576
global_tags = [
539577
'snmp_profile:cisco-csr1000v',
540578
'device_vendor:cisco',
541579
'device_namespace:default',
542-
"snmp_device:{}".format(instance['ip_address']),
580+
"snmp_device:{}".format(device_ip),
581+
"device_ip:{}".format(device_ip),
582+
"device_id:default:{}".format(device_ip),
543583
]
544584

545585
common.assert_common_metrics(aggregator, global_tags, is_e2e=True, loader='core')
@@ -570,12 +610,15 @@ def test_e2e_cisco_nexus(dd_agent_check):
570610
config['init_config']['loader'] = 'core'
571611
instance = config['instances'][0]
572612
aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True)
613+
device_ip = instance['ip_address']
573614

574615
common_tags = [
575616
'snmp_profile:cisco-nexus',
576617
'device_vendor:cisco',
577618
'device_namespace:default',
578-
"snmp_device:{}".format(instance['ip_address']),
619+
"snmp_device:{}".format(device_ip),
620+
"device_ip:{}".format(device_ip),
621+
"device_id:default:{}".format(device_ip),
579622
'snmp_host:Nexus-eu1.companyname.managed',
580623
]
581624

@@ -786,6 +829,8 @@ def test_e2e_cisco_legacy_wlc(dd_agent_check):
786829
'device_vendor:cisco',
787830
'snmp_host:DDOGWLC',
788831
'snmp_device:' + ip_address,
832+
"device_ip:" + ip_address,
833+
"device_id:default:" + ip_address,
789834
]
790835
common.assert_common_metrics(aggregator, tags, is_e2e=True, loader='core')
791836

0 commit comments

Comments
 (0)