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

Test Base Tuning #1030

Merged
merged 1 commit into from
Oct 28, 2023
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
30 changes: 15 additions & 15 deletions src/test/java/io/nats/client/utils/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,20 @@ public static void runInServer(boolean debug, boolean jetstream, Options.Builder
runInServer(debug, jetstream, builder, null, inServerTest);
}

private static ServerInfo RUN_SERVER_INFO;
public static ServerInfo RUN_SERVER_INFO;

public static ServerInfo ensureRunServerInfo() throws Exception {
if (RUN_SERVER_INFO == null) {
runInServer(false, false, null, null, nc -> {});
}
return RUN_SERVER_INFO;
}

public static void initRunServerInfo(Connection nc) {
if (RUN_SERVER_INFO == null) {
RUN_SERVER_INFO = nc.getServerInfo();
}
}

public static void runInServer(boolean debug, boolean jetstream, Options.Builder builder, VersionCheck vc, InServerTest inServerTest) throws Exception {
if (vc != null && RUN_SERVER_INFO != null) {
Expand All @@ -186,9 +199,7 @@ public static void runInServer(boolean debug, boolean jetstream, Options.Builder
try (NatsTestServer ts = new NatsTestServer(debug, jetstream);
Connection nc = standardConnection(builder.server(ts.getURI()).build()))
{
if (RUN_SERVER_INFO == null) {
initRunServerInfo(nc);
}
initRunServerInfo(nc);

if (vc != null) {
if (!vc.runTest(RUN_SERVER_INFO)) {
Expand All @@ -207,17 +218,6 @@ public static void runInServer(boolean debug, boolean jetstream, Options.Builder
}
}

public static ServerInfo ensureRunServerInfo() throws Exception {
if (RUN_SERVER_INFO == null) {
runInServer(nc -> {});
}
return RUN_SERVER_INFO;
}

private static void initRunServerInfo(Connection nc) {
RUN_SERVER_INFO = nc.getServerInfo();
}

public static class LongRunningNatsTestServer extends NatsTestServer {
public final boolean jetstream;
public final Options.Builder builder;
Expand Down