1818package org .apache .ignite .spi .discovery .datacenter ;
1919
2020import java .util .Collection ;
21+ import java .util .concurrent .ThreadLocalRandom ;
2122import org .apache .ignite .IgniteSystemProperties ;
2223import org .apache .ignite .cluster .ClusterNode ;
2324import org .apache .ignite .testframework .junits .common .GridCommonAbstractTest ;
@@ -43,43 +44,16 @@ public class MultiDataCenterRignTest extends GridCommonAbstractTest {
4344 /** */
4445 @ Test
4546 public void testRing () throws Exception {
46- for (int i = 0 ; i < 10 ; i += 2 ) {
47- System .setProperty (IgniteSystemProperties .IGNITE_DATA_CENTER_ID , DC_ID_0 );
48-
49- startGrid (i );
50-
51- System .setProperty (IgniteSystemProperties .IGNITE_DATA_CENTER_ID , DC_ID_1 );
52-
53- startGrid (i + 1 );
54- }
55-
56- waitForTopology (10 );
57-
58- Collection <ClusterNode > nodes = grid (0 ).cluster ().forServers ().nodes ();
59-
60- int swithes = 0 ;
61- String curDcId = null ;
47+ ThreadLocalRandom rnd = ThreadLocalRandom .current ();
6248
63- for (ClusterNode node : nodes ) {
64- if (!node .dataCenterId ().equals (curDcId )){
65- swithes ++;
49+ boolean order = rnd .nextBoolean ();
6650
67- curDcId = node .dataCenterId ();
68- }
69- }
70-
71- assertEquals (2 , swithes );
72- }
73-
74- /** */
75- @ Test
76- public void testRingWithCordinatorChange () throws Exception {
7751 for (int i = 0 ; i < 10 ; i += 2 ) {
78- System .setProperty (IgniteSystemProperties .IGNITE_DATA_CENTER_ID , DC_ID_1 );
52+ System .setProperty (IgniteSystemProperties .IGNITE_DATA_CENTER_ID , order ? DC_ID_0 : DC_ID_1 );
7953
8054 startGrid (i );
8155
82- System .setProperty (IgniteSystemProperties .IGNITE_DATA_CENTER_ID , DC_ID_0 );
56+ System .setProperty (IgniteSystemProperties .IGNITE_DATA_CENTER_ID , order ? DC_ID_1 : DC_ID_0 );
8357
8458 startGrid (i + 1 );
8559 }
0 commit comments