diff --git a/esrally/mechanic/launcher.py b/esrally/mechanic/launcher.py index c45823d41..9fc603346 100644 --- a/esrally/mechanic/launcher.py +++ b/esrally/mechanic/launcher.py @@ -35,20 +35,17 @@ class ClusterLauncher: The cluster launcher performs cluster-wide tasks that need to be done in the startup / shutdown phase. """ - def __init__(self, cfg, metrics_store, on_post_launch=None, client_factory_class=client.EsClientFactory): + def __init__(self, cfg, metrics_store, client_factory_class=client.EsClientFactory): """ Creates a new ClusterLauncher. :param cfg: The config object. :param metrics_store: A metrics store that is configured to receive system metrics. - :param on_post_launch: An optional function that takes the Elasticsearch client as a parameter. It is invoked after the - REST API is available. :param client_factory_class: A factory class that can create an Elasticsearch client. """ self.cfg = cfg self.metrics_store = metrics_store - self.on_post_launch = on_post_launch self.client_factory = client_factory_class def start(self): @@ -98,8 +95,6 @@ def start(self): logger.error("REST API layer is not yet available. Forcefully terminating cluster.") self.stop(c) raise exceptions.LaunchError("Elasticsearch REST API layer is not available. Forcefully terminated cluster.") - if self.on_post_launch: - self.on_post_launch(es_default) return c def stop(self, c): diff --git a/esrally/mechanic/mechanic.py b/esrally/mechanic/mechanic.py index f6bb7f378..41352d791 100644 --- a/esrally/mechanic/mechanic.py +++ b/esrally/mechanic/mechanic.py @@ -360,9 +360,7 @@ def receiveMsg_NodesStopped(self, msg, sender): self.transition_when_all_children_responded(sender, msg, "cluster_stopping", "cluster_stopped", self.on_all_nodes_stopped) def on_all_nodes_started(self): - # we might not have a car if we benchmark external clusters - post_launch_handler = PostLaunchHandler([self.car]) if self.car else None - self.cluster_launcher = launcher.ClusterLauncher(self.cfg, self.metrics_store, on_post_launch=post_launch_handler) + self.cluster_launcher = launcher.ClusterLauncher(self.cfg, self.metrics_store) # Workaround because we could raise a LaunchError here and thespian will attempt to retry a failed message. # In that case, we will get a followup RallyAssertionError because on the second attempt, Rally will check # the status which is now "nodes_started" but we expected the status to be "nodes_starting" previously. @@ -410,21 +408,6 @@ def on_all_nodes_stopped(self): # do not self-terminate, let the parent actor handle this -class PostLaunchHandler: - def __init__(self, components, hook_handler_class=team.BootstrapHookHandler): - self.handlers = [] - if components: - for component in components: - handler = hook_handler_class(component) - if handler.can_load(): - handler.load() - self.handlers.append(handler) - - def __call__(self, client): - for handler in self.handlers: - handler.invoke(team.BootstrapPhase.post_launch.name, client=client) - - @thespian.actors.requireCapability('coordinator') class Dispatcher(thespian.actors.ActorTypeDispatcher): def __init__(self): diff --git a/esrally/mechanic/team.py b/esrally/mechanic/team.py index 941fe9327..f68005da2 100644 --- a/esrally/mechanic/team.py +++ b/esrally/mechanic/team.py @@ -416,7 +416,6 @@ def __eq__(self, other): class BootstrapPhase(Enum): post_install = 10 - post_launch = 20 @classmethod def valid(cls, name): diff --git a/tests/mechanic/launcher_test.py b/tests/mechanic/launcher_test.py index 0b69543dd..954e2b16d 100644 --- a/tests/mechanic/launcher_test.py +++ b/tests/mechanic/launcher_test.py @@ -110,25 +110,7 @@ class ClusterLauncherTests(TestCase): test_host = opts.TargetHosts("10.0.0.10:9200,10.0.0.11:9200") client_options = opts.ClientOptions('timeout:60') - def test_launches_cluster_with_post_launch_handler(self): - on_post_launch = mock.Mock() - cfg = config.Config() - cfg.add(config.Scope.application, "client", "hosts", self.test_host) - cfg.add(config.Scope.application, "client", "options", self.client_options) - cfg.add(config.Scope.application, "mechanic", "telemetry.devices", []) - cfg.add(config.Scope.application, "mechanic", "telemetry.params", {}) - - cluster_launcher = launcher.ClusterLauncher(cfg, MockMetricsStore(), - on_post_launch=on_post_launch, client_factory_class=MockClientFactory) - cluster = cluster_launcher.start() - - self.assertEqual([{"host": "10.0.0.10", "port":9200}, {"host": "10.0.0.11", "port":9200}], cluster.hosts) - self.assertIsNotNone(cluster.telemetry) - # this requires at least Python 3.6 - # on_post_launch.assert_called_once() - self.assertEqual(1, on_post_launch.call_count) - - def test_launches_cluster_without_post_launch_handler(self): + def test_launches_cluster(self): cfg = config.Config() cfg.add(config.Scope.application, "client", "hosts", self.test_host) cfg.add(config.Scope.application, "client", "options", self.client_options) @@ -161,18 +143,14 @@ def test_launches_cluster_with_telemetry_client_timeout_enabled(self): @mock.patch("time.sleep") def test_error_on_cluster_launch(self, sleep): - on_post_launch = mock.Mock() cfg = config.Config() cfg.add(config.Scope.application, "client", "hosts", self.test_host) # Simulate that the client will raise an error upon startup cfg.add(config.Scope.application, "client", "options", opts.ClientOptions("raise-error-on-info:true")) - #cfg.add(config.Scope.application, "client", "options", {"raise-error-on-info": True}) cfg.add(config.Scope.application, "mechanic", "telemetry.devices", []) cfg.add(config.Scope.application, "mechanic", "telemetry.params", {}) - cluster_launcher = launcher.ClusterLauncher(cfg, MockMetricsStore(), - on_post_launch=on_post_launch, client_factory_class=MockClientFactory) + cluster_launcher = launcher.ClusterLauncher(cfg, MockMetricsStore(), client_factory_class=MockClientFactory) with self.assertRaisesRegex(exceptions.LaunchError, "Elasticsearch REST API layer is not available. Forcefully terminated cluster."): cluster_launcher.start() - self.assertEqual(0, on_post_launch.call_count) diff --git a/tests/mechanic/team_test.py b/tests/mechanic/team_test.py index 71b932a96..9935be149 100644 --- a/tests/mechanic/team_test.py +++ b/tests/mechanic/team_test.py @@ -223,5 +223,5 @@ def test_cannot_register_for_unknown_phase(self): handler.loader.registration_function = hook with self.assertRaises(exceptions.SystemSetupError) as ctx: handler.load() - self.assertEqual("Unknown bootstrap phase [this_is_an_unknown_install_phase]. Valid phases are: ['post_install', 'post_launch'].", + self.assertEqual("Unknown bootstrap phase [this_is_an_unknown_install_phase]. Valid phases are: ['post_install'].", ctx.exception.args[0])