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

Docker tests #22

Merged
merged 76 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
39beb63
Docker tests initial
vsuharnikov Oct 4, 2024
849e595
Fixes a logback blaming for multiple configs
vsuharnikov Oct 4, 2024
1ec30be
Test logs and summary in the directory
vsuharnikov Oct 4, 2024
14b296b
Fix
vsuharnikov Oct 4, 2024
a8082fa
- Build docker image in SBT;
vsuharnikov Oct 4, 2024
dca3962
Parallel run and forked tests
vsuharnikov Oct 4, 2024
b5f140f
Merge remote-tracking branch 'github/main' into docker-tests
vsuharnikov Oct 21, 2024
e062302
Fixed exposing ports, less logs
vsuharnikov Oct 21, 2024
1756c86
Setup network
vsuharnikov Oct 21, 2024
77d552f
- RewardTestSuite does all required checks;
vsuharnikov Oct 23, 2024
74a4c97
Run integration tests separately
vsuharnikov Oct 23, 2024
7a5bb4e
Merge github/main
vsuharnikov Oct 23, 2024
dd0c652
Run integration tests on GitHub, save logs
vsuharnikov Oct 23, 2024
48ca5fd
Generate genesis using a provided dependency
vsuharnikov Oct 24, 2024
8af4ac5
Merge github/main
vsuharnikov Oct 24, 2024
c82ec1f
Migration to new configs: unit tests
vsuharnikov Oct 24, 2024
589d218
Migration to new configs: docker tests
vsuharnikov Oct 24, 2024
c253e07
Migration to new configs: local-network
vsuharnikov Oct 25, 2024
dfc14fe
Moving the network setup to a base class
vsuharnikov Oct 25, 2024
2e6bb88
Added ElBridgeClient, moving classes
vsuharnikov Oct 28, 2024
c1b7b78
WIP L2-379, logs
vsuharnikov Oct 28, 2024
5e16a31
Node number in logs
vsuharnikov Oct 28, 2024
724e339
OneNodeTestSuite
vsuharnikov Oct 28, 2024
ed49d7f
Logging improvements
vsuharnikov Oct 29, 2024
8fc8c32
Docker network cleanup, connecting EC nodes together
vsuharnikov Oct 29, 2024
6c36762
updateGenesis task
vsuharnikov Oct 30, 2024
c9eb84c
Generate genesis each test task run
vsuharnikov Oct 30, 2024
0b7e497
BridgeTestSuite WIP
vsuharnikov Oct 30, 2024
8f316e5
Stuck cleanup on GitHub
vsuharnikov Oct 30, 2024
1f103a9
Fixes
vsuharnikov Oct 31, 2024
2131a80
Generate waves genesis block for each test suite to have a stable min…
vsuharnikov Oct 31, 2024
bee0913
L2-379 checks
vsuharnikov Oct 31, 2024
3588126
L2-380 WIP
vsuharnikov Oct 31, 2024
29e7ec2
L2-380
vsuharnikov Oct 31, 2024
4ba3b8a
BridgeContract
vsuharnikov Nov 1, 2024
32c2ec1
L2-264 Integration test
vsuharnikov Nov 1, 2024
1294c0c
L2-325
vsuharnikov Nov 1, 2024
6cb30e0
Logging test names, test updates
vsuharnikov Nov 2, 2024
e8e9541
Test updates
vsuharnikov Nov 2, 2024
c1868a2
- New genesis template: first node has multiple miners;
vsuharnikov Nov 2, 2024
b653882
Test fixes
vsuharnikov Nov 5, 2024
05ab1aa
SyncingTestSuite
vsuharnikov Nov 5, 2024
c38d27c
Fix
vsuharnikov Nov 5, 2024
6091958
Fix (2)
vsuharnikov Nov 5, 2024
7cdaa71
L2-383
vsuharnikov Nov 6, 2024
7fa3c38
README
vsuharnikov Nov 7, 2024
3ad3d47
Parallel docker tests
vsuharnikov Nov 7, 2024
aa36240
README: where is logs
vsuharnikov Nov 7, 2024
f713aeb
Merge 'github/main'
vsuharnikov Nov 8, 2024
72de16f
Fixes
vsuharnikov Nov 8, 2024
9055d7f
Fixes: removed excess code
vsuharnikov Nov 8, 2024
3b9b229
Fixes: moving files
vsuharnikov Nov 8, 2024
2776740
Fixes: removed excess files
vsuharnikov Nov 8, 2024
6d10175
Cleanup
vsuharnikov Nov 8, 2024
a692b69
Fix docker image build for tests
vsuharnikov Nov 8, 2024
2dc311a
HttpEngineApiClient: added timeouts
vsuharnikov Nov 11, 2024
8c51129
- Logging retries of requests to Engine API;
vsuharnikov Nov 11, 2024
825949c
SBT: docker command uses cache to avoid requesting the base image (so…
vsuharnikov Nov 11, 2024
d825d9e
EcContainer: increased a log level
vsuharnikov Nov 12, 2024
4b4ae86
Fixed unit tests
vsuharnikov Nov 12, 2024
1229157
Choose an execution client in tests
vsuharnikov Nov 14, 2024
69b5306
Stabilized AlternativeChainTestSuite
vsuharnikov Nov 14, 2024
d4fc5fb
Moved generateWavesGenesisConfig
vsuharnikov Nov 15, 2024
fa6b513
Accounts cleanup
vsuharnikov Nov 15, 2024
ac93d2e
AlternativeChainTestSuite fix
vsuharnikov Nov 15, 2024
6486b23
AlternativeChainTestSuite fix (2)
vsuharnikov Nov 15, 2024
462da10
eventually
vsuharnikov Nov 15, 2024
f69efd4
Removed HasRetry
vsuharnikov Nov 18, 2024
10fadf8
Fixed AlternativeChainTestSuite
vsuharnikov Nov 18, 2024
593f99b
Logging method calls
vsuharnikov Nov 18, 2024
2eb0819
Logging result, HTTP logs in a separate file
vsuharnikov Nov 18, 2024
df021a3
Cleanup
vsuharnikov Nov 18, 2024
af04887
AlternativeChainTestSuite fix
vsuharnikov Nov 18, 2024
aeb09aa
Cleanup
vsuharnikov Nov 19, 2024
109317f
Cleanup
vsuharnikov Nov 19, 2024
5817862
Cleanup (2)
vsuharnikov Nov 20, 2024
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
26 changes: 24 additions & 2 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,34 @@ jobs:
check-pr:
name: Check PR
runs-on: ubuntu-latest
env:
JAVA_OPTS: -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
SBT_IT_TEST_THREADS: 2
services:
docker:
image: docker:latest
options: --privileged # Required for Docker-in-Docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 2375:2375
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'sbt'
- name: Check PR
run: sbt --batch "compile;test"
- uses: sbt/setup-sbt@v1
- name: Run tests
run: |
sbt --batch "test;docker;consensus-client-it/test"
- name: Archive logs
uses: actions/upload-artifact@v4
if: always()
with:
name: test-logs_${{ env.BRANCH_NAME }}_${{ github.run_id }}
path: consensus-client-it/target/test-logs
if-no-files-found: warn
retention-days: 14
3 changes: 3 additions & 0 deletions .gitignore
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
Expand Down
20 changes: 20 additions & 0 deletions README.md
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`.
70 changes: 48 additions & 22 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
Global / onChangedBuildSource := ReloadOnSourceChanges
import com.github.sbt.git.SbtGit.GitKeys.gitCurrentBranch

enablePlugins(UniversalDeployPlugin, GitVersioning)
enablePlugins(UniversalDeployPlugin, GitVersioning, sbtdocker.DockerPlugin)

git.useGitDescribe := true
git.baseVersion := "1.0.0"
git.uncommittedSignifier := Some("DIRTY")

scalaVersion := "2.13.15"
organization := "network.units"
organizationName := "Units Network"
name := "consensus-client"
maintainer := "Units Network Team"
resolvers ++= Resolver.sonatypeOssRepos("releases") ++ Resolver.sonatypeOssRepos("snapshots") ++ Seq(Resolver.mavenLocal)
inScope(Global)(
Seq(
onChangedBuildSource := ReloadOnSourceChanges,
scalaVersion := "2.13.15",
organization := "network.units",
organizationName := "Units Network",
resolvers ++= Resolver.sonatypeOssRepos("releases") ++ Resolver.sonatypeOssRepos("snapshots") ++ Seq(Resolver.mavenLocal),
scalacOptions ++= Seq(
"-Xsource:3",
"-feature",
"-deprecation",
"-unchecked",
"-language:higherKinds",
"-language:implicitConversions",
"-language:postfixOps",
"-Ywarn-unused:-implicits",
"-Xlint"
)
)
)

name := "consensus-client"
maintainer := "Units Network Team"

libraryDependencies ++= Seq(
"com.wavesplatform" % "node-testkit" % "1.5.8" % "test",
"com.wavesplatform" % "node" % "1.5.8" % "provided",
"com.wavesplatform" % "node-testkit" % "1.5.8" % Test,
"com.wavesplatform" % "node" % "1.5.8" % Provided,
"com.softwaremill.sttp.client3" % "core_2.13" % "3.10.1",
"com.softwaremill.sttp.client3" %% "play-json" % "3.10.1",
"com.github.jwt-scala" %% "jwt-play-json" % "10.0.1"
)

scalacOptions ++= Seq(
"-Xsource:3",
"-feature",
"-deprecation",
"-unchecked",
"-language:higherKinds",
"-language:implicitConversions",
"-language:postfixOps",
"-Ywarn-unused:-implicits",
"-Xlint"
)

Compile / packageDoc / publishArtifact := false

def makeJarName(
Expand Down Expand Up @@ -81,3 +87,23 @@ buildTarballsForDocker := {
baseDirectory.value / "docker" / "target" / "consensus-client.tgz"
)
}

inTask(docker)(
Seq(
imageNames := Seq(
ImageName(s"consensus-client:${gitCurrentBranch.value}"), // Integration tests
ImageName("consensus-client:local") // local-network
),
dockerfile := NativeDockerfile(baseDirectory.value / "docker" / "Dockerfile"),
buildOptions := BuildOptions(cache = true)
)
)

docker := docker.dependsOn(LocalRootProject / buildTarballsForDocker).value

lazy val `consensus-client` = project.in(file("."))

lazy val `consensus-client-it` = project
.dependsOn(
`consensus-client` % "compile;test->test"
)
67 changes: 67 additions & 0 deletions consensus-client-it/build.sbt
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
)
)
)
}
}
)
)
Loading