public class TestInvalidAutoIdealState extends ZkUnitTestBase {
// TODO Disable this test, need refactor it for testing message generation based on state priority
// @Test
void testInvalidReplica2() throws Exception
{
HelixAdmin admin = new ZKHelixAdmin(ZK_ADDR);
// create cluster
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String clusterName = className + "_" + methodName;
String db = "TestDB";
System.out.println("START " + clusterName + " at "
+ new Date(System.currentTimeMillis()));
// System.out.println("Creating cluster: " + clusterName);
admin.addCluster(clusterName, true);
// add MasterSlave state mode definition
admin.addStateModelDef(clusterName, "MasterSlave", new StateModelDefinition(
StateModelConfigGenerator.generateConfigForMasterSlave()));
// Add nodes to the cluster
int n = 3;
System.out.println("Adding " + n + " participants to the cluster");
for (int i = 0; i < n; i++) {
int port = 12918 + i;
InstanceConfig instanceConfig = new InstanceConfig("localhost_" + port);
instanceConfig.setHostName("localhost");
instanceConfig.setPort("" + port);
instanceConfig.setInstanceEnabled(true);
admin.addInstance(clusterName, instanceConfig);
// System.out.println("\t Added participant: " + instanceConfig.getInstanceName());
}
// construct ideal-state manually
IdealState idealState = new IdealState(db);
idealState.setIdealStateMode(IdealStateModeProperty.AUTO.toString());
idealState.setNumPartitions(2);
idealState.setReplicas("" + 2); // should be 3
idealState.setStateModelDefRef("MasterSlave");
idealState.getRecord().setListField("TestDB_0", Arrays.asList("localhost_12918", "localhost_12919", "localhost_12920"));
idealState.getRecord().setListField("TestDB_1", Arrays.asList("localhost_12919", "localhost_12918", "localhost_12920"));
admin.setResourceIdealState(clusterName, "TestDB", idealState);
// start participants
MockParticipant[] participants = new MockParticipant[n];
for (int i = 0; i < n; i++)
{