Skip to content

Commit e196962

Browse files
rename the second expect field & add changelog
Signed-off-by: saravanan palanisamy <saravanan30erd@gmail.com>
1 parent 5e7ce91 commit e196962

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

CHANGELOG.md

+19-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44

55
[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-lib/compare/1.15.0...HEAD
66

7+
### Added
8+
9+
- New field `expect_one_of` in `jsonpath` tolerance. Sometimes the json payload
10+
values will be dynamic, e.g. field `status` in response payload may provide
11+
any values(either `ok` or `error` or `info`). Using `expect` field, we can
12+
mention only one value as expected value but sometimes steady state can be
13+
met with one or more values. e.g. you want to define two values either `ok` or
14+
`info` as expected value. In these cases, you can use both `expect` and
15+
`expect_one_of` to define both expected values.[#191][191]
16+
17+
[191]: https://github.com/chaostoolkit/chaostoolkit-lib/pull/191
18+
19+
720
## [1.15.0][] - 2020-09-11
821

922
[1.15.0]: https://github.com/chaostoolkit/chaostoolkit-lib/compare/1.14.1...1.15.0
@@ -136,7 +149,7 @@
136149
was interrupted from a control. With the strategies, you can now decide
137150
that they are always applied, never or only when the experiment deviated.
138151
This is a flag passed to the settings as follows:
139-
152+
140153
```
141154
runtime:
142155
rollbacks:
@@ -215,13 +228,13 @@
215228
### Added
216229

217230
- Optional default value for environment variable in configuration
218-
- Warn the user for an action process returning a non-zero exit code
231+
- Warn the user for an action process returning a non-zero exit code
219232
- Support for process path relative to homedir ~
220233
- Indicate path in validation when path is not found nor executable [#159][159]
221234

222235
### Changed
223236

224-
- Changed the method's one-step minimum requirement.
237+
- Changed the method's one-step minimum requirement.
225238
An experiment with an empty method (without any activities) is now valid.
226239

227240
[159]: https://github.com/chaostoolkit/chaostoolkit-lib/issues/159
@@ -333,7 +346,7 @@
333346

334347
### Changed
335348

336-
- Fix to ensure a control's `configuration` parameter is populated when it the
349+
- Fix to ensure a control's `configuration` parameter is populated when it the
337350
control is being `configured` [#114][114]
338351
- Load and apply global controls, those declared in the settings, from the
339352
`run_experiment` function rather than out of band [#116][116]
@@ -400,7 +413,7 @@
400413
#### Added
401414

402415
- a new tolerance type called `range` to support scenarios such as:
403-
416+
404417
value type is:
405418
```
406419
{
@@ -765,7 +778,7 @@
765778

766779
### Changed
767780

768-
- Log a message when loading the configuration
781+
- Log a message when loading the configuration
769782
- Raise `InvalidExperiment` when a configuration or secret references a key
770783
in the environment and that key does not exist (it may not be set however)
771784
[#40][40]. This bails the experiment at validation time so before it runs.

chaoslib/hypothesis.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -335,19 +335,19 @@ def _(tolerance: dict, value: Any, configuration: Configuration = None,
335335
result = values == expect
336336

337337
if "expect" in tolerance and result is False:
338-
expect_alt = tolerance.get("expect_alt")
339-
if "expect_alt" in tolerance:
340-
if not isinstance(expect_alt, list):
341-
result = values == [expect_alt]
338+
expect_one_of = tolerance.get("expect_one_of")
339+
if "expect_one_of" in tolerance:
340+
if not isinstance(expect_one_of, list):
341+
result = values == [expect_one_of]
342342
else:
343-
result = values == expect_alt
343+
result = values == expect_one_of
344344

345345
if result is False:
346-
if "expect" in tolerance and "expect_alt" in tolerance:
346+
if "expect" in tolerance and "expect_one_of" in tolerance:
347347
logger.debug(
348348
"jsonpath found '{}' but expected '{}' or '{}'".format(
349349
str(values), str(tolerance["expect"]),
350-
str(tolerance["expect_alt"])))
350+
str(tolerance["expect_one_of"])))
351351
elif "expect" in tolerance:
352352
logger.debug(
353353
"jsonpath found '{}' but expected '{}'".format(

tests/test_tolerance.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_tolerance_jsonpath_must_match_expected_value():
143143
"type": "jsonpath",
144144
"path": "$.foo[?(@.baz)].baz",
145145
"expect": [["hello", "bonjour"]],
146-
"expect_alt": [["hello", "joe"]]
146+
"expect_one_of": [["hello", "joe"]]
147147
}
148148
ensure_hypothesis_tolerance_is_valid(t)
149149
assert within_tolerance(
@@ -168,7 +168,7 @@ def test_tolerance_jsonpath_must_match_expected_value():
168168
"type": "jsonpath",
169169
"path": "$.foo[?(@.baz)].baz",
170170
"expect": [[["hello"], ["bonjour"]]],
171-
"expect_alt": [[["hello"], ["joe"]]]
171+
"expect_one_of": [[["hello"], ["joe"]]]
172172
}
173173
ensure_hypothesis_tolerance_is_valid(t)
174174
assert within_tolerance(

0 commit comments

Comments
 (0)