|
@@ -33,6 +33,7 @@ import java.io.ByteArrayOutputStream;
|
|
import java.io.PrintStream;
|
|
import java.io.PrintStream;
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
+import static org.junit.Assert.assertFalse;
|
|
import static org.junit.Assert.assertTrue;
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -46,7 +47,10 @@ public class TestECAdmin {
|
|
private ECAdmin admin = new ECAdmin(conf);
|
|
private ECAdmin admin = new ECAdmin(conf);
|
|
|
|
|
|
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
|
+ private final ByteArrayOutputStream err = new ByteArrayOutputStream();
|
|
|
|
+
|
|
private static final PrintStream OLD_OUT = System.out;
|
|
private static final PrintStream OLD_OUT = System.out;
|
|
|
|
+ private static final PrintStream OLD_ERR = System.err;
|
|
|
|
|
|
@Rule
|
|
@Rule
|
|
public Timeout globalTimeout = new Timeout(300000);
|
|
public Timeout globalTimeout = new Timeout(300000);
|
|
@@ -54,6 +58,7 @@ public class TestECAdmin {
|
|
@Before
|
|
@Before
|
|
public void setup() throws Exception {
|
|
public void setup() throws Exception {
|
|
System.setOut(new PrintStream(out));
|
|
System.setOut(new PrintStream(out));
|
|
|
|
+ System.setErr(new PrintStream(err));
|
|
}
|
|
}
|
|
|
|
|
|
@After
|
|
@After
|
|
@@ -62,8 +67,10 @@ public class TestECAdmin {
|
|
System.out.flush();
|
|
System.out.flush();
|
|
System.err.flush();
|
|
System.err.flush();
|
|
out.reset();
|
|
out.reset();
|
|
|
|
+ err.reset();
|
|
} finally {
|
|
} finally {
|
|
System.setOut(OLD_OUT);
|
|
System.setOut(OLD_OUT);
|
|
|
|
+ System.setErr(OLD_ERR);
|
|
}
|
|
}
|
|
|
|
|
|
if (cluster != null) {
|
|
if (cluster != null) {
|
|
@@ -77,10 +84,13 @@ public class TestECAdmin {
|
|
cluster = DFSTestUtil.setupCluster(conf, 6, 3, 0);
|
|
cluster = DFSTestUtil.setupCluster(conf, 6, 3, 0);
|
|
String[] args = {"-verifyClusterSetup"};
|
|
String[] args = {"-verifyClusterSetup"};
|
|
final int ret = admin.run(args);
|
|
final int ret = admin.run(args);
|
|
- LOG.info("Commend stdout: {}", out.toString());
|
|
|
|
- assertEquals(2, ret);
|
|
|
|
- assertTrue(out.toString()
|
|
|
|
|
|
+ LOG.info("Command stdout: {}", out.toString());
|
|
|
|
+ LOG.info("Command stderr: {}", err.toString());
|
|
|
|
+ assertEquals("Return value of the command is not successful", 2, ret);
|
|
|
|
+ assertTrue("Result of cluster topology verify " +
|
|
|
|
+ "should be logged correctly", out.toString()
|
|
.contains("less than the minimum required number of DataNodes"));
|
|
.contains("less than the minimum required number of DataNodes"));
|
|
|
|
+ assertTrue("Error output should be empty", err.toString().isEmpty());
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -91,10 +101,13 @@ public class TestECAdmin {
|
|
.getByID(SystemErasureCodingPolicies.RS_10_4_POLICY_ID).getName());
|
|
.getByID(SystemErasureCodingPolicies.RS_10_4_POLICY_ID).getName());
|
|
String[] args = {"-verifyClusterSetup"};
|
|
String[] args = {"-verifyClusterSetup"};
|
|
final int ret = admin.run(args);
|
|
final int ret = admin.run(args);
|
|
- LOG.info("Commend stdout: {}", out.toString());
|
|
|
|
- assertEquals(2, ret);
|
|
|
|
- assertTrue(out.toString()
|
|
|
|
|
|
+ LOG.info("Command stdout: {}", out.toString());
|
|
|
|
+ LOG.info("Command stderr: {}", err.toString());
|
|
|
|
+ assertEquals("Return value of the command is not successful", 2, ret);
|
|
|
|
+ assertTrue("Result of cluster topology verify " +
|
|
|
|
+ "should be logged correctly", out.toString()
|
|
.contains("less than the minimum required number of racks"));
|
|
.contains("less than the minimum required number of racks"));
|
|
|
|
+ assertTrue("Error output should be empty", err.toString().isEmpty());
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -108,10 +121,13 @@ public class TestECAdmin {
|
|
.getByID(SystemErasureCodingPolicies.XOR_2_1_POLICY_ID).getName());
|
|
.getByID(SystemErasureCodingPolicies.XOR_2_1_POLICY_ID).getName());
|
|
String[] args = {"-verifyClusterSetup"};
|
|
String[] args = {"-verifyClusterSetup"};
|
|
final int ret = admin.run(args);
|
|
final int ret = admin.run(args);
|
|
- LOG.info("Commend stdout: {}", out.toString());
|
|
|
|
- assertEquals(2, ret);
|
|
|
|
- assertTrue(out.toString()
|
|
|
|
|
|
+ LOG.info("Command stdout: {}", out.toString());
|
|
|
|
+ LOG.info("Command stderr: {}", err.toString());
|
|
|
|
+ assertEquals("Return value of the command is not successful", 2, ret);
|
|
|
|
+ assertTrue("Result of cluster topology verify " +
|
|
|
|
+ "should be logged correctly", out.toString()
|
|
.contains("less than the minimum required number of racks"));
|
|
.contains("less than the minimum required number of racks"));
|
|
|
|
+ assertTrue("Error output should be empty", err.toString().isEmpty());
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -125,10 +141,13 @@ public class TestECAdmin {
|
|
.getByID(SystemErasureCodingPolicies.RS_3_2_POLICY_ID).getName());
|
|
.getByID(SystemErasureCodingPolicies.RS_3_2_POLICY_ID).getName());
|
|
String[] args = {"-verifyClusterSetup"};
|
|
String[] args = {"-verifyClusterSetup"};
|
|
final int ret = admin.run(args);
|
|
final int ret = admin.run(args);
|
|
- LOG.info("Commend stdout: {}", out.toString());
|
|
|
|
- assertEquals(2, ret);
|
|
|
|
- assertTrue(out.toString()
|
|
|
|
|
|
+ LOG.info("Command stdout: {}", out.toString());
|
|
|
|
+ LOG.info("Command stderr: {}", err.toString());
|
|
|
|
+ assertEquals("Return value of the command is not successful", 2, ret);
|
|
|
|
+ assertTrue("Result of cluster topology verify " +
|
|
|
|
+ "should be logged correctly", out.toString()
|
|
.contains("less than the minimum required number of racks"));
|
|
.contains("less than the minimum required number of racks"));
|
|
|
|
+ assertTrue("Error output should be empty", err.toString().isEmpty());
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -136,8 +155,13 @@ public class TestECAdmin {
|
|
cluster = DFSTestUtil.setupCluster(conf, 9, 3, 0);
|
|
cluster = DFSTestUtil.setupCluster(conf, 9, 3, 0);
|
|
String[] args = {"-verifyClusterSetup"};
|
|
String[] args = {"-verifyClusterSetup"};
|
|
final int ret = admin.run(args);
|
|
final int ret = admin.run(args);
|
|
- LOG.info("Commend stdout: {}", out.toString());
|
|
|
|
- assertEquals(0, ret);
|
|
|
|
|
|
+ LOG.info("Command stdout: {}", out.toString());
|
|
|
|
+ LOG.info("Command stderr: {}", err.toString());
|
|
|
|
+ assertEquals("Return value of the command is successful", 0, ret);
|
|
|
|
+ assertTrue("Result of cluster topology verify " +
|
|
|
|
+ "should be logged correctly", out.toString().contains(
|
|
|
|
+ "The cluster setup can support EC policies: RS-6-3-1024k"));
|
|
|
|
+ assertTrue("Error output should be empty", err.toString().isEmpty());
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -148,8 +172,72 @@ public class TestECAdmin {
|
|
.getByID(SystemErasureCodingPolicies.RS_6_3_POLICY_ID).getName());
|
|
.getByID(SystemErasureCodingPolicies.RS_6_3_POLICY_ID).getName());
|
|
String[] args = {"-verifyClusterSetup"};
|
|
String[] args = {"-verifyClusterSetup"};
|
|
final int ret = admin.run(args);
|
|
final int ret = admin.run(args);
|
|
- LOG.info("Commend stdout: {}", out.toString());
|
|
|
|
- assertEquals(0, ret);
|
|
|
|
- assertTrue(out.toString().contains("No erasure coding policy is enabled"));
|
|
|
|
|
|
+ LOG.info("Command stdout: {}", out.toString());
|
|
|
|
+ LOG.info("Command stderr: {}", err.toString());
|
|
|
|
+ assertEquals("Return value of the command is successful", 0, ret);
|
|
|
|
+ assertTrue("Result of cluster topology verify " +
|
|
|
|
+ "should be logged correctly",
|
|
|
|
+ out.toString().contains("No erasure coding policy is given"));
|
|
|
|
+ assertTrue("Error output should be empty", err.toString().isEmpty());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testUnsuccessfulEnablePolicyMessage() throws Exception {
|
|
|
|
+ cluster = DFSTestUtil.setupCluster(conf, 5, 2, 0);
|
|
|
|
+ cluster.getFileSystem().disableErasureCodingPolicy(
|
|
|
|
+ SystemErasureCodingPolicies
|
|
|
|
+ .getByID(SystemErasureCodingPolicies.RS_6_3_POLICY_ID).getName());
|
|
|
|
+ String[] args = {"-enablePolicy", "-policy", "RS-3-2-1024k"};
|
|
|
|
+
|
|
|
|
+ final int ret = admin.run(args);
|
|
|
|
+ LOG.info("Command stdout: {}", out.toString());
|
|
|
|
+ LOG.info("Command stderr: {}", err.toString());
|
|
|
|
+ assertEquals("Return value of the command is successful", 0, ret);
|
|
|
|
+ assertTrue("Enabling policy should be logged", out.toString()
|
|
|
|
+ .contains("Erasure coding policy RS-3-2-1024k is enabled"));
|
|
|
|
+ assertTrue("Warning about cluster topology should be printed",
|
|
|
|
+ err.toString().contains("Warning: The cluster setup does not support " +
|
|
|
|
+ "EC policy RS-3-2-1024k. Reason:"));
|
|
|
|
+ assertTrue("Warning about cluster topology should be printed",
|
|
|
|
+ err.toString()
|
|
|
|
+ .contains("less than the minimum required number of racks"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testSuccessfulEnablePolicyMessage() throws Exception {
|
|
|
|
+ cluster = DFSTestUtil.setupCluster(conf, 5, 3, 0);
|
|
|
|
+ cluster.getFileSystem().disableErasureCodingPolicy(
|
|
|
|
+ SystemErasureCodingPolicies
|
|
|
|
+ .getByID(SystemErasureCodingPolicies.RS_6_3_POLICY_ID).getName());
|
|
|
|
+ String[] args = {"-enablePolicy", "-policy", "RS-3-2-1024k"};
|
|
|
|
+
|
|
|
|
+ final int ret = admin.run(args);
|
|
|
|
+ LOG.info("Command stdout: {}", out.toString());
|
|
|
|
+ LOG.info("Command stderr: {}", err.toString());
|
|
|
|
+ assertEquals("Return value of the command is successful", 0, ret);
|
|
|
|
+ assertTrue("Enabling policy should be logged", out.toString()
|
|
|
|
+ .contains("Erasure coding policy RS-3-2-1024k is enabled"));
|
|
|
|
+ assertFalse("Warning about cluster topology should not be printed",
|
|
|
|
+ out.toString().contains("Warning: The cluster setup does not support"));
|
|
|
|
+ assertTrue("Error output should be empty", err.toString().isEmpty());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testEnableNonExistentPolicyMessage() throws Exception {
|
|
|
|
+ cluster = DFSTestUtil.setupCluster(conf, 5, 3, 0);
|
|
|
|
+ cluster.getFileSystem().disableErasureCodingPolicy(
|
|
|
|
+ SystemErasureCodingPolicies
|
|
|
|
+ .getByID(SystemErasureCodingPolicies.RS_6_3_POLICY_ID).getName());
|
|
|
|
+ String[] args = {"-enablePolicy", "-policy", "NonExistentPolicy"};
|
|
|
|
+
|
|
|
|
+ final int ret = admin.run(args);
|
|
|
|
+ LOG.info("Command stdout: {}", out.toString());
|
|
|
|
+ LOG.info("Command stderr: {}", err.toString());
|
|
|
|
+ assertEquals("Return value of the command is unsuccessful", 2, ret);
|
|
|
|
+ assertFalse("Enabling policy should not be logged when " +
|
|
|
|
+ "it was unsuccessful", out.toString().contains("is enabled"));
|
|
|
|
+ assertTrue("Error message should be printed",
|
|
|
|
+ err.toString().contains("RemoteException: The policy name " +
|
|
|
|
+ "NonExistentPolicy does not exist"));
|
|
}
|
|
}
|
|
}
|
|
}
|