mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 11:48:33 +08:00
Use patch.dict instead of modifying the environment variable in test_standalone_metrics_server
This commit is contained in:
@@ -38,15 +38,15 @@ def test_standalone_metrics_server_disabled_by_default():
|
||||
|
||||
|
||||
def test_standalone_metrics_server():
|
||||
os.environ["MONITOR_STANDALONE_METRICS_SERVER_ENABLE"] = "true"
|
||||
reload_module(module_build_service.common.monitor)
|
||||
with mock.patch.dict(os.environ, {"MONITOR_STANDALONE_METRICS_SERVER_ENABLE": "true"}):
|
||||
reload_module(module_build_service.common.monitor)
|
||||
|
||||
r = requests.get("http://127.0.0.1:10040/metrics")
|
||||
count = len([
|
||||
l for l in r.text.splitlines()
|
||||
if (l.startswith("# TYPE") and "_created " not in l)
|
||||
])
|
||||
assert count == num_of_metrics
|
||||
r = requests.get("http://127.0.0.1:10040/metrics")
|
||||
count = len([
|
||||
l for l in r.text.splitlines()
|
||||
if (l.startswith("# TYPE") and "_created " not in l)
|
||||
])
|
||||
assert count == num_of_metrics
|
||||
|
||||
|
||||
@mock.patch("module_build_service.common.monitor.builder_failed_counter.labels")
|
||||
|
||||
Reference in New Issue
Block a user