forked from crypto-org-chain/cronos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: Integrate testground to run benchmark on cluster (crypto-org…
…-chain#1627) * Problem: Integrate testground to run benchmark on cluster * resolve * align release * Apply suggestions from code review
- Loading branch information
Showing
29 changed files
with
3,811 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ lib | ||
, stdenv | ||
, callPackage | ||
, buildPackages | ||
, runCommand | ||
, bundle-exe | ||
, rev ? "dirty" | ||
}: | ||
let | ||
# make-tarball don't follow symbolic links to avoid duplicate file, the bundle should have no external references. | ||
# reset the ownership and permissions to make the extract result more normal. | ||
make-tarball = drv: runCommand "tarball-${drv.name}" | ||
{ | ||
nativeBuildInputs = with buildPackages; [ gnutar gzip ]; | ||
} '' | ||
tar cfv - -C "${drv}" \ | ||
--owner=0 --group=0 --mode=u+rw,uga+r --hard-dereference . \ | ||
| gzip -9 > $out | ||
''; | ||
bundle-win-exe = drv: callPackage ./bundle-win-exe.nix { cronosd = drv; }; | ||
matrix = lib.cartesianProductOfSets { | ||
network = [ "mainnet" "testnet" ]; | ||
pkgtype = [ | ||
"nix" # normal nix package | ||
"bundle" # relocatable bundled package | ||
"tarball" # tarball of the bundle, for distribution and checksum | ||
]; | ||
}; | ||
in | ||
builtins.listToAttrs (builtins.map | ||
({ network, pkgtype }: { | ||
name = builtins.concatStringsSep "-" ( | ||
[ "cronosd" ] ++ | ||
lib.optional (network != "mainnet") network ++ | ||
lib.optional (pkgtype != "nix") pkgtype | ||
); | ||
value = | ||
let | ||
cronosd = callPackage ../. { | ||
inherit rev network; | ||
}; | ||
bundle = | ||
if stdenv.hostPlatform.isWindows then | ||
bundle-win-exe cronosd | ||
else | ||
bundle-exe cronosd; | ||
in | ||
if pkgtype == "bundle" then | ||
bundle | ||
else if pkgtype == "tarball" then | ||
make-tarball bundle | ||
else | ||
cronosd; | ||
}) | ||
matrix | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ dockerTools, runCommandLocal, cronos-matrix, benchmark-testcase }: | ||
let | ||
tmpDir = runCommandLocal "tmp" { } '' | ||
mkdir -p $out/tmp/ | ||
''; | ||
in | ||
dockerTools.buildLayeredImage { | ||
name = "cronos-testground"; | ||
created = "now"; | ||
contents = [ | ||
benchmark-testcase | ||
cronos-matrix.cronosd | ||
tmpDir | ||
]; | ||
config = { | ||
Expose = [ 9090 26657 26656 1317 26658 26660 26659 30000 ]; | ||
Cmd = [ "/bin/stateless-testcase" ]; | ||
Env = [ | ||
"PYTHONUNBUFFERED=1" | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Testground | ||
|
||
The implementation is inspired by [testground](https://github.com/testground/testground), but we did a lot of simplifications to make it easier to deploy: | ||
|
||
- No centralized sync service, each node are assigned an unique continuous integer identifier, and node's hostname can be derived from that, that's how nodes discover each other and build the network. | ||
- Don't support networking configuration, but we might implement it in the future. | ||
|
||
## 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: | ||
|
||
```bash | ||
$ nix build .#testground-image | ||
# for apple silicon mac: nix build .#legacyPackages.aarch64-linux.testground-image | ||
# for x86 mac: nix build .#legacyPackages.x86_64-linux.testground-image | ||
$ docker load < ./result | ||
Loaded image: cronos-testground:<imageID> | ||
$ docker tag cronos-testground:<imageID> ghcr.io/crypto-org-chain/cronos-testground:latest | ||
``` | ||
|
||
Or one liner like this: | ||
|
||
```bash | ||
docker load < $(nix build .#legacyPackages.aarch64-linux.testground-image --no-link --print-out-paths) \ | ||
| grep "^Loaded image:" \ | ||
| cut -d ' ' -f 3 \ | ||
| xargs -I{} docker tag {} ghcr.io/crypto-org-chain/cronos-testground:latest | ||
``` | ||
## Generate data files locally | ||
You need to have the `cronosd` in `PATH`. | ||
```bash | ||
nix run .#stateless-testcase -- gen /tmp/data/out \ | ||
--validator-generate-load \ | ||
--validators 3 \ | ||
--fullnodes 0 \ | ||
--num-accounts 800 \ | ||
--num-txs 20 \ | ||
--app-patch '{"mempool": {"max-txs": -1}}' \ | ||
--config-patch '{"mempool": {"size": 100000}}' \ | ||
--tx-type erc20-transfer \ | ||
--genesis-patch '{"consensus_params": {"block": {"max_gas": "263000000"}}}' | ||
``` | ||
* `validators`/`fullnodes` is the number of validators/full nodes. | ||
* `num_accounts` is the number of test accounts for each full node. | ||
* `num_txs` is the number of test transactions to be sent for each test account. | ||
* `config`/`app` is the config patch for config/app.toml. | ||
* `genesis` is the patch for genesis.json. | ||
## Embed the data directory | ||
Embed the data directory into the image, it produce a new image: | ||
```bash | ||
$ nix run github:crypto-org-chain/cronos#stateless-testcase patchimage cronos-testground:latest /tmp/data/out | ||
``` | ||
## Run With Docker Compose | ||
```bash | ||
$ mkdir /tmp/outputs | ||
$ jsonnet -S testground/benchmark/compositions/docker-compose.jsonnet \ | ||
--ext-str outputs=/tmp/colima \ | ||
--ext-code nodes=3 \ | ||
| docker-compose -f /dev/stdin up --remove-orphans --force-recreate | ||
``` | ||
It'll collect the node data files to the `/tmp/outputs` directory. | ||
## Run In Cluster | ||
Please use [cronos-testground](https://github.com/crypto-org-chain/cronos-testground) to run the benchmark in k8s cluster. |
Empty file.
Oops, something went wrong.