Skip to content

Commit

Permalink
Dockerize testbed runner
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Richardson <[email protected]>
  • Loading branch information
awrichar committed Aug 15, 2024
1 parent e5862a0 commit 2f0f624
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 23 deletions.
42 changes: 27 additions & 15 deletions domains/noto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*/

ext {
testProcess = null

goFiles = fileTree(".") {
include "internal/**/*.go"
}
Expand Down Expand Up @@ -44,19 +42,18 @@ task copySolidity(type: Copy) {
includeEmptyDirs = false
}

task startTestbed {
doFirst {
project.ext.testProcess = new ProcessBuilder()
.directory(project(':kata').projectDir)
.command("go", "run", "./testbed", "${projectDir}/testbed.config.yaml")
.start()
}
task startTestbed(type: DockerCompose) {
composeFile '../../testinfra/docker-compose-test.yml'
composeFile 'docker-compose-test.yml'
args '-p', 'paladin-noto'
args 'up', '-d', '--build'
}

task stopTestbed {
doFirst {
project.ext.testProcess.destroy()
}
task stopTestbed(type: DockerCompose) {
composeFile '../../testinfra/docker-compose-test.yml'
composeFile 'docker-compose-test.yml'
args '-p', 'paladin-noto'
args 'down'
}

task test(type: Exec) {
Expand All @@ -75,7 +72,22 @@ task test(type: Exec) {

dependsOn copySolidity
dependsOn startTestbed
finalizedBy stopTestbed

ignoreExitValue true

doLast {
ExecResult execResult = executionResult.get()
if (execResult.exitValue != 0) {
startTestbed.dumpLogs("testbed")
}
execResult.assertNormalExitValue()
}
}

task build {
dependsOn test
}

task build(dependsOn: test) {}
task clean {
dependsOn stopTestbed
}
24 changes: 24 additions & 0 deletions domains/noto/docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Extensions to ../testinfra/docker-compose-test.yml
services:
postgres:
ports: !reset []
expose:
- 5432
besu:
ports: !reset []
expose:
- 8545
- 8546
testbed:
build:
context: ../kata
dockerfile: testbed/Dockerfile
command: testbed.config.yaml
depends_on:
besu:
condition: service_healthy
volumes:
- ../domains/noto/testbed.config.yaml:/usr/src/app/testbed.config.yaml
ports:
- 49600:49600
- 49601:49601
4 changes: 2 additions & 2 deletions domains/noto/internal/noto/e2e_noto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
// TODO: fix things that should not be hard-coded
var (
toDomain = "to-domain"
testbedAddr = "http://127.0.0.1:49603"
grpcAddr = "unix:/tmp/testbed.paladin.1542386773.sock"
testbedAddr = "http://127.0.0.1:49600"
grpcAddr = "dns:localhost:49601"
account1 = "0x9180ff8fa5c502b9bfe5dfeaf477e157dbfaba5c"
)

Expand Down
8 changes: 5 additions & 3 deletions domains/noto/testbed.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ db:
migrationsDir: './db/migrations/sqlite'
rpcServer:
http:
port: 49603
address: 0.0.0.0
port: 49600
ws:
disabled: true
blockchain:
ws:
url: ws://localhost:8546
url: ws://besu:8546
initialConnectAttempts: 25
bus:
grpc:
socketAddress: /tmp/testbed.paladin.1542386773.sock
socketProtocol: tcp
socketAddress: ":49601"
signer:
keyDerivation:
type: "bip32"
Expand Down
11 changes: 11 additions & 0 deletions kata/testbed/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.22

WORKDIR /usr/src/app

ENV CGO_ENABLED 1

COPY go.mod go.sum /usr/src/app/
COPY . /usr/src/app
RUN go build -o /usr/local/bin/testbed ./testbed

ENTRYPOINT [ "/usr/local/bin/testbed" ]
2 changes: 2 additions & 0 deletions testinfra/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ task besuBootstrapTool(type: Exec) {

task startTestInfra(type: DockerCompose, dependsOn: tasks.besuBootstrapTool) {
composeFile 'docker-compose-test.yml'
args '-p', 'paladin-testinfra'
args 'up', '-d'
}

task stopTestInfra(type: DockerCompose) {
composeFile 'docker-compose-test.yml'
args '-p', 'paladin-testinfra'
args 'down'
}

Expand Down
4 changes: 1 addition & 3 deletions testinfra/docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
services:
postgres:
container_name: paladin-test-db
image: postgres
ports:
- 5432:5432
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: my-secret
besu_bootstrap:
container_name: paladin-besu-bootstrap
image: paladin/besu_bootstrap
user: 0:0
volumes:
- besu_data:/var/besu:rw
command:
- /var/besu
besu:
container_name: paladin-test-besu
image: hyperledger/besu:latest
user: 0:0
volumes:
Expand Down Expand Up @@ -46,6 +43,7 @@ services:
- --data-path=/var/besu/data
- --node-private-key-file=/var/besu/key
- --revert-reason-enabled
- --host-allowlist=localhost,besu
volumes:
besu_data:
driver: local

0 comments on commit 2f0f624

Please sign in to comment.