subrat-mishra commented on code in PR #105:
URL:
https://github.com/apache/hbase-operator-tools/pull/105#discussion_r853740652
##########
hbase-hbck2/src/test/java/org/apache/hbase/TestHBCK2.java:
##########
@@ -121,26 +125,62 @@ public void testSetTableStateInMeta() throws IOException {
// Restore the state.
state = this.hbck2.setTableState(hbck, TABLE_NAME, state.getState());
assertTrue("Found=" + state.getState(), state.isDisabled());
+
+ // Test the new method with arg list
+ String[] args = new String[]{TABLE_NAME.getNameAsString(), "DISABLED"};
+ state = this.hbck2.setTableStateByArgs(hbck, args);
+ assertTrue("Found=" + state.getState(), state.isEnabled());
+ }
+ }
+
+ @Test
+ public void testSetTableStateWithInputFiles() throws IOException {
+ File testFile = new File(TEST_UTIL.getDataTestDir().toString(),
"inputForSetTableTest");
+ writeStringsToAFile(testFile, new String[]{TABLE_NAME.getNameAsString() +
" DISABLED"});
+ String result = testRunWithArgs(new String[]{SET_TABLE_STATE, "-i",
testFile.toString()});
+ assertTrue(result.contains("tableName=TestHBCK2, state=ENABLED"));
+
+ // Restore the state.
+ try (ClusterConnection connection = this.hbck2.connect(); Hbck hbck =
connection.getHbck()) {
+ TableState state = this.hbck2.setTableState(hbck, TABLE_NAME,
TableState.State.ENABLED);
+ assertTrue("Found=" + state.getState(), state.isDisabled());
+ }
+ }
+
+ @Test
+ public void testUnAssigns() throws IOException {
+ try (Admin admin = TEST_UTIL.getConnection().getAdmin()) {
+ List<RegionInfo> regions = admin.getRegions(TABLE_NAME);
+ for (RegionInfo ri : regions) {
+ RegionState rs =
TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
+ getRegionStates().getRegionState(ri.getEncodedName());
+ LOG.info("RS: {}", rs.toString());
+ }
+ String[] regionStrsArray =
+
regions.stream().map(RegionInfo::getEncodedName).toArray(String[]::new);
+ File testFile = new File(TEST_UTIL.getDataTestDir().toString(),
"inputForUnAssignsTest");
+ writeStringsToAFile(testFile, regionStrsArray);
+ String result = testRunWithArgs(new String[]{UNASSIGNS, "-i",
testFile.toString()});
Review Comment:
Is it a good idea to add a test case to support multiple file options?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]