Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Specify initial serialization buffer capacity for Payloads
[controller.git]
/
opendaylight
/
md-sal
/
sal-distributed-datastore
/
src
/
test
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
datastore
/
shardmanager
/
ShardManagerGetSnapshotReplyActorTest.java
diff --git
a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActorTest.java
b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActorTest.java
index f2b11b01c311aaaf0b798ed809fed267dd9f3d75..d289e02d448a5a58070ae99919e60a15347616c8 100644
(file)
--- a/
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActorTest.java
+++ b/
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActorTest.java
@@
-7,14
+7,15
@@
*/
package org.opendaylight.controller.cluster.datastore.shardmanager;
*/
package org.opendaylight.controller.cluster.datastore.shardmanager;
-import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import akka.actor.ActorRef;
import akka.actor.Status.Failure;
import akka.actor.Terminated;
import static org.junit.Assert.assertEquals;
import akka.actor.ActorRef;
import akka.actor.Status.Failure;
import akka.actor.Terminated;
-import akka.testkit.JavaTestKit;
+import akka.testkit.javadsl.TestKit;
+import java.time.Duration;
import java.util.Arrays;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@
-24,8
+25,11
@@
import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.ShardManagerSnapshot;
+import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
-import scala.concurrent.duration.Duration;
+import org.opendaylight.controller.cluster.raft.persisted.ByteState;
+import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
import scala.concurrent.duration.FiniteDuration;
/**
import scala.concurrent.duration.FiniteDuration;
/**
@@
-38,58
+42,66
@@
public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
@Test
public void testSuccess() {
@Test
public void testSuccess() {
-
JavaTestKit kit = new Java
TestKit(getSystem());
+
TestKit kit = new
TestKit(getSystem());
- byte[] shardManagerSnapshot = new byte[]{0,5,9};
+ List<String> shardList = Arrays.asList("shard1", "shard2", "shard3");
+ ShardManagerSnapshot shardManagerSnapshot = new ShardManagerSnapshot(shardList, Collections.emptyMap());
ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
-
Arrays.asList("shard1", "shard2", "shard3")
, "config", shardManagerSnapshot, kit.getRef(),
- "shard-manager", Duration.create(100, TimeUnit.SECONDS)), "testSuccess");
+
shardList
, "config", shardManagerSnapshot, kit.getRef(),
+ "shard-manager",
Finite
Duration.create(100, TimeUnit.SECONDS)), "testSuccess");
kit.watch(replyActor);
kit.watch(replyActor);
-
byte[] shard1Snapshot = new byte[]{1,2,3}
;
+
ByteState shard1SnapshotState = ByteState.of(new byte[]{1,2,3})
;
replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard1", MEMBER_1, "config").toString(),
replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard1", MEMBER_1, "config").toString(),
- shard1Snapshot), ActorRef.noSender());
+ Snapshot.create(shard1SnapshotState, Collections.<ReplicatedLogEntry>emptyList(),
+ 2, 1, 2, 1, 1, "member-1", null)), ActorRef.noSender());
-
byte[] shard2Snapshot = new byte[]{4,5,6}
;
+
ByteState shard2SnapshotState = ByteState.of(new byte[]{4,5,6})
;
replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard2", MEMBER_1, "config").toString(),
replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard2", MEMBER_1, "config").toString(),
- shard2Snapshot), ActorRef.noSender());
+ Snapshot.create(shard2SnapshotState, Collections.<ReplicatedLogEntry>emptyList(),
+ 2, 1, 2, 1, 1, "member-1", null)), ActorRef.noSender());
- kit.expectNoM
sg(FiniteDuration.create(500, TimeUnit.MILLISECONDS
));
+ kit.expectNoM
essage(Duration.ofMillis(500
));
-
byte[] shard3Snapshot = new byte[]{7,8,9}
;
+
ByteState shard3SnapshotState = ByteState.of(new byte[]{7,8,9})
;
replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard3", MEMBER_1, "config").toString(),
replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard3", MEMBER_1, "config").toString(),
- shard3Snapshot), ActorRef.noSender());
+ Snapshot.create(shard3SnapshotState, Collections.<ReplicatedLogEntry>emptyList(),
+ 2, 1, 2, 1, 1, "member-1", null)), ActorRef.noSender());
DatastoreSnapshot datastoreSnapshot = kit.expectMsgClass(DatastoreSnapshot.class);
assertEquals("getType", "config", datastoreSnapshot.getType());
DatastoreSnapshot datastoreSnapshot = kit.expectMsgClass(DatastoreSnapshot.class);
assertEquals("getType", "config", datastoreSnapshot.getType());
- assertArrayEquals("getShardManagerSnapshot", shardManagerSnapshot, datastoreSnapshot.getShardManagerSnapshot());
+ assertEquals("getShardManagerSnapshot", shardManagerSnapshot.getShardList(),
+ datastoreSnapshot.getShardManagerSnapshot().getShardList());
List<ShardSnapshot> shardSnapshots = datastoreSnapshot.getShardSnapshots();
assertEquals("ShardSnapshot size", 3, shardSnapshots.size());
assertEquals("ShardSnapshot 1 getName", "shard1", shardSnapshots.get(0).getName());
List<ShardSnapshot> shardSnapshots = datastoreSnapshot.getShardSnapshots();
assertEquals("ShardSnapshot size", 3, shardSnapshots.size());
assertEquals("ShardSnapshot 1 getName", "shard1", shardSnapshots.get(0).getName());
- assertArrayEquals("ShardSnapshot 1 getSnapshot", shard1Snapshot, shardSnapshots.get(0).getSnapshot());
+ assertEquals("ShardSnapshot 1 getSnapshot", shard1SnapshotState,
+ shardSnapshots.get(0).getSnapshot().getState());
assertEquals("ShardSnapshot 2 getName", "shard2", shardSnapshots.get(1).getName());
assertEquals("ShardSnapshot 2 getName", "shard2", shardSnapshots.get(1).getName());
- assertArrayEquals("ShardSnapshot 2 getSnapshot", shard2Snapshot, shardSnapshots.get(1).getSnapshot());
+ assertEquals("ShardSnapshot 2 getSnapshot", shard2SnapshotState,
+ shardSnapshots.get(1).getSnapshot().getState());
assertEquals("ShardSnapshot 3 getName", "shard3", shardSnapshots.get(2).getName());
assertEquals("ShardSnapshot 3 getName", "shard3", shardSnapshots.get(2).getName());
- assertArrayEquals("ShardSnapshot 3 getSnapshot", shard3Snapshot, shardSnapshots.get(2).getSnapshot());
+ assertEquals("ShardSnapshot 3 getSnapshot", shard3SnapshotState,
+ shardSnapshots.get(2).getSnapshot().getState());
kit.expectMsgClass(Terminated.class);
}
@Test
public void testGetSnapshotFailureReply() {
kit.expectMsgClass(Terminated.class);
}
@Test
public void testGetSnapshotFailureReply() {
-
JavaTestKit kit = new Java
TestKit(getSystem());
+
TestKit kit = new
TestKit(getSystem());
- byte[] shardManagerSnapshot = new byte[]{0,5,9};
ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
- Arrays.asList("shard1", "shard2"), "config",
shardManagerSnapshot
, kit.getRef(), "shard-manager",
- Duration.create(100, TimeUnit.SECONDS)), "testGetSnapshotFailureReply");
+ Arrays.asList("shard1", "shard2"), "config",
null
, kit.getRef(), "shard-manager",
+
Finite
Duration.create(100, TimeUnit.SECONDS)), "testGetSnapshotFailureReply");
kit.watch(replyActor);
replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard1", MEMBER_1, "config").toString(),
kit.watch(replyActor);
replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard1", MEMBER_1, "config").toString(),
- new byte[]{1,2,3}), ActorRef.noSender());
+ Snapshot.create(ByteState.of(new byte[]{1,2,3}), Collections.<ReplicatedLogEntry>emptyList(),
+ 2, 1, 2, 1, 1, "member-1", null)), ActorRef.noSender());
replyActor.tell(new Failure(new RuntimeException()), ActorRef.noSender());
replyActor.tell(new Failure(new RuntimeException()), ActorRef.noSender());
@@
-99,12
+111,11
@@
public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
@Test
public void testGetSnapshotTimeout() {
@Test
public void testGetSnapshotTimeout() {
-
JavaTestKit kit = new Java
TestKit(getSystem());
+
TestKit kit = new
TestKit(getSystem());
- byte[] shardManagerSnapshot = new byte[]{0,5,9};
ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
- Arrays.asList("shard1"), "config",
shardManagerSnapshot
, kit.getRef(), "shard-manager",
- Duration.create(100, TimeUnit.MILLISECONDS)), "testGetSnapshotTimeout");
+ Arrays.asList("shard1"), "config",
null
, kit.getRef(), "shard-manager",
+
Finite
Duration.create(100, TimeUnit.MILLISECONDS)), "testGetSnapshotTimeout");
kit.watch(replyActor);
kit.watch(replyActor);