-
Notifications
You must be signed in to change notification settings - Fork 820
Closed
Description
As of 0.22.1, the tests/certs
and tests/proc
directories are missing from the source distribution, which leads to test failures:
$ pytest
========================================================= test session starts =========================================================
platform linux -- Python 3.13.3, pytest-8.4.0, pluggy-1.6.0
rootdir: /tmp/prometheus_client-0.22.1
configfile: pyproject.toml
collected 253 items
tests/test_asgi.py ssssssss [ 3%]
tests/test_core.py ......................................................................................................... [ 44%]
tests/test_exposition.py ............................F.............................. [ 67%]
tests/test_gc_collector.py .. [ 68%]
tests/test_graphite_bridge.py ....... [ 71%]
tests/test_multiprocess.py ............................. [ 83%]
tests/test_parser.py ........................... [ 93%]
tests/test_platform_collector.py .. [ 94%]
tests/test_process_collector.py FFF. [ 96%]
tests/test_samples.py .. [ 96%]
tests/test_twisted.py s [ 97%]
tests/test_wsgi.py ....... [100%]
============================================================== FAILURES ===============================================================
___________________________________________ TestPushGateway.test_push_with_tls_auth_handler ___________________________________________
self = <test_exposition.TestPushGateway testMethod=test_push_with_tls_auth_handler>
def test_push_with_tls_auth_handler(self):
def my_auth_handler(url, method, timeout, headers, data):
certs_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'certs')
return tls_auth_handler(url, method, timeout, headers, data, os.path.join(certs_dir, "cert.pem"), os.path.join(certs_dir, "key.pem"))
> push_to_gateway(self.address, "my_job_with_tls_auth", self.registry, handler=my_auth_handler)
tests/test_exposition.py:362:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
prometheus_client/exposition.py:554: in push_to_gateway
_use_gateway('PUT', gateway, job, registry, grouping_key, timeout, handler)
prometheus_client/exposition.py:646: in _use_gateway
handler(
tests/test_exposition.py:360: in my_auth_handler
return tls_auth_handler(url, method, timeout, headers, data, os.path.join(certs_dir, "cert.pem"), os.path.join(certs_dir, "key.pem"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = 'http://localhost:44163/metrics/job/my_job_with_tls_auth', method = 'PUT', timeout = 30
headers = [('Content-Type', 'text/plain; version=0.0.4; charset=utf-8')], data = b'# HELP g help\n# TYPE g gauge\ng 0.0\n'
certfile = '/tmp/prometheus_client-0.22.1/tests/certs/cert.pem', keyfile = '/tmp/prometheus_client-0.22.1/tests/certs/key.pem'
cafile = None, protocol = <_SSLMethod.PROTOCOL_TLS_CLIENT: 16>, insecure_skip_verify = False
def tls_auth_handler(
url: str,
method: str,
timeout: Optional[float],
headers: List[Tuple[str, str]],
data: bytes,
certfile: str,
keyfile: str,
cafile: Optional[str] = None,
protocol: int = ssl.PROTOCOL_TLS_CLIENT,
insecure_skip_verify: bool = False,
) -> Callable[[], None]:
"""Handler that implements an HTTPS connection with TLS Auth.
The default protocol (ssl.PROTOCOL_TLS_CLIENT) will also enable
ssl.CERT_REQUIRED and SSLContext.check_hostname by default. This can be
disabled by setting insecure_skip_verify to True.
Both this handler and the TLS feature on pushgateay are experimental."""
context = ssl.SSLContext(protocol=protocol)
if cafile is not None:
context.load_verify_locations(cafile)
else:
context.load_default_certs()
if insecure_skip_verify:
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
> context.load_cert_chain(certfile=certfile, keyfile=keyfile)
E FileNotFoundError: [Errno 2] No such file or directory
prometheus_client/exposition.py:503: FileNotFoundError
_________________________________________________ TestProcessCollector.test_namespace _________________________________________________
self = <test_process_collector.TestProcessCollector testMethod=test_namespace>
def test_namespace(self):
collector = ProcessCollector(proc=self.test_proc, pid=lambda: 26231, registry=self.registry, namespace='n')
collector._ticks = 100
collector._pagesize = 4096
> self.assertEqual(17.21, self.registry.get_sample_value('n_process_cpu_seconds_total'))
E AssertionError: 17.21 != None
tests/test_process_collector.py:30: AssertionError
__________________________________________________ TestProcessCollector.test_working __________________________________________________
self = <test_process_collector.TestProcessCollector testMethod=test_working>
def test_working(self):
collector = ProcessCollector(proc=self.test_proc, pid=lambda: 26231, registry=self.registry)
collector._ticks = 100
collector._pagesize = 4096
> self.assertEqual(17.21, self.registry.get_sample_value('process_cpu_seconds_total'))
E AssertionError: 17.21 != None
tests/test_process_collector.py:17: AssertionError
________________________________________________ TestProcessCollector.test_working_584 ________________________________________________
self = <test_process_collector.TestProcessCollector testMethod=test_working_584>
def test_working_584(self):
collector = ProcessCollector(proc=self.test_proc, pid=lambda: "584\n", registry=self.registry)
collector._ticks = 100
collector._pagesize = 4096
> self.assertEqual(0.0, self.registry.get_sample_value('process_cpu_seconds_total'))
E AssertionError: 0.0 != None
tests/test_process_collector.py:43: AssertionError
======================================================= short test summary info =======================================================
FAILED tests/test_exposition.py::TestPushGateway::test_push_with_tls_auth_handler - FileNotFoundError: [Errno 2] No such file or directory
FAILED tests/test_process_collector.py::TestProcessCollector::test_namespace - AssertionError: 17.21 != None
FAILED tests/test_process_collector.py::TestProcessCollector::test_working - AssertionError: 17.21 != None
FAILED tests/test_process_collector.py::TestProcessCollector::test_working_584 - AssertionError: 0.0 != None
============================================== 4 failed, 240 passed, 9 skipped in 4.19s ===============================================
Metadata
Metadata
Assignees
Labels
No labels