Simpify assignment of workload parameters target_throughout and search_clients #82
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.
Description
Simplify the assignment of parameters
target-throughput
andsearch_clients
to reduce the code duplication, which was introduced in the commit dd2ff3b.Initially I planned to use Jinja
macro
syntax to reuse the redundant codes, but after looking at the target codes, I think simplifying the code itself might be a better option.For
target_throughput
, I propose to change fromto
For
search_clients
, I propose to change fromto
or from
to
Some reasons:
target-throughput
, there was a specified value assigned to everywhere has got the field, so it's typical to use"target-throughput": {{ target_throughput | default(2) }}
to assign a default value if adding the ability to assign custom value. This way is commonly used in the repository, such as https://github.com/opensearch-project/opensearch-benchmark-workloads/blob/1/nyc_taxis/test_procedures/default.json#L34 and https://github.com/opensearch-project/opensearch-benchmark-workloads/blob/1/so/test_procedures/default.json#L12, and there is no need to use the current tedious statements for "target-throughput".Although there is a difference in the error message after the code change, but I think it's acceptable, because there is no such tedious value validation for other fields.
For example, assigning non-number value to
target-throughput
after my code change will throw the following error.The below is the error before my code change:
I guess the error message comes from opensearch-benchmark validates the user input of "target-throughput", although the field is not assigned in json file.
and search_clients
in existing statementif search_clients is defined and search_clients
make no sense in this case. Empty value such asNone
ornone
or "" still be assigned in json file.| tojson
is necessary here in,"clients": {{ search_clients | tojson}}
, looking at the document https://jinja.palletsprojects.com/en/2.11.x/templates/#tojson,tojson()
used to escape certain special characters in HTML contexts. The 2 parameterstarget_throughout
andsearch_clients
has number value, and I don't think escaping character is necessary here.Besides, using expression
| tojson
seems comes from Elasticsearch code elastic/rally-tracks@dcd691f, but don't understand the meaning of that.Testing:
Issues Resolved
#64
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.