Skip to content

Commit

Permalink
fixes to launcher/cluster tooling to setup test/perf network with des…
Browse files Browse the repository at this point in the history
…ired jetstream settings
  • Loading branch information
aricart committed Mar 27, 2023
1 parent 6f127a7 commit 16e7b21
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
16 changes: 12 additions & 4 deletions tests/helpers/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { rgb24 } from "https://deno.land/std@0.177.0/fmt/colors.ts";
import { setTimeout } from "https://deno.land/std@0.177.0/node/timers.ts";

const defaults = {
c: 2,
c: 3,
p: 4222,
chaos: false,
};
Expand All @@ -40,7 +40,7 @@ const argv = parse(

if (argv.h || argv.help) {
console.log(
"usage: cluster [--count 2] [--port 4222] [--debug] [--jetstream] [--chaos millis]\n",
"usage: cluster [--count 3] [--port 4222] [--debug] [--jetstream] [--chaos millis]\n",
);
Deno.exit(0);
}
Expand All @@ -50,12 +50,20 @@ try {
const cluster = argv.jetstream
? await NatsServer.jetstreamCluster(
argv.count,
{ port },
{
port,
jetstream: {
max_file_store: -1,
max_mem_store: -1,
},
},
argv.debug,
)
: await NatsServer.cluster(
argv.count,
{ port },
{
port,
},
argv.debug,
);

Expand Down
16 changes: 16 additions & 0 deletions tests/helpers/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ export class NatsServer implements PortInfo {
debug = false,
): Promise<NatsServer[]> {
serverConf = serverConf || {};
const js = serverConf.jetstream as {
max_file_store?: number;
max_mem_store?: number;
};
if (js) {
delete serverConf.jetstream;
}
// form a cluster with the specified count
const servers = await NatsServer.cluster(count, serverConf, false);

Expand All @@ -290,6 +297,14 @@ export class NatsServer implements PortInfo {

// jetstream defaults
const { jetstream } = jsopts();
if (js) {
if (js.max_file_store !== undefined) {
jetstream.max_file_store = js.max_file_store;
}
if (js.max_mem_store !== undefined) {
jetstream.max_mem_store = js.max_mem_store;
}
}
// need a server name for a cluster
const serverName = nuid.next();
// customize the store dir and make it
Expand Down Expand Up @@ -540,6 +555,7 @@ export class NatsServer implements PortInfo {
const portsFile = path.resolve(
path.join(tmp, `nats-server_${srv.pid}.ports`),
);
console.info(`config: ${confFile}`);

const pi = await check(
() => {
Expand Down
2 changes: 1 addition & 1 deletion tests/jstest_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function jsopts() {
// trace: true,
jetstream: {
max_file_store: 1024 * 1024,
max_memory_store: 1024 * 1024,
max_mem_store: 1024 * 1024,
store_dir: "/tmp",
},
};
Expand Down

0 comments on commit 16e7b21

Please sign in to comment.