fix serialization of delta ops, #22604
This commit is contained in:
parent
45f4727625
commit
cc7065601a
8 changed files with 54 additions and 24 deletions
|
|
@ -17,6 +17,7 @@ import akka.testkit.TestKit
|
|||
import akka.cluster.UniqueAddress
|
||||
import akka.remote.RARP
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import akka.actor.Props
|
||||
|
||||
class ReplicatedDataSerializerSpec extends TestKit(ActorSystem(
|
||||
"ReplicatedDataSerializerSpec",
|
||||
|
|
@ -24,6 +25,11 @@ class ReplicatedDataSerializerSpec extends TestKit(ActorSystem(
|
|||
akka.actor.provider=cluster
|
||||
akka.remote.netty.tcp.port=0
|
||||
akka.remote.artery.canonical.port = 0
|
||||
akka.actor {
|
||||
serialize-messages = off
|
||||
serialize-creators = off
|
||||
allow-java-serialization = off
|
||||
}
|
||||
"""))) with WordSpecLike with Matchers with BeforeAndAfterAll {
|
||||
|
||||
val serializer = new ReplicatedDataSerializer(system.asInstanceOf[ExtendedActorSystem])
|
||||
|
|
@ -34,6 +40,10 @@ class ReplicatedDataSerializerSpec extends TestKit(ActorSystem(
|
|||
val address2 = UniqueAddress(Address(Protocol, system.name, "other.host.org", 4711), 2L)
|
||||
val address3 = UniqueAddress(Address(Protocol, system.name, "some.host.org", 4712), 3L)
|
||||
|
||||
val ref1 = system.actorOf(Props.empty, "ref1")
|
||||
val ref2 = system.actorOf(Props.empty, "ref2")
|
||||
val ref3 = system.actorOf(Props.empty, "ref3")
|
||||
|
||||
override def afterAll {
|
||||
shutdown()
|
||||
}
|
||||
|
|
@ -71,14 +81,14 @@ class ReplicatedDataSerializerSpec extends TestKit(ActorSystem(
|
|||
checkSerialization(GSet() + "a" + "b")
|
||||
|
||||
checkSerialization(GSet() + 1 + 2 + 3)
|
||||
checkSerialization(GSet() + address1 + address2)
|
||||
checkSerialization(GSet() + ref1 + ref2)
|
||||
|
||||
checkSerialization(GSet() + 1L + "2" + 3 + address1)
|
||||
checkSerialization(GSet() + 1L + "2" + 3 + ref1)
|
||||
|
||||
checkSameContent(GSet() + "a" + "b", GSet() + "a" + "b")
|
||||
checkSameContent(GSet() + "a" + "b", GSet() + "b" + "a")
|
||||
checkSameContent(GSet() + address1 + address2 + address3, GSet() + address2 + address1 + address3)
|
||||
checkSameContent(GSet() + address1 + address2 + address3, GSet() + address3 + address2 + address1)
|
||||
checkSameContent(GSet() + ref1 + ref2 + ref3, GSet() + ref2 + ref1 + ref3)
|
||||
checkSameContent(GSet() + ref1 + ref2 + ref3, GSet() + ref3 + ref2 + ref1)
|
||||
}
|
||||
|
||||
"serialize ORSet" in {
|
||||
|
|
@ -89,7 +99,7 @@ class ReplicatedDataSerializerSpec extends TestKit(ActorSystem(
|
|||
checkSerialization(ORSet().add(address1, "a").add(address2, "b").remove(address1, "a"))
|
||||
checkSerialization(ORSet().add(address1, 1).add(address2, 2))
|
||||
checkSerialization(ORSet().add(address1, 1L).add(address2, 2L))
|
||||
checkSerialization(ORSet().add(address1, "a").add(address2, 2).add(address3, 3L).add(address3, address3))
|
||||
checkSerialization(ORSet().add(address1, "a").add(address2, 2).add(address3, 3L).add(address3, ref3))
|
||||
|
||||
val s1 = ORSet().add(address1, "a").add(address2, "b")
|
||||
val s2 = ORSet().add(address2, "b").add(address1, "a")
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import com.typesafe.config.ConfigFactory
|
|||
import akka.cluster.ddata.DurableStore.DurableDataEnvelope
|
||||
import akka.cluster.ddata.GCounter
|
||||
import akka.cluster.ddata.VersionVector
|
||||
import akka.cluster.ddata.ORSet
|
||||
import akka.cluster.ddata.ORMultiMap
|
||||
|
||||
class ReplicatorMessageSerializerSpec extends TestKit(ActorSystem(
|
||||
"ReplicatorMessageSerializerSpec",
|
||||
|
|
@ -33,6 +35,11 @@ class ReplicatorMessageSerializerSpec extends TestKit(ActorSystem(
|
|||
akka.actor.provider=cluster
|
||||
akka.remote.netty.tcp.port=0
|
||||
akka.remote.artery.canonical.port = 0
|
||||
akka.actor {
|
||||
serialize-messages = off
|
||||
serialize-creators = off
|
||||
allow-java-serialization = off
|
||||
}
|
||||
"""))) with WordSpecLike with Matchers with BeforeAndAfterAll {
|
||||
|
||||
val serializer = new ReplicatorMessageSerializer(system.asInstanceOf[ExtendedActorSystem])
|
||||
|
|
@ -61,8 +68,10 @@ class ReplicatorMessageSerializerSpec extends TestKit(ActorSystem(
|
|||
"serialize Replicator messages" in {
|
||||
val ref1 = system.actorOf(Props.empty, "ref1")
|
||||
val data1 = GSet.empty[String] + "a"
|
||||
val delta1 = GCounter.empty.increment(address1, 17).increment(address2, 2)
|
||||
val delta2 = delta1.increment(address2, 1)
|
||||
val delta1 = GCounter.empty.increment(address1, 17).increment(address2, 2).delta.get
|
||||
val delta2 = delta1.increment(address2, 1).delta.get
|
||||
val delta3 = ORSet.empty[String].add(address1, "a").delta.get
|
||||
val delta4 = ORMultiMap.empty[String, String].addBinding(address1, "a", "b").delta.get
|
||||
|
||||
checkSerialization(Get(keyA, ReadLocal))
|
||||
checkSerialization(Get(keyA, ReadMajority(2.seconds), Some("x")))
|
||||
|
|
@ -92,7 +101,9 @@ class ReplicatorMessageSerializerSpec extends TestKit(ActorSystem(
|
|||
"B" → DataEnvelope(GSet() + "b" + "c")), sendBack = true))
|
||||
checkSerialization(DeltaPropagation(address1, reply = true, Map(
|
||||
"A" → Delta(DataEnvelope(delta1), 1L, 1L),
|
||||
"B" → Delta(DataEnvelope(delta2), 3L, 5L))))
|
||||
"B" → Delta(DataEnvelope(delta2), 3L, 5L),
|
||||
"C" → Delta(DataEnvelope(delta3), 1L, 1L),
|
||||
"DC" → Delta(DataEnvelope(delta4), 1L, 1L))))
|
||||
|
||||
checkSerialization(new DurableDataEnvelope(data1))
|
||||
val pruning = Map(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue