Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
mmguero committed Nov 4, 2024
1 parent 60efa89 commit bc7053d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/maltest/maltest.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ def main():
default=True,
help=f'Start Malcolm once provisioning is complete (default true)',
)
configArgGroup.add_argument(
'--stay-up',
dest='stayUp',
type=mmguero.str2bool,
nargs='?',
metavar="true|false",
const=True,
default=False,
help=f'Stay running until CTRL+C or SIGKILL is received',
)
configArgGroup.add_argument(
'--sleep',
dest='postInitSleep',
Expand Down Expand Up @@ -350,7 +360,7 @@ def main():
exitCode = pytest.main(list(mmguero.Flatten(['-p', 'no:cacheprovider', args.testPath, extraArgs])))

# if we started Malcolm, sleep until instructed
if args.startMalcolm:
if args.stayUp:
malcolmVm.WaitForShutdown()

finally:
Expand Down
9 changes: 5 additions & 4 deletions src/maltest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ def WaitForLastEventTime(
if not self.apiSession:
self.apiSession = requests.Session()

now = datetime.now(timezone.utc)
timeoutEnd = time.time() + MALCOLM_LAST_INGEST_AGE_SECONDS_TIMEOUT
while (result == False) and (ShuttingDown[0] == False) and (time.time() < timeoutEnd):
try:
Expand All @@ -378,15 +377,17 @@ def WaitForLastEventTime(
dataSourceStats = response.json()
self.logger.debug(json.dumps(dataSourceStats))
except Exception as e:
self.logger.warning(f"Error \"{e}\" waiting for Malcolm to become ready")
self.logger.warning(f"Error \"{e}\" getting ingest statistics")
dataSourceStats = {}

if (
isinstance(dataSourceStats, dict)
and dataSourceStats
and all(
(now - datetime.fromisoformat(timestamp)).total_seconds()
> MALCOLM_LAST_INGEST_AGE_SECONDS_THRESHOLD
(
(datetime.now(timezone.utc) - datetime.fromisoformat(timestamp)).total_seconds()
> MALCOLM_LAST_INGEST_AGE_SECONDS_THRESHOLD
)
for timestamp in dataSourceStats.values()
)
):
Expand Down

0 comments on commit bc7053d

Please sign in to comment.