|
17 | 17 | package io.grpc.testing.integration; |
18 | 18 |
|
19 | 19 | import static com.google.common.truth.Truth.assertThat; |
20 | | -import static io.grpc.testing.integration.TestCases.MCS; |
| 20 | +import static io.grpc.testing.integration.TestCases.MCS_CS; |
21 | 21 | import static org.junit.Assert.assertEquals; |
22 | 22 | import static org.junit.Assert.assertFalse; |
23 | 23 | import static org.junit.Assert.assertNotEquals; |
@@ -576,16 +576,10 @@ private void runTest(TestCases testCase) throws Exception { |
576 | 576 | break; |
577 | 577 | } |
578 | 578 |
|
579 | | - case MCS: { |
| 579 | + case MCS_CS: { |
580 | 580 | tester.testMcs(); |
581 | 581 | break; |
582 | 582 | } |
583 | | - |
584 | | - case MCSSS: { |
585 | | - tester.testMcs_serverStreaming(); |
586 | | - break; |
587 | | - } |
588 | | - |
589 | 583 | default: |
590 | 584 | throw new IllegalArgumentException("Unknown test case: " + testCase); |
591 | 585 | } |
@@ -622,8 +616,8 @@ private class Tester extends AbstractInteropTest { |
622 | 616 |
|
623 | 617 | @Override |
624 | 618 | protected ManagedChannelBuilder<?> createChannelBuilder() { |
625 | | - boolean useSubchannelMetricsSink = testCase.equals(MCS.toString()); |
626 | | - boolean useGeneric = testCase.equals(MCS.toString())? true : false; |
| 619 | + boolean useSubchannelMetricsSink = testCase.equals(MCS_CS.toString()); |
| 620 | + boolean useGeneric = testCase.equals(MCS_CS.toString())? true : false; |
627 | 621 | ChannelCredentials channelCredentials; |
628 | 622 | if (customCredentialsType != null) { |
629 | 623 | useGeneric = true; // Retain old behavior; avoids erroring if incompatible |
@@ -683,7 +677,7 @@ protected ManagedChannelBuilder<?> createChannelBuilder() { |
683 | 677 | if (serverHostOverride != null) { |
684 | 678 | channelBuilder.overrideAuthority(serverHostOverride); |
685 | 679 | } |
686 | | - if (testCase.equals(MCS.toString())) { |
| 680 | + if (testCase.equals(MCS_CS.toString())) { |
687 | 681 | channelBuilder.disableServiceConfigLookUp(); |
688 | 682 | try { |
689 | 683 | @SuppressWarnings("unchecked") |
@@ -1101,32 +1095,37 @@ Object take() throws InterruptedException { |
1101 | 1095 | } |
1102 | 1096 |
|
1103 | 1097 | public void testMcs() throws Exception { |
1104 | | - StreamingOutputCallResponseObserver responseObserver1 = new StreamingOutputCallResponseObserver(); |
| 1098 | + StreamingOutputCallResponseObserver responseObserver1 = |
| 1099 | + new StreamingOutputCallResponseObserver(); |
1105 | 1100 | StreamObserver<StreamingOutputCallRequest> streamObserver1 = |
1106 | 1101 | asyncStub.fullDuplexCall(responseObserver1); |
1107 | | - streamObserver1.onNext(StreamingOutputCallRequest.newBuilder() |
1108 | | - .addResponseParameters(ResponseParameters.newBuilder().setSize(1).build()).build()); |
1109 | | - assertThat(responseObserver1.take()).isInstanceOf(StreamingOutputCallResponse.class); |
| 1102 | + StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder() |
| 1103 | + .setPayload(Payload.newBuilder().setBody( |
| 1104 | + ByteString.copyFrom(MCS_CS.description().getBytes())).build()).build(); |
| 1105 | + streamObserver1.onNext(request); |
| 1106 | + Object responseObj = responseObserver1.take(); |
| 1107 | + StreamingOutputCallResponse callResponse = (StreamingOutputCallResponse) responseObj; |
| 1108 | + String clientSocketAddressInCall1 = new String(callResponse.getPayload().getBody().toByteArray()); |
1110 | 1109 |
|
1111 | 1110 | StreamingOutputCallResponseObserver responseObserver2 = new StreamingOutputCallResponseObserver(); |
1112 | 1111 | StreamObserver<StreamingOutputCallRequest> streamObserver2 = |
1113 | 1112 | asyncStub.fullDuplexCall(responseObserver2); |
1114 | | - streamObserver2.onNext(StreamingOutputCallRequest.newBuilder() |
1115 | | - .addResponseParameters(ResponseParameters.newBuilder().setSize(1).build()).build()); |
1116 | | - assertThat(responseObserver2.take()).isInstanceOf(StreamingOutputCallResponse.class); |
| 1113 | + streamObserver2.onNext(request); |
| 1114 | + callResponse = (StreamingOutputCallResponse) responseObserver2.take(); |
| 1115 | + String clientSocketAddressInCall2 = new String(callResponse.getPayload().getBody().toByteArray()); |
1117 | 1116 |
|
1118 | | - assertThat(fakeMetricsSink.openConnectionCount).isEqualTo(1); |
| 1117 | + assertThat(clientSocketAddressInCall1).isEqualTo(clientSocketAddressInCall2); |
1119 | 1118 |
|
1120 | 1119 | // The first connection is at max rpc call count of 2, so the 3rd rpc will cause a new |
1121 | 1120 | // connection to be created in the same subchannel and not get queued. |
1122 | 1121 | StreamingOutputCallResponseObserver responseObserver3 = new StreamingOutputCallResponseObserver(); |
1123 | 1122 | StreamObserver<StreamingOutputCallRequest> streamObserver3 = |
1124 | 1123 | asyncStub.fullDuplexCall(responseObserver3); |
1125 | | - streamObserver3.onNext(StreamingOutputCallRequest.newBuilder() |
1126 | | - .addResponseParameters(ResponseParameters.newBuilder().setSize(1).build()).build()); |
1127 | | - assertThat(responseObserver3.take()).isInstanceOf(StreamingOutputCallResponse.class); |
| 1124 | + streamObserver3.onNext(request); |
| 1125 | + callResponse = (StreamingOutputCallResponse) responseObserver3.take(); |
| 1126 | + String clientSocketAddressInCall3 = new String(callResponse.getPayload().getBody().toByteArray()); |
1128 | 1127 |
|
1129 | | - assertThat(fakeMetricsSink.openConnectionCount).isEqualTo(2); |
| 1128 | + assertThat(clientSocketAddressInCall3).isNotEqualTo(clientSocketAddressInCall1); |
1130 | 1129 | } |
1131 | 1130 |
|
1132 | 1131 | public void testMcs_serverStreaming() throws Exception { |
|
0 commit comments