Skip to content

Commit

Permalink
Fix testTimeouts for map collection features
Browse files Browse the repository at this point in the history
moved timeout related tests of map collection to ArcusTimeoutTest.java
  • Loading branch information
Wooseok Son committed Aug 22, 2016
1 parent 1d6b852 commit 936ddf6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 99 deletions.
35 changes: 35 additions & 0 deletions src/test/java/net/spy/memcached/ArcusTimeoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,39 @@ public void testFlushByPrefixTimeout()
flushFuture.get(1L, TimeUnit.MILLISECONDS);
flushFuture.cancel(true);
}

@Test(expected = TimeoutException.class)
public void testMopInsertBulkMultipleTimeout()
throws InterruptedException, ExecutionException, TimeoutException {
String key = "MyMopKey";
String value = "MyValue";

int mkeySize = mc.getMaxPipedItemCount();
Map<String, Object> mkeys = new TreeMap<String, Object>();
for (int i = 0; i < mkeySize; i++) {
mkeys.put(String.valueOf(i), value);
}

Future<Map<Integer, CollectionOperationStatus>> future = mc.asyncMopPipedInsertBulk(
key, mkeys, new CollectionAttributes());
future.get(1L, TimeUnit.NANOSECONDS);
future.cancel(true);
}

public void testMopInsertBulkTimeout()
throws InterruptedException, ExecutionException, TimeoutException {
String key = "MyMopKey";
String value = "MyValue";
int keySize = 250000;

String[] keys = new String[keySize];
for (int i = 0; i < keys.length; i++) {
keys[i] = "MyMopKey" + i;
}

Future<Map<String, CollectionOperationStatus>> future = mc.asyncMopInsertBulk(
Arrays.asList(keys), key, value, new CollectionAttributes());
future.get(1L, TimeUnit.MILLISECONDS);
future.cancel(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,41 +88,6 @@ public void testInsertAndGet() {
}
}

public void testTimeout() {
String key = "MyMopKey";
String value = "MyValue";

int mkeySize = mc.getMaxPipedItemCount();
Map<String, Object> mkeys = new TreeMap<String, Object>();
for (int i = 0; i < mkeySize; i++) {
mkeys.put(String.valueOf(i), value);
}

try {
// SET
Future<Map<Integer, CollectionOperationStatus>> future = mc
.asyncMopPipedInsertBulk(key, mkeys,
new CollectionAttributes());
try {
Map<Integer, CollectionOperationStatus> errorList = future.get(
1L, TimeUnit.NANOSECONDS);

Assert.assertTrue("Error list is not empty." + errorList,
errorList.isEmpty());
} catch (TimeoutException e) {
future.cancel(true);
return;
} catch (Exception e) {
future.cancel(true);
Assert.fail();
}
Assert.fail();
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}
}

public void testInsertAndGetUsingSingleClient() {
String key = "MyMopKey333";
String value = "MyValue";
Expand Down Expand Up @@ -181,41 +146,6 @@ public void testInsertAndGetUsingSingleClient() {
}
}

public void testTimeoutUsingSingleClient() {
String key = "MyMopKey";
String value = "MyValue";

int mkeySize = mc.getMaxPipedItemCount();
Map<String, Object> mkeys = new TreeMap<String, Object>();
for (int i = 0; i < mkeySize; i++) {
mkeys.put(String.valueOf(i), value);
}

try {
// SET
Future<Map<Integer, CollectionOperationStatus>> future = mc
.asyncMopPipedInsertBulk(key, mkeys,
new CollectionAttributes());
try {
Map<Integer, CollectionOperationStatus> errorList = future.get(
1L, TimeUnit.NANOSECONDS);

Assert.assertTrue("Error list is not empty." + errorList,
errorList.isEmpty());
} catch (TimeoutException e) {
future.cancel(true);
return;
} catch (Exception e) {
future.cancel(true);
Assert.fail();
}
Assert.fail();
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}
}

public void testErrorCount() {
String key = "MyMopKeyErrorCount";
String value = "MyValue";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,35 +86,6 @@ public void testInsertAndGet() {
}
}

public void testTimeout() {
String value = "MyValue";
int keySize = 250000;

String[] keys = new String[keySize];
for (int i = 0; i < keys.length; i++) {
keys[i] = "MyMopKey" + i;
}

try {
// SET
Future<Map<String, CollectionOperationStatus>> future = mc
.asyncMopInsertBulk(Arrays.asList(keys), MKEY, value,
new CollectionAttributes());
try {
future.get(1L, TimeUnit.MILLISECONDS);
Assert.fail("There is no timeout");
} catch (TimeoutException e) {
future.cancel(true);
return;
} catch (Exception e) {
future.cancel(true);
}
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}
}

public void testCountError() {
String value = "MyValue";

Expand Down

0 comments on commit 936ddf6

Please sign in to comment.