public void testStorageNodeAckFailedOperation() throws Exception {
executeInTransaction(new TransactionCallback() {
@Override
public void execute() throws Exception {
StorageNode node = StorageNodeFactory.newInstance();
final String address = TEST_PREFIX + "foo.com";
node.setAddress(address);
node.setOperationMode(StorageNode.OperationMode.ANNOUNCE);
node.setCqlPort(9142);
node.setErrorMessage("It is broken");
em.persist(node);
em.flush();
assertEquals("The cluster status should be DOWN", StorageNode.Status.DOWN, node.getStatus());
// we need to do this to obtain the new id
StorageNodeCriteria criteria = new StorageNodeCriteria();
criteria.addFilterAddress(address);
StorageNode node2 = nodeManager.findStorageNodeByAddress(address);
nodeManager.ackFailedOperation(subjectManager.getOverlord(), node2.getId());
criteria = new StorageNodeCriteria();
criteria.addFilterAddress(address);
StorageNode node3 = nodeManager.findStorageNodeByAddress(address);
assertEquals("The error message should not affect the equals method", node, node2);
assertEquals("The error message should not affect the equals method", node2, node3);
assertEquals("The cluster status should be JOINING", StorageNode.Status.JOINING, node3.getStatus());
assertNull("The error message should be clean now", node3.getErrorMessage());
}
});
}