-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a smoke test for spring webmvc -> async -> grpc
- Loading branch information
1 parent
b5f90d3
commit daebf6a
Showing
5 changed files
with
95 additions
and
31 deletions.
There are no files selected for viewing
18 changes: 0 additions & 18 deletions
18
...boot-grpc/src/main_java8/java/datadog.smoketest.springboot/SpringbootGrpcApplication.java
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
...oke-tests/springboot-grpc/src/main_java8/java/datadog/smoketest/springboot/AsyncTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package datadog.smoketest.springboot; | ||
|
||
import datadog.smoketest.springboot.grpc.AsynchronousGreeter; | ||
import org.springframework.scheduling.annotation.Async; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class AsyncTask { | ||
|
||
private final AsynchronousGreeter greeter; | ||
|
||
public AsyncTask(AsynchronousGreeter greeter) { | ||
this.greeter = greeter; | ||
} | ||
|
||
@Async | ||
public CompletableFuture<String> greet() { | ||
return CompletableFuture.completedFuture(greeter.greet()); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...boot-grpc/src/main_java8/java/datadog/smoketest/springboot/SpringbootGrpcApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package datadog.smoketest.springboot; | ||
|
||
import java.io.IOException; | ||
import java.lang.management.ManagementFactory; | ||
|
||
import datadog.smoketest.springboot.grpc.AsynchronousGreeter; | ||
import datadog.smoketest.springboot.grpc.LocalInterface; | ||
import datadog.smoketest.springboot.grpc.SynchronousGreeter; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
@SpringBootApplication | ||
@EnableAsync | ||
@EnableScheduling | ||
public class SpringbootGrpcApplication { | ||
|
||
@Bean | ||
AsyncTask asyncTask(AsynchronousGreeter greeter) { | ||
return new AsyncTask(greeter); | ||
} | ||
|
||
@Bean | ||
AsynchronousGreeter asynchronousGreeter(LocalInterface localInterface) { | ||
return new AsynchronousGreeter(localInterface.getPort()); | ||
} | ||
|
||
@Bean | ||
SynchronousGreeter synchronousGreeter(LocalInterface localInterface) { | ||
return new SynchronousGreeter(localInterface.getPort()); | ||
} | ||
|
||
@Bean | ||
LocalInterface localInterface() throws IOException { | ||
return new LocalInterface(); | ||
} | ||
|
||
public static void main(final String[] args) { | ||
ConfigurableApplicationContext app = | ||
SpringApplication.run(SpringbootGrpcApplication.class, args); | ||
Integer port = app.getBean("local.server.port", Integer.class); | ||
System.out.println( | ||
"Bound to " + port + " in " + ManagementFactory.getRuntimeMXBean().getUptime() + "ms"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...pringboot-grpc/src/test/groovy/datadog/smoketest/SpringBootGrpcAsyncAnnotationTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package datadog.smoketest | ||
|
||
class SpringBootGrpcAsyncAnnotationTest extends SpringBootWithGRPCTest { | ||
@Override | ||
Set<String> expectedTraces() { | ||
return ["[grpc.server[grpc.message]]", | ||
"[servlet.request[spring.handler[AsyncTask.greet[grpc.client[grpc.message]]]]]"].toSet() | ||
} | ||
|
||
@Override | ||
String route() { | ||
return "async_annotation_greeting" | ||
} | ||
} |