Copilot commented on code in PR #7561:
URL: https://github.com/apache/texera/pull/7561#discussion_r3760889774
##########
workflow-compiling-service/src/test/scala/org/apache/texera/service/WorkflowCompilingServiceRunSpec.scala:
##########
@@ -19,13 +19,63 @@
package org.apache.texera.service
-import org.apache.texera.auth.RoleAnnotationEnforcer
+import io.dropwizard.core.setup.Environment
+import io.dropwizard.jersey.DropwizardResourceConfig
+import io.dropwizard.jersey.setup.JerseyEnvironment
+import io.dropwizard.jetty.MutableServletContextHandler
+import io.dropwizard.jetty.setup.ServletEnvironment
+import org.apache.texera.auth.{RoleAnnotationEnforcer,
UnauthorizedExceptionMapper}
import org.apache.texera.service.resource.{HealthCheckResource,
WorkflowCompilationResource}
+import org.eclipse.jetty.servlet.FilterHolder
+import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature
+import org.mockito.ArgumentMatchers.{any, eq => eqTo, isA}
+import org.mockito.Mockito.{mock, verify, when}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
class WorkflowCompilingServiceRunSpec extends AnyFlatSpec with Matchers {
+ // Mirrors AccessControlServiceRunSpec: run() is driven against a mocked
Dropwizard
+ // environment so the wiring it installs can be asserted without starting a
server.
+ private def runService(): (JerseyEnvironment, MutableServletContextHandler)
= {
+ val jersey = mock(classOf[JerseyEnvironment])
+ val servlets = mock(classOf[ServletEnvironment])
+ val context = mock(classOf[MutableServletContextHandler])
+ val env = mock(classOf[Environment])
+ when(env.jersey).thenReturn(jersey)
+ when(env.servlets).thenReturn(servlets)
+ when(env.getApplicationContext).thenReturn(context)
+
when(jersey.getResourceConfig).thenReturn(DropwizardResourceConfig.forTesting())
+
+ val service = new WorkflowCompilingService
+ service.run(mock(classOf[WorkflowCompilingServiceConfiguration]), env)
+
+ (jersey, context)
+ }
Review Comment:
Each test calls `runService()`, so this executes `run()` four times. That
starts four non-daemon operator-metadata warmup threads and repeatedly replaces
the global `SqlServer` (`ObjectMapperUtils.scala:41`, `SqlServer.scala:80-82`),
adding heavyweight concurrent work and global-state churn to a wiring test.
Memoize this read-only fixture (or combine the wiring assertions) so the
service starts only once.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]