client_python
client_python copied to clipboard
TestGauge::test_time_block_decorator_with_label failure
Hi, I am running the test suite on some obscure architectures and observed a failure on alpha, with one test:
========================================================================= FAILURES =========================================================================
______________________________________________________ TestGauge.test_time_block_decorator_with_label ______________________________________________________
self = <tests.test_core.TestGauge testMethod=test_time_block_decorator_with_label>
def test_time_block_decorator_with_label(self):
value = self.registry.get_sample_value
self.assertEqual(None, value('g2', {'label1': 'foo'}))
with self.gauge_with_label.time() as metric:
metric.labels('foo')
> self.assertLess(0, value('g2', {'label1': 'foo'}))
E AssertionError: 0 not less than 0.0
metric = <prometheus_client.context_managers.Timer object at 0x20007441790>
self = <tests.test_core.TestGauge testMethod=test_time_block_decorator_with_label>
value = <bound method CollectorRegistry.get_sample_value of <prometheus_client.registry.CollectorRegistry object at 0x20007441310>>
tests/test_core.py:255: AssertionError
This is fully reproducible, and I tested on both python3.10 and python3.11 with same results.
Complete log: 41y0768.log
Any help on why this test could be failing? I know this is an unusual platform, so I can provide shell access to the machine in question if somebody would mind taking a look. I can also interactively debug, or test patches as needed.
Thank you!
What is alpha?
What is alpha?
It's a DEC Alpha machine! I've seen issues show up here before due to (1) low clock resolution and (2) race conditions exposed by its slow speed. If the log isn't enough to identify the problem, I have free shell access to all of the unusual machines I test on. Would provisioning an account so you can investigate directly help?
One additional failure in 0.18.0.
================================================================== FAILURES ===================================================================
_______________________________________________ TestGauge.test_time_block_decorator_with_label ________________________________________________
self = <tests.test_core.TestGauge testMethod=test_time_block_decorator_with_label>
def test_time_block_decorator_with_label(self):
value = self.registry.get_sample_value
self.assertEqual(None, value('g2', {'label1': 'foo'}))
with self.gauge_with_label.time() as metric:
metric.labels('foo')
> self.assertLess(0, value('g2', {'label1': 'foo'}))
E AssertionError: 0 not less than 0.0
metric = <prometheus_client.context_managers.Timer object at 0x2000403df90>
self = <tests.test_core.TestGauge testMethod=test_time_block_decorator_with_label>
value = <bound method CollectorRegistry.get_sample_value of <prometheus_client.registry.CollectorRegistry object at 0x2000403db10>>
tests/test_core.py:255: AssertionError
___________________________________________________ TestMultiProcess.test_gauge_mostrecent ____________________________________________________
self = <tests.test_multiprocess.TestMultiProcess testMethod=test_gauge_mostrecent>
def test_gauge_mostrecent(self):
g1 = Gauge('g', 'help', registry=None, multiprocess_mode='mostrecent')
values.ValueClass = MultiProcessValue(lambda: 456)
g2 = Gauge('g', 'help', registry=None, multiprocess_mode='mostrecent')
g2.set(2)
g1.set(1)
> self.assertEqual(1, self.registry.get_sample_value('g'))
E AssertionError: 1 != 2.0
g1 = prometheus_client.metrics.Gauge(g)
g2 = prometheus_client.metrics.Gauge(g)
self = <tests.test_multiprocess.TestMultiProcess testMethod=test_gauge_mostrecent>
tests/test_multiprocess.py:194: AssertionError
Both failures are possibly related to timing things, which as you say might be due to a low clock resolution. I don't really know much about alpha, and don't have time to try to debug it. I would be happy to accept a contribution to fix the test failures though!