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

Add an option to filter by challange in list command #1865

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions esrally/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,9 @@ def _dry_run(self):
def _id(self):
return self.cfg.opts("system", "delete.id")

def _challenge(self):
return self.cfg.opts("system", "list.challenge", mandatory=False)


# Does not inherit from RaceStore as it is only a delegator with the same API.
class CompositeRaceStore:
Expand Down Expand Up @@ -1880,6 +1883,7 @@ def list(self):
name = self._benchmark_name()
from_date = self._from_date()
to_date = self._to_date()
challenge = self._challenge()

filters = [
{
Expand Down Expand Up @@ -1911,6 +1915,8 @@ def list(self):
query["query"]["bool"]["filter"].append(
{"bool": {"should": [{"term": {"user-tags.benchmark-name": name}}, {"term": {"user-tags.name": name}}]}}
)
if challenge:
query["query"]["bool"]["filter"].append({"bool": {"should": [{"term": {"challenge": challenge}}]}})

result = self.client.search(index="%s*" % EsRaceStore.INDEX_PREFIX, body=query)
hits = result["hits"]["total"]
Expand Down
6 changes: 6 additions & 0 deletions esrally/rally.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ def add_track_source(subparser):
type=valid_date,
default=None,
)
list_parser.add_argument(
"--challenge",
help="Show only records from this challenge",
default=None,
)
add_track_source(list_parser)

delete_parser = subparsers.add_parser("delete", help="Delete records")
Expand Down Expand Up @@ -1098,6 +1103,7 @@ def dispatch_sub_command(arg_parser, args, cfg: types.Config):
cfg.add(config.Scope.applicationOverride, "system", "list.races.benchmark_name", args.benchmark_name)
cfg.add(config.Scope.applicationOverride, "system", "list.from_date", args.from_date)
cfg.add(config.Scope.applicationOverride, "system", "list.to_date", args.to_date)
cfg.add(config.Scope.applicationOverride, "system", "list.challenge", args.challenge)
configure_mechanic_params(args, cfg, command_requires_car=False)
configure_track_params(arg_parser, args, cfg, command_requires_track=False)
dispatch_list(cfg)
Expand Down
1 change: 1 addition & 0 deletions esrally/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"include.tasks",
"indices",
"install.id",
"list.challenge",
"list.config.option",
"list.from_date",
"list.max_results",
Expand Down
2 changes: 2 additions & 0 deletions tests/metrics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,8 @@ def test_filter_race(self):
assert len(self.race_store.list()) == 1
self.cfg.add(config.Scope.application, "system", "list.from_date", "20160131")
assert len(self.race_store.list()) == 1
self.cfg.add(config.Scope.application, "system", "list.challenge", t.default_challenge.name)
assert len(self.race_store.list()) == 1

def test_delete_race(self):
self.cfg.add(config.Scope.application, "system", "delete.id", "0101")
Expand Down
Loading