Skip to content

Commit 58c38a2

Browse files
authored
IGNITE-28546 Fix flaky NodeSslConnectionMetricTest#testClientConnector (#13028)
1 parent 913d638 commit 58c38a2

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

modules/clients/src/test/java/org/apache/ignite/common/NodeSslConnectionMetricTest.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ public class NodeSslConnectionMetricTest extends GridCommonAbstractTest {
6969
/** Cipher suite not supported by cluster nodes. */
7070
private static final String UNSUPPORTED_CIPHER_SUITE = "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256";
7171

72+
/** Local client host. */
73+
private static final String LOCAL_CLIENT_HOST = "127.0.0.1";
74+
75+
/** Local client port. */
76+
private static final String LOCAL_CLIENT_PORT = "10800";
77+
7278
/** Local server address. */
73-
private static final String LOCAL_CLIENT_ADDRESS = "127.0.0.1:10800";
79+
private static final String LOCAL_CLIENT_ADDRESS = LOCAL_CLIENT_HOST + ":" + LOCAL_CLIENT_PORT;
7480

7581
/** Metric timeout. */
7682
private static final long TIMEOUT = 7_000;
@@ -252,7 +258,7 @@ public void testClientConnector() throws Exception {
252258
startClient(clientConfiguration("client", "trustboth", CIPHER_SUITE, "TLSv1.2")),
253259
ClientConnectionException.class);
254260

255-
assertContains(log, ex.getMessage(), LOCAL_CLIENT_ADDRESS);
261+
assertLocalClientAddressPresent(ex.getMessage());
256262

257263
checkSslCommunicationMetrics(reg, 2, 0, 1);
258264

@@ -262,7 +268,7 @@ public void testClientConnector() throws Exception {
262268
ClientConnectionException.class
263269
);
264270

265-
assertContains(log, ex.getMessage(), LOCAL_CLIENT_ADDRESS);
271+
assertLocalClientAddressPresent(ex.getMessage());
266272

267273
checkSslCommunicationMetrics(reg, 3, 0, 2);
268274

@@ -272,7 +278,7 @@ public void testClientConnector() throws Exception {
272278
ClientConnectionException.class
273279
);
274280

275-
assertContains(log, ex.getMessage(), LOCAL_CLIENT_ADDRESS);
281+
assertLocalClientAddressPresent(ex.getMessage());
276282

277283
checkSslCommunicationMetrics(reg, 4, 0, 3);
278284
}
@@ -396,6 +402,16 @@ private void waitForMetricGreaterOrEqual(String name, int expected, Supplier<Int
396402
waitForCondition(() -> expected <= supplier.get(), TIMEOUT));
397403
}
398404

405+
/**
406+
* Checks that local client host and port are present in the message regardless of address rendering format.
407+
*
408+
* @param msg Exception message.
409+
*/
410+
private void assertLocalClientAddressPresent(String msg) {
411+
assertContains(log, msg, LOCAL_CLIENT_HOST);
412+
assertContains(log, msg, LOCAL_CLIENT_PORT);
413+
}
414+
399415
/** Creates {@link SslContextFactory} with specified options. */
400416
private SslContextFactory sslContextFactory(String keyStore, String trustStore, String cipherSuite, String protocol) {
401417
SslContextFactory res = (SslContextFactory)sslTrustedFactory(keyStore, trustStore);

0 commit comments

Comments
 (0)