You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tephra.apache.org by po...@apache.org on 2016/09/09 05:09:08 UTC
[1/2] incubator-tephra git commit: Fix PooledClientProviderTest.
TransactionService may not be registered for discovery once
TransactionServiceMain#start returns.
Repository: incubator-tephra
Updated Branches:
refs/heads/master b9eae01f3 -> 307a585cb
Fix PooledClientProviderTest. TransactionService may not be registered for discovery once TransactionServiceMain#start returns.
This closes #5
Signed-off-by: poorna <po...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-tephra/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tephra/commit/307a585c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tephra/tree/307a585c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tephra/diff/307a585c
Branch: refs/heads/master
Commit: 307a585cb6c288c38362cb85cb4f3ce62b3e607a
Parents: cd251d3
Author: Ali Anwar <an...@berkeley.edu>
Authored: Thu Sep 8 21:28:59 2016 -0700
Committer: poorna <po...@apache.org>
Committed: Thu Sep 8 22:08:52 2016 -0700
----------------------------------------------------------------------
.../distributed/PooledClientProviderTest.java | 38 ++++++++++++++++----
1 file changed, 32 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tephra/blob/307a585c/tephra-core/src/test/java/org/apache/tephra/distributed/PooledClientProviderTest.java
----------------------------------------------------------------------
diff --git a/tephra-core/src/test/java/org/apache/tephra/distributed/PooledClientProviderTest.java b/tephra-core/src/test/java/org/apache/tephra/distributed/PooledClientProviderTest.java
index 90a69e9..507cefb 100644
--- a/tephra-core/src/test/java/org/apache/tephra/distributed/PooledClientProviderTest.java
+++ b/tephra-core/src/test/java/org/apache/tephra/distributed/PooledClientProviderTest.java
@@ -29,6 +29,7 @@ import org.apache.tephra.runtime.DiscoveryModules;
import org.apache.tephra.runtime.TransactionClientModule;
import org.apache.tephra.runtime.TransactionModules;
import org.apache.tephra.runtime.ZKModule;
+import org.apache.thrift.TException;
import org.apache.twill.discovery.DiscoveryServiceClient;
import org.apache.twill.internal.zookeeper.InMemoryZKServer;
import org.apache.twill.zookeeper.ZKClientService;
@@ -47,12 +48,13 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class PooledClientProviderTest {
- public static final int MAX_CLIENT_COUNT = 3;
- public static final long CLIENT_OBTAIN_TIMEOUT = 10;
+ private static final int MAX_CLIENT_COUNT = 3;
+ private static final long CLIENT_OBTAIN_TIMEOUT = 10;
@ClassRule
public static TemporaryFolder tmpFolder = new TemporaryFolder();
@@ -114,12 +116,25 @@ public class PooledClientProviderTest {
final PooledClientProvider clientProvider = new PooledClientProvider(conf,
injector.getInstance(DiscoveryServiceClient.class));
- // test simple case of get + return. Note: this also initializes the provider's pool, which
+ // Test simple case of get + return. Note: this also initializes the provider's pool, which
// takes about one second (discovery). Doing it before we test the threads makes it so that one
// thread doesn't take exceptionally longer than the others.
- try (CloseableThriftClient closeableThriftClient = clientProvider.getCloseableClient()) {
- // do nothing with the client
- }
+
+ // Need to retry, since TransactionServiceMain#start returning doesn't indicate that the TransactionService
+ // has registered itself for discovery yet
+ waitFor("Failed to get client.", new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ try (CloseableThriftClient closeableThriftClient = clientProvider.getCloseableClient()) {
+ // do nothing with the client
+ } catch (TException e) {
+ // simply retry
+ return false;
+ }
+ return true;
+ }
+ });
+
//Now race to get MAX_CLIENT_COUNT+1 clients, exhausting the pool and requesting 1 more.
List<Future<Integer>> clientIds = new ArrayList<Future<Integer>>();
@@ -161,6 +176,17 @@ public class PooledClientProviderTest {
executor.shutdown();
}
+ private void waitFor(String errorMessage, Callable<Boolean> callable) throws Exception {
+ for (int i = 0; i < 600; i++) {
+ boolean value = callable.call();
+ if (value) {
+ return;
+ }
+ TimeUnit.MILLISECONDS.sleep(50);
+ }
+ Assert.fail(errorMessage);
+ }
+
private static class RetrieveClient implements Callable<Integer> {
private final PooledClientProvider pool;
private final long holdClientMs;
[2/2] incubator-tephra git commit: Fix flaky test:
ThriftTransactionServerTest#testThriftServerRestart
Posted by po...@apache.org.
Fix flaky test: ThriftTransactionServerTest#testThriftServerRestart
Signed-off-by: poorna <po...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-tephra/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tephra/commit/cd251d39
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tephra/tree/cd251d39
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tephra/diff/cd251d39
Branch: refs/heads/master
Commit: cd251d3953e8d83287c898223642a50857bb318d
Parents: b9eae01
Author: Ali Anwar <an...@berkeley.edu>
Authored: Thu Sep 8 14:29:27 2016 -0700
Committer: poorna <po...@apache.org>
Committed: Thu Sep 8 22:08:52 2016 -0700
----------------------------------------------------------------------
.../apache/tephra/distributed/ThriftTransactionServerTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tephra/blob/cd251d39/tephra-core/src/test/java/org/apache/tephra/distributed/ThriftTransactionServerTest.java
----------------------------------------------------------------------
diff --git a/tephra-core/src/test/java/org/apache/tephra/distributed/ThriftTransactionServerTest.java b/tephra-core/src/test/java/org/apache/tephra/distributed/ThriftTransactionServerTest.java
index bbe03ed..4f9a79f 100644
--- a/tephra-core/src/test/java/org/apache/tephra/distributed/ThriftTransactionServerTest.java
+++ b/tephra-core/src/test/java/org/apache/tephra/distributed/ThriftTransactionServerTest.java
@@ -96,6 +96,7 @@ public class ThriftTransactionServerTest {
conf.setLong(TxConstants.Service.CFG_DATA_TX_CLIENT_TIMEOUT, TimeUnit.HOURS.toMillis(1));
conf.setInt(TxConstants.Service.CFG_DATA_TX_SERVER_IO_THREADS, 2);
conf.setInt(TxConstants.Service.CFG_DATA_TX_SERVER_THREADS, 4);
+ conf.setInt(TxConstants.HBase.ZK_SESSION_TIMEOUT, 10000);
injector = Guice.createInjector(
new ConfigModule(conf),
@@ -235,7 +236,7 @@ public class ThriftTransactionServerTest {
}
private void waitFor(String errorMessage, Callable<Boolean> callable) throws Exception {
- for (int i = 0; i < 200; i++) {
+ for (int i = 0; i < 600; i++) {
boolean value = callable.call();
if (value) {
return;