Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Do not use ActorSystem.actorFor as it is deprecated
[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 7df9f3713ffc302dcf100c45a93b8fd034b0fffa..5be9030f5957bd361c73ead2d11353eb5d178f95 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
@@
-7,31
+7,29
@@
*/
package org.opendaylight.controller.cluster.raft;
*/
package org.opendaylight.controller.cluster.raft;
-
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import com.google.common.base.Stopwatch;
import com.google.common.util.concurrent.Uninterruptibles;
import com.google.common.base.Stopwatch;
import com.google.common.util.concurrent.Uninterruptibles;
+import java.util.concurrent.TimeUnit;
import org.junit.Test;
import scala.concurrent.duration.FiniteDuration;
import org.junit.Test;
import scala.concurrent.duration.FiniteDuration;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
public class FollowerLogInformationImplTest {
@Test
public void testIsFollowerActive() {
public class FollowerLogInformationImplTest {
@Test
public void testIsFollowerActive() {
- FiniteDuration timeoutDuration =
- new FiniteDuration(500, TimeUnit.MILLISECONDS);
-
- FollowerLogInformation followerLogInformation =
- new FollowerLogInformationImpl(
- "follower1", new AtomicLong(10), new AtomicLong(9), timeoutDuration);
+ MockRaftActorContext context = new MockRaftActorContext();
+ context.setCommitIndex(10);
+ DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
+ configParams.setHeartBeatInterval(new FiniteDuration(500, TimeUnit.MILLISECONDS));
+ configParams.setElectionTimeoutFactor(1);
+ context.setConfigParams(configParams);
+ FollowerLogInformation followerLogInformation =
+ new FollowerLogInformationImpl("follower1", 9, context);
assertFalse("Follower should be termed inactive before stopwatch starts",
followerLogInformation.isFollowerActive());
assertFalse("Follower should be termed inactive before stopwatch starts",
followerLogInformation.isFollowerActive());
@@
-57,8
+55,7
@@
public class FollowerLogInformationImplTest {
// hence getting the actual elapsed time and do a match.
// if the sleep has spilled over, then return the test gracefully
private long sleepWithElaspsedTimeReturned(long millis) {
// hence getting the actual elapsed time and do a match.
// if the sleep has spilled over, then return the test gracefully
private long sleepWithElaspsedTimeReturned(long millis) {
- Stopwatch stopwatch = new Stopwatch();
- stopwatch.start();
+ Stopwatch stopwatch = Stopwatch.createStarted();
Uninterruptibles.sleepUninterruptibly(millis, TimeUnit.MILLISECONDS);
stopwatch.stop();
return stopwatch.elapsed(TimeUnit.MILLISECONDS);
Uninterruptibles.sleepUninterruptibly(millis, TimeUnit.MILLISECONDS);
stopwatch.stop();
return stopwatch.elapsed(TimeUnit.MILLISECONDS);