|
1 | 1 | from unittest.mock import Mock |
2 | 2 | import pytest |
3 | 3 | from osbenchmark import config |
| 4 | +from osbenchmark import metrics |
4 | 5 | from osbenchmark.aggregator import Aggregator, AggregatedResults |
5 | 6 |
|
6 | 7 | @pytest.fixture |
@@ -120,6 +121,21 @@ def test_calculate_weighted_average(aggregator): |
120 | 121 | assert result["latency"]["avg"] == 16 # (10*2 + 20*3) / (2+3) |
121 | 122 | assert result["latency"]["unit"] == "ms" |
122 | 123 |
|
| 124 | +def test_update_config_object_reads_attributes_that_test_runs_actually_have(aggregator): |
| 125 | + # a real TestRun, not a Mock: a Mock creates whatever attribute is asked of it, so it cannot |
| 126 | + # tell us whether update_config_object reads attributes that a test run really carries |
| 127 | + test_run = metrics.TestRun( |
| 128 | + benchmark_version="1.0.0", benchmark_revision="abc123", environment_name="unit-test", |
| 129 | + test_run_id="test1", test_run_timestamp="20250101T000000Z", pipeline="benchmark-only", |
| 130 | + user_tags={}, workload="workload1", workload_params={}, test_procedure="test_proc1", |
| 131 | + cluster_config=["external"], cluster_config_params={"heap_size": "6g"}, plugin_params={}, |
| 132 | + meta_data={}) |
| 133 | + |
| 134 | + aggregator.update_config_object(test_run) |
| 135 | + |
| 136 | + aggregator.config.add.assert_any_call(config.Scope.applicationOverride, "builder", |
| 137 | + "cluster_config.params", {"heap_size": "6g"}) |
| 138 | + |
123 | 139 | def test_calculate_rsd(aggregator): |
124 | 140 | values = [1, 2, 3, 4, 5] |
125 | 141 | rsd = aggregator.calculate_rsd(values, "test_metric") |
|
0 commit comments