Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to fix timing test CI failure. #66

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions tests/client_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ static void millisleep(int ms) {
Sleep(ms);
#else
struct timespec ts = { ms / 1000, (ms % 1000) * 1000000 };

michael-grunder marked this conversation as resolved.
Show resolved Hide resolved
nanosleep(&ts, NULL);
#endif
}
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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();
}
Expand Down
Loading