mirror of https://github.com/dapr/java-sdk.git
Merge branch 'master' into snyk-fix-eeb1d3dd920c0e379451216177858a8d
This commit is contained in:
commit
02e9a90363
|
|
@ -41,9 +41,9 @@ jobs:
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
GOPROXY: https://proxy.golang.org
|
GOPROXY: https://proxy.golang.org
|
||||||
JDK_VER: ${{ matrix.java }}
|
JDK_VER: ${{ matrix.java }}
|
||||||
DAPR_CLI_VER: 1.12.0-rc.1
|
DAPR_CLI_VER: 1.12.0
|
||||||
DAPR_RUNTIME_VER: 1.12.0-rc.5
|
DAPR_RUNTIME_VER: 1.12.4
|
||||||
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0-rc.1/install/install.sh
|
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0/install/install.sh
|
||||||
DAPR_CLI_REF:
|
DAPR_CLI_REF:
|
||||||
DAPR_REF:
|
DAPR_REF:
|
||||||
TOXIPROXY_URL: https://github.com/Shopify/toxiproxy/releases/download/v2.5.0/toxiproxy-server-linux-amd64
|
TOXIPROXY_URL: https://github.com/Shopify/toxiproxy/releases/download/v2.5.0/toxiproxy-server-linux-amd64
|
||||||
|
|
@ -115,7 +115,7 @@ jobs:
|
||||||
- name: Build sdk
|
- name: Build sdk
|
||||||
run: ./mvnw compile -B -q
|
run: ./mvnw compile -B -q
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
run: ./mvnw -B test -q
|
run: ./mvnw test # making it temporarily verbose.
|
||||||
- name: Codecov
|
- name: Codecov
|
||||||
uses: codecov/codecov-action@v3.1.4
|
uses: codecov/codecov-action@v3.1.4
|
||||||
- name: Install jars
|
- name: Install jars
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@ jobs:
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
GOPROXY: https://proxy.golang.org
|
GOPROXY: https://proxy.golang.org
|
||||||
JDK_VER: ${{ matrix.java }}
|
JDK_VER: ${{ matrix.java }}
|
||||||
DAPR_CLI_VER: 1.12.0-rc.1
|
DAPR_CLI_VER: 1.12.0
|
||||||
DAPR_RUNTIME_VER: 1.12.0-rc.5
|
DAPR_RUNTIME_VER: 1.12.4
|
||||||
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0-rc.1/install/install.sh
|
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0/install/install.sh
|
||||||
DAPR_CLI_REF:
|
DAPR_CLI_REF:
|
||||||
DAPR_REF:
|
DAPR_REF:
|
||||||
steps:
|
steps:
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ import io.grpc.inprocess.InProcessChannelBuilder;
|
||||||
import io.grpc.inprocess.InProcessServerBuilder;
|
import io.grpc.inprocess.InProcessServerBuilder;
|
||||||
import io.grpc.testing.GrpcCleanupRule;
|
import io.grpc.testing.GrpcCleanupRule;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
|
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
|
|
@ -47,7 +47,6 @@ import reactor.util.context.ContextView;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
@EnableRuleMigrationSupport
|
@EnableRuleMigrationSupport
|
||||||
public class DaprClientGrpcTelemetryTest {
|
public class DaprClientGrpcTelemetryTest {
|
||||||
|
|
@ -70,6 +69,13 @@ public class DaprClientGrpcTelemetryTest {
|
||||||
|
|
||||||
private DaprClient client;
|
private DaprClient client;
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void teardown() throws Exception {
|
||||||
|
if (client != null) {
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Stream<Arguments> data() {
|
public static Stream<Arguments> data() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
Arguments.of(
|
Arguments.of(
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,21 @@ package io.dapr.utils;
|
||||||
|
|
||||||
import io.dapr.config.Properties;
|
import io.dapr.config.Properties;
|
||||||
import io.grpc.ManagedChannel;
|
import io.grpc.ManagedChannel;
|
||||||
|
import io.grpc.testing.GrpcCleanupRule;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
public class NetworkUtilsTest {
|
public class NetworkUtilsTest {
|
||||||
private final int defaultGrpcPort = 4000;
|
private final int defaultGrpcPort = 4000;
|
||||||
private final String defaultSidecarIP = "127.0.0.1";
|
private final String defaultSidecarIP = "127.0.0.1";
|
||||||
|
|
||||||
|
private ManagedChannel channel;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
System.setProperty(Properties.GRPC_PORT.getName(), Integer.toString(defaultGrpcPort));
|
System.setProperty(Properties.GRPC_PORT.getName(), Integer.toString(defaultGrpcPort));
|
||||||
|
|
@ -16,9 +24,16 @@ public class NetworkUtilsTest {
|
||||||
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "");
|
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void tearDown() {
|
||||||
|
if (channel != null && !channel.isShutdown()) {
|
||||||
|
channel.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuildGrpcManagedChannel() {
|
public void testBuildGrpcManagedChannel() {
|
||||||
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
|
channel = NetworkUtils.buildGrpcManagedChannel();
|
||||||
|
|
||||||
String expectedAuthority = String.format("%s:%s", defaultSidecarIP, defaultGrpcPort);
|
String expectedAuthority = String.format("%s:%s", defaultSidecarIP, defaultGrpcPort);
|
||||||
Assertions.assertEquals(expectedAuthority, channel.authority());
|
Assertions.assertEquals(expectedAuthority, channel.authority());
|
||||||
|
|
@ -27,7 +42,7 @@ public class NetworkUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testBuildGrpcManagedChannel_httpEndpointNoPort() {
|
public void testBuildGrpcManagedChannel_httpEndpointNoPort() {
|
||||||
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "http://example.com");
|
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "http://example.com");
|
||||||
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
|
channel = NetworkUtils.buildGrpcManagedChannel();
|
||||||
|
|
||||||
String expectedAuthority = "example.com:80";
|
String expectedAuthority = "example.com:80";
|
||||||
Assertions.assertEquals(expectedAuthority, channel.authority());
|
Assertions.assertEquals(expectedAuthority, channel.authority());
|
||||||
|
|
@ -36,7 +51,7 @@ public class NetworkUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testBuildGrpcManagedChannel_httpEndpointWithPort() {
|
public void testBuildGrpcManagedChannel_httpEndpointWithPort() {
|
||||||
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "http://example.com:3000");
|
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "http://example.com:3000");
|
||||||
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
|
channel = NetworkUtils.buildGrpcManagedChannel();
|
||||||
|
|
||||||
String expectedAuthority = "example.com:3000";
|
String expectedAuthority = "example.com:3000";
|
||||||
Assertions.assertEquals(expectedAuthority, channel.authority());
|
Assertions.assertEquals(expectedAuthority, channel.authority());
|
||||||
|
|
@ -45,7 +60,7 @@ public class NetworkUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testBuildGrpcManagedChannel_httpsEndpointNoPort() {
|
public void testBuildGrpcManagedChannel_httpsEndpointNoPort() {
|
||||||
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "https://example.com");
|
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "https://example.com");
|
||||||
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
|
channel = NetworkUtils.buildGrpcManagedChannel();
|
||||||
|
|
||||||
String expectedAuthority = "example.com:443";
|
String expectedAuthority = "example.com:443";
|
||||||
Assertions.assertEquals(expectedAuthority, channel.authority());
|
Assertions.assertEquals(expectedAuthority, channel.authority());
|
||||||
|
|
@ -54,7 +69,7 @@ public class NetworkUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testBuildGrpcManagedChannel_httpsEndpointWithPort() {
|
public void testBuildGrpcManagedChannel_httpsEndpointWithPort() {
|
||||||
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "https://example.com:3000");
|
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "https://example.com:3000");
|
||||||
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
|
channel = NetworkUtils.buildGrpcManagedChannel();
|
||||||
|
|
||||||
String expectedAuthority = "example.com:3000";
|
String expectedAuthority = "example.com:3000";
|
||||||
Assertions.assertEquals(expectedAuthority, channel.authority());
|
Assertions.assertEquals(expectedAuthority, channel.authority());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue