Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,13 @@
@RunWith(IoTDBTestRunner.class)
@Category({ClusterIT.class})
public class IoTDBVerifyConnectionIT {
private static final String testConsensusProtocolClass = ConsensusFactory.RATIS_CONSENSUS;

@Before
public void setUp() throws Exception {
EnvFactory.getEnv()
.getConfig()
.getCommonConfig()
.setConfigNodeConsensusProtocolClass(testConsensusProtocolClass)
.setSchemaRegionConsensusProtocolClass(testConsensusProtocolClass)
.setDataRegionConsensusProtocolClass(testConsensusProtocolClass);
.setConfigNodeConsensusProtocolClass(ConsensusFactory.RATIS_CONSENSUS);
}

@After
Expand All @@ -60,7 +57,7 @@ public void tearDown() throws Exception {
}

@Test
public void verifyConnectionAllUpTest() throws Exception {
public void testVerifyConnectionAllUp() throws Exception {
EnvFactory.getEnv().initClusterEnvironment(3, 3);
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
Expand All @@ -74,31 +71,26 @@ public void verifyConnectionAllUpTest() throws Exception {
}

@Test
public void verifyConnectionWithNodeCorruptTest() throws Exception {
EnvFactory.getEnv().initClusterEnvironment(5, 1);
public void testVerifyConnectionWithNodeCrash() throws Exception {
EnvFactory.getEnv().initClusterEnvironment(3, 1);
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
ResultSet resultSet = statement.executeQuery("verify connection details");
Assert.assertEquals(
ImmutableMap.of(ThriftService.STATUS_UP, 38), collectConnectionResult(resultSet));
EnvFactory.getEnv().getConfigNodeWrapperList().get(0).stopForcibly();
ImmutableMap.of(ThriftService.STATUS_UP, 18), collectConnectionResult(resultSet));
final int leaderIndex = EnvFactory.getEnv().getLeaderConfigNodeIndex();
int shutdownIndex = 0;
if (shutdownIndex == leaderIndex) {
shutdownIndex++;
}
EnvFactory.getEnv().getConfigNodeWrapperList().get(shutdownIndex++).stopForcibly();
resultSet = statement.executeQuery("verify connection");
Assert.assertEquals(
ImmutableMap.of(ThriftService.STATUS_UP, 2, ThriftService.STATUS_DOWN, 11),
ImmutableMap.of(ThriftService.STATUS_UP, 2, ThriftService.STATUS_DOWN, 7),
collectConnectionResult(resultSet));
resultSet = statement.executeQuery("verify connection details");
Assert.assertEquals(
ImmutableMap.of(ThriftService.STATUS_UP, 27, ThriftService.STATUS_DOWN, 11),
collectConnectionResult(resultSet));
EnvFactory.getEnv().getConfigNodeWrapperList().get(1).stopForcibly();
Thread.sleep(10000);
resultSet = statement.executeQuery("verify connection");
Assert.assertEquals(
ImmutableMap.of(ThriftService.STATUS_UP, 2, ThriftService.STATUS_DOWN, 20),
collectConnectionResult(resultSet));
resultSet = statement.executeQuery("verify connection details");
Assert.assertEquals(
ImmutableMap.of(ThriftService.STATUS_UP, 18, ThriftService.STATUS_DOWN, 20),
ImmutableMap.of(ThriftService.STATUS_UP, 11, ThriftService.STATUS_DOWN, 7),
collectConnectionResult(resultSet));
}
}
Expand Down