Skip to content

Commit 46de832

Browse files
authored
test(nutanix): add tests for custom tags support (DataDog#23539)
* test(nutanix): add tests for custom tags support * test(nutanix): scope to instance tags only
1 parent cb90e62 commit 46de832

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

nutanix/tests/test_custom_tags.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# (C) Datadog, Inc. 2026-present
2+
# All rights reserved
3+
# Licensed under a 3-clause BSD style license (see LICENSE)
4+
5+
6+
import pytest
7+
8+
from datadog_checks.nutanix import NutanixCheck
9+
from tests.constants import (
10+
BASE_TAGS,
11+
CLUSTER_TAGS,
12+
HOST_NAME,
13+
HOST_TAGS,
14+
PCVM_NAME,
15+
PCVM_TAGS,
16+
)
17+
18+
pytestmark = [pytest.mark.unit]
19+
20+
CUSTOM_TAGS = ['custom_env:test', 'custom_team:agent-integrations', 'custom_key:custom_value']
21+
22+
23+
def test_custom_tags_propagate_to_metrics(dd_run_check, aggregator, mock_instance, mock_http_get, datadog_agent):
24+
"""Custom tags from ``instance['tags']`` propagate to all emitted metrics and external tags."""
25+
mock_instance['tags'] = CUSTOM_TAGS
26+
27+
check = NutanixCheck('nutanix', {}, [mock_instance])
28+
dd_run_check(check)
29+
30+
aggregator.assert_metric("nutanix.health.up", value=1, count=1, tags=BASE_TAGS + CUSTOM_TAGS)
31+
aggregator.assert_metric("nutanix.cluster.count", value=1, tags=CLUSTER_TAGS + CUSTOM_TAGS)
32+
aggregator.assert_metric("nutanix.host.count", value=1, tags=HOST_TAGS + CUSTOM_TAGS, hostname=HOST_NAME)
33+
aggregator.assert_metric("nutanix.vm.count", value=1, tags=PCVM_TAGS + CUSTOM_TAGS)
34+
datadog_agent.assert_external_tags(HOST_NAME, {'nutanix': HOST_TAGS + CUSTOM_TAGS})
35+
datadog_agent.assert_external_tags(PCVM_NAME, {'nutanix': PCVM_TAGS + CUSTOM_TAGS})

0 commit comments

Comments
 (0)