Skip to content
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 specify static responses #1234

Merged

Conversation

danielmitterdorfer
Copy link
Member

With this commit we add the ability to short-circuit Rally's networking layer
and instead of targeting a real cluster, Rally will return static user-defined
responses. This simplifies client-side analysis for bottlenecks or load driver
behavior in general which previously required to setup a stub server (e.g.
nginx)

@danielmitterdorfer danielmitterdorfer added enhancement Improves the status quo :Load Driver Changes that affect the core of the load driver such as scheduling, the measurement approach etc. labels Apr 7, 2021
@danielmitterdorfer danielmitterdorfer added this to the 2.1.1 milestone Apr 7, 2021
@danielmitterdorfer danielmitterdorfer self-assigned this Apr 7, 2021
Copy link
Contributor

@dliappis dliappis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is a very useful PR for stubbing ES responses easily.

I left a few questions/suggestions.

# pylint: disable=unused-variable
def f(p):
return True
return f
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively we could replace the closures with more Pythonic (IMHO? :) ) lambdas e.g.

return lambda f: True

or for startswith:

def startswith(path_pattern):
    return lambda f: f.startswith(path_pattern)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented this with lambdas earlier but then got a PEP-8 violation warning. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL whaaaaaat?

return f

@staticmethod
def endswith(path_pattern):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thought, we could enhance it in the future and support simple shell like patterns like *_snapshot/frozen* easily with https://docs.python.org/3/library/fnmatch.html. This could be quite useful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Before we enhance it, we should probably run microbenchmarks to get a better grasp of the overhead though because we're on the hot code path.

esrally race --track=geonames --challenge=append-no-conflicts-index-only --pipeline=benchmark-only --skip-rest-api-check --distribution-version=8.0.0 --client-options="static_responses:'responses.json'"

.. note::
Use ``--skip-rest-api-check`` to ensure that Rally skips any probing requests that are not directly related to the benchmark (e.g. checks whether the cluster is up).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we automatically skip rest api checks when static_responses is defined?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the idea! I've pushed a change in af77d1b. In that change I've also:

  • Turned --skip-rest-api-check into an undocumented flag again. With the changes in this PR it's also likely that we won't need that flag at all in the future but I'd like to keep it for now.
  • Improved logging
  • Avoided issuing any additional requests (probing for cluster version, telemetry devices) when static responses are enabled.

Copy link
Contributor

@dliappis dliappis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one suggestion (up to you to implement), but LGTM. This is very useful!


Save the above responses as ``responses.json`` and execute a benchmark as follows::

esrally race --track=geonames --challenge=append-no-conflicts-index-only --pipeline=benchmark-only --distribution-version=8.0.0 --client-options="static_responses:'responses.json'"
Copy link
Contributor

@dliappis dliappis Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a few seconds to realize that while specifying a pipeline it won't really target any ES. One might even use the default pipeline, ES will get launched but won't be used.

Should we clarify with a note here or above in the client-options section that when static_responses:'file' is used, the use should also specify the benchmark-only pipeline and the distribution-version as Rally doesn't have a way to derive the version automatically as it'd normally do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've added a note in 37c0900.

@danielmitterdorfer danielmitterdorfer merged commit 3815151 into elastic:master Apr 12, 2021
@danielmitterdorfer danielmitterdorfer deleted the static-responses branch April 12, 2021 10:05
@danielmitterdorfer danielmitterdorfer modified the milestones: 2.1.1, 2.2.0 Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves the status quo :Load Driver Changes that affect the core of the load driver such as scheduling, the measurement approach etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants