Skip to content

Commit 8eff8da

Browse files
authored
IGNITE-28684: MDC test fix with first nodes with predictable assingnment (#13143)
Codex co-authored-by: Dmitriy Pavlov <dpavlov@apache.org>
1 parent 096c941 commit 8eff8da

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/MultiDataCenterRingTest.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class MultiDataCenterRingTest extends GridCommonAbstractTest {
5656
public void testRing() throws Exception {
5757
int cnt = 10;
5858

59-
generateRandomDcOrderCluster(cnt);
59+
generateRandomDcOrderCluster(cnt, 1, 2);
6060

6161
assertEquals(cnt, grid(0).cluster().nodes().size());
6262

@@ -115,10 +115,28 @@ public void testMessageOrder() throws Exception {
115115

116116
/** */
117117
private void generateRandomDcOrderCluster(int cnt) throws Exception {
118+
generateRandomDcOrderCluster(cnt, -1, -1);
119+
}
120+
121+
/**
122+
* @param cnt Nodes count.
123+
* @param dc0NodeIdx Node index that should be assigned to {@link #DC_ID_0}, or {@code -1} if not required.
124+
* @param dc1NodeIdx Node index that should be assigned to {@link #DC_ID_1}, or {@code -1} if not required.
125+
*/
126+
private void generateRandomDcOrderCluster(int cnt, int dc0NodeIdx, int dc1NodeIdx) throws Exception {
118127
ThreadLocalRandom rnd = ThreadLocalRandom.current();
119128

120129
for (int i = 0; i < cnt; i++) {
121-
System.setProperty(IgniteSystemProperties.IGNITE_DATA_CENTER_ID, rnd.nextBoolean() ? DC_ID_0 : DC_ID_1);
130+
String dcId;
131+
132+
if (i == dc0NodeIdx)
133+
dcId = DC_ID_0;
134+
else if (i == dc1NodeIdx)
135+
dcId = DC_ID_1;
136+
else
137+
dcId = rnd.nextBoolean() ? DC_ID_0 : DC_ID_1;
138+
139+
System.setProperty(IgniteSystemProperties.IGNITE_DATA_CENTER_ID, dcId);
122140

123141
startGrid(i);
124142
}

0 commit comments

Comments
 (0)