Skip to content

Commit 55ff5a3

Browse files
committed
Run method even when ssh not present
Signed-off-by: Sylvain Hellegouarch <sh@defuze.org>
1 parent f9cf4e0 commit 55ff5a3

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

33
## [Unreleased][]
44

5-
[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-lib/compare/1.13.0...HEAD
5+
[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-lib/compare/1.13.1...HEAD
6+
7+
## [1.13.1][] - 2020-09-07
8+
9+
[1.13.1]: https://github.com/chaostoolkit/chaostoolkit-lib/compare/1.13.0...1.13.1
10+
11+
### Changed
12+
13+
- Ensure the method is always executed, even when no steady-state was provided
14+
in the experiment.
615

716
## [1.13.0][] - 2020-09-07
817

chaoslib/hypothesis.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ def run_steady_state_hypothesis(experiment: Experiment,
177177
}
178178
hypo = experiment.get("steady-state-hypothesis")
179179
if not hypo:
180-
logger.info(
181-
"No steady state hypothesis defined. That's ok, just exploring.")
180+
logger.debug("No hypothesis declared.")
182181
return
183182

184183
logger.info("Steady state hypothesis: {h}".format(h=hypo.get("title")))

chaoslib/run.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,32 +334,38 @@ def _run(self, strategy: Strategy, schedule: Schedule, # noqa: C901
334334
"rollbacks", {}).get("strategy", "default")
335335
logger.info("Rollbacks strategy: {}".format(rollback_strategy))
336336

337+
with_ssh = has_steady_state_hypothesis_with_probes(experiment)
338+
if not with_ssh:
339+
logger.info(
340+
"No steady state hypothesis defined. That's ok, just "
341+
"exploring.")
342+
337343
try:
338344
try:
339345
control.begin(
340346
"experiment", experiment, experiment, configuration,
341347
secrets)
342348

343349
state = object()
344-
if should_run_before_method(strategy):
350+
if with_ssh and should_run_before_method(strategy):
345351
state = run_gate_hypothesis(
346352
experiment, journal, configuration, secrets,
347353
event_registry, dry)
348354

349355
if state is not None:
350-
if should_run_during_method(strategy):
356+
if with_ssh and should_run_during_method(strategy):
351357
run_hypothesis_during_method(
352358
hypo_pool, continous_hypo_event, strategy,
353359
schedule, experiment, journal, configuration,
354360
secrets, event_registry, dry)
355361

356362
state = run_method(
357-
strategy, activity_pool, experiment, journal,
358-
configuration, secrets, event_registry, dry)
363+
strategy, activity_pool, experiment, journal,
364+
configuration, secrets, event_registry, dry)
359365

360366
continous_hypo_event.set()
361367
if journal["status"] not in ["interrupted", "aborted"]:
362-
if state is not None and \
368+
if with_ssh and (state is not None) and \
363369
should_run_after_method(strategy):
364370
run_deviation_validation_hypothesis(
365371
experiment, journal, configuration, secrets,
@@ -522,6 +528,7 @@ def run_method(strategy: Strategy, activity_pool: ThreadPoolExecutor,
522528
configuration: Configuration, secrets: Secrets,
523529
event_registry: EventHandlerRegistry,
524530
dry: bool = False) -> Optional[List[Run]]:
531+
logger.info("Playing your experiment's method now...")
525532
event_registry.start_method(experiment)
526533
try:
527534
state = apply_activities(
@@ -760,3 +767,12 @@ def apply_rollbacks(experiment: Experiment, configuration: Configuration,
760767
control.with_state(result)
761768

762769
return result
770+
771+
772+
def has_steady_state_hypothesis_with_probes(experiment: Experiment) -> bool:
773+
steady_state_hypothesis = experiment.get("steady-state-hypothesis")
774+
if steady_state_hypothesis:
775+
probes = steady_state_hypothesis.get("probes")
776+
if probes:
777+
return len(probes) > 0
778+
return False

0 commit comments

Comments
 (0)