Skip to content

Commit

Permalink
add property tests for GenPaxos
Browse files Browse the repository at this point in the history
  • Loading branch information
haaase committed Oct 28, 2024
1 parent 3bcb5e8 commit 1a84a05
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Modules/RDTs/.jvm/src/test/scala/GeneralizedPaxosSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import rdts.datatypes.experiments.protocols.simplified.GeneralizedPaxos

class GeneralizedPaxosSuite extends munit.ScalaCheckSuite {

// override def scalaCheckInitialSeed = "ZcBq5Oa3t8-hWG0Snkx22h6nivxFRCvp27NO4tFKzbN="

override def scalaCheckTestParameters =
super.scalaCheckTestParameters
.withMinSuccessfulTests(200)
.withMinSize(60)
.withMaxSize(200)

property("Generalized Paxos")(ConsensusPropertySpec[Int, GeneralizedPaxos](
logging = false,
minDevices = 3,
maxDevices = 7,
writeFreq = 20,
upkeepFreq = 70,
mergeFreq = 70
).property())
}
25 changes: 24 additions & 1 deletion Modules/RDTs/.jvm/src/test/scala/MembershipSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.Prop.propBoolean
import org.scalacheck.{Arbitrary, Gen, Prop}
import rdts.base.{Bottom, Lattice, LocalUid, Uid}
import rdts.datatypes.experiments.protocols.simplified.GeneralizedPaxos
import rdts.datatypes.experiments.protocols.{Consensus, LogHack, Membership, simplified}

import scala.util.Try
Expand All @@ -24,6 +25,28 @@ class MembershipSuite extends munit.ScalaCheckSuite {
addMemberFreq = 1,
removeMemberFreq = 1
).property())

property("Membership with generalized paxos")(MembershipSpec[Int, GeneralizedPaxos, GeneralizedPaxos](
logging = false,
minDevices = 3,
maxDevices = 6,
mergeFreq = 80,
upkeepFreq = 70,
writeFreq = 20,
addMemberFreq = 1,
removeMemberFreq = 1
).property())

property("Membership with two different algos")(MembershipSpec[Int, simplified.Paxos, GeneralizedPaxos](
logging = false,
minDevices = 3,
maxDevices = 6,
mergeFreq = 80,
upkeepFreq = 70,
writeFreq = 20,
addMemberFreq = 1,
removeMemberFreq = 1
).property())
}

class MembershipSpec[A: Arbitrary, C[_]: Consensus, D[_]: Consensus](
Expand Down Expand Up @@ -59,7 +82,7 @@ class MembershipSpec[A: Arbitrary, C[_]: Consensus, D[_]: Consensus](
value <- arbitrary[A]
yield Write(id, value)

def genUpkeep(state: State): Gen[Upkeep] = genId(state).map(Upkeep(_))
def genUpkeep(state: State): Gen[Upkeep] = genId(state).map(Upkeep)

def genAddMember(state: State): Gen[AddMember] =
for
Expand Down

0 comments on commit 1a84a05

Please sign in to comment.