Skip to content

Commit

Permalink
Use 3 nodes for clustered all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frant-hartm committed Nov 22, 2024
1 parent 950c2e6 commit b2cd98e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 40 deletions.
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;
}


}

0 comments on commit b2cd98e

Please sign in to comment.