increase timeout and remove sleep
This commit is contained in:
@@ -33,7 +33,7 @@ TEST(ClientServer, OneClient) {
|
|||||||
auto const loop_timeout = 1000_ms;
|
auto const loop_timeout = 1000_ms;
|
||||||
auto s = createServer<false, true>();
|
auto s = createServer<false, true>();
|
||||||
piMinSleep();
|
piMinSleep();
|
||||||
auto c = createAndConnectClient<TestClient<false, false>>();
|
auto c = createAndConnectClient<TestClient<false, false>>();
|
||||||
|
|
||||||
waitLoop([s]() { return s->clientsCount() > 0; }, loop_timeout);
|
waitLoop([s]() { return s->clientsCount() > 0; }, loop_timeout);
|
||||||
EXPECT_EQ(1, s->clientsCount());
|
EXPECT_EQ(1, s->clientsCount());
|
||||||
@@ -103,7 +103,7 @@ int getClientsPings(const PIVector<ClientSendThread *> & clients) {
|
|||||||
|
|
||||||
|
|
||||||
TEST(ClientServer, ManyClients) {
|
TEST(ClientServer, ManyClients) {
|
||||||
auto const loop_timeout = 100_ms;
|
auto const loop_timeout = 1_s;
|
||||||
constexpr int clients_count = 20;
|
constexpr int clients_count = 20;
|
||||||
PIVector<ClientSendThread *> clients;
|
PIVector<ClientSendThread *> clients;
|
||||||
auto s = createServer<false, false, 100_KiB>();
|
auto s = createServer<false, false, 100_KiB>();
|
||||||
@@ -139,8 +139,9 @@ TEST(ClientServer, ManyClients) {
|
|||||||
for (const auto c: clients) {
|
for (const auto c: clients) {
|
||||||
c->startSend();
|
c->startSend();
|
||||||
}
|
}
|
||||||
loop_timeout.sleep();
|
waitLoop([&clients]() { return getClientsPings(clients) > clients_count * 2; }, loop_timeout);
|
||||||
EXPECT_TRUE(getClientsPings(clients) > clients_count * 2);
|
EXPECT_TRUE(getClientsPings(clients) > clients_count * 2);
|
||||||
|
waitLoop([s]() { return getServerPongs(s) > clients_count * 2; }, loop_timeout);
|
||||||
EXPECT_TRUE(getServerPongs(s) > clients_count * 2);
|
EXPECT_TRUE(getServerPongs(s) > clients_count * 2);
|
||||||
piDeleteAllAndClear(clients);
|
piDeleteAllAndClear(clients);
|
||||||
waitLoop([s]() { return s->clientsCount() == 0; }, loop_timeout);
|
waitLoop([s]() { return s->clientsCount() == 0; }, loop_timeout);
|
||||||
@@ -149,7 +150,7 @@ TEST(ClientServer, ManyClients) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(ClientServer, DynamicClients) {
|
TEST(ClientServer, DynamicClients) {
|
||||||
auto const loop_timeout = 10_ms;
|
auto const loop_timeout = 3_s;
|
||||||
constexpr int clients_count = 20;
|
constexpr int clients_count = 20;
|
||||||
PIVector<ClientSendThread *> clients;
|
PIVector<ClientSendThread *> clients;
|
||||||
PIMutex clients_mutex;
|
PIMutex clients_mutex;
|
||||||
@@ -199,15 +200,14 @@ TEST(ClientServer, DynamicClients) {
|
|||||||
},
|
},
|
||||||
130_Hz);
|
130_Hz);
|
||||||
|
|
||||||
(loop_timeout * clients_count).sleep();
|
waitLoop([s]() { return s->clientsCount() >= 10; }, loop_timeout);
|
||||||
|
|
||||||
EXPECT_GE(s->clientsCount(), 10);
|
EXPECT_GE(s->clientsCount(), 10);
|
||||||
|
|
||||||
deleteThread.stopAndWait();
|
deleteThread.stopAndWait();
|
||||||
spawnThread.stopAndWait();
|
spawnThread.stopAndWait();
|
||||||
|
|
||||||
piDeleteAllAndClear(clients);
|
piDeleteAllAndClear(clients);
|
||||||
waitLoop([s]() { return s->clientsCount() == 0; }, loop_timeout * clients_count);
|
waitLoop([s]() { return s->clientsCount() == 0; }, loop_timeout);
|
||||||
EXPECT_EQ(0, s->clientsCount());
|
EXPECT_EQ(0, s->clientsCount());
|
||||||
|
|
||||||
delete s;
|
delete s;
|
||||||
|
|||||||
Reference in New Issue
Block a user