diff --git a/compositions/cluster-k8s/gen-validators.toml b/compositions/cluster-k8s/gen-validators.toml index 627ef6bf..a1c61791 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" persistent-peers = "10" [[groups]] 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 e2c9d12f..d7aa2ecf 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" persistent-peers = "3" [[groups]] 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 e94f8cd7..4d3e607b 100644 --- a/manifest.toml +++ b/manifest.toml @@ -20,12 +20,16 @@ enabled = true name = "init-val" instances = { min = 1, max = 100, default = 3 } [testcases.params] + latency = { type = "int", default = 0} + bandwidth = { type = "string", default = "256Mib"} persistent-peers = { type = "int", default = 3} [[testcases]] 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/tests/app-sync/run_seeds.go b/tests/app-sync/run_seeds.go index f710215d..98272832 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 c6fa35fd..dcaf8a2b 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/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,