diff --git a/test/test.cc b/test/test.cc index fa85b233..7f26e98a 100644 --- a/test/test.cc +++ b/test/test.cc @@ -34447,11 +34447,12 @@ TEST(KeepAliveParkingTest, BacklogIsRetriedOnceTheQueueHasRoom) { auto a = socks.connect(running.port); ASSERT_TRUE(get_ok(a, 2000)); - // B and D take both workers, and C fills the queue. + // B and D take both workers, and C fills the queue. One at a time: the + // queue has room for one job only until a worker takes it. ASSERT_TRUE(send_get(socks.connect(running.port), "/first")); + ASSERT_TRUE(wait_until([&] { return first.entered() == 1; }, 2000)); ASSERT_TRUE(send_get(socks.connect(running.port), "/second")); - ASSERT_TRUE(wait_until( - [&] { return first.entered() == 1 && second.entered() == 1; }, 2000)); + ASSERT_TRUE(wait_until([&] { return second.entered() == 1; }, 2000)); ASSERT_TRUE(send_get(socks.connect(running.port), "/second")); ASSERT_TRUE(wait_until([&] { return queued == 4; }, 2000)); @@ -34477,7 +34478,13 @@ TEST(KeepAliveParkingTest, ZeroKeepAliveTimeoutServesTheFirstRequest) { RunningServer running(svr); Sockets socks; - EXPECT_TRUE(get_ok(socks.connect(running.port), 1000)); + // The request has to arrive within the 10 ms floor, which a busy machine + // can miss once. Without the floor every attempt fails. + auto served = false; + for (int i = 0; i < 5 && !served; i++) { + served = get_ok(socks.connect(running.port), 1000); + } + EXPECT_TRUE(served); } TEST(KeepAliveParkingTest, StopClosesParkedConnectionsPromptly) {