|
19 | 19 |
|
20 | 20 | package org.apache.iotdb.confignode.it.partition; |
21 | 21 |
|
| 22 | +import org.apache.iotdb.commons.enums.RepairDataPartitionTableProgressState; |
22 | 23 | import org.apache.iotdb.it.env.EnvFactory; |
23 | 24 | import org.apache.iotdb.it.framework.IoTDBTestRunner; |
24 | 25 | import org.apache.iotdb.itbase.category.ClusterIT; |
|
34 | 35 | import org.slf4j.LoggerFactory; |
35 | 36 |
|
36 | 37 | import java.sql.Connection; |
| 38 | +import java.sql.ResultSet; |
37 | 39 | import java.sql.SQLException; |
38 | 40 | import java.sql.Statement; |
39 | 41 | import java.util.ArrayList; |
@@ -128,4 +130,38 @@ public void testConcurrentSubmitDataPartitionTableIntegrityCheckProcedure() |
128 | 130 | Assert.assertEquals( |
129 | 131 | "The other concurrent submissions should be rejected", threadCount - 1, failCount.get()); |
130 | 132 | } |
| 133 | + |
| 134 | + @Test |
| 135 | + public void testShowRepairDataPartitionTableProgress() throws Exception { |
| 136 | + try (final Connection connection = EnvFactory.getEnv().getConnection(); |
| 137 | + final Statement statement = connection.createStatement()) { |
| 138 | + assertRepairProgress(statement, RepairDataPartitionTableProgressState.IDLE.name(), 0.0, 0.0); |
| 139 | + |
| 140 | + statement.execute("REPAIR DATA PARTITION TABLE"); |
| 141 | + assertRepairProgress(statement, null, 0.0, 100.0); |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + private static void assertRepairProgress( |
| 146 | + final Statement statement, |
| 147 | + final String expectedStatus, |
| 148 | + final double minProgress, |
| 149 | + final double maxProgress) |
| 150 | + throws SQLException { |
| 151 | + try (final ResultSet resultSet = |
| 152 | + statement.executeQuery("SHOW REPAIR DATA PARTITION TABLE PROGRESS")) { |
| 153 | + Assert.assertTrue(resultSet.next()); |
| 154 | + if (expectedStatus != null) { |
| 155 | + Assert.assertEquals(expectedStatus, resultSet.getString("Status")); |
| 156 | + } else { |
| 157 | + Assert.assertNotEquals( |
| 158 | + RepairDataPartitionTableProgressState.UNKNOWN.name(), resultSet.getString("Status")); |
| 159 | + } |
| 160 | + final double progress = resultSet.getDouble("Progress(%)"); |
| 161 | + Assert.assertTrue(progress >= minProgress); |
| 162 | + Assert.assertTrue(progress <= maxProgress); |
| 163 | + Assert.assertNotNull(resultSet.getString("Message")); |
| 164 | + Assert.assertFalse(resultSet.next()); |
| 165 | + } |
| 166 | + } |
131 | 167 | } |
0 commit comments