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

Extend error msg to specify operation name for missing index #872

Merged
merged 3 commits into from
Jan 20, 2020
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
2 changes: 1 addition & 1 deletion esrally/driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ def schedule_for(current_track, task, client_index):
sched = scheduler.scheduler_for(task.schedule, task.params)
logger.info("Choosing [%s] for [%s].", sched, task)
runner_for_op = runner.runner_for(op.type)
params_for_op = track.operation_parameters(current_track, op).partition(client_index, num_clients)
params_for_op = track.operation_parameters(current_track, task).partition(client_index, num_clients)

if requires_time_period_schedule(task, runner_for_op, params_for_op):
warmup_time_period = task.warmup_time_period if task.warmup_time_period else 0
Expand Down
7 changes: 4 additions & 3 deletions esrally/track/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,12 @@ def track_file(self, track_name):
return self._track_file


def operation_parameters(t, op):
def operation_parameters(t, task):
op = task.operation
if op.param_source:
return params.param_source_for_name(op.param_source, t, op.params)
else:
return params.param_source_for_operation(op.type, t, op.params)
return params.param_source_for_operation(op.type, t, op.params, task.name)


def used_corpora(t, cfg):
Expand All @@ -323,7 +324,7 @@ def used_corpora(t, cfg):
challenge = t.find_challenge_or_default(cfg.opts("track", "challenge.name"))
for task in challenge.schedule:
for sub_task in task:
param_source = operation_parameters(t, sub_task.operation)
param_source = operation_parameters(t, sub_task)
if hasattr(param_source, "corpora"):
for c in param_source.corpora:
# We might have the same corpus *but* they contain different doc sets. Therefore also need to union over doc sets.
Expand Down
8 changes: 4 additions & 4 deletions esrally/track/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
__PARAM_SOURCES_BY_NAME = {}


def param_source_for_operation(op_type, track, params):
def param_source_for_operation(op_type, track, params, task_name):
try:
# we know that this can only be a Rally core parameter source
return __PARAM_SOURCES_BY_OP[op_type](track, params)
return __PARAM_SOURCES_BY_OP[op_type](track, params, operation_name=task_name)
except KeyError:
return ParamSource(track, params)
return ParamSource(track, params, operation_name=task_name)


def param_source_for_name(name, track, params):
Expand Down Expand Up @@ -365,7 +365,7 @@ def __init__(self, track, params, **kwargs):
}

if not index_name:
raise exceptions.InvalidSyntax("'index' is mandatory")
raise exceptions.InvalidSyntax("'index' is mandatory and is missing for operation '{}'".format(kwargs.get("operation_name")))

if pages:
self.query_params["pages"] = pages
Expand Down
13 changes: 13 additions & 0 deletions tests/track/params_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,19 @@ def test_passes_cache(self):
}
}, p["body"])

def test_create_without_index(self):
with self.assertRaises(exceptions.InvalidSyntax) as ctx:
params.SearchParamSource(track=track.Track(name="unit-test"), params={
"type": "type1",
"body": {
"query": {
"match_all": {}
}
}
}, operation_name="test_operation")

self.assertEqual("'index' is mandatory and is missing for operation 'test_operation'", ctx.exception.args[0])

def test_passes_request_parameters(self):
index1 = track.Index(name="index1", types=["type1"])

Expand Down