*/
@Test
public void testRecreateParticipant() {
final String MODIFIER = "modifier";
final ClusterId clusterId = ClusterId.from("testCluster");
final ParticipantId participantId = ParticipantId.from("testParticipant");
// connect
boolean connected = _zkclient.waitUntilConnected(30000, TimeUnit.MILLISECONDS);
if (!connected) {
LOG.warn("Connection not established");
return;
}
BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_zkclient);
HelixDataAccessor helixAccessor = new ZKHelixDataAccessor(clusterId.stringify(), baseAccessor);
ClusterAccessor accessor = new ClusterAccessor(clusterId, helixAccessor);
// create the cluster
boolean clusterCreated = createCluster(clusterId, accessor, MODIFIER, 0);
Assert.assertTrue(clusterCreated);
// create the participant
boolean created = createParticipant(participantId, accessor, MODIFIER, 1);
Assert.assertTrue(created);
// read the participant
Participant participantSnapshot = accessor.readParticipant(participantId);
Assert.assertEquals(participantSnapshot.getUserConfig().getIntField(MODIFIER, -1), 1);
// create a participant with the same id
boolean created2 = createParticipant(participantId, accessor, MODIFIER, 2);
Assert.assertFalse(created2); // should fail since participant exists
// remove a required property
helixAccessor.removeProperty(helixAccessor.keyBuilder().messages(participantId.stringify()));
// try again, should work this time
created2 = createParticipant(participantId, accessor, MODIFIER, 2);
Assert.assertTrue(created2);