Skip to content

Commit 212e1e3

Browse files
Fix aggregate reading a TestRun attribute that does not exist (#1097)
Signed-off-by: Serhiy Bzhezytskyy <me@serhiy-bzhezytskyy.com>
1 parent a588056 commit 212e1e3

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

osbenchmark/aggregator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def update_config_object(self, test_run: TestRun) -> None:
166166
self.config.add(config.Scope.applicationOverride, "test_run", "pipeline", test_run.pipeline)
167167
self.config.add(config.Scope.applicationOverride, "workload", "params", test_run.workload_params)
168168
self.config.add(config.Scope.applicationOverride, "builder",
169-
"cluster_config.params", test_run.cluster_config_instance_params)
169+
"cluster_config.params", test_run.cluster_config_params)
170170
self.config.add(config.Scope.applicationOverride, "builder", "plugin.params", test_run.plugin_params)
171171
self.config.add(config.Scope.applicationOverride, "workload", "latency.percentiles", test_run.latency_percentiles)
172172
self.config.add(config.Scope.applicationOverride, "workload", "throughput.percentiles", test_run.throughput_percentiles)

tests/aggregator_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from unittest.mock import Mock
22
import pytest
33
from osbenchmark import config
4+
from osbenchmark import metrics
45
from osbenchmark.aggregator import Aggregator, AggregatedResults
56

67
@pytest.fixture
@@ -120,6 +121,21 @@ def test_calculate_weighted_average(aggregator):
120121
assert result["latency"]["avg"] == 16 # (10*2 + 20*3) / (2+3)
121122
assert result["latency"]["unit"] == "ms"
122123

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+
123139
def test_calculate_rsd(aggregator):
124140
values = [1, 2, 3, 4, 5]
125141
rsd = aggregator.calculate_rsd(values, "test_metric")

0 commit comments

Comments
 (0)