Skip to content

Commit b2968af

Browse files
cicoyleartursouza
andauthored
Resolve buildGrpcManagedChannel orphaned channel & ensure connections mocked (#1003)
* okhttpclient is mocked Signed-off-by: Cassandra Coyle <[email protected]> * mock workflowRuntime to rm log: 'The sidecar at address localhost:4001 is unavailable. Will continue retrying.' Signed-off-by: Cassandra Coyle <[email protected]> * fix several NetworkUtilsTest orphaned channels Signed-off-by: Cassandra Coyle <[email protected]> * reset workflow changes since I still see the log output Signed-off-by: Cassandra Coyle <[email protected]> * Close daprClient on DaprClientGrpcTelemetryTest Signed-off-by: Artur Souza <[email protected]> * try latest runtime rc Signed-off-by: Cassandra Coyle <[email protected]> * Update runtime to 1.12.4 Signed-off-by: Artur Souza <[email protected]> * Mvn test is now verbose, temporatily. Signed-off-by: Artur Souza <[email protected]> * try fixing RetryPolicyTest Signed-off-by: Cassandra Coyle <[email protected]> * comment out RetryPolicyTest Signed-off-by: Cassandra Coyle <[email protected]> * add RetryPolicyTest back Signed-off-by: Cassandra Coyle <[email protected]> * trying to figure out which test func is the issue Signed-off-by: Cassandra Coyle <[email protected]> * try ubuntu-20.04 Signed-off-by: Cassandra Coyle <[email protected]> * try rm-ing GrpcChannelFacadeTest Signed-off-by: Cassandra Coyle <[email protected]> * try rm-ing DaprClientHttpTest Signed-off-by: Cassandra Coyle <[email protected]> * try t.join just in case Signed-off-by: Cassandra Coyle <[email protected]> * is this the bad test? Signed-off-by: Cassandra Coyle <[email protected]> * are these other healthcheck tests the problem? Signed-off-by: Cassandra Coyle <[email protected]> * is it the ok test? Signed-off-by: Cassandra Coyle <[email protected]> * is it due to an invoke test? Signed-off-by: Cassandra Coyle <[email protected]> * is it the config/subscribeConfig tests Signed-off-by: Cassandra Coyle <[email protected]> * is it noHotMono? Signed-off-by: Cassandra Coyle <[email protected]> * is it a publish test? Signed-off-by: Cassandra Coyle <[email protected]> * is it the other noHotMono tests? Signed-off-by: Cassandra Coyle <[email protected]> * is it a state test? Signed-off-by: Cassandra Coyle <[email protected]> * is it a save state test? Signed-off-by: Cassandra Coyle <[email protected]> * is it a secret test? Signed-off-by: Cassandra Coyle <[email protected]> * is it a delete state test? Signed-off-by: Cassandra Coyle <[email protected]> * is it the rest -1 and - ending tests? Signed-off-by: Cassandra Coyle <[email protected]> * no client calls, only end of file remaining Signed-off-by: Cassandra Coyle <[email protected]> * add teardown - did it work? Signed-off-by: Cassandra Coyle <[email protected]> * is it just needing daprClientHttpXML to be closed? Signed-off-by: Cassandra Coyle <[email protected]> * Reuse mock and builder. Signed-off-by: Artur Souza <[email protected]> * Try dedicated executor. Signed-off-by: Artur Souza <[email protected]> * Comment out the remaining tests. Signed-off-by: Artur Souza <[email protected]> * Remove before and after. Signed-off-by: Artur Souza <[email protected]> * Remove sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java Signed-off-by: Artur Souza <[email protected]> * Remove sdk/src/test/java/io/dapr/client/DaprHttpTest.java. Signed-off-by: Artur Souza <[email protected]> * Delete a batch of tests. Signed-off-by: Artur Souza <[email protected]> * restore deleted test files Signed-off-by: Cassandra Coyle <[email protected]> * add back in RetryPolicyTest Signed-off-by: Cassandra Coyle <[email protected]> --------- Signed-off-by: Cassandra Coyle <[email protected]> Signed-off-by: Artur Souza <[email protected]> Co-authored-by: Artur Souza <[email protected]> Co-authored-by: Artur Souza <[email protected]>
1 parent 22427c9 commit b2968af

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

Diff for: .github/workflows/build.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ jobs:
4141
GOARCH: amd64
4242
GOPROXY: https://proxy.golang.org
4343
JDK_VER: ${{ matrix.java }}
44-
DAPR_CLI_VER: 1.12.0-rc.1
45-
DAPR_RUNTIME_VER: 1.12.0-rc.5
46-
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0-rc.1/install/install.sh
44+
DAPR_CLI_VER: 1.12.0
45+
DAPR_RUNTIME_VER: 1.12.4
46+
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0/install/install.sh
4747
DAPR_CLI_REF:
4848
DAPR_REF:
4949
TOXIPROXY_URL: https://github.com/Shopify/toxiproxy/releases/download/v2.5.0/toxiproxy-server-linux-amd64
@@ -115,7 +115,7 @@ jobs:
115115
- name: Build sdk
116116
run: ./mvnw compile -B -q
117117
- name: Unit tests
118-
run: ./mvnw -B test -q
118+
run: ./mvnw test # making it temporarily verbose.
119119
- name: Codecov
120120
uses: codecov/[email protected]
121121
- name: Install jars

Diff for: .github/workflows/validate.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
GOARCH: amd64
3838
GOPROXY: https://proxy.golang.org
3939
JDK_VER: ${{ matrix.java }}
40-
DAPR_CLI_VER: 1.12.0-rc.1
41-
DAPR_RUNTIME_VER: 1.12.0-rc.5
42-
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0-rc.1/install/install.sh
40+
DAPR_CLI_VER: 1.12.0
41+
DAPR_RUNTIME_VER: 1.12.4
42+
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.12.0/install/install.sh
4343
DAPR_CLI_REF:
4444
DAPR_REF:
4545
steps:

Diff for: sdk/src/test/java/io/dapr/client/DaprClientGrpcTelemetryTest.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import io.grpc.inprocess.InProcessServerBuilder;
3131
import io.grpc.testing.GrpcCleanupRule;
3232
import org.junit.Rule;
33+
import org.junit.jupiter.api.AfterEach;
3334
import org.junit.jupiter.api.Test;
34-
import org.junit.jupiter.api.extension.RegisterExtension;
3535
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
3636
import org.junit.jupiter.params.ParameterizedTest;
3737
import org.junit.jupiter.params.provider.Arguments;
@@ -47,7 +47,6 @@
4747

4848
import static org.junit.jupiter.api.Assertions.assertEquals;
4949
import static org.junit.jupiter.api.Assertions.assertNull;
50-
import static org.junit.jupiter.api.Assertions.assertTrue;
5150

5251
@EnableRuleMigrationSupport
5352
public class DaprClientGrpcTelemetryTest {
@@ -70,6 +69,13 @@ public class DaprClientGrpcTelemetryTest {
7069

7170
private DaprClient client;
7271

72+
@AfterEach
73+
public void teardown() throws Exception {
74+
if (client != null) {
75+
client.close();
76+
}
77+
}
78+
7379
public static Stream<Arguments> data() {
7480
return Stream.of(
7581
Arguments.of(

Diff for: sdk/src/test/java/io/dapr/utils/NetworkUtilsTest.java

+20-5
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,38 @@
22

33
import io.dapr.config.Properties;
44
import io.grpc.ManagedChannel;
5+
import io.grpc.testing.GrpcCleanupRule;
6+
import org.junit.Rule;
7+
import org.junit.jupiter.api.AfterEach;
58
import org.junit.jupiter.api.Assertions;
69
import org.junit.jupiter.api.BeforeEach;
710
import org.junit.jupiter.api.Test;
811

12+
import static org.mockito.Mockito.mock;
13+
914
public class NetworkUtilsTest {
1015
private final int defaultGrpcPort = 4000;
1116
private final String defaultSidecarIP = "127.0.0.1";
17+
18+
private ManagedChannel channel;
19+
1220
@BeforeEach
1321
public void setUp() {
1422
System.setProperty(Properties.GRPC_PORT.getName(), Integer.toString(defaultGrpcPort));
1523
System.setProperty(Properties.SIDECAR_IP.getName(), defaultSidecarIP);
1624
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "");
1725
}
1826

27+
@AfterEach
28+
public void tearDown() {
29+
if (channel != null && !channel.isShutdown()) {
30+
channel.shutdown();
31+
}
32+
}
33+
1934
@Test
2035
public void testBuildGrpcManagedChannel() {
21-
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
36+
channel = NetworkUtils.buildGrpcManagedChannel();
2237

2338
String expectedAuthority = String.format("%s:%s", defaultSidecarIP, defaultGrpcPort);
2439
Assertions.assertEquals(expectedAuthority, channel.authority());
@@ -27,7 +42,7 @@ public void testBuildGrpcManagedChannel() {
2742
@Test
2843
public void testBuildGrpcManagedChannel_httpEndpointNoPort() {
2944
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "http://example.com");
30-
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
45+
channel = NetworkUtils.buildGrpcManagedChannel();
3146

3247
String expectedAuthority = "example.com:80";
3348
Assertions.assertEquals(expectedAuthority, channel.authority());
@@ -36,7 +51,7 @@ public void testBuildGrpcManagedChannel_httpEndpointNoPort() {
3651
@Test
3752
public void testBuildGrpcManagedChannel_httpEndpointWithPort() {
3853
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "http://example.com:3000");
39-
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
54+
channel = NetworkUtils.buildGrpcManagedChannel();
4055

4156
String expectedAuthority = "example.com:3000";
4257
Assertions.assertEquals(expectedAuthority, channel.authority());
@@ -45,7 +60,7 @@ public void testBuildGrpcManagedChannel_httpEndpointWithPort() {
4560
@Test
4661
public void testBuildGrpcManagedChannel_httpsEndpointNoPort() {
4762
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "https://example.com");
48-
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
63+
channel = NetworkUtils.buildGrpcManagedChannel();
4964

5065
String expectedAuthority = "example.com:443";
5166
Assertions.assertEquals(expectedAuthority, channel.authority());
@@ -54,7 +69,7 @@ public void testBuildGrpcManagedChannel_httpsEndpointNoPort() {
5469
@Test
5570
public void testBuildGrpcManagedChannel_httpsEndpointWithPort() {
5671
System.setProperty(Properties.GRPC_ENDPOINT.getName(), "https://example.com:3000");
57-
ManagedChannel channel = NetworkUtils.buildGrpcManagedChannel();
72+
channel = NetworkUtils.buildGrpcManagedChannel();
5873

5974
String expectedAuthority = "example.com:3000";
6075
Assertions.assertEquals(expectedAuthority, channel.authority());

0 commit comments

Comments
 (0)