Skip to content

Commit

Permalink
Merge pull request #300 from powerfulseal/no-sleep-before-exit
Browse files Browse the repository at this point in the history
When running a number of loops, don't sleep on the last one
  • Loading branch information
seeker89 committed Aug 25, 2020
2 parents de0d4da + d11585a commit edb7499
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -61,7 +61,7 @@ powerfulseal autonomous --policy-file ./policy.yaml

## Installing

- [docker hub](https://hub.docker.com/r/powerfulseal/powerfulseal/tags): `docker pull powerfulseal/powerfulseal:3.1.0`
- [docker hub](https://hub.docker.com/r/powerfulseal/powerfulseal/tags): `docker pull powerfulseal/powerfulseal:3.1.1`
- [pip](https://pypi.org/project/powerfulseal/): `pip install powerfulseal`


Expand Down
4 changes: 2 additions & 2 deletions docs/2_getting-started.md
Expand Up @@ -85,7 +85,7 @@ For help, just type `help`. For more information about the modes, see our [docs
For each [release](https://github.com/powerfulseal/powerfulseal/releases) a `docker` image is built and published to the [docker hub](https://hub.docker.com/r/powerfulseal/powerfulseal/tags).

```sh
docker pull powerfulseal/powerfulseal:3.1.0
docker pull powerfulseal/powerfulseal:3.1.1
```

### Run docker image
Expand All @@ -97,7 +97,7 @@ Below is an example of using the `-v` flag to inject your local `kubeconfig` to
```sh
docker run -it \
-v ~/.kube:/root/.kube \
powerfulseal/powerfulseal:3.1.0 \
powerfulseal/powerfulseal:3.1.1 \
interactive
```

Expand Down
2 changes: 1 addition & 1 deletion docs/policies/kubectl.md
Expand Up @@ -66,7 +66,7 @@ scenarios:
spec:
containers:
- name: powerfulseal
image: powerfulseal/powerfulseal:3.1.0
image: powerfulseal/powerfulseal:3.1.1
args:
- autonomous
- --policy-file=/policy.yml
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/powerfulseal.yml
Expand Up @@ -34,7 +34,7 @@ spec:
containers:
- name: powerfulseal
imagePullPolicy: Always
image: powerfulseal/powerfulseal:3.1.0
image: powerfulseal/powerfulseal:3.1.1
args:
- autonomous
- --policy-file=/policy.yml
Expand Down
6 changes: 4 additions & 2 deletions powerfulseal/policy/policy_runner.py
Expand Up @@ -117,9 +117,11 @@ def run(self, inventory, k8s_inventory, driver, executor,
else:
logger.error("Scenario failed, reporting and carrying on")
sleep_time = int(random.uniform(wait_min, wait_max))
logger.info("Sleeping for %s seconds", sleep_time)
time.sleep(sleep_time)
if loops is not None:
loops -= 1
if loops < 1:
break
logger.info("Sleeping for %s seconds", sleep_time)
time.sleep(sleep_time)
logger.info("All done here!")
return True
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = powerfulseal
version = 3.1.0
version = 3.1.1
author = Mikolaj Pawlikowski
author_email = mikolaj@pawlikowski.pl
description = PowerfulSeal - a powerful testing tool for Kubernetes clusters
Expand Down
2 changes: 1 addition & 1 deletion tests/policy/example_config.yml
Expand Up @@ -66,7 +66,7 @@ scenarios:
serviceAccountName: powerfulseal
containers:
- name: powerfulseal
image: powerfulseal/powerfulseal:3.1.0
image: powerfulseal/powerfulseal:3.1.1
args:
- autonomous
- --policy-file=/policy.yml
Expand Down
2 changes: 1 addition & 1 deletion tests/policy/test_policy_runner.py
Expand Up @@ -60,7 +60,7 @@ def test_parses_config_correctly(monkeypatch):
LOOPS = policy.get("config").get("runStrategy").get("runs")
assert policy.get("scenarios")[1].get("name") == crd_scenario_name
runner.run(inventory, k8s_inventory, driver, executor)
assert sleep_mock.call_count == LOOPS
assert sleep_mock.call_count == (LOOPS - 1)
for call in sleep_mock.call_args_list:
args, _ = call
assert 77 <= args[0] <= 78

0 comments on commit edb7499

Please sign in to comment.