-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into vivek-datadog/AGENT-10479
- Loading branch information
Showing
7 changed files
with
84 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add the ability to assert the `external_tags` when running tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# (C) Datadog, Inc. 2023-present | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) | ||
import pytest | ||
|
||
DEFAULT_EXTERNAL_TAGS = [ | ||
('hostname1', {'src1_name': ['test1:t1']}), | ||
('hostname2', {'src2_name': ['test2:t2']}), | ||
('hostname3', {'src3_name': ['test3:t3']}), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'hostname, tags, raise_exception', | ||
[ | ||
pytest.param('hostname1', {'src1_name': ['test1:t1']}, False, id="hostname1 and tags found"), | ||
pytest.param('hostname2', {'src2_name': ['test2:t2']}, False, id="hostname2 and tags found"), | ||
pytest.param('hostname3', {'src3_name': ['test3:t3']}, False, id="hostname3 and tags found"), | ||
pytest.param('hostname4', {'src4_name': ['test4:t4']}, True, id="hostname4 and tags not found"), | ||
pytest.param('hostname1', {'src2_name': ['test2:t2']}, True, id="hostname1 found and tags are wrong"), | ||
], | ||
) | ||
def test_assert_external_tags(datadog_agent, hostname, tags, raise_exception): | ||
datadog_agent.set_external_tags(DEFAULT_EXTERNAL_TAGS) | ||
|
||
try: | ||
datadog_agent.assert_external_tags(hostname, tags) | ||
except AssertionError: | ||
if not raise_exception: | ||
raise | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'external_tags, count, raise_exception', | ||
[ | ||
pytest.param(DEFAULT_EXTERNAL_TAGS, 3, False, id="correct count"), | ||
pytest.param([], 0, False, id="no tags"), | ||
pytest.param([('hostname1', {'src1_name': ['test1:t1']})], 1, False, id="one tag"), | ||
pytest.param([('hostname1', {'src1_name': ['test1:t1']})], 2, True, id="wrong count"), | ||
], | ||
) | ||
def test_assert_external_tags_count(datadog_agent, external_tags, count, raise_exception): | ||
datadog_agent.set_external_tags(external_tags) | ||
|
||
try: | ||
datadog_agent.assert_external_tags_count(count) | ||
except AssertionError: | ||
if not raise_exception: | ||
raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Attempt client connection before fetching consumer offsets |