Merge branch 'master' into snyk-fix-eeb1d3dd920c0e379451216177858a8d

This commit is contained in:
Artur Souza 2024-02-08 14:48:34 -08:00 committed by GitHub
commit 02e9a90363
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 14 deletions

View File

@ -41,9 +41,9 @@ jobs:
GOARCH: amd64
GOPROXY: https://proxy.golang.org
JDK_VER: ${{ matrix.java }}
DAPR_CLI_VER: 1.12.0-rc.1
DAPR_RUNTIME_VER: 1.12.0-rc.5
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0-rc.1/install/install.sh
DAPR_CLI_VER: 1.12.0
DAPR_RUNTIME_VER: 1.12.4
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0/install/install.sh
DAPR_CLI_REF:
DAPR_REF:
TOXIPROXY_URL: https://github.com/Shopify/toxiproxy/releases/download/v2.5.0/toxiproxy-server-linux-amd64
@ -115,7 +115,7 @@ jobs:
- name: Build sdk
run: ./mvnw compile -B -q
- name: Unit tests
run: ./mvnw -B test -q
run: ./mvnw test # making it temporarily verbose.
- name: Codecov
uses: codecov/codecov-action@v3.1.4
- name: Install jars

View File

@ -37,9 +37,9 @@ jobs:
GOARCH: amd64
GOPROXY: https://proxy.golang.org
JDK_VER: ${{ matrix.java }}
DAPR_CLI_VER: 1.12.0-rc.1
DAPR_RUNTIME_VER: 1.12.0-rc.5
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0-rc.1/install/install.sh
DAPR_CLI_VER: 1.12.0
DAPR_RUNTIME_VER: 1.12.4
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0/install/install.sh
DAPR_CLI_REF:
DAPR_REF:
steps:

View File

@ -30,8 +30,8 @@ import io.grpc.inprocess.InProcessChannelBuilder;
import io.grpc.inprocess.InProcessServerBuilder;
import io.grpc.testing.GrpcCleanupRule;
import org.junit.Rule;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.jupiter.params.ParameterizedTest;
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.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@EnableRuleMigrationSupport
public class DaprClientGrpcTelemetryTest {
@ -70,6 +69,13 @@ public class DaprClientGrpcTelemetryTest {
private DaprClient client;
@AfterEach
public void teardown() throws Exception {
if (client != null) {
client.close();
}
}
public static Stream<Arguments> data() {
return Stream.of(
Arguments.of(

View File

@ -2,13 +2,21 @@ package io.dapr.utils;
import io.dapr.config.Properties;
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.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
public class NetworkUtilsTest {
private final int defaultGrpcPort = 4000;
private final String defaultSidecarIP = "127.0.0.1";
private ManagedChannel channel;
@BeforeEach
public void setUp() {
System.setProperty(Properties.GRPC_PORT.getName(), Integer.toString(defaultGrpcPort));
@ -16,9 +24,16 @@ public class NetworkUtilsTest {
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "");
}
@AfterEach
public void tearDown() {
if (channel != null && !channel.isShutdown()) {
channel.shutdown();
}
}
@Test
public void testBuildGrpcManagedChannel() {
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
channel = NetworkUtils.buildGrpcManagedChannel();
String expectedAuthority = String.format("%s:%s", defaultSidecarIP, defaultGrpcPort);
Assertions.assertEquals(expectedAuthority, channel.authority());
@ -27,7 +42,7 @@ public class NetworkUtilsTest {
@Test
public void testBuildGrpcManagedChannel_httpEndpointNoPort() {
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "http://example.com");
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
channel = NetworkUtils.buildGrpcManagedChannel();
String expectedAuthority = "example.com:80";
Assertions.assertEquals(expectedAuthority, channel.authority());
@ -36,7 +51,7 @@ public class NetworkUtilsTest {
@Test
public void testBuildGrpcManagedChannel_httpEndpointWithPort() {
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "http://example.com:3000");
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
channel = NetworkUtils.buildGrpcManagedChannel();
String expectedAuthority = "example.com:3000";
Assertions.assertEquals(expectedAuthority, channel.authority());
@ -45,7 +60,7 @@ public class NetworkUtilsTest {
@Test
public void testBuildGrpcManagedChannel_httpsEndpointNoPort() {
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "https://example.com");
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
channel = NetworkUtils.buildGrpcManagedChannel();
String expectedAuthority = "example.com:443";
Assertions.assertEquals(expectedAuthority, channel.authority());
@ -54,7 +69,7 @@ public class NetworkUtilsTest {
@Test
public void testBuildGrpcManagedChannel_httpsEndpointWithPort() {
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "https://example.com:3000");
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
channel = NetworkUtils.buildGrpcManagedChannel();
String expectedAuthority = "example.com:3000";
Assertions.assertEquals(expectedAuthority, channel.authority());