-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to benchmark Elasticsearch with and without x-pack #485
Merged
danielmitterdorfer
merged 12 commits into
elastic:master
from
danielmitterdorfer:cars-v1
Apr 27, 2018
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5c40c19
Remove plugin-specific names in bootstrap handler
danielmitterdorfer 987a825
Introduce team versioning
danielmitterdorfer d629acf
Read variables also from car config bases
danielmitterdorfer ca27b01
Externalize Elasticsearch build commands
danielmitterdorfer 7b81007
Invoke install hooks for cars
danielmitterdorfer dd98aef
Add usage examples to docs
danielmitterdorfer d67cc2b
Hyphenate x-pack mixins
danielmitterdorfer d1e0079
Allow multiple cars to refer to the same hook
danielmitterdorfer f923b9d
Use mock#call_count instead of assert_not_called
danielmitterdorfer e582fab
Skip PostLaunchHook for external clusters
danielmitterdorfer 9a768d8
Reword error message
danielmitterdorfer f50c579
Fix newlines
danielmitterdorfer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -327,6 +327,8 @@ def __init__(self, name, core_plugin=False, config=None, root_path=None, config_ | |
self.root_path = root_path | ||
self.config_paths = config_paths | ||
self.variables = variables | ||
# name of the initial Python file to load for plugins. | ||
self.entry_point = "plugin" | ||
|
||
def __str__(self): | ||
return "Plugin descriptor for [%s]" % self.name | ||
|
@@ -344,28 +346,37 @@ def __eq__(self, other): | |
return isinstance(other, type(self)) and (self.name, self.config, self.core_plugin) == (other.name, other.config, other.core_plugin) | ||
|
||
|
||
class PluginBootstrapPhase(Enum): | ||
class BootstrapPhase(Enum): | ||
post_install = 10 | ||
post_launch = 20 | ||
|
||
@classmethod | ||
def valid(cls, name): | ||
for n in PluginBootstrapPhase.names(): | ||
for n in BootstrapPhase.names(): | ||
if n == name: | ||
return True | ||
return False | ||
|
||
@classmethod | ||
def names(cls): | ||
return [p.name for p in list(PluginBootstrapPhase)] | ||
return [p.name for p in list(BootstrapPhase)] | ||
|
||
|
||
class PluginBootstrapHookHandler: | ||
def __init__(self, plugin, loader_class=modules.ComponentLoader): | ||
self.plugin = plugin | ||
class BootstrapHookHandler: | ||
""" | ||
Responsible for loading and executing component-specific intitialization code. | ||
""" | ||
def __init__(self, component, loader_class=modules.ComponentLoader): | ||
""" | ||
Creates a new BootstrapHookHandler. | ||
|
||
:param component: The component that should be loaded. In practice, this is a PluginDescriptor instance. | ||
:param loader_class: The implementation that loads the provided component's code. | ||
""" | ||
self.component = component | ||
# Don't allow the loader to recurse. The subdirectories may contain Elasticsearch specific files which we do not want to add to | ||
# Rally's Python load path. We may need to define a more advanced strategy in the future. | ||
self.loader = loader_class(root_path=self.plugin.root_path, component_entry_point="plugin", recurse=False) | ||
self.loader = loader_class(root_path=self.component.root_path, component_entry_point=self.component.entry_point, recurse=False) | ||
self.hooks = {} | ||
|
||
def can_load(self): | ||
|
@@ -380,24 +391,25 @@ def load(self): | |
# just pass our own exceptions transparently. | ||
raise | ||
except BaseException: | ||
msg = "Could not load plugin bootstrap hooks in [{}]".format(self.loader.root_path) | ||
msg = "Could not load bootstrap hooks in [{}]".format(self.loader.root_path) | ||
logger.exception(msg) | ||
raise exceptions.SystemSetupError(msg) | ||
|
||
def register(self, phase, hook): | ||
logger.info("Registering plugin bootstrap hook [%s] for phase [%s] in plugin [%s]", hook.__name__, phase, self.plugin.name) | ||
if not PluginBootstrapPhase.valid(phase): | ||
raise exceptions.SystemSetupError("Phase [{}] is unknown. Valid phases are: {}.".format(phase, PluginBootstrapPhase.names())) | ||
logger.info("Registering bootstrap hook [%s] for phase [%s] in component [%s]", hook.__name__, phase, self.component.name) | ||
if not BootstrapPhase.valid(phase): | ||
raise exceptions.SystemSetupError("Unknown bootstrap phase [{}]. Valid phases are: {}.".format(phase, BootstrapPhase.names())) | ||
if phase not in self.hooks: | ||
self.hooks[phase] = [] | ||
self.hooks[phase].append(hook) | ||
|
||
def invoke(self, phase, **kwargs): | ||
if phase in self.hooks: | ||
logger.info("Invoking phase [%s] for plugin [%s] in config [%s]", phase, self.plugin.name, self.plugin.config) | ||
logger.info("Invoking phase [%s] for component [%s] in config [%s]", phase, self.component.name, self.component.config) | ||
for hook in self.hooks[phase]: | ||
logger.info("Invoking hook [%s].", hook.__name__) | ||
logger.info("Invoking bootstrap hook [%s].", hook.__name__) | ||
# hooks should only take keyword arguments to be forwards compatible with Rally! | ||
hook(config_names=self.plugin.config, **kwargs) | ||
hook(config_names=self.component.config, **kwargs) | ||
else: | ||
logger.debug("Plugin [%s] in config [%s] has no hook registered for phase [%s].", self.plugin.name, self.plugin.config, phase) | ||
logger.debug("Component [%s] in config [%s] has no hook registered for phase [%s].", | ||
self.component.name, self.component.config, phase) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline missing here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline missing as pointed by GitHub
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.