diff --git a/src/maltest/maltest.py b/src/maltest/maltest.py index 06559bd..52b22ea 100755 --- a/src/maltest/maltest.py +++ b/src/maltest/maltest.py @@ -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', @@ -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: diff --git a/src/maltest/utils.py b/src/maltest/utils.py index 79c9713..b4c8f37 100644 --- a/src/maltest/utils.py +++ b/src/maltest/utils.py @@ -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: @@ -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() ) ):