17
17
*/
18
18
package org .apache .hadoop .hbase .ipc ;
19
19
20
+ import java .net .InetSocketAddress ;
21
+ import org .apache .hadoop .hbase .CallDroppedException ;
20
22
import org .apache .hadoop .hbase .HBaseClassTestRule ;
21
23
import org .apache .hadoop .hbase .monitoring .MonitoredRPCHandlerImpl ;
22
24
import org .apache .hadoop .hbase .testclassification .RPCTests ;
@@ -60,7 +62,7 @@ public void testCallCleanup() {
60
62
}
61
63
62
64
@ Test
63
- public void testCallRunnerDrop () {
65
+ public void testCallRunnerDropDisconnected () {
64
66
RpcServerInterface mockRpcServer = Mockito .mock (RpcServerInterface .class );
65
67
Mockito .when (mockRpcServer .isStarted ()).thenReturn (true );
66
68
ServerCall mockCall = Mockito .mock (ServerCall .class );
@@ -71,4 +73,21 @@ public void testCallRunnerDrop() {
71
73
cr .drop ();
72
74
Mockito .verify (mockCall , Mockito .times (1 )).cleanup ();
73
75
}
76
+
77
+ @ Test
78
+ public void testCallRunnerDropConnected () {
79
+ RpcServerInterface mockRpcServer = Mockito .mock (RpcServerInterface .class );
80
+ MetricsHBaseServer mockMetrics = Mockito .mock (MetricsHBaseServer .class );
81
+ Mockito .when (mockRpcServer .getMetrics ()).thenReturn (mockMetrics );
82
+ Mockito .when (mockRpcServer .isStarted ()).thenReturn (true );
83
+ Mockito .when (mockRpcServer .getListenerAddress ()).thenReturn (InetSocketAddress .createUnresolved ("foo" , 60020 ));
84
+ ServerCall mockCall = Mockito .mock (ServerCall .class );
85
+ Mockito .when (mockCall .disconnectSince ()).thenReturn (-1L );
86
+
87
+ CallRunner cr = new CallRunner (mockRpcServer , mockCall );
88
+ cr .setStatus (new MonitoredRPCHandlerImpl ());
89
+ cr .drop ();
90
+ Mockito .verify (mockCall , Mockito .times (1 )).cleanup ();
91
+ Mockito .verify (mockMetrics ).exception (Mockito .any (CallDroppedException .class ));
92
+ }
74
93
}
0 commit comments