-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
613d21a
commit e51a320
Showing
76 changed files
with
2,473 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
.DS_Store | ||
target | ||
.bloop | ||
.bsp | ||
.metals | ||
metals.sbt | ||
.idea | ||
docker/data | ||
docker/logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# consensus-client | ||
|
||
## 👨💻 Development | ||
|
||
1. Run unit tests: | ||
```bash | ||
sbt test | ||
``` | ||
|
||
2. Run integration tests: | ||
1. Build the Docker image: | ||
```bash | ||
sbt docker | ||
``` | ||
Note: Build the Docker image whenever the consensus client code is updated, including after pulling from the repository. | ||
2. Run the integration tests: | ||
```bash | ||
sbt "consensus-client-it/test" | ||
``` | ||
3. See logs in `consensus-client-it/target/test-logs`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import com.github.sbt.git.SbtGit.git.gitCurrentBranch | ||
import sbt.Tests.Group | ||
|
||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
description := "Consensus client integration tests" | ||
|
||
libraryDependencies ++= Seq( | ||
"org.testcontainers" % "testcontainers" % "1.20.3", | ||
"org.web3j" % "core" % "4.9.8" | ||
).map(_ % Test) | ||
|
||
val logsDirectory = taskKey[File]("The directory for logs") // Task to evaluate and recreate the logs directory every time | ||
|
||
Global / concurrentRestrictions := { | ||
val threadNumber = Option(System.getenv("SBT_IT_TEST_THREADS")).fold(1)(_.toInt) | ||
Seq(Tags.limit(Tags.ForkedTestGroup, threadNumber)) | ||
} | ||
|
||
inConfig(Test)( | ||
Seq( | ||
logsDirectory := { | ||
val runId: String = Option(System.getenv("RUN_ID")).getOrElse(DateTimeFormatter.ofPattern("MM-dd--HH_mm_ss").format(LocalDateTime.now)) | ||
val r = target.value / "test-logs" / runId | ||
r.mkdirs() | ||
r | ||
}, | ||
javaOptions ++= Seq( | ||
s"-Dlogback.configurationFile=${(Test / resourceDirectory).value}/logback-test.xml", // Fixes a logback blaming for multiple configs | ||
s"-Dcc.it.configs.dir=${baseDirectory.value.getParent}/local-network/configs", | ||
s"-Dcc.it.docker.image=consensus-client:${gitCurrentBranch.value}" | ||
), | ||
testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-fFWD", ((Test / logsDirectory).value / "summary.log").toString), | ||
fork := true, | ||
testForkedParallel := true, | ||
testGrouping := { | ||
val javaHomeVal = (test / javaHome).value | ||
val baseLogDirVal = (Test / logsDirectory).value | ||
val envVarsVal = (Test / envVars).value | ||
val javaOptionsVal = (Test / javaOptions).value | ||
|
||
val tests = (Test / definedTests).value | ||
|
||
tests.zipWithIndex.map { case (suite, i) => | ||
val suiteLogDir = baseLogDirVal / suite.name.replaceAll("""(\w)\w*\.""", "$1.") // foo.bar.Baz -> f.b.Baz | ||
Group( | ||
suite.name, | ||
Seq(suite), | ||
Tests.SubProcess( | ||
ForkOptions( | ||
javaHome = javaHomeVal, | ||
outputStrategy = (Test / outputStrategy).value, | ||
bootJars = Vector.empty[java.io.File], | ||
workingDirectory = Option((Test / baseDirectory).value), | ||
runJVMOptions = Vector( | ||
s"-Dcc.it.logs.dir=$suiteLogDir" | ||
) ++ javaOptionsVal, | ||
connectInput = false, | ||
envVars = envVarsVal | ||
) | ||
) | ||
) | ||
} | ||
} | ||
) | ||
) |
Oops, something went wrong.