forked from p15670423/monkey
BB: Fix API call to kill all monkeys
This commit is contained in:
parent
51cfb73ce0
commit
88422f9764
|
@ -1,6 +1,6 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from time import sleep
|
import time
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from bson import json_util
|
from bson import json_util
|
||||||
|
@ -15,7 +15,7 @@ LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def avoid_race_condition(func):
|
def avoid_race_condition(func):
|
||||||
sleep(SLEEP_BETWEEN_REQUESTS_SECONDS)
|
time.sleep(SLEEP_BETWEEN_REQUESTS_SECONDS)
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,10 +48,15 @@ class MonkeyIslandClient(object):
|
||||||
|
|
||||||
@avoid_race_condition
|
@avoid_race_condition
|
||||||
def kill_all_monkeys(self):
|
def kill_all_monkeys(self):
|
||||||
if self.requests.get("api", {"action": "killall"}).ok:
|
response = self.requests.post_json(
|
||||||
|
"api/monkey_control/stop-all-agents", data={"kill_time": time.time()}
|
||||||
|
)
|
||||||
|
if response.ok:
|
||||||
LOGGER.info("Killing all monkeys after the test.")
|
LOGGER.info("Killing all monkeys after the test.")
|
||||||
else:
|
else:
|
||||||
LOGGER.error("Failed to kill all monkeys.")
|
LOGGER.error("Failed to kill all monkeys.")
|
||||||
|
LOGGER.error(response.status_code)
|
||||||
|
LOGGER.error(response.content)
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
@avoid_race_condition
|
@avoid_race_condition
|
||||||
|
|
Loading…
Reference in New Issue