Skip to content

Commit

Permalink
add ipv6 tests, wait for generator
Browse files Browse the repository at this point in the history
  • Loading branch information
khanayan123 committed Jan 10, 2025
1 parent 4c75e27 commit 7d68776
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
38 changes: 38 additions & 0 deletions tests/parametric/test_config_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,44 @@ def test_dd_trace_agent_http_url_nonexistent(self, library_env, test_agent, test
assert url.hostname == "random-host"
assert url.port == 9999

@parametrize(
"library_env",
[
{
"DD_TRACE_AGENT_URL": "http://[::1]:5000",
"DD_AGENT_HOST": "localhost",
"DD_AGENT_PORT": "8126",
}
],
)
def test_dd_trace_agent_http_url_ipv6(self, library_env, test_agent, test_library):
with test_library as t:
resp = t.config()

url = urlparse(resp["dd_trace_agent_url"])
assert url.scheme == "http"
assert url.hostname == "::1"
assert url.port == 5000
assert resp["dd_trace_agent_url"] == "http://[::1]:5000"

@parametrize(
"library_env",
[
{
"DD_AGENT_HOST": "[::1]",
"DD_AGENT_PORT": "5000",
}
],
)
def test_dd_agent_host_ipv6(self, library_env, test_agent, test_library):
with test_library as t:
resp = t.config()

url = urlparse(resp["dd_trace_agent_url"])
assert url.scheme == "http"
assert url.hostname == "::1"
assert url.port == 5000
assert resp["dd_trace_agent_url"] == "http://[::1]:5000"

@scenarios.parametric
@features.tracing_configuration_consistency
Expand Down
24 changes: 13 additions & 11 deletions tests/test_config_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,24 +501,26 @@ def test_log_injection_128bit_traceid_disabled(self):
class Test_Config_RuntimeMetrics_Enabled:
# This test verifies runtime metrics by asserting the prescene of a metric in the dogstatsd endpoint
def test_config_runtimemetrics_enabled(self):
data = list(interfaces.library.get_data("/dogstatsd/v2/proxy"))[0]
lines = data["request"]["content"].split("\n")
metric_found = False
for line in lines:
if runtime_metrics[context.library.library] in line:
metric_found = True
break
assert metric_found, f"The metric {runtime_metrics[context.library.library]} was not found in any line"

for data in interfaces.library.get_data("/dogstatsd/v2/proxy"):
lines = data["request"]["content"].split("\n")
metric_found = False
for line in lines:
if runtime_metrics[context.library.library] in line:
metric_found = True
break
assert metric_found, f"The metric {runtime_metrics[context.library.library]} was not found in any line"
break

@rfc("https://docs.google.com/document/d/1kI-gTAKghfcwI7YzKhqRv2ExUstcHqADIWA4-TZ387o/edit#heading=h.8v16cioi7qxp")
@scenarios.tracing_config_nondefault
@features.tracing_configuration_consistency
class Test_Config_RuntimeMetrics_Default:
# test that by default runtime metrics are disabled
def test_config_runtimemetrics_default(self):
data = list(interfaces.library.get_data("/dogstatsd/v2/proxy"))
assert len(data) == 0
iterations = 0
for data in interfaces.library.get_data("/dogstatsd/v2/proxy"):
iterations += 1
assert iterations == 0, "Runtime metrics are enabled by default"


# Parse the JSON-formatted log message from stdout and return the 'dd' object
Expand Down

0 comments on commit 7d68776

Please sign in to comment.