From 9188dbdb60be8968abfa465e1e4e70de2c5e2791 Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Tue, 13 Aug 2024 07:38:51 -0700 Subject: [PATCH] Fix timing based macOS CI failure. * Reduce sleep time from 3s to 1s. No need to sleep so long. * Sleep for additional time to account for timing/preemption issues in the CI runner. Signed-off-by: michael-grunder --- tests/client_test.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/client_test.c b/tests/client_test.c index 56788064..564638b4 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -94,6 +94,7 @@ static void millisleep(int ms) { Sleep(ms); #else struct timespec ts = { ms / 1000, (ms % 1000) * 1000000 }; + nanosleep(&ts, NULL); #endif } @@ -1319,15 +1320,13 @@ static void test_blocking_connection_timeouts(struct config config) { valkeyContext *c; valkeyReply *reply; ssize_t s; - const char *sleep_cmd = "DEBUG SLEEP 3\r\n"; - struct timeval tv; + const char *sleep_cmd = "DEBUG SLEEP 1\r\n"; + struct timeval tv = {.tv_sec = 0, .tv_usec = 10000}; c = do_connect(config); test("Successfully completes a command when the timeout is not exceeded: "); reply = valkeyCommand(c,"SET foo fast"); freeReplyObject(reply); - tv.tv_sec = 0; - tv.tv_usec = 10000; valkeySetTimeout(c, tv); reply = valkeyCommand(c, "GET foo"); test_cond(reply != NULL && reply->type == VALKEY_REPLY_STRING && memcmp(reply->str, "fast", 4) == 0); @@ -1345,8 +1344,6 @@ static void test_blocking_connection_timeouts(struct config config) { sdsfree(c->obuf); c->obuf = sdsempty(); - tv.tv_sec = 0; - tv.tv_usec = 10000; valkeySetTimeout(c, tv); reply = valkeyCommand(c, "GET foo"); #ifndef _WIN32 @@ -1359,7 +1356,7 @@ static void test_blocking_connection_timeouts(struct config config) { freeReplyObject(reply); // wait for the DEBUG SLEEP to complete so that the server is unblocked for the following tests - millisleep(3000); + millisleep(1500); } else { test_skipped(); }