http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/ddbd7716/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestDistributedLogServerClientRouting.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestDistributedLogServerClientRouting.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestDistributedLogServerClientRouting.java new file mode 100644 index 0000000..0e5f187 --- /dev/null +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestDistributedLogServerClientRouting.java @@ -0,0 +1,59 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.twitter.distributedlog.service; + +import com.twitter.finagle.NoBrokersAvailableException; +import com.twitter.util.Await; +import org.junit.Test; + +import java.nio.ByteBuffer; + +import static com.google.common.base.Charsets.UTF_8; +import static org.junit.Assert.fail; + +/** + * Test the server with client side routing. + */ +public class TestDistributedLogServerClientRouting extends TestDistributedLogServerBase { + + public TestDistributedLogServerClientRouting() { + super(true); + } + + @Test(timeout = 60000) + public void testAcceptNewStream() throws Exception { + String name = "dlserver-accept-new-stream"; + + dlClient.routingService.addHost(name, dlServer.getAddress()); + dlClient.routingService.setAllowRetrySameHost(false); + + Await.result(dlClient.dlClient.setAcceptNewStream(false)); + + try { + Await.result(dlClient.dlClient.write(name, ByteBuffer.wrap("1".getBytes(UTF_8)))); + fail("Should fail because the proxy couldn't accept new stream"); + } catch (NoBrokersAvailableException nbae) { + // expected + } + checkStream(0, 0, 0, name, dlServer.getAddress(), false, false); + + Await.result(dlServer.dlServer.getLeft().setAcceptNewStream(true)); + Await.result(dlClient.dlClient.write(name, ByteBuffer.wrap("1".getBytes(UTF_8)))); + checkStream(1, 1, 1, name, dlServer.getAddress(), true, true); + } +}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/ddbd7716/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestDistributedLogServerServerRouting.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestDistributedLogServerServerRouting.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestDistributedLogServerServerRouting.java new file mode 100644 index 0000000..f3dfd11 --- /dev/null +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestDistributedLogServerServerRouting.java @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.twitter.distributedlog.service; + +/** + * Test the server with client side routing. + */ +public class TestDistributedLogServerServerRouting extends TestDistributedLogServerBase { + + public TestDistributedLogServerServerRouting() { + super(false); + } +} http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/ddbd7716/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestRegionUnavailable.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestRegionUnavailable.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestRegionUnavailable.java index cfe9d8a..f4c140e 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestRegionUnavailable.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/TestRegionUnavailable.java @@ -68,6 +68,7 @@ public class TestRegionUnavailable extends DistributedLogServerTestCase { private TwoRegionDLClient client; public TestRegionUnavailable() { + super(true); this.localCluster = new ArrayList<DLServer>(); this.remoteCluster = new ArrayList<DLServer>(); } http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/ddbd7716/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestClusterBalancer.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestClusterBalancer.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestClusterBalancer.java index 9b39f09..05eb724 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestClusterBalancer.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestClusterBalancer.java @@ -51,6 +51,7 @@ public class TestClusterBalancer extends DistributedLogServerTestCase { private DLClient client; public TestClusterBalancer() { + super(true); this.cluster = new ArrayList<DLServer>(); } @@ -62,7 +63,7 @@ public class TestClusterBalancer extends DistributedLogServerTestCase { for (int i = 0; i < numServers; i++) { cluster.add(createDistributedLogServer(initPort + i)); } - client = createDistributedLogClient("cluster_client"); + client = createDistributedLogClient("cluster_client", Optional.<String>absent()); } @After http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/ddbd7716/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestSimpleBalancer.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestSimpleBalancer.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestSimpleBalancer.java index 3508e7c..59d1d10 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestSimpleBalancer.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestSimpleBalancer.java @@ -42,12 +42,16 @@ public class TestSimpleBalancer extends DistributedLogServerTestCase { DLClient targetClient; DLServer targetServer; + public TestSimpleBalancer() { + super(true); + } + @Before @Override public void setup() throws Exception { super.setup(); targetServer = createDistributedLogServer(7003); - targetClient = createDistributedLogClient("target"); + targetClient = createDistributedLogClient("target", Optional.<String>absent()); } @After http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/ddbd7716/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestStreamMover.java ---------------------------------------------------------------------- diff --git a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestStreamMover.java b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestStreamMover.java index f4679b7..3f90f35 100644 --- a/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestStreamMover.java +++ b/distributedlog-service/src/test/java/com/twitter/distributedlog/service/balancer/TestStreamMover.java @@ -17,6 +17,7 @@ */ package com.twitter.distributedlog.service.balancer; +import com.google.common.base.Optional; import com.twitter.distributedlog.service.DistributedLogClient; import com.twitter.distributedlog.service.DistributedLogCluster.DLServer; import com.twitter.distributedlog.service.DistributedLogServerTestCase; @@ -35,12 +36,16 @@ public class TestStreamMover extends DistributedLogServerTestCase { DLClient targetClient; DLServer targetServer; + public TestStreamMover() { + super(true); + } + @Before @Override public void setup() throws Exception { super.setup(); targetServer = createDistributedLogServer(7003); - targetClient = createDistributedLogClient("target"); + targetClient = createDistributedLogClient("target", Optional.<String>absent()); } @After