Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix intermittent test failures in CDS
[controller.git]
/
opendaylight
/
md-sal
/
sal-akka-raft
/
src
/
test
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
raft
/
FollowerLogInformationImplTest.java
diff --git
a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java
b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java
index 75496f97526d70eeef6fbdb1fd49b8127550b79a..843b9bebbd3956a3bda56c251a03e697bbc72867 100644
(file)
--- a/
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java
+++ b/
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java
@@
-13,7
+13,6
@@
import com.google.common.base.Stopwatch;
import com.google.common.util.concurrent.Uninterruptibles;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import com.google.common.util.concurrent.Uninterruptibles;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
-import org.opendaylight.controller.cluster.raft.FollowerLogInformation.FollowerState;
import scala.concurrent.duration.FiniteDuration;
public class FollowerLogInformationImplTest {
import scala.concurrent.duration.FiniteDuration;
public class FollowerLogInformationImplTest {
@@
-30,7
+29,7
@@
public class FollowerLogInformationImplTest {
context.setConfigParams(configParams);
FollowerLogInformation followerLogInformation =
context.setConfigParams(configParams);
FollowerLogInformation followerLogInformation =
- new FollowerLogInformationImpl(
"follower1"
, 9, context);
+ new FollowerLogInformationImpl(
new PeerInfo("follower1", null, VotingState.VOTING)
, 9, context);
assertFalse("Follower should be termed inactive before stopwatch starts",
followerLogInformation.isFollowerActive());
assertFalse("Follower should be termed inactive before stopwatch starts",
followerLogInformation.isFollowerActive());
@@
-65,9
+64,9
@@
public class FollowerLogInformationImplTest {
@Test
public void testOkToReplicate(){
MockRaftActorContext context = new MockRaftActorContext();
@Test
public void testOkToReplicate(){
MockRaftActorContext context = new MockRaftActorContext();
+ context.setCommitIndex(0);
FollowerLogInformation followerLogInformation =
FollowerLogInformation followerLogInformation =
- new FollowerLogInformationImpl(
- "follower1", 10, context);
+ new FollowerLogInformationImpl(new PeerInfo("follower1", null, VotingState.VOTING), 10, context);
assertTrue(followerLogInformation.okToReplicate());
assertFalse(followerLogInformation.okToReplicate());
assertTrue(followerLogInformation.okToReplicate());
assertFalse(followerLogInformation.okToReplicate());
@@
-83,19
+82,18
@@
public class FollowerLogInformationImplTest {
@Test
public void testVotingNotInitializedState() {
@Test
public void testVotingNotInitializedState() {
+ final PeerInfo peerInfo = new PeerInfo("follower1", null, VotingState.VOTING_NOT_INITIALIZED);
MockRaftActorContext context = new MockRaftActorContext();
MockRaftActorContext context = new MockRaftActorContext();
- FollowerLogInformation followerLogInformation = new FollowerLogInformationImpl("follower1", -1, context);
+ context.setCommitIndex(0);
+ FollowerLogInformation followerLogInformation = new FollowerLogInformationImpl(peerInfo, -1, context);
- followerLogInformation.setFollowerState(FollowerState.VOTING_NOT_INITIALIZED);
assertFalse(followerLogInformation.okToReplicate());
assertFalse(followerLogInformation.okToReplicate());
- assertFalse(followerLogInformation.canParticipateInConsensus());
followerLogInformation.markFollowerActive();
assertFalse(followerLogInformation.isFollowerActive());
followerLogInformation.markFollowerActive();
assertFalse(followerLogInformation.isFollowerActive());
-
followerLogInformation.setFollowerState(Follower
State.VOTING);
+
peerInfo.setVotingState(Voting
State.VOTING);
assertTrue(followerLogInformation.okToReplicate());
assertTrue(followerLogInformation.okToReplicate());
- assertTrue(followerLogInformation.canParticipateInConsensus());
followerLogInformation.markFollowerActive();
assertTrue(followerLogInformation.isFollowerActive());
followerLogInformation.markFollowerActive();
assertTrue(followerLogInformation.isFollowerActive());
@@
-103,12
+101,12
@@
public class FollowerLogInformationImplTest {
@Test
public void testNonVotingState() {
@Test
public void testNonVotingState() {
+ final PeerInfo peerInfo = new PeerInfo("follower1", null, VotingState.NON_VOTING);
MockRaftActorContext context = new MockRaftActorContext();
MockRaftActorContext context = new MockRaftActorContext();
- FollowerLogInformation followerLogInformation = new FollowerLogInformationImpl("follower1", -1, context);
+ context.setCommitIndex(0);
+ FollowerLogInformation followerLogInformation = new FollowerLogInformationImpl(peerInfo, -1, context);
- followerLogInformation.setFollowerState(FollowerState.NON_VOTING);
assertTrue(followerLogInformation.okToReplicate());
assertTrue(followerLogInformation.okToReplicate());
- assertFalse(followerLogInformation.canParticipateInConsensus());
followerLogInformation.markFollowerActive();
assertTrue(followerLogInformation.isFollowerActive());
followerLogInformation.markFollowerActive();
assertTrue(followerLogInformation.isFollowerActive());