From b0877e00e2097e441507aff6d89d5956e9d4a970 Mon Sep 17 00:00:00 2001 From: Nathaniel Bauernfeind Date: Tue, 6 Sep 2022 20:21:04 -0600 Subject: [PATCH 1/2] Use unit test execution context for java-client unit tests --- .../engine/context/QueryLibrary.java | 4 ++ .../python/server/EmbeddedServer.java | 2 + .../server/jetty/JettyServerComponent.java | 2 + .../jetty/JettyFlightRoundTripTest.java | 1 + .../server/netty/NettyServerComponent.java | 2 + .../console/NoConsoleSessionModule.java | 27 +++++++++++ .../SessionToExecutionStateModule.java | 14 ++++++ .../server/runner/DeephavenApiServer.java | 8 +++- ...avenApiServerInProcessGroovyComponent.java | 4 +- ...avenApiServerInProcessPythonComponent.java | 4 +- .../server/session/SessionState.java | 4 +- .../ApplicationServiceGrpcImplTest.java | 3 +- .../runner/DeephavenApiServerTestBase.java | 48 +++++++++++++++++-- .../server/session/SessionServiceTest.java | 3 +- .../server/session/SessionStateTest.java | 5 +- .../table/ExportTableUpdateListenerTest.java | 3 +- .../test/FlightMessageRoundTripTest.java | 10 +++- 17 files changed, 130 insertions(+), 14 deletions(-) create mode 100644 server/src/main/java/io/deephaven/server/console/NoConsoleSessionModule.java create mode 100644 server/src/main/java/io/deephaven/server/console/SessionToExecutionStateModule.java diff --git a/engine/context/src/main/java/io/deephaven/engine/context/QueryLibrary.java b/engine/context/src/main/java/io/deephaven/engine/context/QueryLibrary.java index 724cd0011e0..3bb72dd7660 100644 --- a/engine/context/src/main/java/io/deephaven/engine/context/QueryLibrary.java +++ b/engine/context/src/main/java/io/deephaven/engine/context/QueryLibrary.java @@ -108,4 +108,8 @@ public Collection getImportStrings() { public void updateVersionString() { versionString = UuidCreator.toString(UuidCreator.getRandomBased()); } + + public void updateVersionString(String version) { + versionString = version; + } } diff --git a/py/embedded-server/java-runtime/src/main/java/io/deephaven/python/server/EmbeddedServer.java b/py/embedded-server/java-runtime/src/main/java/io/deephaven/python/server/EmbeddedServer.java index a45d98be2c5..0f62b6e71ef 100644 --- a/py/embedded-server/java-runtime/src/main/java/io/deephaven/python/server/EmbeddedServer.java +++ b/py/embedded-server/java-runtime/src/main/java/io/deephaven/python/server/EmbeddedServer.java @@ -11,6 +11,7 @@ import io.deephaven.io.log.LogLevel; import io.deephaven.io.logger.LogBuffer; import io.deephaven.io.logger.LogBufferOutputStream; +import io.deephaven.server.console.SessionToExecutionStateModule; import io.deephaven.server.console.groovy.GroovyConsoleSessionModule; import io.deephaven.server.console.python.PythonConsoleSessionModule; import io.deephaven.server.console.python.PythonGlobalScopeModule; @@ -48,6 +49,7 @@ public class EmbeddedServer { JettyServerModule.class, PythonConsoleSessionModule.class, GroovyConsoleSessionModule.class, + SessionToExecutionStateModule.class, }) public interface PythonServerComponent extends DeephavenApiServerComponent { @Component.Builder diff --git a/server/jetty/src/main/java/io/deephaven/server/jetty/JettyServerComponent.java b/server/jetty/src/main/java/io/deephaven/server/jetty/JettyServerComponent.java index 3c052082e45..e5dc662be55 100644 --- a/server/jetty/src/main/java/io/deephaven/server/jetty/JettyServerComponent.java +++ b/server/jetty/src/main/java/io/deephaven/server/jetty/JettyServerComponent.java @@ -5,6 +5,7 @@ import dagger.BindsInstance; import dagger.Component; +import io.deephaven.server.console.SessionToExecutionStateModule; import io.deephaven.server.console.groovy.GroovyConsoleSessionModule; import io.deephaven.server.console.python.PythonConsoleSessionModule; import io.deephaven.server.console.python.PythonGlobalScopeCopyModule; @@ -28,6 +29,7 @@ JettyServerModule.class, PythonConsoleSessionModule.class, GroovyConsoleSessionModule.class, + SessionToExecutionStateModule.class, }) public interface JettyServerComponent extends DeephavenApiServerComponent { @Component.Builder diff --git a/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java b/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java index 4c4012eaca5..ce60873d830 100644 --- a/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java +++ b/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java @@ -7,6 +7,7 @@ import dagger.Module; import dagger.Provides; import io.deephaven.server.arrow.ArrowModule; +import io.deephaven.server.log.LogModule; import io.deephaven.server.session.SessionModule; import io.deephaven.server.test.AuthTestModule; import io.deephaven.server.test.FlightMessageRoundTripTest; diff --git a/server/netty/src/main/java/io/deephaven/server/netty/NettyServerComponent.java b/server/netty/src/main/java/io/deephaven/server/netty/NettyServerComponent.java index 3469794ac2b..d50256c9519 100644 --- a/server/netty/src/main/java/io/deephaven/server/netty/NettyServerComponent.java +++ b/server/netty/src/main/java/io/deephaven/server/netty/NettyServerComponent.java @@ -5,6 +5,7 @@ import dagger.BindsInstance; import dagger.Component; +import io.deephaven.server.console.SessionToExecutionStateModule; import io.deephaven.server.console.groovy.GroovyConsoleSessionModule; import io.deephaven.server.console.python.PythonConsoleSessionModule; import io.deephaven.server.console.python.PythonGlobalScopeCopyModule; @@ -28,6 +29,7 @@ NettyServerModule.class, PythonConsoleSessionModule.class, GroovyConsoleSessionModule.class, + SessionToExecutionStateModule.class, }) public interface NettyServerComponent extends DeephavenApiServerComponent { @Component.Builder diff --git a/server/src/main/java/io/deephaven/server/console/NoConsoleSessionModule.java b/server/src/main/java/io/deephaven/server/console/NoConsoleSessionModule.java new file mode 100644 index 00000000000..f2eb1a65213 --- /dev/null +++ b/server/src/main/java/io/deephaven/server/console/NoConsoleSessionModule.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending + */ +package io.deephaven.server.console; + +import dagger.Module; +import dagger.Provides; +import dagger.multibindings.IntoMap; +import dagger.multibindings.StringKey; +import io.deephaven.engine.util.NoLanguageDeephavenSession; +import io.deephaven.engine.util.ScriptSession; +import io.deephaven.server.console.groovy.InitScriptsModule; + +@Module(includes = InitScriptsModule.ServiceLoader.class) +public class NoConsoleSessionModule { + @Provides + @IntoMap + @StringKey("none") + ScriptSession bindScriptSession(NoLanguageDeephavenSession noLanguageSession) { + return noLanguageSession; + } + + @Provides + NoLanguageDeephavenSession bindNoLanguageSession() { + return new NoLanguageDeephavenSession(); + } +} diff --git a/server/src/main/java/io/deephaven/server/console/SessionToExecutionStateModule.java b/server/src/main/java/io/deephaven/server/console/SessionToExecutionStateModule.java new file mode 100644 index 00000000000..6eecb5fc743 --- /dev/null +++ b/server/src/main/java/io/deephaven/server/console/SessionToExecutionStateModule.java @@ -0,0 +1,14 @@ +package io.deephaven.server.console; + +import dagger.Module; +import dagger.Provides; +import io.deephaven.engine.context.ExecutionContext; +import io.deephaven.engine.util.ScriptSession; + +@Module +public class SessionToExecutionStateModule { + @Provides + ExecutionContext bindExecutionContext(ScriptSession session) { + return session.getExecutionContext(); + } +} diff --git a/server/src/main/java/io/deephaven/server/runner/DeephavenApiServer.java b/server/src/main/java/io/deephaven/server/runner/DeephavenApiServer.java index 5b2eb27594a..5f47aa89fbc 100644 --- a/server/src/main/java/io/deephaven/server/runner/DeephavenApiServer.java +++ b/server/src/main/java/io/deephaven/server/runner/DeephavenApiServer.java @@ -5,6 +5,7 @@ import io.deephaven.auth.AuthenticationRequestHandler; import io.deephaven.configuration.Configuration; +import io.deephaven.engine.context.ExecutionContext; import io.deephaven.engine.table.impl.perf.QueryPerformanceRecorder; import io.deephaven.engine.table.impl.perf.UpdatePerformanceTracker; import io.deephaven.engine.table.impl.util.MemoryTableLoggers; @@ -51,6 +52,7 @@ public class DeephavenApiServer { private final UriResolvers uriResolvers; private final SessionService sessionService; private final Map authenticationHandlers; + private final Provider executionContextProvider; @Inject public DeephavenApiServer( @@ -62,7 +64,8 @@ public DeephavenApiServer( final ApplicationInjector applicationInjector, final UriResolvers uriResolvers, final SessionService sessionService, - final Map authenticationHandlers) { + final Map authenticationHandlers, + final Provider executionContextProvider) { this.server = server; this.ugp = ugp; this.logInit = logInit; @@ -72,6 +75,7 @@ public DeephavenApiServer( this.uriResolvers = uriResolvers; this.sessionService = sessionService; this.authenticationHandlers = authenticationHandlers; + this.executionContextProvider = executionContextProvider; } @VisibleForTesting @@ -162,6 +166,8 @@ public void join() throws InterruptedException { void startForUnitTests() throws Exception { pluginRegistration.registerAll(); applicationInjector.run(); + executionContextProvider.get().getQueryLibrary().updateVersionString("DEFAULT"); + log.info().append("Starting server...").endl(); server.start(); } diff --git a/server/src/main/java/io/deephaven/server/runner/DeephavenApiServerInProcessGroovyComponent.java b/server/src/main/java/io/deephaven/server/runner/DeephavenApiServerInProcessGroovyComponent.java index 4d61c51b3cf..346d4e59bb0 100644 --- a/server/src/main/java/io/deephaven/server/runner/DeephavenApiServerInProcessGroovyComponent.java +++ b/server/src/main/java/io/deephaven/server/runner/DeephavenApiServerInProcessGroovyComponent.java @@ -5,6 +5,7 @@ import dagger.BindsInstance; import dagger.Component; +import io.deephaven.server.console.SessionToExecutionStateModule; import io.deephaven.server.console.groovy.GroovyConsoleSessionModule; import io.deephaven.server.log.LogModule; import io.grpc.ManagedChannelBuilder; @@ -18,7 +19,8 @@ DeephavenApiServerModule.class, LogModule.class, GroovyConsoleSessionModule.class, - ServerBuilderInProcessModule.class + ServerBuilderInProcessModule.class, + SessionToExecutionStateModule.class, }) public interface DeephavenApiServerInProcessGroovyComponent { diff --git a/server/src/main/java/io/deephaven/server/runner/DeephavenApiServerInProcessPythonComponent.java b/server/src/main/java/io/deephaven/server/runner/DeephavenApiServerInProcessPythonComponent.java index 2cd576e51fe..83c84b4eb0c 100644 --- a/server/src/main/java/io/deephaven/server/runner/DeephavenApiServerInProcessPythonComponent.java +++ b/server/src/main/java/io/deephaven/server/runner/DeephavenApiServerInProcessPythonComponent.java @@ -5,6 +5,7 @@ import dagger.BindsInstance; import dagger.Component; +import io.deephaven.server.console.SessionToExecutionStateModule; import io.deephaven.server.console.python.PythonConsoleSessionModule; import io.deephaven.server.console.python.PythonGlobalScopeCopyModule; import io.deephaven.server.log.LogModule; @@ -20,7 +21,8 @@ LogModule.class, PythonConsoleSessionModule.class, PythonGlobalScopeCopyModule.class, - ServerBuilderInProcessModule.class + ServerBuilderInProcessModule.class, + SessionToExecutionStateModule.class, }) public interface DeephavenApiServerInProcessPythonComponent { diff --git a/server/src/main/java/io/deephaven/server/session/SessionState.java b/server/src/main/java/io/deephaven/server/session/SessionState.java index 22967b0c391..d2b4bf01b73 100644 --- a/server/src/main/java/io/deephaven/server/session/SessionState.java +++ b/server/src/main/java/io/deephaven/server/session/SessionState.java @@ -136,13 +136,13 @@ public static ExportObject wrapAsExport(final T export) { @AssistedInject public SessionState(final Scheduler scheduler, - final Provider scriptSessionProvider, + final Provider executionContextProvider, @Assisted final AuthContext authContext) { this.sessionId = UuidCreator.toString(UuidCreator.getRandomBased()); this.logPrefix = "SessionState{" + sessionId + "}: "; this.scheduler = scheduler; this.authContext = authContext; - this.executionContext = scriptSessionProvider.get().getExecutionContext(); + this.executionContext = executionContextProvider.get(); log.info().append(logPrefix).append("session initialized").endl(); } diff --git a/server/src/test/java/io/deephaven/server/appmode/ApplicationServiceGrpcImplTest.java b/server/src/test/java/io/deephaven/server/appmode/ApplicationServiceGrpcImplTest.java index 9174541b82d..ecd8a8072a4 100644 --- a/server/src/test/java/io/deephaven/server/appmode/ApplicationServiceGrpcImplTest.java +++ b/server/src/test/java/io/deephaven/server/appmode/ApplicationServiceGrpcImplTest.java @@ -3,6 +3,7 @@ */ package io.deephaven.server.appmode; +import io.deephaven.engine.context.ExecutionContext; import io.deephaven.engine.liveness.LivenessScopeStack; import io.deephaven.engine.util.NoLanguageDeephavenSession; import io.deephaven.engine.util.ScriptSession; @@ -42,7 +43,7 @@ public void setup() { livenessScope = LivenessScopeStack.open(); scheduler = new TestControlledScheduler(); sessionService = new SessionService(scheduler, - authContext -> new SessionState(scheduler, NoLanguageDeephavenSession::new, authContext), + authContext -> new SessionState(scheduler, ExecutionContext::createForUnitTests, authContext), TOKEN_EXPIRE_MS, Optional.empty(), Collections.emptyMap()); applicationServiceGrpcImpl = new ApplicationServiceGrpcImpl(scheduler, sessionService, new TypeLookup(ObjectTypeLookup.NoOp.INSTANCE)); diff --git a/server/src/test/java/io/deephaven/server/runner/DeephavenApiServerTestBase.java b/server/src/test/java/io/deephaven/server/runner/DeephavenApiServerTestBase.java index 427e4c7418d..f63c38c66ed 100644 --- a/server/src/test/java/io/deephaven/server/runner/DeephavenApiServerTestBase.java +++ b/server/src/test/java/io/deephaven/server/runner/DeephavenApiServerTestBase.java @@ -3,12 +3,17 @@ */ package io.deephaven.server.runner; +import dagger.BindsInstance; +import dagger.Component; +import io.deephaven.engine.context.ExecutionContext; import io.deephaven.engine.updategraph.UpdateGraphProcessor; import io.deephaven.engine.liveness.LivenessScope; import io.deephaven.engine.liveness.LivenessScopeStack; import io.deephaven.io.logger.LogBuffer; import io.deephaven.io.logger.LogBufferGlobal; import io.deephaven.proto.DeephavenChannel; +import io.deephaven.server.console.NoConsoleSessionModule; +import io.deephaven.server.log.LogModule; import io.deephaven.util.SafeCloseable; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; @@ -17,17 +22,54 @@ import org.junit.Before; import org.junit.Rule; +import javax.inject.Named; +import javax.inject.Singleton; +import java.io.PrintStream; import java.util.concurrent.TimeUnit; /** * Manages a single instance of {@link DeephavenApiServer}. */ public abstract class DeephavenApiServerTestBase { + @Singleton + @Component(modules = { + DeephavenApiServerModule.class, + LogModule.class, + NoConsoleSessionModule.class, + ServerBuilderInProcessModule.class + }) + public interface TestComponent { + + DeephavenApiServer getServer(); + + ManagedChannelBuilder channelBuilder(); + + @Component.Builder + interface Builder { + + @BindsInstance + Builder withSchedulerPoolSize(@Named("scheduler.poolSize") int numThreads); + + @BindsInstance + Builder withSessionTokenExpireTmMs(@Named("session.tokenExpireMs") long tokenExpireMs); + + @BindsInstance + Builder withOut(@Named("out") PrintStream out); + + @BindsInstance + Builder withErr(@Named("err") PrintStream err); + + @BindsInstance + Builder withExecutionContext(ExecutionContext context); + + TestComponent build(); + } + } @Rule public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule(); - private DeephavenApiServerInProcessGroovyComponent serverComponent; + private TestComponent serverComponent; private LogBuffer logBuffer; private DeephavenApiServer server; private SafeCloseable scopeCloseable; @@ -40,8 +82,8 @@ public void setUp() throws Exception { logBuffer = new LogBuffer(128); LogBufferGlobal.setInstance(logBuffer); - serverComponent = DaggerDeephavenApiServerInProcessGroovyComponent - .builder() + serverComponent = DaggerDeephavenApiServerTestBase_TestComponent.builder() + .withExecutionContext(ExecutionContext.createForUnitTests()) .withSchedulerPoolSize(4) .withSessionTokenExpireTmMs(sessionTokenExpireTmMs()) .withOut(System.out) diff --git a/server/src/test/java/io/deephaven/server/session/SessionServiceTest.java b/server/src/test/java/io/deephaven/server/session/SessionServiceTest.java index 1c66173a101..8253f5527d6 100644 --- a/server/src/test/java/io/deephaven/server/session/SessionServiceTest.java +++ b/server/src/test/java/io/deephaven/server/session/SessionServiceTest.java @@ -4,6 +4,7 @@ package io.deephaven.server.session; import io.deephaven.base.verify.Assert; +import io.deephaven.engine.context.ExecutionContext; import io.deephaven.engine.liveness.LivenessScopeStack; import io.deephaven.engine.util.NoLanguageDeephavenSession; import io.deephaven.server.util.TestControlledScheduler; @@ -30,7 +31,7 @@ public void setup() { livenessScope = LivenessScopeStack.open(); scheduler = new TestControlledScheduler(); sessionService = new SessionService(scheduler, - authContext -> new SessionState(scheduler, NoLanguageDeephavenSession::new, authContext), + authContext -> new SessionState(scheduler, ExecutionContext::createForUnitTests, authContext), TOKEN_EXPIRE_MS, Optional.empty(), Collections.emptyMap()); } diff --git a/server/src/test/java/io/deephaven/server/session/SessionStateTest.java b/server/src/test/java/io/deephaven/server/session/SessionStateTest.java index 79eec750bd8..b576b5da6bf 100644 --- a/server/src/test/java/io/deephaven/server/session/SessionStateTest.java +++ b/server/src/test/java/io/deephaven/server/session/SessionStateTest.java @@ -5,6 +5,7 @@ import io.deephaven.base.verify.Assert; import io.deephaven.base.verify.AssertionFailure; +import io.deephaven.engine.context.ExecutionContext; import io.deephaven.engine.util.NoLanguageDeephavenSession; import io.deephaven.proto.util.ExportTicketHelper; import io.deephaven.server.table.ExportTableUpdateListenerTest; @@ -61,7 +62,7 @@ public void setup() { livenessScope = new LivenessScope(); LivenessScopeStack.push(livenessScope); scheduler = new TestControlledScheduler(); - session = new SessionState(scheduler, NoLanguageDeephavenSession::new, AUTH_CONTEXT); + session = new SessionState(scheduler, ExecutionContext::createForUnitTests, AUTH_CONTEXT); session.initializeExpiration(new SessionService.TokenExpiration(UUID.randomUUID(), DateTimeUtils.nanosToTime(Long.MAX_VALUE), session)); nextExportId = 1; @@ -637,7 +638,7 @@ public void testCannotOutOfOrderServerExports() { @Test public void testVerifyExpirationSession() { - final SessionState session = new SessionState(scheduler, NoLanguageDeephavenSession::new, AUTH_CONTEXT); + final SessionState session = new SessionState(scheduler, ExecutionContext::createForUnitTests, AUTH_CONTEXT); final SessionService.TokenExpiration expiration = new SessionService.TokenExpiration(UUID.randomUUID(), DateTimeUtils.nanosToTime(Long.MAX_VALUE), session); diff --git a/server/src/test/java/io/deephaven/server/table/ExportTableUpdateListenerTest.java b/server/src/test/java/io/deephaven/server/table/ExportTableUpdateListenerTest.java index cebddeded14..9a858f6cc0b 100644 --- a/server/src/test/java/io/deephaven/server/table/ExportTableUpdateListenerTest.java +++ b/server/src/test/java/io/deephaven/server/table/ExportTableUpdateListenerTest.java @@ -4,6 +4,7 @@ package io.deephaven.server.table; import io.deephaven.base.verify.Assert; +import io.deephaven.engine.context.ExecutionContext; import io.deephaven.engine.table.impl.TableUpdateImpl; import io.deephaven.engine.updategraph.UpdateGraphProcessor; import io.deephaven.engine.util.NoLanguageDeephavenSession; @@ -340,7 +341,7 @@ private void expectNoMessage() { public class TestSessionState extends SessionState { public TestSessionState() { - super(scheduler, NoLanguageDeephavenSession::new, AUTH_CONTEXT); + super(scheduler, ExecutionContext::createForUnitTests, AUTH_CONTEXT); initializeExpiration(new SessionService.TokenExpiration(UUID.randomUUID(), DateTimeUtils.nanosToTime(Long.MAX_VALUE), this)); } diff --git a/server/test/src/main/java/io/deephaven/server/test/FlightMessageRoundTripTest.java b/server/test/src/main/java/io/deephaven/server/test/FlightMessageRoundTripTest.java index 6fd5d095356..13430caad0c 100644 --- a/server/test/src/main/java/io/deephaven/server/test/FlightMessageRoundTripTest.java +++ b/server/test/src/main/java/io/deephaven/server/test/FlightMessageRoundTripTest.java @@ -15,6 +15,7 @@ import io.deephaven.barrage.flatbuf.BarrageSnapshotRequest; import io.deephaven.barrage.flatbuf.ColumnConversionMode; import io.deephaven.base.verify.Assert; +import io.deephaven.engine.context.ExecutionContext; import io.deephaven.engine.liveness.LivenessScopeStack; import io.deephaven.engine.table.Table; import io.deephaven.engine.updategraph.UpdateGraphProcessor; @@ -132,6 +133,11 @@ int provideMaxInboundMessageSize() { ScheduledExecutorService provideExecutorService() { return null; } + + @Provides + ExecutionContext provideExecutionContext() { + return ExecutionContext.createForUnitTests(); + } } public interface TestComponent { @@ -150,6 +156,8 @@ public interface TestComponent { AuthTestModule.BasicAuthTestImpl basicAuthHandler(); Map authRequestHandlers(); + + ExecutionContext executionContext(); } private GrpcServer server; @@ -174,7 +182,7 @@ public void setup() throws IOException { scriptSession = component.scriptSession(); sessionService = component.sessionService(); - executionContext = scriptSession.getExecutionContext().open(); + executionContext = component.executionContext().open(); serverLocation = Location.forGrpcInsecure("localhost", actualPort); currentSession = sessionService.newSession(new AuthContext.SuperUser()); From ff4bcbeb386f5da8fcdcadfff3a7a635fe541f99 Mon Sep 17 00:00:00 2001 From: Nathaniel Bauernfeind Date: Tue, 6 Sep 2022 21:29:43 -0600 Subject: [PATCH 2/2] devin's comments --- server/jetty/build.gradle | 1 + .../server/jetty/JettyFlightRoundTripTest.java | 5 +++-- server/netty/build.gradle | 1 + .../server/netty/NettyFlightRoundTripTest.java | 4 +++- .../runner/DeephavenApiServerTestBase.java | 7 ++----- .../runner/ExecutionContextUnitTestModule.java | 16 ++++++++++++++++ .../server/test/FlightMessageRoundTripTest.java | 5 ----- 7 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 server/src/test/java/io/deephaven/server/runner/ExecutionContextUnitTestModule.java diff --git a/server/jetty/build.gradle b/server/jetty/build.gradle index 0d36fbd39bc..b9883ec7569 100644 --- a/server/jetty/build.gradle +++ b/server/jetty/build.gradle @@ -36,6 +36,7 @@ dependencies { implementation project(':grpc-java:grpc-mtls') testImplementation project(':server-test') + testImplementation TestTools.projectDependency(project, ':server') testRuntimeOnly project(':log-to-slf4j') Classpaths.inheritSlf4j(project, 'slf4j-simple', 'testRuntimeOnly') diff --git a/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java b/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java index ce60873d830..8d977dc8cc3 100644 --- a/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java +++ b/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java @@ -7,7 +7,7 @@ import dagger.Module; import dagger.Provides; import io.deephaven.server.arrow.ArrowModule; -import io.deephaven.server.log.LogModule; +import io.deephaven.server.runner.ExecutionContextUnitTestModule; import io.deephaven.server.session.SessionModule; import io.deephaven.server.test.AuthTestModule; import io.deephaven.server.test.FlightMessageRoundTripTest; @@ -31,7 +31,8 @@ static JettyConfig providesJettyConfig() { SessionModule.class, AuthTestModule.class, JettyServerModule.class, - JettyTestConfig.class + JettyTestConfig.class, + ExecutionContextUnitTestModule.class, }) public interface JettyTestComponent extends TestComponent { } diff --git a/server/netty/build.gradle b/server/netty/build.gradle index 1014c0e6242..4076a5d0985 100644 --- a/server/netty/build.gradle +++ b/server/netty/build.gradle @@ -23,6 +23,7 @@ dependencies { implementation project(':grpc-java:grpc-mtls') testImplementation project(':server-test') + testImplementation TestTools.projectDependency(project, ':server') testRuntimeOnly project(':log-to-slf4j') Classpaths.inheritSlf4j(project, 'slf4j-simple', 'testRuntimeOnly') diff --git a/server/netty/src/test/java/io/deephaven/server/netty/NettyFlightRoundTripTest.java b/server/netty/src/test/java/io/deephaven/server/netty/NettyFlightRoundTripTest.java index d37cd8b747f..32901a5b879 100644 --- a/server/netty/src/test/java/io/deephaven/server/netty/NettyFlightRoundTripTest.java +++ b/server/netty/src/test/java/io/deephaven/server/netty/NettyFlightRoundTripTest.java @@ -7,6 +7,7 @@ import dagger.Module; import dagger.Provides; import io.deephaven.server.arrow.ArrowModule; +import io.deephaven.server.runner.ExecutionContextUnitTestModule; import io.deephaven.server.session.SessionModule; import io.deephaven.server.test.AuthTestModule; import io.deephaven.server.test.FlightMessageRoundTripTest; @@ -30,7 +31,8 @@ static NettyConfig providesNettyConfig() { SessionModule.class, AuthTestModule.class, NettyServerModule.class, - NettyTestConfig.class + NettyTestConfig.class, + ExecutionContextUnitTestModule.class, }) public interface NettyTestComponent extends TestComponent { } diff --git a/server/src/test/java/io/deephaven/server/runner/DeephavenApiServerTestBase.java b/server/src/test/java/io/deephaven/server/runner/DeephavenApiServerTestBase.java index f63c38c66ed..af4a3f8d729 100644 --- a/server/src/test/java/io/deephaven/server/runner/DeephavenApiServerTestBase.java +++ b/server/src/test/java/io/deephaven/server/runner/DeephavenApiServerTestBase.java @@ -36,7 +36,8 @@ public abstract class DeephavenApiServerTestBase { DeephavenApiServerModule.class, LogModule.class, NoConsoleSessionModule.class, - ServerBuilderInProcessModule.class + ServerBuilderInProcessModule.class, + ExecutionContextUnitTestModule.class, }) public interface TestComponent { @@ -59,9 +60,6 @@ interface Builder { @BindsInstance Builder withErr(@Named("err") PrintStream err); - @BindsInstance - Builder withExecutionContext(ExecutionContext context); - TestComponent build(); } } @@ -83,7 +81,6 @@ public void setUp() throws Exception { LogBufferGlobal.setInstance(logBuffer); serverComponent = DaggerDeephavenApiServerTestBase_TestComponent.builder() - .withExecutionContext(ExecutionContext.createForUnitTests()) .withSchedulerPoolSize(4) .withSessionTokenExpireTmMs(sessionTokenExpireTmMs()) .withOut(System.out) diff --git a/server/src/test/java/io/deephaven/server/runner/ExecutionContextUnitTestModule.java b/server/src/test/java/io/deephaven/server/runner/ExecutionContextUnitTestModule.java new file mode 100644 index 00000000000..f0b3521cd80 --- /dev/null +++ b/server/src/test/java/io/deephaven/server/runner/ExecutionContextUnitTestModule.java @@ -0,0 +1,16 @@ +package io.deephaven.server.runner; + +import dagger.Module; +import dagger.Provides; +import io.deephaven.engine.context.ExecutionContext; + +import javax.inject.Singleton; + +@Module +public class ExecutionContextUnitTestModule { + @Provides + @Singleton + public ExecutionContext provideExecutionContext() { + return ExecutionContext.createForUnitTests(); + } +} diff --git a/server/test/src/main/java/io/deephaven/server/test/FlightMessageRoundTripTest.java b/server/test/src/main/java/io/deephaven/server/test/FlightMessageRoundTripTest.java index 13430caad0c..48f54787c5a 100644 --- a/server/test/src/main/java/io/deephaven/server/test/FlightMessageRoundTripTest.java +++ b/server/test/src/main/java/io/deephaven/server/test/FlightMessageRoundTripTest.java @@ -133,11 +133,6 @@ int provideMaxInboundMessageSize() { ScheduledExecutorService provideExecutorService() { return null; } - - @Provides - ExecutionContext provideExecutionContext() { - return ExecutionContext.createForUnitTests(); - } } public interface TestComponent {