Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing test cases #2033

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: 0ef76a5cc39626f783416ca75e43556e2bb2739d
CORE_REPO_SHA: d054dff47d2da663a39b9656d106c3d15f344269

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,7 @@ def test_no_metric_for_websockets(self):
self.send_input({"type": "websocket.receive", "text": "ping"})
self.send_input({"type": "websocket.disconnect"})
self.get_all_output()
metrics_list = self.memory_metrics_reader.get_metrics_data()
self.assertEqual(
len(metrics_list.resource_metrics[0].scope_metrics), 0
)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())


class TestAsgiAttributes(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,4 @@ def test_metric_uninstrument(self):
self.assertEqual(len(metrics), 1)
CeleryInstrumentor().uninstrument()

metrics = self.get_metrics()
self.assertEqual(len(metrics), 1)

for metric in metrics:
for point in list(metric.data.data_points):
self.assertEqual(point.count, 1)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def test_metrics_one_connection(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
self.assert_pool_idle_used_expected(
Expand All @@ -78,8 +77,7 @@ def test_metrics_without_pool_name(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
self.assert_pool_idle_used_expected(
Expand All @@ -100,8 +98,7 @@ def test_metrics_two_connections(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
with engine.connect():
Expand All @@ -122,8 +119,7 @@ def test_metrics_connections(self):
pool_logging_name=pool_name,
)

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())

with engine.connect():
with engine.connect():
Expand Down Expand Up @@ -156,5 +152,4 @@ def test_metric_uninstrument(self):

engine.connect()

metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 0)
self.assertIsNone(self.memory_metrics_reader.get_metrics_data())
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from timeit import default_timer
from urllib import request
from urllib.parse import urlencode
from pytest import mark
from platform import python_implementation
from sys import version_info

import httpretty

Expand Down Expand Up @@ -185,16 +188,27 @@ def test_basic_metric_request_not_empty(self):
),
)

@mark.skipif(
python_implementation() == "PyPy" or version_info.minor == 7,
reason="Fails randomly in 3.7 and pypy"
)
def test_metric_uninstrument(self):
with request.urlopen(self.URL):
metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 3)

self.assertEqual(
metrics[0].data.data_points[0].sum, 1
)
self.assertEqual(
metrics[1].data.data_points[0].sum, 0
)
self.assertEqual(
metrics[2].data.data_points[0].sum, 6
)

URLLibInstrumentor().uninstrument()
with request.urlopen(self.URL):
metrics = self.get_sorted_metrics()
self.assertEqual(len(metrics), 3)

for metric in metrics:
for point in list(metric.data.data_points):
self.assertEqual(point.count, 1)
self.assertIsNone(
self.memory_metrics_reader.get_metrics_data()
)
Loading