Skip to content

Commit

Permalink
Merge pull request OpenTSDB#21 from hi3g/test_hsbase_store
Browse files Browse the repository at this point in the history
added fix for the change with optionals
  • Loading branch information
vonbirdie committed Aug 5, 2014
2 parents 4f83ad5 + 0c7ab9b commit 55c396e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions test/storage/TestHBaseStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void allocateUIDUnableToIncrementMaxId() throws Exception {


@Test // Test the creation of an ID with a race condition.
public void getOrCreateIdAssignIdWithRaceCondition() {
public void getOrCreateIdAssignIdWithRaceCondition() throws Exception{
// Simulate a race between client A and client B.
// A does a Get and sees that there's no ID for this name.
// B does a Get and sees that there's no ID too, and B actually goes
Expand All @@ -211,17 +211,18 @@ public void getOrCreateIdAssignIdWithRaceCondition() {
.thenReturn(Deferred.fromResult(false));
// For simplicity return an empty ArrayList, then the call back should return
// null
final byte[] value = {'1','2','3'};
ArrayList<KeyValue> al = new ArrayList<KeyValue>();
al.add(new KeyValue(new byte[] {'h', 'o', 's', 't'}, new byte[] {},
new byte[] {}, value));
when(client.get(any(GetRequest.class)))
.thenReturn(Deferred.fromResult(new ArrayList<KeyValue>()));

try {
byte[] uid = tsdb_store.allocateUID(foo_array, UniqueId.UniqueIdType.METRIC,
UniqueId.UniqueIdType.METRIC.width).joinUninterruptibly();
if (null != uid)
fail("Should have received null but received uid = " + uid);
} catch (Exception e) {
fail("Received unexpected exception = " + e);
}
.thenReturn(Deferred.fromResult(al));


byte[] uid = tsdb_store.allocateUID(foo_array, UniqueId.UniqueIdType.METRIC,
UniqueId.UniqueIdType.METRIC.width).joinUninterruptibly();
assertEquals(value,uid);

// Verify the order of execution too.
final InOrder order = inOrder(client);
order.verify(client, times(1)).atomicIncrement(incrementForRow(MAX_UID));
Expand Down

0 comments on commit 55c396e

Please sign in to comment.