Skip to content

Commit

Permalink
Revert "Use sleep to avoid resolution errors in Windows"
Browse files Browse the repository at this point in the history
This reverts commit 6a81afa.
  • Loading branch information
ocelotl committed Oct 11, 2023
1 parent a6bd58e commit 0d64a45
Showing 1 changed file with 40 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from itertools import count
from platform import system
from time import sleep
from unittest import TestCase

from pytest import mark
Expand All @@ -29,6 +28,14 @@


class TestSumAggregation(TestCase):
@mark.skipif(
system() != "Linux",
reason=(
"Tests fail because Windows time_ns resolution is too low so "
"two different time measurements may end up having the exact same"
"value."
),
)
def test_asynchronous_delta_temporality(self):

eight_multiple_generator = count(start=8, step=8)
Expand Down Expand Up @@ -66,7 +73,7 @@ def observable_counter_callback(callback_options):
results = []

for _ in range(10):
sleep(0)

results.append(reader.get_metrics_data())

self.assertEqual(counter, 10)
Expand All @@ -77,7 +84,7 @@ def observable_counter_callback(callback_options):
results = []

for _ in range(10):
sleep(0)

results.append(reader.get_metrics_data())

self.assertEqual(counter, 20)
Expand Down Expand Up @@ -136,7 +143,7 @@ def observable_counter_callback(callback_options):
results = []

for _ in range(10):
sleep(0)

results.append(reader.get_metrics_data())

self.assertEqual(counter, 30)
Expand All @@ -146,6 +153,14 @@ def observable_counter_callback(callback_options):
for metrics_data in results:
self.assertIsNone(metrics_data)

@mark.skipif(
system() != "Linux",
reason=(
"Tests fail because Windows time_ns resolution is too low so "
"two different time measurements may end up having the exact same"
"value."
),
)
def test_asynchronous_cumulative_temporality(self):

eight_multiple_generator = count(start=8, step=8)
Expand Down Expand Up @@ -183,7 +198,7 @@ def observable_counter_callback(callback_options):
results = []

for _ in range(10):
sleep(0)

results.append(reader.get_metrics_data())

self.assertEqual(counter, 10)
Expand All @@ -194,7 +209,7 @@ def observable_counter_callback(callback_options):
results = []

for _ in range(10):
sleep(0)

results.append(reader.get_metrics_data())

self.assertEqual(counter, 20)
Expand Down Expand Up @@ -225,7 +240,7 @@ def observable_counter_callback(callback_options):
results = []

for _ in range(10):
sleep(0)

results.append(reader.get_metrics_data())

self.assertEqual(counter, 30)
Expand All @@ -235,6 +250,14 @@ def observable_counter_callback(callback_options):
for metrics_data in results:
self.assertIsNone(metrics_data)

@mark.skipif(
system() != "Linux",
reason=(
"Tests fail because Windows time_ns resolution is too low so "
"two different time measurements may end up having the exact same"
"value."
),
)
def test_synchronous_delta_temporality(self):

aggregation = SumAggregation()
Expand All @@ -252,7 +275,7 @@ def test_synchronous_delta_temporality(self):
results = []

for _ in range(10):
sleep(0)

results.append(reader.get_metrics_data())

for metrics_data in results:
Expand All @@ -262,7 +285,6 @@ def test_synchronous_delta_temporality(self):

for _ in range(10):
counter.add(8)
sleep(0)
results.append(reader.get_metrics_data())

previous_time_unix_nano = (
Expand Down Expand Up @@ -319,14 +341,22 @@ def test_synchronous_delta_temporality(self):
results = []

for _ in range(10):
sleep(0)

results.append(reader.get_metrics_data())

provider.shutdown()

for metrics_data in results:
self.assertIsNone(metrics_data)

@mark.skipif(
system() != "Linux",
reason=(
"Tests fail because Windows time_ns resolution is too low so "
"two different time measurements may end up having the exact same"
"value."
),
)
def test_synchronous_cumulative_temporality(self):

aggregation = SumAggregation()
Expand Down

0 comments on commit 0d64a45

Please sign in to comment.