|
20 | 20 | import org.elasticsearch.common.util.concurrent.ThreadContext; |
21 | 21 | import org.elasticsearch.core.Strings; |
22 | 22 | import org.elasticsearch.core.TimeValue; |
23 | | -import org.elasticsearch.telemetry.InstrumentType; |
24 | | -import org.elasticsearch.telemetry.RecordingMeterRegistry; |
25 | 23 | import org.elasticsearch.test.ESTestCase; |
26 | 24 | import org.elasticsearch.test.EnumSerializationTestUtils; |
27 | 25 | import org.elasticsearch.test.MockLog; |
|
32 | 30 |
|
33 | 31 | import java.util.List; |
34 | 32 | import java.util.Map; |
35 | | -import java.util.Set; |
36 | 33 | import java.util.concurrent.CountDownLatch; |
37 | 34 |
|
38 | 35 | import static org.elasticsearch.test.MockLog.assertThatLogger; |
|
42 | 39 | import static org.elasticsearch.transport.RemoteClusterSettings.SniffConnectionStrategySettings.REMOTE_CLUSTER_SEEDS; |
43 | 40 | import static org.elasticsearch.transport.RemoteClusterSettings.toConfig; |
44 | 41 | import static org.elasticsearch.transport.RemoteConnectionStrategy.buildConnectionProfile; |
45 | | -import static org.hamcrest.Matchers.equalTo; |
46 | 42 | import static org.mockito.Mockito.mock; |
47 | 43 |
|
48 | 44 | public class RemoteConnectionStrategyTests extends ESTestCase { |
@@ -219,11 +215,6 @@ public void testConnectionAttemptMetricsAndLogging() { |
219 | 215 | new ClusterConnectionManager(TestProfiles.LIGHT_PROFILE, mock(Transport.class), threadContext) |
220 | 216 | ) |
221 | 217 | ) { |
222 | | - assert transportService.getTelemetryProvider() != null; |
223 | | - final var meterRegistry = transportService.getTelemetryProvider().getMeterRegistry(); |
224 | | - assert meterRegistry instanceof RecordingMeterRegistry; |
225 | | - final var metricRecorder = ((RecordingMeterRegistry) meterRegistry).getRecorder(); |
226 | | - |
227 | 218 | for (boolean shouldConnectFail : new boolean[] { true, false }) { |
228 | 219 | for (boolean isInitialConnectAttempt : new boolean[] { true, false }) { |
229 | 220 | final var strategy = new FakeConnectionStrategy( |
@@ -265,34 +256,12 @@ public void testConnectionAttemptMetricsAndLogging() { |
265 | 256 | expectedLogMessage |
266 | 257 | ) |
267 | 258 | ); |
268 | | - if (shouldConnectFail) { |
269 | | - metricRecorder.collect(); |
270 | | - final var counterName = RemoteClusterService.CONNECTION_ATTEMPT_FAILURES_COUNTER_NAME; |
271 | | - final var measurements = metricRecorder.getMeasurements(InstrumentType.LONG_UP_DOWN_COUNTER, counterName); |
272 | | - assertFalse(measurements.isEmpty()); |
273 | | - final var measurement = measurements.getLast(); |
274 | | - assertThat(measurement.getLong(), equalTo(1L)); |
275 | | - final var attributes = measurement.attributes(); |
276 | | - final var keySet = Set.of( |
277 | | - RemoteConnectionStrategy.linkedProjectIdLabel, |
278 | | - RemoteConnectionStrategy.linkedProjectAliasLabel, |
279 | | - RemoteConnectionStrategy.connectionAtemptLabel |
280 | | - ); |
281 | | - final var expectedAttemptType = isInitialConnectAttempt |
282 | | - ? RemoteConnectionStrategy.ConnectionAttempt.initial |
283 | | - : RemoteConnectionStrategy.ConnectionAttempt.reconnect; |
284 | | - assertThat(attributes.keySet(), equalTo(keySet)); |
285 | | - assertThat(attributes.get(RemoteConnectionStrategy.linkedProjectIdLabel), equalTo(linkedProjectId.toString())); |
286 | | - assertThat(attributes.get(RemoteConnectionStrategy.linkedProjectAliasLabel), equalTo(alias)); |
287 | | - assertThat(attributes.get(RemoteConnectionStrategy.connectionAtemptLabel), equalTo(expectedAttemptType.toString())); |
288 | | - } |
289 | 259 | } |
290 | 260 | } |
291 | 261 |
|
292 | 262 | // Now verify connection errors when closing (node shutting down) are logged at debug and not warn. |
293 | 263 | final var strategy = new FakeConnectionStrategy(originProjectId, linkedProjectId, alias, transportService, connectionManager); |
294 | 264 | waitForConnect(strategy); |
295 | | - metricRecorder.resetCalls(); |
296 | 265 | strategy.setShouldConnectFail(true); |
297 | 266 | strategy.setWaitInConnect(true); |
298 | 267 | final var expectedLogLevel = Level.DEBUG; |
@@ -320,11 +289,6 @@ public void testConnectionAttemptMetricsAndLogging() { |
320 | 289 | expectedLogMessage |
321 | 290 | ) |
322 | 291 | ); |
323 | | - // Expect no metric change if the strategy has been closed. |
324 | | - metricRecorder.collect(); |
325 | | - final var counterName = RemoteClusterService.CONNECTION_ATTEMPT_FAILURES_COUNTER_NAME; |
326 | | - final var measurements = metricRecorder.getMeasurements(InstrumentType.LONG_UP_DOWN_COUNTER, counterName); |
327 | | - assertTrue(measurements.isEmpty()); |
328 | 292 | } |
329 | 293 | } |
330 | 294 |
|
|
0 commit comments