Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more tests and fix JUnit time conversion #2

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more tests
  • Loading branch information
reibitto committed Mar 20, 2024
commit bcb64dcc774f21d82bb41146ca07e265206839f5
16 changes: 16 additions & 0 deletions src/test/scala/sbttestshards/ShardingAlgorithmSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ class ShardingAlgorithmSpec extends ScalaCheckSuite {
}
}

property("only choose shard if initialDuration indicates node started early") {
forAll { (tests: List[SpecInfo]) =>
val initialDurations = Map(0 -> Duration.ofMinutes(-1000))
val algo = ShardingAlgorithm.Balance(tests, ShardingInfo(3, initialDurations))

val bucketMap = algo.distributeEvenly.toSeq.groupBy(_._2).map { case (k, v) =>
k -> v.map(_._1.timeTaken).reduceOption(_.plus(_)).getOrElse(Duration.ZERO)
}

if (tests.isEmpty)
bucketMap.isEmpty
else
bucketMap.keys.toSeq == Seq(0)
}
}

property("not choose shard if initialDuration exceeds the available time") {
forAll { (tests: List[SpecInfo]) =>
val initialDurations = Map(0 -> Duration.ofMinutes(1000))
Expand Down