From: Patrick Donnelly Date: Sat, 25 May 2024 18:31:44 +0000 (-0400) Subject: qa/tasks/vstart_runner: avoid deprecation warning X-Git-Tag: testing/wip-pdonnell-testing-20240611.170412-debug~14^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7658896d9b20821f346be93890dddc02208beb6a;p=ceph-ci.git qa/tasks/vstart_runner: avoid deprecation warning /home/pdonnell/ceph/qa/tasks/vstart_runner.py:1280: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). time_elapsed = (datetime.datetime.utcnow() - started_at).total_seconds() Signed-off-by: Patrick Donnelly --- diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 1c881808d06..e843c0965a4 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -1220,13 +1220,13 @@ class LoggingResultTemplate(object): def startTest(self, test): log.info("Starting test: {0}".format(self.getDescription(test))) - test.started_at = datetime.datetime.utcnow() + test.started_at = datetime.datetime.now(datetime.timezone.utc) return super(LoggingResultTemplate, self).startTest(test) def stopTest(self, test): log.info("Stopped test: {0} in {1}s".format( self.getDescription(test), - (datetime.datetime.utcnow() - test.started_at).total_seconds() + (datetime.datetime.now(datetime.timezone.utc) - test.started_at).total_seconds() )) def addSkip(self, test, reason): @@ -1259,7 +1259,7 @@ def launch_individually(overall_suite): if opt_rotate_logs: logrotate = LogRotate() - started_at = datetime.datetime.utcnow() + started_at = datetime.datetime.now(datetime.timezone.utc) for suite_, case in enumerate_methods(overall_suite): # don't run logrotate beforehand since some ceph daemons might be # down and pre/post-rotate scripts in logrotate.conf might fail. @@ -1277,7 +1277,7 @@ def launch_individually(overall_suite): no_of_tests_failed += 1 no_of_tests_execed += 1 - time_elapsed = (datetime.datetime.utcnow() - started_at).total_seconds() + time_elapsed = (datetime.datetime.now(datetime.timezone.utc) - started_at).total_seconds() if result.wasSuccessful(): log.info('')