Skip to content

Commit e526561

Browse files
authored
IGNITE-27913 Fixed flaky MultipleSSLContextsTest (#12772)
Thank you for submitting the pull request to the Apache Ignite. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### The Contribution Checklist - [ ] There is a single JIRA ticket related to the pull request. - [ ] The web-link to the pull request is attached to the JIRA ticket. - [ ] The JIRA ticket has the _Patch Available_ state. - [ ] The pull request body describes changes that have been made. The description explains _WHAT_ and _WHY_ was made instead of _HOW_. - [ ] The pull request title is treated as the final commit message. The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue. - [ ] A reviewer has been mentioned through the JIRA comments (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) - [ ] The pull request has been checked by the Teamcity Bot and the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html)) ### Notes - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute) - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules) - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines) - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot) If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
1 parent e5305d7 commit e526561

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

modules/core/src/test/java/org/apache/ignite/ssl/MultipleSSLContextsTest.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.apache.ignite.configuration.ClientConnectorConfiguration;
3535
import org.apache.ignite.configuration.ConnectorConfiguration;
3636
import org.apache.ignite.configuration.IgniteConfiguration;
37+
import org.apache.ignite.internal.IgniteEx;
3738
import org.apache.ignite.testframework.GridTestUtils;
3839
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
3940
import org.junit.Test;
@@ -43,6 +44,9 @@
4344
* trust stores. SSL for all three transports are enabled at the same time.
4445
*/
4546
public class MultipleSSLContextsTest extends GridCommonAbstractTest {
47+
/** */
48+
private static final int SRV_NODES_CNT = 3;
49+
4650
/** */
4751
private boolean clientMode = false;
4852

@@ -102,15 +106,14 @@ private Factory<SSLContext> thinClientSSLFactory() {
102106
}
103107

104108
/**
105-
* @param addr Address of a node to connect to.
109+
* @param port Port to connect to.
106110
* @return {@link ClientConfiguration} that can be used to start a thin client.
107111
*/
108-
private ClientConfiguration clientConfiguration(String addr) {
109-
ClientConfiguration clientCfg = new ClientConfiguration().setAddresses(addr);
110-
clientCfg.setSslContextFactory(thinClientSSLFactory());
111-
clientCfg.setSslMode(SslMode.REQUIRED);
112-
113-
return clientCfg;
112+
private ClientConfiguration clientConfiguration(int port) {
113+
return new ClientConfiguration()
114+
.setAddresses("127.0.0.1:" + port)
115+
.setSslContextFactory(thinClientSSLFactory())
116+
.setSslMode(SslMode.REQUIRED);
114117
}
115118

116119
/**
@@ -123,7 +126,8 @@ private Factory<SSLContext> connectorSSLFactory() {
123126
/** {@inheritDoc} */
124127
@Override protected void beforeTestsStarted() throws Exception {
125128
clientMode = false;
126-
startGrids(3);
129+
130+
startGrids(SRV_NODES_CNT);
127131
}
128132

129133
/**
@@ -171,22 +175,18 @@ public void testThickClients() throws Exception {
171175
}
172176
}
173177

174-
/**
175-
* Checks that thin clients with SSL enabled can join the cluster and perform some work on it.
176-
*
177-
* @throws Exception If failed.
178-
*/
178+
/** Checks that thin clients with SSL enabled can join the cluster and perform some work on it. */
179179
@Test
180-
public void testThinClients() throws Exception {
181-
int clientsNum = 3;
180+
public void testThinClients() {
181+
int clientsNum = SRV_NODES_CNT;
182182
int keysNum = 1000;
183183
String cacheName = "thinClientCache";
184184

185185
List<IgniteClient> clients = new ArrayList<>(clientsNum);
186186

187187
try {
188188
for (int i = 0; i < clientsNum; i++) {
189-
IgniteClient client = Ignition.startClient(clientConfiguration("127.0.0.1:1080" + i));
189+
IgniteClient client = connectIgniteClientTo(grid(i));
190190

191191
clients.add(client);
192192
}
@@ -239,4 +239,9 @@ private void assertCacheContent(Map<Integer, Integer> exp, IgniteCache<Integer,
239239
assertEquals("Cache contains an unexpected value for a key=" + key, expVal, actVal);
240240
}
241241
}
242+
243+
/** */
244+
private IgniteClient connectIgniteClientTo(IgniteEx ignite) {
245+
return Ignition.startClient(clientConfiguration(ignite.context().clientListener().port()));
246+
}
242247
}

0 commit comments

Comments
 (0)