The test was using LogRecord's asctime attribute to calculate a time
difference between two log entries. Although the attribute is documented
with no caveat, others have run into the problem that it does not exist
on logging.LogRecord unless a formatter with a format string referencing
{asctime} has been used. Since there's a 'created' time that's more
appropriate for this test anyway, use that instead.
This commit enables updating pytest, because pytest's logging init
code has changed: https://github.com/pytest-dev/pytest/discussions/9324
Signed-off-by: Dan Mick <dmick@redhat.com>
import argparse
-from datetime import datetime
from unittest.mock import Mock, patch
from teuthology.orchestra import cluster
# there must be at least 2 seconds between the log record
# of the first message and the log record of the second one
#
- t1 = datetime.strptime(records[1].asctime.split(',')[0], "%Y-%m-%d %H:%M:%S")
- t2 = datetime.strptime(records[2].asctime.split(',')[0], "%Y-%m-%d %H:%M:%S")
- assert (t2 - t1).total_seconds() > 2
+ assert (records[2].created - records[1].created) > 2
def test_wait_until_osds_up():