Skip to content
Closed
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,10 +19,10 @@
package org.apache.zookeeper.server.quorum;

import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.Map;
Expand All @@ -39,17 +39,15 @@
import org.apache.zookeeper.server.quorum.Leader.Proposal;
import org.apache.zookeeper.test.ClientBase;
import org.apache.zookeeper.test.ClientBase.CountdownWatcher;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.After;
import org.junit.Test;

public class DIFFSyncConsistencyTest extends QuorumPeerTestBase {

private static int SERVER_COUNT = 3;
private MainThread[] mt = new MainThread[SERVER_COUNT];

@Test
@Timeout(value = 120)
@Test(timeout = 120 * 1000)
public void testInconsistentDueToUncommittedLog() throws Exception {
final int LEADER_TIMEOUT_MS = 10_000;
final int[] clientPorts = new int[SERVER_COUNT];
Expand All @@ -75,8 +73,8 @@ public TestQPMain getTestQPMain() {
}

for (int i = 0; i < SERVER_COUNT; i++) {
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i], CONNECTION_TIMEOUT),
"waiting for server " + i + " being up");
assertTrue("waiting for server " + i + " being up",
ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i], CONNECTION_TIMEOUT));
}

int leader = findLeader(mt);
Expand Down Expand Up @@ -113,7 +111,7 @@ public TestQPMain getTestQPMain() {
assertTrue(outstanding.size() > 0);
Proposal p = findProposalOfType(outstanding, OpCode.create);
LOG.info("Old leader id: {}. All proposals: {}", leader, outstanding);
assertNotNull(p, "Old leader doesn't have 'create' proposal");
assertNotNull("Old leader doesn't have 'create' proposal", p);

// Make sure leader sync the proposal to disk.
int sleepTime = 0;
Expand Down Expand Up @@ -161,7 +159,7 @@ public TestQPMain getTestQPMain() {
++c;
try {
Stat stat = zk.exists("/zk" + leader, false);
assertNotNull(stat, "server " + leader + " should have /zk");
assertNotNull("server " + leader + " should have /zk", stat);
break;
} catch (KeeperException.ConnectionLossException e) {

Expand Down Expand Up @@ -197,7 +195,7 @@ public TestQPMain getTestQPMain() {
}

int newLeader = findLeader(mt);
assertNotEquals(newLeader, leader, "new leader is still the old leader " + leader + " !!");
assertNotEquals("new leader is still the old leader " + leader + " !!", newLeader, leader);

// This simulates the case where clients connected to the old leader had a view of the data
// "/zkX", but clients connect to the new leader does not have the same view of data (missing "/zkX").
Expand All @@ -210,14 +208,14 @@ public TestQPMain getTestQPMain() {
zk = new ZooKeeper("127.0.0.1:" + clientPorts[i], ClientBase.CONNECTION_TIMEOUT, watch);
watch.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
Stat val = zk.exists("/zk" + leader, false);
assertNotNull(val, "Data inconsistency detected! "
+ "Server " + i + " should have a view of /zk" + leader + "!");
assertNotNull("Data inconsistency detected! Server " + i + " should have a view of /zk" + leader + "!",
val);
}

zk.close();
}

@AfterEach
@After
public void tearDown() {
for (int i = 0; i < mt.length; i++) {
try {
Expand Down