From 8625515bf1cd40dd28563f58917a0f5cf29a1c5f Mon Sep 17 00:00:00 2001 From: huangyi Date: Fri, 21 Jun 2024 10:54:22 +0800 Subject: [PATCH 1/6] Problem: use prebuilt image in testground Solution: - build image manually, don't use testground builders at all. - update doc. --- testground/README.md | 24 +++++++++++++------- testground/benchmark/benchmark/cli.py | 9 +++++++- testground/benchmark/compositions/local.toml | 7 +++--- testground/benchmark/manifest.toml | 5 +--- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/testground/README.md b/testground/README.md index c52b153efe..6bd1d3f9c2 100644 --- a/testground/README.md +++ b/testground/README.md @@ -1,13 +1,21 @@ -# Guide - [Testground documentation](https://docs.testground.ai/) -## Getting started +## Build Image + +> Prerequisites: nix, linux remote builder for macOS + +You can test with the prebuilt images in github registry, to build the images locally for yourself: + +```bash +$ nix build .#testground-image +# for mac: nix build .#legacyPackages.aarch64-linux.testground-image +$ docker load < ./result +Loaded image: cronos-testground: +``` -### Prerequisites +Then use the image `cronos-testground:` in the test directly. -- docker -- go 1.22, or higher +## Run Test ### Install Testground @@ -20,7 +28,7 @@ $ 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 @@ -28,7 +36,7 @@ $ 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: diff --git a/testground/benchmark/benchmark/cli.py b/testground/benchmark/benchmark/cli.py index a86912c0b1..6df142c18b 100644 --- a/testground/benchmark/benchmark/cli.py +++ b/testground/benchmark/benchmark/cli.py @@ -9,10 +9,17 @@ 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 ":" warning messages + stdout = b"\n".join( + line for line in stdout.splitlines() if not line.startswith(b":") + ) + + return stdout + def __call__(self, *args, **kwargs): "execute the command and clean the output" return self.raw(*args, **kwargs).decode().strip() diff --git a/testground/benchmark/compositions/local.toml b/testground/benchmark/compositions/local.toml index ba24473eb3..b6dc82d39b 100644 --- a/testground/benchmark/compositions/local.toml +++ b/testground/benchmark/compositions/local.toml @@ -6,7 +6,6 @@ author = "core-app" plan = "benchmark" case = "entrypoint" total_instances = 10 -builder = "docker:nix" runner = "local:docker" disable_metrics = false @@ -16,12 +15,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" diff --git a/testground/benchmark/manifest.toml b/testground/benchmark/manifest.toml index 9184c54e7c..0344741157 100644 --- a/testground/benchmark/manifest.toml +++ b/testground/benchmark/manifest.toml @@ -1,12 +1,9 @@ name = "benchmark" [defaults] -builder = "docker:nix" +builder = "local:docker" runner = "local:docker" -[builders."docker:nix"] -enabled = true - [runners."local:docker"] enabled = true From 8c4829ea4e28be2b433c90d491c76d4b36207fc6 Mon Sep 17 00:00:00 2001 From: huangyi Date: Fri, 21 Jun 2024 11:32:17 +0800 Subject: [PATCH 2/6] update doc --- testground/README.md | 3 +-- testground/benchmark/compositions/local.toml | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testground/README.md b/testground/README.md index 6bd1d3f9c2..e2571f9d88 100644 --- a/testground/README.md +++ b/testground/README.md @@ -11,10 +11,9 @@ $ nix build .#testground-image # for mac: nix build .#legacyPackages.aarch64-linux.testground-image $ docker load < ./result Loaded image: cronos-testground: +$ docker tag cronos-testground: ghcr.io/crypto-org-chain/cronos-testground:latest ``` -Then use the image `cronos-testground:` in the test directly. - ## Run Test ### Install Testground diff --git a/testground/benchmark/compositions/local.toml b/testground/benchmark/compositions/local.toml index b6dc82d39b..4d710e2955 100644 --- a/testground/benchmark/compositions/local.toml +++ b/testground/benchmark/compositions/local.toml @@ -6,6 +6,7 @@ author = "core-app" plan = "benchmark" case = "entrypoint" total_instances = 10 +builder = "docker:go" # not used runner = "local:docker" disable_metrics = false From 99e7b6182b85a84825d4c48f8a6517d7a5f69a71 Mon Sep 17 00:00:00 2001 From: yihuang Date: Fri, 21 Jun 2024 11:36:40 +0800 Subject: [PATCH 3/6] Update testground/README.md Signed-off-by: yihuang --- testground/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testground/README.md b/testground/README.md index e2571f9d88..f4dc897498 100644 --- a/testground/README.md +++ b/testground/README.md @@ -4,7 +4,7 @@ > Prerequisites: nix, linux remote builder for macOS -You can test with the prebuilt images in github registry, to build the images locally for yourself: +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: ```bash $ nix build .#testground-image From 91833e6fcb70b5ec1625e178a67ae65b8a524fc5 Mon Sep 17 00:00:00 2001 From: yihuang Date: Fri, 21 Jun 2024 11:38:23 +0800 Subject: [PATCH 4/6] Update testground/benchmark/manifest.toml Signed-off-by: yihuang --- testground/benchmark/manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testground/benchmark/manifest.toml b/testground/benchmark/manifest.toml index 0344741157..b9d3afbb0c 100644 --- a/testground/benchmark/manifest.toml +++ b/testground/benchmark/manifest.toml @@ -1,7 +1,7 @@ name = "benchmark" [defaults] -builder = "local:docker" +builder = "docker:go" runner = "local:docker" [runners."local:docker"] From 7c1bf5868b2150076082f069d8e881d1621e8388 Mon Sep 17 00:00:00 2001 From: yihuang Date: Fri, 21 Jun 2024 11:53:47 +0800 Subject: [PATCH 5/6] Update testground/README.md Signed-off-by: yihuang --- testground/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testground/README.md b/testground/README.md index f4dc897498..40018edbb1 100644 --- a/testground/README.md +++ b/testground/README.md @@ -2,7 +2,7 @@ ## Build Image -> Prerequisites: nix, linux remote builder for macOS +> 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: From 542c92e2282195b11d316c3a86472011f9ba136f Mon Sep 17 00:00:00 2001 From: huangyi Date: Fri, 21 Jun 2024 12:01:56 +0800 Subject: [PATCH 6/6] cleanup --- testground/benchmark/benchmark/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testground/benchmark/benchmark/cli.py b/testground/benchmark/benchmark/cli.py index 6df142c18b..6ceed40128 100644 --- a/testground/benchmark/benchmark/cli.py +++ b/testground/benchmark/benchmark/cli.py @@ -25,12 +25,12 @@ def __call__(self, *args, **kwargs): 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, )