Make test_list_wait_active_timeout tolerate a loaded machine #205
@@ -1262,17 +1262,21 @@ void test_list_wait_active_timeout()
|
||||
list_op->reply.hdr.retval = 0;
|
||||
list_op->reply.sec_list.flags = OSD_LIST_PRIMARY;
|
||||
std::function<void(osd_op_t*)>(list_op->callback)(list_op);
|
||||
assert(listed.size() == 1 && listed.at(2) == 0);
|
||||
assert(listed.at(2) == 0);
|
||||
|
||||
// PG 1 times out
|
||||
sleep_until(start, 1200);
|
||||
tfd->tick((timespec){ .tv_sec = 1, .tv_nsec = 200000000 });
|
||||
assert(listed.size() == 2 && listed.at(1) == -EPIPE);
|
||||
|
||||
// PG 3 times out too
|
||||
sleep_until(start, 2000);
|
||||
tfd->tick((timespec){ .tv_sec = 0, .tv_nsec = 800000000 });
|
||||
assert(listed.size() == 3 && listed.at(3) == -EPIPE);
|
||||
// Only the listing timer moves the listing on from here: PG 1 times out, then PG 3.
|
||||
// The timer follows the real time that passed, so a stall of the test can't fail it
|
||||
timespec prev = start;
|
||||
for (int i = 0; i < 50 && listed.size() < 3; i++)
|
||||
{
|
||||
usleep(100000);
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
long ns = (now.tv_sec - prev.tv_sec)*1000000000l + now.tv_nsec - prev.tv_nsec;
|
||||
tfd->tick((timespec){ .tv_sec = ns / 1000000000, .tv_nsec = ns % 1000000000 });
|
||||
prev = now;
|
||||
}
|
||||
assert(listed.size() == 3 && listed.at(1) == -EPIPE && listed.at(3) == -EPIPE);
|
||||
|
||||
delete cli;
|
||||
delete tfd;
|
||||
|
||||
Reference in New Issue
Block a user