|
18 | 18 | */ |
19 | 19 | package org.elasticsearch.cluster.coordination; |
20 | 20 |
|
| 21 | +import org.apache.logging.log4j.Level; |
21 | 22 | import org.elasticsearch.Version; |
| 23 | +import org.elasticsearch.cluster.NotMasterException; |
22 | 24 | import org.elasticsearch.cluster.node.DiscoveryNode; |
23 | 25 | import org.elasticsearch.common.settings.Settings; |
24 | 26 | import org.elasticsearch.test.ESTestCase; |
25 | 27 | import org.elasticsearch.test.transport.CapturingTransport; |
26 | 28 | import org.elasticsearch.test.transport.CapturingTransport.CapturedRequest; |
| 29 | +import org.elasticsearch.transport.RemoteTransportException; |
| 30 | +import org.elasticsearch.transport.TransportException; |
27 | 31 | import org.elasticsearch.transport.TransportResponse; |
28 | 32 | import org.elasticsearch.transport.TransportService; |
29 | 33 |
|
|
32 | 36 |
|
33 | 37 | import static org.elasticsearch.node.Node.NODE_NAME_SETTING; |
34 | 38 | import static org.hamcrest.Matchers.equalTo; |
| 39 | +import static org.hamcrest.core.Is.is; |
35 | 40 |
|
36 | 41 | public class JoinHelperTests extends ESTestCase { |
37 | 42 |
|
@@ -107,4 +112,23 @@ public void testJoinDeduplication() { |
107 | 112 | capturingTransport.handleRemoteError(capturedRequest2a.requestId, new CoordinationStateRejectedException("dummy")); |
108 | 113 | assertFalse(joinHelper.isJoinPending()); |
109 | 114 | } |
| 115 | + |
| 116 | + public void testFailedJoinAttemptLogLevel() { |
| 117 | + assertThat(JoinHelper.FailedJoinAttempt.getLogLevel(new TransportException("generic transport exception")), is(Level.INFO)); |
| 118 | + |
| 119 | + assertThat(JoinHelper.FailedJoinAttempt.getLogLevel( |
| 120 | + new RemoteTransportException("remote transport exception with generic cause", new Exception())), is(Level.INFO)); |
| 121 | + |
| 122 | + assertThat(JoinHelper.FailedJoinAttempt.getLogLevel( |
| 123 | + new RemoteTransportException("caused by CoordinationStateRejectedException", |
| 124 | + new CoordinationStateRejectedException("test"))), is(Level.DEBUG)); |
| 125 | + |
| 126 | + assertThat(JoinHelper.FailedJoinAttempt.getLogLevel( |
| 127 | + new RemoteTransportException("caused by FailedToCommitClusterStateException", |
| 128 | + new FailedToCommitClusterStateException("test"))), is(Level.DEBUG)); |
| 129 | + |
| 130 | + assertThat(JoinHelper.FailedJoinAttempt.getLogLevel( |
| 131 | + new RemoteTransportException("caused by NotMasterException", |
| 132 | + new NotMasterException("test"))), is(Level.DEBUG)); |
| 133 | + } |
110 | 134 | } |
0 commit comments