Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 3 nodes for clustered all tests #5406

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,36 @@
import io.vertx.core.spi.cluster.ClusterManager;
import io.vertx.test.fakecluster.FakeClusterManager;

import java.util.concurrent.atomic.AtomicInteger;

/**
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class ClusteredAsyncMapTest extends AsyncMapTest {

int pos;
protected final int numNodes = 3;
AtomicInteger pos = new AtomicInteger();

public void setUp() throws Exception {
super.setUp();
startNodes(numNodes);
}

@Override
protected ClusterManager getClusterManager() {
return new FakeClusterManager();
}

@Override
protected Vertx getVertx() {
Vertx vertx = vertices[pos];
if (++pos == getNumNodes()) {
pos = 0;
}
return vertx;
int i = pos.incrementAndGet();
i = mod(i, numNodes);
return vertices[i];
}

private int mod(int idx, int size) {
int i = idx % size;
return i < 0 ? i + size : i;
}

@Test
Expand All @@ -59,17 +75,4 @@ public void testGetLocalAsyncMap() {
await();
}

public void setUp() throws Exception {
super.setUp();
startNodes(getNumNodes());
}

protected int getNumNodes() {
return 2;
}

@Override
protected ClusterManager getClusterManager() {
return new FakeClusterManager();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@
*/
public class ClusteredAsynchronousLockTest extends AsynchronousLockTest {

@Override
protected ClusterManager getClusterManager() {
return new FakeClusterManager();
}

protected final int numNodes = 3;
AtomicInteger pos = new AtomicInteger();

public void setUp() throws Exception {
super.setUp();
startNodes(numNodes);
}

AtomicInteger pos = new AtomicInteger();
@Override
protected ClusterManager getClusterManager() {
return new FakeClusterManager();
}

@Override
protected Vertx getVertx() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,36 @@
import io.vertx.core.spi.cluster.ClusterManager;
import io.vertx.test.fakecluster.FakeClusterManager;

import java.util.concurrent.atomic.AtomicInteger;

/**
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class ClusteredSharedCounterTest extends SharedCounterTest {

protected final int numNodes = 3;
AtomicInteger pos = new AtomicInteger();

public void setUp() throws Exception {
super.setUp();
startNodes(numNodes);
}

@Override
protected ClusterManager getClusterManager() {
return new FakeClusterManager();
}

protected final int numNodes = 2;
@Override
protected Vertx getVertx() {
int i = pos.incrementAndGet();
i = mod(i, numNodes);
return vertices[i];
}

public void setUp() throws Exception {
super.setUp();
startNodes(numNodes);
private int mod(int idx, int size) {
int i = idx % size;
return i < 0 ? i + size : i;
}

@Test
Expand All @@ -57,15 +72,4 @@ public void testGetLocalCounter() {
await();
}

int pos;
@Override
protected Vertx getVertx() {
Vertx vertx = vertices[pos];
if (++pos == numNodes) {
pos = 0;
}
return vertx;
}


}
Loading