Skip to content

Commit

Permalink
Problem: use prebuilt image in testground (#1480)
Browse files Browse the repository at this point in the history
* Problem: use prebuilt image in testground

Solution:
- build image manually, don't use testground builders at all.
- update doc.

* update doc

* Update testground/README.md

Signed-off-by: yihuang <[email protected]>

* Update testground/benchmark/manifest.toml

Signed-off-by: yihuang <[email protected]>

* Update testground/README.md

Signed-off-by: yihuang <[email protected]>

* cleanup

---------

Signed-off-by: yihuang <[email protected]>
  • Loading branch information
yihuang authored Jun 21, 2024
1 parent 903b590 commit 3a0e503
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
23 changes: 15 additions & 8 deletions testground/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# Guide

[Testground documentation](https://docs.testground.ai/)

## Getting started
## Build Image

> Prerequisites: nix, for macOS also need [linux remote builder](https://nix.dev/manual/nix/2.22/advanced-topics/distributed-builds.html)
You can test with the prebuilt images in [github registry](https://github.com/crypto-org-chain/cronos/pkgs/container/cronos-testground), or build the image locally:

### Prerequisites
```bash
$ nix build .#testground-image
# for mac: nix build .#legacyPackages.aarch64-linux.testground-image
$ docker load < ./result
Loaded image: cronos-testground:<imageID>
$ docker tag cronos-testground:<imageID> ghcr.io/crypto-org-chain/cronos-testground:latest
```

- docker
- go 1.22, or higher
## Run Test

### Install Testground

Expand All @@ -20,15 +27,15 @@ $ make install

It'll install the `testground` binary in your `$GOPATH/bin` directory, and build several docker images.

### Running Testground
### Run Testground Daemon

```bash
$ TESTGROUND_HOME=$PWD/data testground daemon
```

Keep the daemon process running during the test.

### Running Test Plan
### Run Test Plan

Import the test plan before the first run:

Expand Down
13 changes: 10 additions & 3 deletions testground/benchmark/benchmark/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ def __init__(self, cmd):
def raw(self, *args, stdin=None, stderr=subprocess.STDOUT, **kwargs):
"execute the command"
args = " ".join(build_cli_args_safe(*args, **kwargs))
return interact(
stdout = interact(
f"{self.cmd} {args}", input=stdin, stderr=stderr, env=os.environ
)

# filter out "<jemalloc>:" warning messages
stdout = b"\n".join(
line for line in stdout.splitlines() if not line.startswith(b"<jemalloc>:")
)

return stdout

def __call__(self, *args, **kwargs):
"execute the command and clean the output"
return self.raw(*args, **kwargs).decode().strip()


def interact(cmd, ignore_error=False, input=None, **kwargs):
kwargs.setdefault("stderr", subprocess.STDOUT)
def interact(cmd, ignore_error=False, input=None, stderr=subprocess.STDOUT, **kwargs):
proc = subprocess.Popen(
cmd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=stderr,
shell=True,
**kwargs,
)
Expand Down
8 changes: 5 additions & 3 deletions testground/benchmark/compositions/local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ author = "core-app"
plan = "benchmark"
case = "entrypoint"
total_instances = 10
builder = "docker:nix"
builder = "docker:go" # not used
runner = "local:docker"
disable_metrics = false

Expand All @@ -16,12 +16,14 @@ halt_height = "5"

[[groups]]
id = "validators"
builder = "docker:nix"
[groups.instances]
count = 3
[groups.run]
artifact = "ghcr.io/crypto-org-chain/cronos-testground:latest"

[[groups]]
id = "fullnodes"
builder = "docker:nix"
[groups.instances]
count = 7
[groups.run]
artifact = "ghcr.io/crypto-org-chain/cronos-testground:latest"
5 changes: 1 addition & 4 deletions testground/benchmark/manifest.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name = "benchmark"

[defaults]
builder = "docker:nix"
builder = "docker:go"
runner = "local:docker"

[builders."docker:nix"]
enabled = true

[runners."local:docker"]
enabled = true

Expand Down

0 comments on commit 3a0e503

Please sign in to comment.