11import com .github .sbt .git .SbtGit .git .gitCurrentBranch
2+ import com .spotify .docker .client .DefaultDockerClient
23import org .web3j .codegen .SolidityFunctionWrapperGenerator
34import org .web3j .tx .Contract
45import play .api .libs .json .Json
@@ -8,11 +9,13 @@ import java.io.FileInputStream
89import java .time .LocalDateTime
910import java .time .format .DateTimeFormatter
1011import scala .sys .process .*
12+ import scala .sys .props
13+ import scala .util .control .NonFatal
1114
1215description := " Consensus client integration tests"
1316
1417libraryDependencies ++= Seq (
15- " org.testcontainers" % " testcontainers" % " 1.20.4 " ,
18+ " org.testcontainers" % " testcontainers" % " 2.0.1 " ,
1619 " org.web3j" % " core" % " 4.9.8"
1720).map(_ % Test )
1821
@@ -57,11 +60,29 @@ Test / sourceGenerators += Def.task {
5760
5861val logsDirectory = taskKey[File ](" The directory for logs" ) // Task to evaluate and recreate the logs directory every time
5962
60- Global / concurrentRestrictions := {
61- val threadNumber = Option (System .getenv(" SBT_IT_TEST_THREADS" )).fold(1 )(_.toInt)
62- Seq (Tags .limit(Tags .ForkedTestGroup , threadNumber))
63- }
63+ Global / concurrentRestrictions := Seq (
64+ Tags .limit(
65+ Tags .ForkedTestGroup ,
66+ Option (Integer .getInteger(" cc.it.max-parallel-suites" ))
67+ .getOrElse[Integer ] {
68+ try {
69+ val docker = DefaultDockerClient .fromEnv().build()
70+ try {
71+ val dockerCpu : Int = docker.info().cpus()
72+ sLog.value.info(s " Docker CPU count: $dockerCpu" )
73+ dockerCpu * 2
74+ } finally docker.close()
75+ } catch {
76+ case NonFatal (_) =>
77+ sLog.value.warn(s " Could not connect to Docker, is the daemon running? " )
78+ sLog.value.info(s " System CPU count: ${EvaluateTask .SystemProcessors }" )
79+ EvaluateTask .SystemProcessors
80+ }
81+ }
82+ )
83+ )
6484
85+ val LogbackTestLevel = " logback.test.level"
6586inConfig(Test )(
6687 Seq (
6788 logsDirectory := {
@@ -74,7 +95,8 @@ inConfig(Test)(
7495 s " -Dlogback.configurationFile= ${(Test / resourceDirectory).value}/logback-test.xml " , // Fixes a logback blaming for multiple configs
7596 s " -Dcc.it.configs.dir= ${baseDirectory.value.getParent}/local-network/configs " ,
7697 s " -Dcc.it.docker.image=consensus-client: ${gitCurrentBranch.value}" ,
77- s " -Dcc.it.contracts.dir= ${baseDirectory.value / " .." / " contracts" / " eth" }"
98+ s " -Dcc.it.contracts.dir= ${baseDirectory.value / " .." / " contracts" / " eth" }" ,
99+ s " -D $LogbackTestLevel= ${props.getOrElse(LogbackTestLevel , " TRACE" )}"
78100 ),
79101 testOptions += Tests .Argument (TestFrameworks .ScalaTest , " -fFWD" , ((Test / logsDirectory).value / " summary.log" ).toString),
80102 fork := true ,
0 commit comments