Skip to content

Commit

Permalink
Fixed flappers and test_SSLHandshakeFirst by skipping if server is < …
Browse files Browse the repository at this point in the history
…2.10.0 (#784)

* Fixed SSLHandshakeFirst test by skipping if server is < 2.10.0

Signed-off-by: Ivan Kozlovic <[email protected]>

* More flappers

Added missing `-a 127.0.0.1` in some tests to prevent the server
from sending other IP addresses to the client.

Signed-off-by: Ivan Kozlovic <[email protected]>

---------

Signed-off-by: Ivan Kozlovic <[email protected]>
  • Loading branch information
kozlovic authored Aug 8, 2024
1 parent e56a792 commit 01cfb28
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -7847,7 +7847,7 @@ void test_AssignSubToDispatch(void)
{
testf("%d subs over %d threads: Verify that the dispatchers have been assigned: ", tc->numSubs, tc->expectedDispatchers);
for (i = 0; (s == NATS_OK) && (i < tc->numSubs); i++)
{
{
natsSub_Lock(subs[i]);
if (subs[i]->dispatcher != &pool->dispatchers[i % tc->expectedDispatchers])
s = NATS_ERR;
Expand Down Expand Up @@ -18352,7 +18352,7 @@ void test_GetClientID(void)
testCond(true);
return;
}
pid1 = _startServer("nats://127.0.0.1:4222", "-cluster nats://127.0.0.1:6222 -cluster_name abc", true);
pid1 = _startServer("nats://127.0.0.1:4222", "-a 127.0.0.1 -p 4222 -cluster nats://127.0.0.1:6222 -cluster_name abc", true);
CHECK_SERVER_STARTED(pid1);

test("Create nc1: ");
Expand All @@ -18371,7 +18371,7 @@ void test_GetClientID(void)
testCond((s == NATS_OK) && (cid != 0));

test("Wait for discovered callback: ");
pid2 = _startServer("nats://127.0.0.1:4223", "-p 4223 -cluster nats://127.0.0.1:6223 -cluster_name abc -routes nats://127.0.0.1:6222", true);
pid2 = _startServer("nats://127.0.0.1:4223", "-a 127.0.0.1 -p 4223 -cluster nats://127.0.0.1:6223 -cluster_name abc -routes nats://127.0.0.1:6222", true);
CHECK_SERVER_STARTED(pid2);

natsMutex_Lock(arg.m);
Expand Down Expand Up @@ -21289,6 +21289,16 @@ void test_SSLHandshakeFirst(void)
natsOptions *opts = NULL;
natsPid serverPid = NATS_INVALID_PID;

if (!serverVersionAtLeast(2, 10, 0))
{
char txt[200];

snprintf(txt, sizeof(txt), "Skipping since requires server version of at least 2.10.0, got %s: ", serverVersion);
test(txt);
testCond(true);
return;
}

serverPid = _startServer("nats://127.0.0.1:4443", "-config tlsfirst.conf", true);
CHECK_SERVER_STARTED(serverPid);

Expand Down Expand Up @@ -21411,18 +21421,15 @@ void test_SSLReconnectWithAuthError(void)
IFOK(s, natsOptions_SetTimeout(opts, 250));
IFOK(s, natsOptions_SetMaxReconnect(opts, 1000));
IFOK(s, natsOptions_SetReconnectWait(opts, 100));
IFOK(s, natsOptions_SetReconnectJitter(opts, 0, 0));
IFOK(s, natsOptions_SetClosedCB(opts, _closedCb, (void*) &args));
IFOK(s, natsOptions_SetServers(opts, (const char*[2]){"tls://user:[email protected]:4443", "tls://bad:[email protected]:4444"}, 2));
IFOK(s, natsOptions_SetNoRandomize(opts, true));
IFOK(s, natsOptions_SetIgnoreDiscoveredServers(opts, true));
if (opts == NULL)
FAIL("Unable to create reconnect options!");

pid1 = _startServer("nats://127.0.0.1:4443", "-p 4443 -cluster_name abc -cluster nats://127.0.0.1:6222 -tls -tlscert certs/server-cert.pem -tlskey certs/server-key.pem -tlscacert certs/ca.pem -user user -pass pwd", true);
pid1 = _startServer("nats://127.0.0.1:4443", "-a 127.0.0.1 -p 4443 -cluster_name abc -cluster nats://127.0.0.1:6222 -tls -tlscert certs/server-cert.pem -tlskey certs/server-key.pem -tlscacert certs/ca.pem -user user -pass pwd", true);
CHECK_SERVER_STARTED(pid1);

pid2 = _startServer("nats://127.0.0.1:4444", "-p 4444 -cluster_name abc -cluster nats://127.0.0.1:6223 -routes nats://127.0.0.1:6222 -tls -tlscert certs/server-cert.pem -tlskey certs/server-key.pem -tlscacert certs/ca.pem -user user -pass pwd", true);
pid2 = _startServer("nats://127.0.0.1:4444", "-a 127.0.0.1 -p 4444 -cluster_name abc -cluster nats://127.0.0.1:6223 -routes nats://127.0.0.1:6222 -tls -tlscert certs/server-cert.pem -tlskey certs/server-key.pem -tlscacert certs/ca.pem -user user -pass pwd", true);
CHECK_SERVER_STARTED(pid2);

test("Connect to server1: ");
Expand Down Expand Up @@ -21636,7 +21643,7 @@ void test_ReconnectImplicitUserInfo(void)
"}\n"\
"no_auth_user: b\n");
test("Start server1: ");
snprintf(cmdLine, sizeof(cmdLine), "-cluster_name \"local\" -cluster nats://127.0.0.1:6222 -c %s", conf);
snprintf(cmdLine, sizeof(cmdLine), "-a 127.0.0.1 -p 4222 -cluster_name \"local\" -cluster nats://127.0.0.1:6222 -c %s", conf);
pid1 = _startServer("nats://127.0.0.1:4222", cmdLine, true);
CHECK_SERVER_STARTED(pid1);
testCond(true);
Expand All @@ -21652,7 +21659,7 @@ void test_ReconnectImplicitUserInfo(void)
testCond(s == NATS_OK);

test("Start server2: ");
snprintf(cmdLine, sizeof(cmdLine), "-p 4223 -cluster_name \"local\" -cluster nats://127.0.0.1:6223 -routes nats://127.0.0.1:6222 -c %s", conf);
snprintf(cmdLine, sizeof(cmdLine), "-a 127.0.0.1 -p 4223 -cluster_name \"local\" -cluster nats://127.0.0.1:6223 -routes nats://127.0.0.1:6222 -c %s", conf);
pid2 = _startServer("nats://127.0.0.1:4223", cmdLine, true);
CHECK_SERVER_STARTED(pid2);
testCond(true);
Expand Down

0 comments on commit 01cfb28

Please sign in to comment.