Skip to content

Commit

Permalink
Resolved excessive errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacramento-20 committed Jun 17, 2023
1 parent 0fa3a93 commit 64f736b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions scout/scout.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def is_done(self):
class ScoutConfig:
credentials_file: pathlib.Path
output_dir: pathlib.Path
docker_image: str
docker_image: str = "rossja/ncc-scoutsuite:aws-latest"
docker_poll_interval: float = 16.0
docker_socket: str | None = None
docker_timeout: int = 5
Expand Down Expand Up @@ -164,7 +164,7 @@ def handle_finished_containers(self) -> None:
json.dump(r, fd)
self.task_completion_callback(cfg.label, True)
logging.info(
"Scout run completed, id %s sta+-tus %d",
"Scout run completed, id %s status %d",
cfg.label,
r[DOCKER_STATUSCODE_KEY],
)
Expand Down
27 changes: 17 additions & 10 deletions scout/tests/testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def test_scout(s):
time.strftime("scout-%Y%m%d-%H%M%S"),
f"scout aws --no-browser --result-format json \
--report-dir {OUTDIR_CONTAINER_MOUNT} --logfile \
{OUTDIR_CONTAINER_MOUNT}/scout.log", # Commands_scout
{OUTDIR_CONTAINER_MOUNT}/scout.log",
volumes={
"./dev/aws-credentials": {"bind": "/root/.aws/credentials", "mode": "ro"},
"./data": {"bind": "/root/output", "mode": "rw"},
}, # volumes_scout
},
)

logging.info("RUNNING TEST SCOUT")
Expand All @@ -72,24 +72,35 @@ def test_scout(s):
def task_1(s, seconds: int):
taskcfg = scout.ScoutTask(
time.strftime("scout-%Y%m%d-%H%M%S"),
f"sleep {seconds}", # commands
f"sleep {seconds}",
)

taskcfg2 = scout.ScoutTask(time.strftime("scout-%Y%m%d-%H%M%S"), f"sleep 5")
taskcfg2 = scout.ScoutTask(
time.strftime("scout-%Y%m%d-%H%M%S"),
f"sleep {seconds-2}",
)

taskcfg3 = scout.ScoutTask(
time.strftime("scout-%Y%m%d-%H%M%S"),
f"sleep {seconds-4}",
)

logging.info(
"RUNNING TEST 1 - The container was removed after n seconds, along with another set of tasks."
)
s.enqueue(taskcfg)
s.enqueue(taskcfg2)
s.enqueue(taskcfg2)
s.enqueue(taskcfg3)
s.enqueue(taskcfg3)
logging.info("Task submitted")
s.shutdown()


def task_2(s, seconds: int):
taskcfg = scout.ScoutTask(
time.strftime("scout-%Y%m%d-%H%M%S"),
"tail -f /dev/null", # commands
"tail -f /dev/null",
)

logging.info(
Expand All @@ -105,7 +116,7 @@ def task_2(s, seconds: int):
def task_3(s, seconds: int):
taskcfg = scout.ScoutTask(
time.strftime("scout-%Y%m%d-%H%M%S"),
f"sh -c 'sleep {seconds} && exit 1'",
f"sh -c 'sleep {seconds} && false'",
)

logging.info("RUNNING TEST 3 - Container removed after returning an error.")
Expand All @@ -132,22 +143,18 @@ def main():
s = scout.Scout(cfg, callback)
logging.info("Submitting task to Scout module")

# python3 testrun.py -t1 "tempo de execução em segundos"
if args.test1:
seconds = args.test1
task_1(s, seconds)

# #python3 testrun.py -t2 "tempo de execução em segundos"
if args.test2:
seconds = args.test2
task_2(s, seconds)

# python3 testrun.py -t3 "tempo de execução em segundos"
if args.test3:
seconds = args.test3
task_3(s, seconds)

# python3 testrun.py -scout
if args.scout_suite:
test_scout(s)

Expand Down

0 comments on commit 64f736b

Please sign in to comment.