REST-spec: Allow stashed values to be used in property names as well
Fix the nodes.info/20_transport test to use the master node, rather than to rely on applying a regex to the whole $body
This commit is contained in:
parent
a55476bf70
commit
e7ac5f296e
|
@ -168,11 +168,28 @@ The last response obtained gets always stashed automatically as a string, called
|
|||
This is useful when needing to test apis that return text rather than json (e.g. cat api),
|
||||
as it allows to treat the whole body as an ordinary string field.
|
||||
|
||||
Stashed values can be used in property names, eg:
|
||||
|
||||
....
|
||||
- do:
|
||||
cluster.state: {}
|
||||
|
||||
- set: {master_node: master}
|
||||
|
||||
- do:
|
||||
nodes.info:
|
||||
metric: [ transport ]
|
||||
|
||||
- is_true: nodes.$master.transport.profiles
|
||||
....
|
||||
|
||||
|
||||
Note that not only expected values can be retrieved from the stashed values (as in the
|
||||
example above), but the same goes for actual values:
|
||||
|
||||
....
|
||||
- match: { $body: /^.+$/ } # the returned `body` matches the provided regex
|
||||
- match: { $body: /^.+$/ } # the returned `body` matches the provided regex if the body is text
|
||||
- match: { $body: {} } # the returned `body` matches the JSON object if the body is JSON
|
||||
....
|
||||
|
||||
The stash should be reset at the beginning of each test file.
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
---
|
||||
|
||||
"node_info test profile is empty":
|
||||
- do:
|
||||
cluster.state: {}
|
||||
|
||||
- set: {master_node: master}
|
||||
|
||||
- do:
|
||||
nodes.info:
|
||||
metric: [ transport ]
|
||||
|
||||
# there is no possbility to use is_true here due to unknown node_id
|
||||
# which is part of the path, just checking for profiles in the body
|
||||
- match: { $body: /profiles/ }
|
||||
- is_true: nodes.$master.transport.profiles
|
||||
|
|
Loading…
Reference in New Issue