]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/tasks/vstart_runner: avoid deprecation warning
authorPatrick Donnelly <pdonnell@redhat.com>
Sat, 25 May 2024 18:31:44 +0000 (14:31 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 5 Jun 2024 12:41:22 +0000 (08:41 -0400)
    /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 <pdonnell@redhat.com>
qa/tasks/vstart_runner.py

index 1c881808d06518a3d9a8767020c1ed17a8903053..e843c0965a4e7cedd429b7c34b02377faf250991 100644 (file)
@@ -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('')