Skip to content

Commit 98e394f

Browse files
committed
add debug log
1 parent 5e874ca commit 98e394f

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

contract-tests/images/mock-collector/mock_collector_client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ def wait_condition(
115115
if exact_match:
116116
return 0 < len(exported) == len(current) and present_metrics_lower.issubset(received_metrics)
117117
else:
118-
return present_metrics_lower.issubset(received_metrics)
118+
matched = present_metrics_lower.issubset(received_metrics)
119+
if not matched:
120+
value = json.dumps(received_metrics)
121+
_logger.error(f"metrics not matched, actual {value}")
122+
return matched
119123

120124
exported_metrics: List[ExportMetricsServiceRequest] = _wait_for_content(get_export, wait_condition)
121125
metrics: List[ResourceScopeMetric] = []
@@ -144,6 +148,4 @@ def _wait_for_content(get_export: Callable[[], List[T]], wait_condition: Callabl
144148
except Exception:
145149
_logger.exception("Error while reading content")
146150

147-
actual_exported: List[T] = get_export()
148-
actual_exported_value = json.dumps(actual_exported)
149-
raise RuntimeError(f"Timeout waiting for content {actual_exported_value}")
151+
raise RuntimeError("Timeout waiting for content")

contract-tests/tests/test/amazon/runtime/runtime_metrics_test.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,27 @@
44

55
from mock_collector_client import ResourceScopeMetric
66
from requests import Response
7+
from typing_extensions import override
78

89
import amazon.utils.application_signals_constants as constants
9-
from amazon.django.django_test import DjangoTest
10+
from amazon.base.contract_test_base import ContractTestBase
1011
from opentelemetry.proto.common.v1.common_pb2 import AnyValue
1112
from opentelemetry.proto.metrics.v1.metrics_pb2 import Metric, NumberDataPoint
1213

1314

14-
class RuntimeMetricsTest(DjangoTest):
15+
class RuntimeMetricsTest(ContractTestBase):
16+
@override
17+
@staticmethod
18+
def get_application_image_name() -> str:
19+
return "aws-application-signals-tests-django-app"
20+
21+
@override
22+
def get_application_wait_pattern(self) -> str:
23+
return "Quit the server with CONTROL-C."
24+
25+
@override
26+
def get_application_extra_environment_variables(self):
27+
return {"DJANGO_SETTINGS_MODULE": "django_server.settings"}
1528

1629
def test_runtime_succeeds(self) -> None:
1730
self.mock_collector_client.clear_signals()

0 commit comments

Comments
 (0)