diff --git a/compositions/cluster-k8s/gen-validators.toml b/compositions/cluster-k8s/gen-validators.toml index d33d0f83..0c79a965 100644 --- a/compositions/cluster-k8s/gen-validators.toml +++ b/compositions/cluster-k8s/gen-validators.toml @@ -11,6 +11,8 @@ disable_metrics = false [global.run.test_params] + latency = "0" + bandwidth = "320Mib" validator = "80" persistent-peers = "10" diff --git a/compositions/cluster-k8s/node-sync-15.toml b/compositions/cluster-k8s/node-sync-15.toml index 2c2e877b..f7380c69 100644 --- a/compositions/cluster-k8s/node-sync-15.toml +++ b/compositions/cluster-k8s/node-sync-15.toml @@ -11,6 +11,8 @@ disable_metrics = false [global.run.test_params] + latency = "0" + bandwidth = "320Mib" validator = "3" persistent-peers = "3" bridge = "4" diff --git a/compositions/local-docker/gen-validators.toml b/compositions/local-docker/gen-validators.toml index 2a603151..056a4e5c 100644 --- a/compositions/local-docker/gen-validators.toml +++ b/compositions/local-docker/gen-validators.toml @@ -11,6 +11,8 @@ disable_metrics = false [global.run.test_params] + latency = "0" + bandwidth = "320Mib" validator = "3" persistent-peers = "3" diff --git a/compositions/local-docker/node-sync.toml b/compositions/local-docker/node-sync.toml index 4e7e8639..7831c7e4 100644 --- a/compositions/local-docker/node-sync.toml +++ b/compositions/local-docker/node-sync.toml @@ -11,6 +11,8 @@ disable_metrics = false [global.run.test_params] + latency = "0" + bandwidth = "320Mib" validator = "3" persistent-peers = "3" bridge = "3" diff --git a/manifest.toml b/manifest.toml index 6cc6e595..1735f530 100644 --- a/manifest.toml +++ b/manifest.toml @@ -20,6 +20,8 @@ enabled = true name = "init-val" instances = { min = 1, max = 100, default = 3 } [testcases.params] + latency = { type = "int", default = 0} + bandwidth = { type = "string", default = "256Mib"} validator = { type = "int", default = 3} persistent-peers = { type = "int", default = 3} @@ -27,6 +29,8 @@ instances = { min = 1, max = 100, default = 3 } name = "node-sync" instances = { min = 4, max = 100, default = 12 } [testcases.params] + latency = { type = "int", default = 0} + bandwidth = { type = "string", default = "256Mib"} validator = { type = "int", default = 3} persistent-peers = { type = "int", default = 3} bridge = { type = "int", default = 3} diff --git a/testkit/appkit/app.go b/testkit/appkit/app.go index 0253abd5..43b9145f 100644 --- a/testkit/appkit/app.go +++ b/testkit/appkit/app.go @@ -73,6 +73,7 @@ func (ak *AppKit) GetHomePath() string { return ak.home } + func (ak *AppKit) InitChain(moniker string) (string, error) { return ak.execCmd([]string{"init", moniker, "--chain-id", ak.ChainId, "--home", ak.home}) } diff --git a/tests/app-sync/run_seeds.go b/tests/app-sync/run_seeds.go index bf2622a9..a56e74dd 100644 --- a/tests/app-sync/run_seeds.go +++ b/tests/app-sync/run_seeds.go @@ -9,6 +9,7 @@ import ( "github.com/celestiaorg/test-infra/testkit" "github.com/celestiaorg/test-infra/testkit/appkit" + "github.com/celestiaorg/test-infra/tests/common" "github.com/testground/sdk-go/network" "github.com/testground/sdk-go/run" @@ -31,7 +32,8 @@ func RunSeed(runenv *runtime.RunEnv, initCtx *run.InitContext) error { Network: "default", Enable: true, Default: network.LinkShape{ - Bandwidth: 4 << 26, // 256Mib + Latency: time.Duration(runenv.IntParam("latency")), + Bandwidth: common.GetBandwidthValue(runenv.StringParam("bandwidth")), }, CallbackState: "network-configured", RoutingPolicy: network.AllowAll, diff --git a/tests/app-sync/run_validator.go b/tests/app-sync/run_validator.go index a4baac99..dd18e333 100644 --- a/tests/app-sync/run_validator.go +++ b/tests/app-sync/run_validator.go @@ -26,7 +26,8 @@ func RunValidator(runenv *runtime.RunEnv, initCtx *run.InitContext) error { Network: "default", Enable: true, Default: network.LinkShape{ - Bandwidth: 5 << 26, // 320Mib + Latency: time.Duration(runenv.IntParam("latency")), + Bandwidth: common.GetBandwidthValue(runenv.StringParam("bandwidth")), }, CallbackState: "network-configured", RoutingPolicy: network.AllowAll, diff --git a/tests/common/doc.go b/tests/common/doc.go index 3fefe721..0d50e49f 100644 --- a/tests/common/doc.go +++ b/tests/common/doc.go @@ -1,5 +1,9 @@ /* -Package common is a helper around redundant creation of App or Node part +Package common is a helper around redundant creation of Network, App and Node part + +As testground doesn't have native support of uint64 conversion from .toml files, +GetBandwidthValue in network.go is used to adjust the bandwidth per instance +for each of the test-case In order to eliminate the boilerplate code of creating a validators' set, please use `common.BuildValidator`. This Func does: @@ -10,6 +14,10 @@ please use `common.BuildValidator`. This Func does: In addition, the func returns initialized cobra cmd, so you can continue operating with the validator +Default: network.LinkShape{ + Bandwidth: common.GetBandwidthValue(runenv.StringParam("bandwidth")), +} + appcmd, err := common.BuildValidator(ctx, runenv, initCtx) appcmd.PayForData(...) */ diff --git a/tests/common/network.go b/tests/common/network.go new file mode 100644 index 00000000..bc0be8bf --- /dev/null +++ b/tests/common/network.go @@ -0,0 +1,18 @@ +package common + +import "fmt" + +func GetBandwidthValue(v string) uint64 { + var bandwidthMap = map[string]uint64{ + "100Mib": 13 << 23, + "256Mib": 4 << 26, + "320Mib": 5 << 26, + "512Mib": 8 << 26, + "1024Mib": 16 << 26, + } + if val, ok := bandwidthMap[v]; ok { + return val + } else { + panic(fmt.Errorf("can't find any bandwidth value to given - %s", v)) + } +} diff --git a/tests/common/validator.go b/tests/common/validator.go index 5a9fd6a7..34bc9db1 100644 --- a/tests/common/validator.go +++ b/tests/common/validator.go @@ -24,6 +24,7 @@ func BuildValidator(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.In const chainId string = "tia-test" cmd := appkit.New(home, chainId) + keyringName := fmt.Sprintf("keyName-%d", initCtx.GlobalSeq) accAddr, err := cmd.CreateKey(keyringName, "test", home) if err != nil { diff --git a/tests/node-sync/run_app.go b/tests/node-sync/run_app.go index 5ceed9e8..94608eb7 100644 --- a/tests/node-sync/run_app.go +++ b/tests/node-sync/run_app.go @@ -24,7 +24,8 @@ func RunAppValidator(runenv *runtime.RunEnv, initCtx *run.InitContext) error { Network: "default", Enable: true, Default: network.LinkShape{ - Bandwidth: 5 << 26, // 320Mib + Latency: time.Duration(runenv.IntParam("latency")), + Bandwidth: common.GetBandwidthValue(runenv.StringParam("bandwidth")), }, CallbackState: "network-configured", RoutingPolicy: network.AllowAll, diff --git a/tests/node-sync/run_bridge.go b/tests/node-sync/run_bridge.go index f3cbc6c4..1f846ddc 100644 --- a/tests/node-sync/run_bridge.go +++ b/tests/node-sync/run_bridge.go @@ -9,6 +9,7 @@ import ( "github.com/celestiaorg/test-infra/testkit" "github.com/celestiaorg/test-infra/testkit/appkit" "github.com/celestiaorg/test-infra/testkit/nodekit" + "github.com/celestiaorg/test-infra/tests/common" "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/peer" "github.com/testground/sdk-go/network" @@ -35,7 +36,8 @@ func RunBridgeNode(runenv *runtime.RunEnv, initCtx *run.InitContext) error { Network: "default", Enable: true, Default: network.LinkShape{ - Bandwidth: 5 << 26, // 320Mib + Latency: time.Duration(runenv.IntParam("latency")), + Bandwidth: common.GetBandwidthValue(runenv.StringParam("bandwidth")), }, CallbackState: "network-configured", RoutingPolicy: network.AllowAll, diff --git a/tests/node-sync/run_full.go b/tests/node-sync/run_full.go index 6c7a20e4..f3b13170 100644 --- a/tests/node-sync/run_full.go +++ b/tests/node-sync/run_full.go @@ -8,6 +8,7 @@ import ( "github.com/celestiaorg/celestia-node/node" "github.com/celestiaorg/test-infra/testkit" "github.com/celestiaorg/test-infra/testkit/nodekit" + "github.com/celestiaorg/test-infra/tests/common" "github.com/testground/sdk-go/network" "github.com/testground/sdk-go/run" "github.com/testground/sdk-go/runtime" @@ -31,8 +32,8 @@ func RunFullNode(runenv *runtime.RunEnv, initCtx *run.InitContext) error { Network: "default", Enable: true, Default: network.LinkShape{ - // Latency: 100 * time.Millisecond, - Bandwidth: 5 << 26, // 320Mib + Latency: time.Duration(runenv.IntParam("latency")), + Bandwidth: common.GetBandwidthValue(runenv.StringParam("bandwidth")), }, CallbackState: "network-configured", RoutingPolicy: network.AllowAll, diff --git a/tests/node-sync/run_light.go b/tests/node-sync/run_light.go index b25ae816..0cf40794 100644 --- a/tests/node-sync/run_light.go +++ b/tests/node-sync/run_light.go @@ -8,6 +8,7 @@ import ( "github.com/celestiaorg/celestia-node/node" "github.com/celestiaorg/test-infra/testkit" "github.com/celestiaorg/test-infra/testkit/nodekit" + "github.com/celestiaorg/test-infra/tests/common" "github.com/testground/sdk-go/network" "github.com/testground/sdk-go/run" "github.com/testground/sdk-go/runtime" @@ -31,7 +32,8 @@ func RunLightNode(runenv *runtime.RunEnv, initCtx *run.InitContext) error { Network: "default", Enable: true, Default: network.LinkShape{ - Bandwidth: 5 << 26, // 320Mib + Latency: time.Duration(runenv.IntParam("latency")), + Bandwidth: common.GetBandwidthValue(runenv.StringParam("bandwidth")), }, CallbackState: "network-configured", RoutingPolicy: network.AllowAll,