Skip to content

Commit

Permalink
Adjustments to build and stress test timings
Browse files Browse the repository at this point in the history
* Correct sonatype entries in build.sbt

* Change timings in stress test
---------

Co-authored-by: Jonas Chapuis <jonas.chapuis@zf.com>
  • Loading branch information
jchapuis and Jonas Chapuis committed Feb 29, 2024
1 parent c1841b2 commit 740242d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ jobs:
with:
jvm: temurin:17
apps: sbt
- run: sbt scalafmtCheckAll compile coverage +test example/multi-jvm:test coverageReport coverageAggregate versionPolicyCheck documentation/makeSite
- uses: catchpoint/workflow-telemetry-action@v2
- run: sbt scalafmtCheckAll compile coverage +test "repeat 3 example/multi-jvm:test" coverageReport coverageAggregate versionPolicyCheck documentation/makeSite
- uses: codecov/codecov-action@v2.1.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5 changes: 2 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ val commonSettings = Seq(
inThisBuild(
List(
organization := "io.github.endless4s",
homepage := Some(url("https://github.com/endless4s/endless")),
homepage := Some(url("https://github.com/endless4s/endless-transaction")),
licenses := List("MIT License" -> url("http://opensource.org/licenses/mit-license.php")),
developers := List(
Developer(
Expand All @@ -46,7 +46,7 @@ inThisBuild(
),
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeProjectHosting := Some(
xerial.sbt.Sonatype.GitHubHosting("endless4s", "endless", "me@jonaschapuis.com")
xerial.sbt.Sonatype.GitHubHosting("endless4s", "endless-transaction", "me@jonaschapuis.com")
),
Global / onChangedBuildSource := ReloadOnSourceChanges,
PB.protocVersion := "3.17.3", // works on Apple Silicon,
Expand Down Expand Up @@ -105,7 +105,6 @@ lazy val example = (project in file("example"))
(munit ++ `munit-cats-effect-3` ++ `scalacheck-effect-munit` ++ `log4cats-testing` ++ `cats-scalacheck` ++ `cats-effect-testkit` ++ scalatest ++
Seq(postgresql, `pekko-persistence-jdbc`) ++ slick).map(_ % Test)
)
.settings(scalaVersion := scala213)
.settings(crossScalaVersions := Nil)
.enablePlugins(MultiJvmPlugin)
.configs(MultiJvm)
Expand Down
2 changes: 1 addition & 1 deletion example/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</encoder>
</appender>

<logger name="endless.transaction.example.app.AccountsApp" level="WARN"/>
<logger name="endless.transaction.example.app.pekko.PekkoAccountsApp" level="WARN"/>
<logger name="endless.transaction.example" level="INFO"/>
<logger name="org.apache.pekko" level="INFO"/>
<logger name="com.zaxxer.hikari" level="WARN"/>
Expand Down
1 change: 1 addition & 0 deletions example/src/main/resources/pekko.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pekko {
]
sharding {
remember-entities-store = eventsourced
waiting-for-state-timeout = 10s
}
}
}
12 changes: 0 additions & 12 deletions example/src/multi-jvm/resources/logback.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ class StressSuiteMultiJvmNode1 extends AnyFunSuite {
accountsCount,
originAmount - transferAmount
),
IO.sleep(testTimeout)
IO.sleep(testTimeout) >> logger.info("Test timed out")
)
.toResource
- <- logger
.info("Waiting just a bit more to ensure cluster is stable to allow all nodes to succeed")
.toResource
_ <- IO.sleep(atLeastOneNodeUpWaitingTime).toResource
_ <- logger.info("Shutting down").toResource
} yield assert(
Expand Down Expand Up @@ -124,10 +127,10 @@ object Common {

val dbInitializationWaitingTime = 2.seconds
val clusterFormationWaitingTime = 2.seconds
val atLeastOneNodeUpWaitingTime = 2.minutes
val atLeastOneNodeUpWaitingTime = 5.minutes
val nodeRestartWaitingTime = 5.seconds
val minRestartDelaySeconds = 7
val maxRestartDelaySeconds = 15
val minRestartDelaySeconds = 8
val maxRestartDelaySeconds = 20
val testTimeout = atLeastOneNodeUpWaitingTime + 1.minute
val checkRetryTimeout = 5.seconds
val accountsCount = 1000
Expand Down Expand Up @@ -180,34 +183,34 @@ object Common {
_ <- IO.fromFuture(IO.blocking(SchemaUtils.createIfNotExists()))
} yield ()

def restartingPassiveNode(httpPort: Port, arteryPort: Port): IO[Unit] = {
lazy val restartingNode: IO[Unit] = for {
logger <- Slf4jLogger.create[IO]
checkSuccessful <- Ref.of[IO, Boolean](false)
random <- Random.scalaUtilRandom[IO]
restartPeriod <- random
.betweenInt(minRestartDelaySeconds, maxRestartDelaySeconds)
.map(_.seconds)
_ <- IO.race(
passiveNode(httpPort, arteryPort, checkSuccessful)
.handleErrorWith((error: Throwable) => logger.error(error)("Node hard fail").toResource)
.use_,
IO.sleep(restartPeriod)
)
_ <- checkSuccessful.get.flatMap {
case true => logger.info("Balance check successful, terminating...")
case false =>
logger.info("Restarting node...") >> IO.sleep(nodeRestartWaitingTime) >> restartingNode
}
} yield ()
IO.race(restartingNode, IO.sleep(testTimeout))
.map(assertion =>
assert(
assertion.fold(_ => true, _ => false),
"Timed out waiting for transfers to complete as expected"
def restartingPassiveNode(httpPort: Port, arteryPort: Port): IO[Unit] =
Slf4jLogger.create[IO].flatMap { logger =>
lazy val restartingNode: IO[Unit] = for {
checkSuccessful <- Ref.of[IO, Boolean](false)
random <- Random.scalaUtilRandom[IO]
restartPeriod <- random
.betweenInt(minRestartDelaySeconds, maxRestartDelaySeconds)
.map(_.seconds)
_ <- IO.race(
passiveNode(httpPort, arteryPort, checkSuccessful)
.handleErrorWith((error: Throwable) => logger.error(error)("Node hard fail").toResource)
.use_,
IO.sleep(restartPeriod)
)
)
}
_ <- checkSuccessful.get.flatMap {
case true => logger.info("Balance check successful, terminating...")
case false =>
logger.info("Restarting node...") >> IO.sleep(nodeRestartWaitingTime) >> restartingNode
}
} yield ()
IO.race(restartingNode, IO.sleep(testTimeout) >> logger.info("Test timed out"))
.map(assertion =>
assert(
assertion.fold(_ => true, _ => false),
"Timed out waiting for transfers to complete as expected"
)
)
}

private def passiveNode(
httpPort: Port,
Expand Down

0 comments on commit 740242d

Please sign in to comment.