This is an automated email from the ASF dual-hosted git repository.
janhoy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-orbit.git
The following commit(s) were added to refs/heads/main by this push:
new 74c1a507 Restore metrics.metrics_store_class so solr-orbit stop works
again (#124)
74c1a507 is described below
commit 74c1a50790b1997590579fc8ae088b10233d5e68
Author: Syed Ahnaf Raza <[email protected]>
AuthorDate: Sat Oct 17 04:29:41 2026 +0500
Restore metrics.metrics_store_class so solr-orbit stop works again (#124)
* Test that solr-orbit stop can open the metrics store
builder.stop() and the builder actor call metrics.metrics_store_class(),
which no longer exists, so stopping a node fails with an AttributeError (#123).
* Restore metrics.metrics_store_class so solr-orbit stop works again
The builder still selects the metrics store class through this helper,
which went away when metrics_store() started picking the class inline. Bring it
back and let metrics_store() use it, so both paths pick the same store.
Fixes #123
---
solrorbit/metrics.py | 12 ++++++++++--
tests/builder/mechanic_test.py | 32 ++++++++++++++++++++++++++++++++
tests/metrics_test.py | 14 ++++++++++++++
3 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/solrorbit/metrics.py b/solrorbit/metrics.py
index 070e34cd..ada94680 100644
--- a/solrorbit/metrics.py
+++ b/solrorbit/metrics.py
@@ -74,6 +74,15 @@ def calculate_system_results(store, node_name):
return calc()
+def metrics_store_class(cfg):
+ """
+ :param cfg: Config object.
+ :return: The metrics store class selected by the ``datastore.type``
reporting option.
+ """
+ store_type = cfg.opts("reporting", "datastore.type", mandatory=False,
default_value="in-memory")
+ return FilesystemMetricsStore if store_type == "filesystem" else
InMemoryMetricsStore
+
+
def metrics_store(cfg, read_only=True, workload=None, test_procedure=None,
cluster_config=None, meta_info=None):
"""
Creates a proper metrics store based on the current configuration.
@@ -82,8 +91,7 @@ def metrics_store(cfg, read_only=True, workload=None,
test_procedure=None, clust
:param read_only: Whether to open the metrics store only for reading
(Default: True).
:return: A metrics store implementation.
"""
- store_type = cfg.opts("reporting", "datastore.type", mandatory=False,
default_value="in-memory")
- cls = FilesystemMetricsStore if store_type == "filesystem" else
InMemoryMetricsStore
+ cls = metrics_store_class(cfg)
store = cls(cfg=cfg, meta_info=meta_info)
logging.getLogger(__name__).info("Creating %s", str(store))
diff --git a/tests/builder/mechanic_test.py b/tests/builder/mechanic_test.py
index 33dfc6f8..cdc625c3 100644
--- a/tests/builder/mechanic_test.py
+++ b/tests/builder/mechanic_test.py
@@ -25,6 +25,7 @@
# specific language governing permissions and limitations
# under the License.
+import datetime
import unittest.mock as mock
from unittest import TestCase
@@ -142,6 +143,37 @@ class BuilderTests(TestCase):
self.assertFalse(launcher.started)
self.assertEqual(cleanup.call_count, 2)
+ @mock.patch("solrorbit.paths.install_root", return_value="/install-root")
+ @mock.patch("solrorbit.builder.builder._delete_node_file")
+ @mock.patch("solrorbit.builder.builder._load_node_file")
+ @mock.patch("solrorbit.builder.provisioner.cleanup")
+ @mock.patch("solrorbit.builder.provisioner.load_node_configuration")
+ @mock.patch("solrorbit.builder.launcher.ProcessLauncher")
+ @mock.patch("solrorbit.metrics.results_store")
+ @mock.patch("solrorbit.metrics.test_run_store")
+ def test_stop_persists_system_metrics_of_the_test_run(self,
test_run_store, results_store, process_launcher,
+
load_node_configuration, cleanup, load_node_file,
+ delete_node_file,
install_root):
+ cfg = config.Config()
+ cfg.add(config.Scope.application, "system", "env.name", "unittest")
+ cfg.add(config.Scope.application, "workload", "params", {})
+ cfg.add(config.Scope.application, "builder", "preserve.install", False)
+ load_node_configuration.return_value = mock.Mock(build_type="tar",
binary_path="/install", data_paths=["/data"])
+ load_node_file.return_value =
([BuilderTests.Node("benchmark-node-0")], "17")
+ current_test_run = mock.Mock(test_run_id="17",
test_run_timestamp=datetime.datetime(2026, 10, 16),
+ workload_name="geonames",
test_procedure_name="append-no-conflicts")
+ test_run_store.return_value.find_by_test_run_id.return_value =
current_test_run
+
+ builder.stop(cfg)
+
+ nodes, metrics_store =
process_launcher.return_value.stop.call_args.args
+ self.assertEqual(["benchmark-node-0"], [node.node_name for node in
nodes])
+ self.assertEqual("17", metrics_store.open_context["test-run-id"])
+ current_test_run.add_results.assert_called_once()
+
results_store.return_value.store_results.assert_called_once_with(current_test_run)
+ delete_node_file.assert_called_once_with("/install-root")
+ cleanup.assert_called_once_with(preserve=False,
install_dir="/install", data_paths=["/data"])
+
class ClusterDistributionVersionTests(TestCase):
@staticmethod
diff --git a/tests/metrics_test.py b/tests/metrics_test.py
index 7cee51b8..f24a72dd 100644
--- a/tests/metrics_test.py
+++ b/tests/metrics_test.py
@@ -94,6 +94,20 @@ class ExtractUserTagsTests(TestCase):
self.assertDictEqual({"os": "Linux", "cpu": "ARM"},
metrics.extract_user_tags_from_config(cfg))
+class MetricsStoreClassTests(TestCase):
+ def test_defaults_to_the_in_memory_store(self):
+ cfg = config.Config()
+ self.assertIs(metrics.InMemoryMetricsStore,
metrics.metrics_store_class(cfg))
+
+ def test_selects_the_configured_store(self):
+ for store_type, store_class in [("in-memory",
metrics.InMemoryMetricsStore),
+ ("filesystem",
metrics.FilesystemMetricsStore)]:
+ with self.subTest(store_type=store_type):
+ cfg = config.Config()
+ cfg.add(config.Scope.application, "reporting",
"datastore.type", store_type)
+ self.assertIs(store_class, metrics.metrics_store_class(cfg))
+
+
class InMemoryMetricsStoreTests(TestCase):
TEST_RUN_TIMESTAMP = datetime.datetime(2016, 1, 31)
TEST_RUN_ID = "6ebc6e53-ee20-4b0c-99b4-09697987e9f4"