Skip to content

Commit 7f6754c

Browse files
committed
test_prometheus_log_exporter: fix wrong measurement unit expected
Unit is now bytes and not kb. Fix this error: ``` ___________________________________ test_550 ___________________________________ plex = <module 'prometheus-log-exporter' from '/home/runner/work/birdhouse-deploy/birdhouse-deploy/birdhouse/optional-components/prometheus-log-parser/config/thredds/prometheus-log-exporter.py'> def test_550(plex): log = """172.20.0.1 - - [2025-06-17T03:08:02+00:00] "GET /thredds/catalog.html HTTP/1.1" 302 0 "-" "python-requests/2.31.0" "-" 172.20.0.1 - - [2025-06-17T03:08:02+00:00] "GET /twitcher/ows/proxy/thredds/catalog/catalog.html HTTP/1.0" 200 4200 "-" "python-requests/2.31.0" "172.20.0.1" 172.20.0.1 - - [2025-06-17T03:08:02+00:00] "GET /thredds/catalog/catalog.html HTTP/1.1" 200 4219 "-" "python-requests/2.31.0" "-" 172.20.0.1 - - [2025-06-17T03:08:04+00:00] "GET /twitcher/ows/proxy/thredds/wms/birdhouse/testdata/ta_Amon_MRI-CGCM3_decadal1980_r1i1p1_199101-200012.nc?service=WMS&version=1.3.0&request=GetCapabilities HTTP/1.1" 200 19320 "-" "python-requests/2.31.0" "-" 172.20.0.1 - - [2025-06-17T03:08:06+00:00] "GET /twitcher/ows/proxy/thredds/wms/birdhouse/testdata/ta_Amon_MRI-CGCM3_decadal1980_r1i1p1_199101-200012.nc?service=WMS&version=1.3.0&request=GetCapabilities HTTP/1.1" 200 19320 "-" "python-requests/2.31.0" "-" 172.20.0.1 - - [2025-06-17T03:08:07+00:00] "GET /twitcher/ows/proxy/thredds/wms/birdhouse/testdata/ta_Amon_MRI-CGCM3_decadal1980_r1i1p1_199101-200012.nc?service=WMS&version=1.3.0&request=GetCapabilities HTTP/1.1" 200 19320 "-" "python-requests/2.31.0" "-" 192.168.0.45 - - [2025-06-17T03:08:32+00:00] "GET /twitcher/ows/proxy/thredds/dodsC/birdhouse/testdata/ta_Amon_MRI-CGCM3_decadal1980_r1i1p1_199101-200012.nc.dds HTTP/1.1" 200 584 "-" "oc4.9.2" "-" 192.168.0.45 - - [2025-06-17T03:08:32+00:00] "GET /twitcher/ows/proxy/thredds/dodsC/birdhouse/testdata/ta_Amon_MRI-CGCM3_decadal1980_r1i1p1_199101-200012.nc.das HTTP/1.1" 200 3684 "-" "oc4.9.2" "-" 192.168.0.45 - - [2025-06-17T03:08:32+00:00] "GET /twitcher/ows/proxy/thredds/dodsC/birdhouse/testdata/ta_Amon_MRI-CGCM3_decadal1980_r1i1p1_199101-200012.nc.dds HTTP/1.1" 200 584 "-" "oc4.9.2" "-" 192.168.0.45 - - [2025-06-17T03:08:32+00:00] "GET /twitcher/ows/proxy/thredds/dodsC/birdhouse/testdata/ta_Amon_MRI-CGCM3_decadal1980_r1i1p1_199101-200012.nc.dods?time,time_bnds,plev,lat,lat_bnds,lon,lon_bnds HTTP/1.1" 200 15027 "-" "oc4.9.2" "-" """ for line in log.strip().splitlines(): plex.parse_line(line.strip()) samples = list(get_samples(plex.counter.collect(), "thredds_transfer_size_bytes")) assert len(samples) == 2 s1, s2 = samples > assert s1.value == (584 + 3684 + 584)/1024, "Total size does not match expected value" E AssertionError: Total size does not match expected value E assert 4852.0 == (((584 + 3684) + 584) / 1024) E + where 4852.0 = Sample(name='thredds_transfer_size_bytes_total', labels={'remote_addr': '192.168.0.45', 'tds_service': 'dodsC', 'datas...adal1980_r1i1p1_199101-200012.nc', 'variable': ''}, value=4852.0, timestamp=None, exemplar=None, native_histogram=None).value tests/unit/test_prometheus_log_exporter.py:30: AssertionError ```
1 parent 2b959d8 commit 7f6754c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/unit/test_prometheus_log_exporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def test_550(plex):
2727
assert len(samples) == 2
2828

2929
s1, s2 = samples
30-
assert s1.value == (584 + 3684 + 584)/1024, "Total size does not match expected value"
30+
assert s1.value == 584 + 3684 + 584, "Total size does not match expected value"
3131
assert s1.labels["dataset"] == "birdhouse/testdata/ta_Amon_MRI-CGCM3_decadal1980_r1i1p1_199101-200012.nc"
3232
assert s1.labels["tds_service"] == "dodsC", "Service type does not match expected value"
3333
assert s1.labels["variable"] == ""
3434

35-
assert s2.value == 15027 / 1024
35+
assert s2.value == 15027
3636
assert s2.labels["variable"] == "time,time_bnds,plev,lat,lat_bnds,lon,lon_bnds"
3737

3838

0 commit comments

Comments
 (0)