-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fixing code snippet testing for attributes that contain a period #28770
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
Labels
>test
Issues or PRs that are addressing/adding tests
Comments
nik9000
added a commit
to nik9000/elasticsearch
that referenced
this issue
Mar 6, 2018
`$_path` is used by documentation tests to ignore a value from a response, for example: ``` [source,js] ---- { "count": 1, "datafeeds": [ { "datafeed_id": "datafeed-total-requests", "state": "started", "node": { ... "attributes": { "ml.machine_memory": "17179869184", "ml.max_open_jobs": "20", "ml.enabled": "true" } }, "assignment_explanation": "" } ] } ---- // TESTRESPONSE[s/"17179869184"/$body.$_path/] ``` That example shows `17179869184` in the compiled docs but when it runs the tests generated by that doc it ignores `17179869184` and asserts instead that there is a value in that field. This is required because we can't predict things like "how many milliseconds will this take?" and "how much memory will this take?". Before this change it was impossible to use `$_path` when any component of the path contained a `.`. This fixes the `$_path` evaluator to properly escape `.`. Closes elastic#28770
nik9000
added a commit
that referenced
this issue
Mar 19, 2018
`$_path` is used by documentation tests to ignore a value from a response, for example: ``` [source,js] ---- { "count": 1, "datafeeds": [ { "datafeed_id": "datafeed-total-requests", "state": "started", "node": { ... "attributes": { "ml.machine_memory": "17179869184", "ml.max_open_jobs": "20", "ml.enabled": "true" } }, "assignment_explanation": "" } ] } ---- // TESTRESPONSE[s/"17179869184"/$body.$_path/] ``` That example shows `17179869184` in the compiled docs but when it runs the tests generated by that doc it ignores `17179869184` and asserts instead that there is a value in that field. This is required because we can't predict things like "how many milliseconds will this take?" and "how much memory will this take?". Before this change it was impossible to use `$_path` when any component of the path contained a `.`. This fixes the `$_path` evaluator to properly escape `.`. Closes #28770
nik9000
added a commit
that referenced
this issue
Mar 19, 2018
`$_path` is used by documentation tests to ignore a value from a response, for example: ``` [source,js] ---- { "count": 1, "datafeeds": [ { "datafeed_id": "datafeed-total-requests", "state": "started", "node": { ... "attributes": { "ml.machine_memory": "17179869184", "ml.max_open_jobs": "20", "ml.enabled": "true" } }, "assignment_explanation": "" } ] } ---- // TESTRESPONSE[s/"17179869184"/$body.$_path/] ``` That example shows `17179869184` in the compiled docs but when it runs the tests generated by that doc it ignores `17179869184` and asserts instead that there is a value in that field. This is required because we can't predict things like "how many milliseconds will this take?" and "how much memory will this take?". Before this change it was impossible to use `$_path` when any component of the path contained a `.`. This fixes the `$_path` evaluator to properly escape `.`. Closes #28770
@lcawl this should be fixed in master and 6.x. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue is related to the instructions in https://github.com/elastic/elasticsearch/blob/master/docs/README.asciidoc
// TESTRESPONSE[s/"17179869184"/$body.$_path/] failed because it seemed to stumble over the periods in this code snippet:
The work-around is as follows:
TESTRESPONSE[s/"17179869184"/$body.datafeeds.0.node.attributes.ml\.machine_memory/]
Ideally the code snippet testing would be better able to handle the periods.
The text was updated successfully, but these errors were encountered: