Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding latency/bandwidth configuration through .toml files #57

Merged
merged 5 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compositions/cluster-k8s/gen-validators.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
disable_metrics = false

[global.run.test_params]
latency = "0"
bandwidth = "320Mib"
validator = "80"
persistent-peers = "10"

Expand Down
2 changes: 2 additions & 0 deletions compositions/cluster-k8s/node-sync-15.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
disable_metrics = false

[global.run.test_params]
latency = "0"
bandwidth = "320Mib"
validator = "3"
persistent-peers = "3"
bridge = "4"
Expand Down
2 changes: 2 additions & 0 deletions compositions/local-docker/gen-validators.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
disable_metrics = false

[global.run.test_params]
latency = "0"
bandwidth = "320Mib"
validator = "3"
persistent-peers = "3"

Expand Down
2 changes: 2 additions & 0 deletions compositions/local-docker/node-sync.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
disable_metrics = false

[global.run.test_params]
latency = "0"
bandwidth = "320Mib"
validator = "3"
persistent-peers = "3"
bridge = "3"
Expand Down
4 changes: 4 additions & 0 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ 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}

[[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}
Expand Down
1 change: 1 addition & 0 deletions testkit/appkit/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
Expand Down
4 changes: 3 additions & 1 deletion tests/app-sync/run_seeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion tests/app-sync/run_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion tests/common/doc.go
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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(...)
*/
Expand Down
18 changes: 18 additions & 0 deletions tests/common/network.go
Original file line number Diff line number Diff line change
@@ -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))
}
}
1 change: 1 addition & 0 deletions tests/common/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion tests/node-sync/run_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion tests/node-sync/run_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions tests/node-sync/run_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion tests/node-sync/run_light.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down