diff --git a/snmp/tests/compose/data/features.snmprec b/snmp/tests/compose/data/features.snmprec new file mode 100644 index 0000000000000..5e18b69505a41 --- /dev/null +++ b/snmp/tests/compose/data/features.snmprec @@ -0,0 +1,6 @@ +1.3.6.1.2.1.1.1.0|4|Fake features test device +1.3.6.1.2.1.1.2.0|6|1.2.3.20231012 +1.3.6.1.2.1.1.5.0|4|features.device.name +1.3.6.1.2.1.2.2.1.14.10|65|99 +1.3.6.1.2.1.31.1.1.1.1.10|4|If1 +1.3.6.1.2.1.31.1.1.1.18.10|4|If1Alias diff --git a/snmp/tests/fixtures/user_profiles/features.yaml b/snmp/tests/fixtures/user_profiles/features.yaml new file mode 100644 index 0000000000000..bd11230cf488d --- /dev/null +++ b/snmp/tests/fixtures/user_profiles/features.yaml @@ -0,0 +1,30 @@ +# This profile is used to test features. +# Especially deprecated features since they are not used anymore in our default profiles, +# but we need to keep backward compatibility. + +extends: + - _base.yaml + +sysobjectid: 1.2.3.20231012 + +metrics: +- MIB: IF-MIB + table: + OID: 1.3.6.1.2.1.2.2 + name: ifTable + symbols: + - OID: 1.3.6.1.2.1.2.2.1.14 + name: ifInErrors + metric_tags: + # TEST CASE deprecated `column` syntax + - column: + OID: 1.3.6.1.2.1.31.1.1.1.1 + name: ifName + table: ifXTable + tag: tag_using_deprecated_column_syntax + # TEST CASE `symbol` syntax + - symbol: + OID: 1.3.6.1.2.1.31.1.1.1.18 + name: ifAlias + table: ifXTable + tag: tag_using_symbol_syntax diff --git a/snmp/tests/test_e2e_core_profiles/test_profile_features.py b/snmp/tests/test_e2e_core_profiles/test_profile_features.py new file mode 100644 index 0000000000000..b6eaec191ad7c --- /dev/null +++ b/snmp/tests/test_e2e_core_profiles/test_profile_features.py @@ -0,0 +1,60 @@ +# (C) Datadog, Inc. 2023-present +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) + +import pytest + +from .. import common +from ..test_e2e_core_metadata import assert_device_metadata +from .utils import ( + assert_common_metrics, + create_e2e_core_test_config, + get_device_ip_from_config, +) + +pytestmark = [pytest.mark.e2e, common.py3_plus_only, common.snmp_integration_only] + + +def test_e2e_features(dd_agent_check): + profile = 'features' + config = create_e2e_core_test_config(profile) + aggregator = common.dd_agent_check_wrapper(dd_agent_check, config, rate=True) + + ip_address = get_device_ip_from_config(config) + common_tags = [ + 'snmp_profile:features', + 'snmp_host:features.device.name', + 'device_namespace:default', + 'snmp_device:' + ip_address, + ] + + # --- TEST EXTENDED METRICS --- + + # --- TEST METRICS --- + assert_common_metrics(aggregator, common_tags) + + tag_rows = [ + [ + 'tag_using_deprecated_column_syntax:If1', + 'tag_using_symbol_syntax:If1Alias', + ], + ] + for tag_row in tag_rows: + aggregator.assert_metric('snmp.ifInErrors', metric_type=aggregator.GAUGE, tags=common_tags + tag_row) + + # --- TEST METADATA --- + device = { + 'description': 'Fake features test device', + 'id': 'default:' + ip_address, + 'id_tags': ['device_namespace:default', 'snmp_device:' + ip_address], + 'ip_address': '' + ip_address, + 'name': 'features.device.name', + 'profile': 'features', + 'status': 1, + 'sys_object_id': '1.2.3.20231012', + } + device['tags'] = common_tags + assert_device_metadata(aggregator, device) + + # --- CHECK COVERAGE --- + aggregator.assert_all_metrics_covered()