Skip to content

Commit

Permalink
[TEST ONLY] test fixes for 2.11 server changes (#798)
Browse files Browse the repository at this point in the history
* [TEST ONLY] server adds stream metadata now

* [TEST ONLY] protect JetStreamSubscribeFlowControl against rate limiting
  • Loading branch information
levb authored Sep 11, 2024
1 parent 5dfb172 commit 2d74e02
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23249,7 +23249,7 @@ void test_JetStreamMgtStreams(void)
&& (si != NULL)
&& (si->Config != NULL)
&& (strcmp(si->Config->Name, "TEST210") == 0)
&& (si->Config->Metadata.Count == 2)
&& (si->Config->Metadata.Count >= 2)
&& (si->Config->Compression == js_StorageCompressionS2)
&& (si->Config->FirstSeq == 9999)
&& (strcmp(si->Config->SubjectTransform.Source, "foo210") == 0)
Expand Down Expand Up @@ -27938,9 +27938,45 @@ void test_JetStreamSubscribeFlowControl(void)
char *subj = NULL;
natsBuffer *buf = NULL;

JS_SETUP(2, 3, 3);
natsConnection *nc = NULL;
jsCtx *js = NULL;
natsPid pid = NATS_INVALID_PID;
char confFile[256] = {'\0'};
char datastore[256] = {'\0'};
char cmdLine[1024] = {'\0'};

ENSURE_JS_VERSION(2, 3, 3);

test("Start server: ");
_makeUniqueDir(datastore, sizeof(datastore), "datastore_");

data = malloc(100*1024);
if (serverVersionAtLeast(2, 11, 0))
{
_createConfFile(confFile, sizeof(confFile),
"jetstream: {\n"
" enabled: true\n"
" max_buffered_size: 1Gb\n"
" max_buffered_msgs: 20000\n"
"}\n");
snprintf(cmdLine, sizeof(cmdLine), "-js -sd %s -c %s", datastore, confFile);
}
else
{
snprintf(cmdLine, sizeof(cmdLine), "-js -sd %s", datastore);
}
pid = _startServer("nats://127.0.0.1:4222", cmdLine, true);
CHECK_SERVER_STARTED(pid);
testCond(true);

test("Connect: ");
s = natsConnection_Connect(&nc, NULL);
testCond(s == NATS_OK);

test("Get context: ");
s = natsConnection_JetStream(&js, nc, NULL);
testCond(s == NATS_OK);

data = malloc(100 * 1024);
if (data == NULL)
FAIL("Unable to allocate data");

Expand Down Expand Up @@ -28080,6 +28116,7 @@ void test_JetStreamSubscribeFlowControl(void)
natsSubscription_Destroy(nsub);
_destroyDefaultThreadArgs(&args);
JS_TEARDOWN;
remove(confFile);
}

static void
Expand Down

0 comments on commit 2d74e02

Please sign in to comment.