// TODO There is no guarantee that records get assigned to different nodes, causes intermittent failures
@Test
public void shouldThrowAnExceptionIfARecordIsStoredOnMoreThanOneNode() throws Exception {
final Assigner assigner = context.mock(Assigner.class);
final Hive hive = Hive.load(getHive().getUri(), (HiveDataSourceProvider) getHive().getDataSourceProvider(), assigner);
context.checking(new Expectations() {
{
exactly(2).of(assigner).chooseNode(with(any(Collection.class)), with(anything()));
will(onConsecutiveCalls(returnValue(hive.getNode(1)), returnValue(hive.getNode(2))));
}
});
String asia = "Asia";
hive.directory().insertPrimaryIndexKey(asia);
hive.directory().insertPrimaryIndexKey(asia);
context.assertIsSatisfied(); //asserts that this is no longer probabalistic
Session session = null;
try {
session = factory.openSession(asia);
Collection<Integer> nodeIds = hive.directory().getNodeIdsOfPrimaryIndexKey(asia);
assertEquals(2, nodeIds.size());
Node node = getNodeForFirstId(hive, nodeIds);
assertCorrectNode(session, node);
fail("No exception thrown");
} catch (IllegalStateException e) {