Drop lagom test
MODIFY
instrumentation/akka-http-10.0/akka-http-10.0.gradle
instrumentation/akka-http-10.0/akka-http-10.0.gradle
@@ -8,23 +8,11 @@ apply from: "$rootDir/gradle/test-with-scala.gradle"
apply plugin: 'org.unbroken-dome.test-sets'
testSets {
- lagomTest
-
version101Test {
dirName = 'test'
}
}
-compileLagomTestJava {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
-}
-
-compileLagomTestGroovy {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
-}
-
muzzle {
pass {
group = 'com.typesafe.akka'
@@ -74,31 +62,14 @@ dependencies {
testImplementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
- lagomTestImplementation project(':instrumentation:akka-http-10.0')
-
- lagomTestImplementation group: 'com.lightbend.lagom', name: 'lagom-javadsl-testkit_2.11', version: '1.4.0'
-
// There are some internal API changes in 10.1 that we would like to test separately for
version101TestImplementation group: 'com.typesafe.akka', name: 'akka-http_2.11', version: '10.1.0'
version101TestImplementation group: 'com.typesafe.akka', name: 'akka-stream_2.11', version: '2.5.11'
}
-test.dependsOn lagomTest
test.dependsOn version101Test
compileVersion101TestGroovy {
classpath = classpath.plus(files(compileVersion101TestScala.destinationDir))
dependsOn compileVersion101TestScala
}
-
-// Lagom test supports running only on java 8 for now.
-// To run it on java 11 requires some complicated juggling of scala dependencies
-// At the same time, "minJavaVersionForTests"/"maxJavaVersionForTests" functionality
-// does not work currently with custom source sets.
-// They all use the same constraints as the main test source set.
-lagomTest {
- onlyIf {
- String java8Home = findJavaHome(JavaVersion.VERSION_1_8)
- java8Home != null && executable == toExecutable(java8Home)
- }
-}

DELETE
instrumentation/akka-http-10.0/src/lagomTest/groovy/LagomTest.groovy
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import static com.lightbend.lagom.javadsl.testkit.ServiceTest.TestServer
-import static com.lightbend.lagom.javadsl.testkit.ServiceTest.defaultSetup
-import static com.lightbend.lagom.javadsl.testkit.ServiceTest.startServer
-import static io.opentelemetry.trace.Span.Kind.SERVER
-
-import akka.NotUsed
-import akka.stream.javadsl.Source
-import akka.stream.testkit.TestSubscriber.Probe
-import akka.stream.testkit.javadsl.TestSink
-import io.opentelemetry.auto.test.AgentTestRunner
-import io.opentelemetry.trace.attributes.SemanticAttributes
-import java.util.function.Function
-import play.inject.guice.GuiceApplicationBuilder
-import spock.lang.Shared
-
-class LagomTest extends AgentTestRunner {
-
- @Shared
- private TestServer server
-
- def setupSpec() {
- server = startServer(defaultSetup()
- .withCluster(false)
- .withPersistence(false)
- .withCassandra(false)
- .withJdbc(false)
- .configureBuilder(
- new Function<GuiceApplicationBuilder, GuiceApplicationBuilder>() {
- @Override
- GuiceApplicationBuilder apply(GuiceApplicationBuilder builder) {
- return builder
- .bindings(new ServiceTestModule())
- }
- }))
- }
-
- def cleanupSpec() {
- server.stop()
- }
-
- def "normal request traces"() {
- setup:
- EchoService service = server.client(EchoService)
-
- Source<String, NotUsed> input =
- Source.from(Arrays.asList("msg1", "msg2", "msg3"))
- .concat(Source.maybe())
- Source<String, NotUsed> output = service.echo().invoke(input)
- .toCompletableFuture().get()
- Probe<String> probe = output.runWith(TestSink.probe(server.system()), server.materializer())
- probe.request(10)
- probe.expectNext("msg1")
- probe.expectNext("msg2")
- probe.expectNext("msg3")
- probe.cancel()
-
- expect:
- assertTraces(1) {
- trace(0, 2) {
- span(0) {
- operationName expectedOperationName()
- spanKind SERVER
- errored false
- attributes {
- "${SemanticAttributes.HTTP_URL.key()}" "ws://localhost:${server.port()}/echo"
- "${SemanticAttributes.HTTP_METHOD.key()}" "GET"
- "${SemanticAttributes.HTTP_STATUS_CODE.key()}" 101
- "${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
- "${SemanticAttributes.HTTP_USER_AGENT.key()}" String
- }
- }
- span(1) {
- childOf span(0)
- operationName 'tracedMethod'
- attributes {
- }
- }
- }
- }
- }
-
- def "error traces"() {
- setup:
- EchoService service = server.client(EchoService)
-
- Source<String, NotUsed> input =
- Source.from(Arrays.asList("msg1", "msg2", "msg3"))
- .concat(Source.maybe())
- try {
- service.error().invoke(input).toCompletableFuture().get()
- } catch (Exception e) {
- }
-
- expect:
- assertTraces(1) {
- trace(0, 1) {
- span(0) {
- operationName expectedOperationName()
- spanKind SERVER
- errored true
- attributes {
- "${SemanticAttributes.HTTP_URL.key()}" "ws://localhost:${server.port()}/error"
- "${SemanticAttributes.HTTP_METHOD.key()}" "GET"
- "${SemanticAttributes.HTTP_STATUS_CODE.key()}" 500
- "${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
- "${SemanticAttributes.HTTP_USER_AGENT.key()}" String
- }
- }
- }
- }
- }
-
- String expectedOperationName() {
- return "akka.request"
- }
-}

DELETE
instrumentation/akka-http-10.0/src/lagomTest/java/EchoService.java
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import static com.lightbend.lagom.javadsl.api.Service.named;
-import static com.lightbend.lagom.javadsl.api.Service.namedCall;
-
-import akka.NotUsed;
-import akka.stream.javadsl.Source;
-import com.lightbend.lagom.javadsl.api.Descriptor;
-import com.lightbend.lagom.javadsl.api.Service;
-import com.lightbend.lagom.javadsl.api.ServiceCall;
-
-public interface EchoService extends Service {
-
- ServiceCall<Source<String, NotUsed>, Source<String, NotUsed>> echo();
-
- ServiceCall<Source<String, NotUsed>, Source<String, NotUsed>> error();
-
- @Override
- default Descriptor descriptor() {
- return named("echo").withCalls(namedCall("echo", this::echo), namedCall("error", this::error));
- }
-}

DELETE
instrumentation/akka-http-10.0/src/lagomTest/java/EchoServiceImpl.java
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import akka.NotUsed;
-import akka.stream.javadsl.Source;
-import com.lightbend.lagom.javadsl.api.ServiceCall;
-import io.opentelemetry.OpenTelemetry;
-import io.opentelemetry.trace.Span;
-import io.opentelemetry.trace.Tracer;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-public class EchoServiceImpl implements EchoService {
- private static final Tracer TRACER = OpenTelemetry.getTracer("io.opentelemetry.auto");
-
- @Override
- public ServiceCall<Source<String, NotUsed>, Source<String, NotUsed>> echo() {
- CompletableFuture<Source<String, NotUsed>> fut = new CompletableFuture<>();
- ServiceTestModule.executor.submit(() -> fut.complete(Source.from(tracedMethod())));
- return req -> fut;
- }
-
- @Override
- public ServiceCall<Source<String, NotUsed>, Source<String, NotUsed>> error() {
- throw new RuntimeException("lagom exception");
- }
-
- public List<String> tracedMethod() {
- Span span = TRACER.spanBuilder("tracedMethod").startSpan();
- try {
- return java.util.Arrays.asList("msg1", "msg2", "msg3");
- } finally {
- span.end();
- }
- }
-}

DELETE
instrumentation/akka-http-10.0/src/lagomTest/java/ServiceTestModule.java
-/*
- * Copyright The OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Binder;
-import com.lightbend.lagom.internal.javadsl.BinderAccessor;
-import com.lightbend.lagom.internal.javadsl.server.JavadslServicesRouter;
-import com.lightbend.lagom.internal.javadsl.server.ResolvedServices;
-import com.lightbend.lagom.internal.javadsl.server.ResolvedServicesProvider;
-import com.lightbend.lagom.internal.javadsl.server.ServiceInfoProvider;
-import com.lightbend.lagom.internal.server.status.MetricsServiceImpl;
-import com.lightbend.lagom.javadsl.api.ServiceInfo;
-import com.lightbend.lagom.javadsl.server.LagomServiceRouter;
-import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport;
-import com.lightbend.lagom.javadsl.server.status.MetricsService;
-import java.util.Arrays;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-public class ServiceTestModule extends AbstractModule implements ServiceGuiceSupport {
- public static final ExecutorService executor = Executors.newCachedThreadPool();
-
- @Override
- protected void configure() {
- bindServices(
- serviceBinding(EchoService.class, EchoServiceImpl.class)
- // , serviceBinding(HelloService.class, HelloServiceImpl.class)
- );
- }
-
- // ------------------------------
-
- /**
- * This is a copy of {@link
- * com.lightbend.lagom.javadsl.server.ServiceGuiceSupport#bindServices(ServiceGuiceSupport.ServiceBinding[])}
- * that should survive deprecation. When removing the method from the superclass this should
- * inherit the removed code.
- *
- * <p>This method is used in docs/ so that many tests can share a single Guice module.
- */
- @Override
- public void bindServices(ServiceBinding<?>... serviceBindings) {
- Binder binder = BinderAccessor.binder(this);
-
- for (ServiceBinding binding : serviceBindings) {
- // First, bind the client implementation. A service should be able to be a client to itself.
- bindClient(binding.serviceInterface());
-
- // Now, bind the server implementation to itself as an eager singleton.
- if (binding instanceof ClassServiceBinding) {
- binder.bind(((ClassServiceBinding<?>) binding).serviceImplementation()).asEagerSingleton();
- } else {
- Object service = ((InstanceServiceBinding<?>) binding).service();
- binder.bind((Class<Object>) service.getClass()).toInstance(service);
- }
- }
-
- ServiceBinding<?> primaryServiceBinding = serviceBindings[0];
- // Bind the service info for the first one passed in
- binder
- .bind(ServiceInfo.class)
- .toProvider(
- new ServiceInfoProvider(
- primaryServiceBinding.serviceInterface(),
- Arrays.stream(serviceBindings)
- .map(ServiceBinding::serviceInterface)
- .toArray(Class[]::new)));
-
- // Bind the metrics
- ServiceBinding<MetricsService> metricsServiceBinding =
- serviceBinding(MetricsService.class, MetricsServiceImpl.class);
- binder
- .bind(((ClassServiceBinding<?>) metricsServiceBinding).serviceImplementation())
- .asEagerSingleton();
- ServiceBinding<?>[] allServiceBindings = new ServiceBinding<?>[serviceBindings.length + 1];
- System.arraycopy(serviceBindings, 0, allServiceBindings, 0, serviceBindings.length);
- allServiceBindings[allServiceBindings.length - 1] = metricsServiceBinding;
-
- // Bind the resolved services
- binder
- .bind(ResolvedServices.class)
- .toProvider(new ResolvedServicesProvider(allServiceBindings));
-
- // And bind the router
- binder.bind(LagomServiceRouter.class).to(JavadslServicesRouter.class);
- }
-}

DELETE
instrumentation/akka-http-10.0/src/lagomTest/resources/application.conf
-lagom.circuit-breaker {
- // Disable Lagom circuit-breaker
- default {
- enabled = off
- }
-}

Drop lagom test (#1069)