Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed a number of TAP test issues.

Change-Id: I1193262637596d0576838a67db7a61ff1447ad37
Reviewed-on: http://review.couchbase.org/13394
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Matt Ingenthron <matt@couchbase.com>
  • Loading branch information...
commit f1d750e70f4f295491861a51115965f72c8b9782 1 parent 88bb58b
@ingenthr ingenthr authored ingenthr committed
Showing with 21 additions and 27 deletions.
  1. +21 −27 src/test/java/com/couchbase/client/TapTest.java
View
48 src/test/java/com/couchbase/client/TapTest.java
@@ -29,9 +29,7 @@
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
-import net.spy.memcached.BinaryConnectionFactory;
import net.spy.memcached.ClientBaseCase;
-import net.spy.memcached.FailureMode;
import net.spy.memcached.TestConfig;
import net.spy.memcached.tapmessage.ResponseMessage;
@@ -47,17 +45,9 @@
@Override
protected void initClient() throws Exception {
- initClient(new BinaryConnectionFactory() {
- @Override
- public long getOperationTimeout() {
- return 15000;
- }
-
- @Override
- public FailureMode getFailureMode() {
- return FailureMode.Retry;
- }
- });
+ List<URI> uris = new LinkedList<URI>();
+ uris.add(URI.create("http://" + TestConfig.IPV4_ADDR + ":8091/pools"));
+ client = new CouchbaseClient(uris, "default", "");
}
@@ -88,23 +78,23 @@ public void testBackfill() throws Exception {
}
public void testTapDump() throws Exception {
- List<URI> uris = new LinkedList<URI>();
- uris.add(URI.create("http://" + TestConfig.IPV4_ADDR + ":8091/pools"));
- TapClient tc = new TapClient(uris, "default", "");
HashMap<String, Boolean> items = new HashMap<String, Boolean>();
for (int i = 0; i < 25; i++) {
- client.set("key" + i, 0, "value" + i).get();
+ assert(client.set("key" + i, 0, "value" + i).get());
items.put("key" + i + ",value" + i, new Boolean(false));
}
- tc.tapDump(null);
+ List<URI> uris = new LinkedList<URI>();
+ uris.add(URI.create("http://" + TestConfig.IPV4_ADDR + ":8091/pools"));
+ TapClient tapClient = new TapClient(uris, "default", "");
+ tapClient.tapDump(null);
long st = System.currentTimeMillis();
- while (tc.hasMoreMessages()) {
+ while (tapClient.hasMoreMessages()) {
if ((System.currentTimeMillis() - st) > TAP_DUMP_TIMEOUT) {
fail("Tap dump took too long");
}
ResponseMessage m;
- if ((m = tc.getNextMessage()) != null) {
+ if ((m = tapClient.getNextMessage()) != null) {
String key = m.getKey() + "," + new String(m.getValue());
if (items.containsKey(key)) {
items.put(key, new Boolean(true));
@@ -118,14 +108,16 @@ public void testTapDump() throws Exception {
}
public void testTapBucketDoesNotExist() throws Exception {
- TapClient client =
- new TapClient(Arrays.asList(new URI("http://" + TestConfig.IPV4_ADDR
- + ":8091/pools")), "abucket", "apassword");
-
+ TapClient tapClient = null;
+ tapClient = new TapClient(Arrays.asList(new URI("http://"
+ + TestConfig.IPV4_ADDR + ":8091/pools")), "abucket", "apassword");
try {
- client.tapBackfill(null, 5, TimeUnit.SECONDS);
+ tapClient.tapBackfill(null, 5, TimeUnit.SECONDS);
+ fail("TAP started with a misconfiguration on " + tapClient);
} catch (RuntimeException e) {
- System.err.println(e.getMessage());
+ // expected
+ System.err.println("Expected tap of non existent bucket "
+ + "failure:\n" + e.getMessage());
return;
}
}
@@ -133,8 +125,10 @@ public void testTapBucketDoesNotExist() throws Exception {
private void checkTapKeys(HashMap<String, Boolean> items) {
for (Entry<String, Boolean> kv : items.entrySet()) {
if (!kv.getValue().booleanValue()) {
- fail();
+ fail("Failed to receive one of the previously set items: \""
+ + kv.getKey() + "\". Number of items received: " + items.size());
}
}
+ System.err.println("Received " + items.size() + " items over TAP.");
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.