Skip to content

Commit 278f6e2

Browse files
committed
add debug log
1 parent 5e874ca commit 278f6e2

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ 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+
metrics_list = list(received_metrics)
121+
value = json.dumps(metrics_list)
122+
_logger.error(f"metrics not matched, actual {value}")
123+
return matched
119124

120125
exported_metrics: List[ExportMetricsServiceRequest] = _wait_for_content(get_export, wait_condition)
121126
metrics: List[ResourceScopeMetric] = []
@@ -144,6 +149,4 @@ def _wait_for_content(get_export: Callable[[], List[T]], wait_condition: Callabl
144149
except Exception:
145150
_logger.exception("Error while reading content")
146151

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}")
152+
raise RuntimeError("Timeout waiting for content")

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3+
import time
34
from typing import Dict, List
45

56
from mock_collector_client import ResourceScopeMetric
67
from requests import Response
8+
from typing_extensions import override
79

810
import amazon.utils.application_signals_constants as constants
9-
from amazon.django.django_test import DjangoTest
11+
from amazon.base.contract_test_base import ContractTestBase
1012
from opentelemetry.proto.common.v1.common_pb2 import AnyValue
1113
from opentelemetry.proto.metrics.v1.metrics_pb2 import Metric, NumberDataPoint
1214

1315

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

1634
def test_runtime_succeeds(self) -> None:
1735
self.mock_collector_client.clear_signals()
1836
response: Response = self.send_request("GET", "success")
1937
self.assertEqual(200, response.status_code)
38+
time.sleep(60)
2039

2140
metrics: List[ResourceScopeMetric] = self.mock_collector_client.get_metrics(
2241
{

0 commit comments

Comments
 (0)