Skip to content

Commit

Permalink
feat: adding latency/bandwidth configuration through .toml files
Browse files Browse the repository at this point in the history
This gives us more flexibility in test-case development
Related to Test-Plan #1
  • Loading branch information
Bidon15 committed Aug 30, 2022
1 parent a3172d7 commit 5c6ea34
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 8 deletions.
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"
persistent-peers = "10"

[[groups]]
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"
persistent-peers = "3"

[[groups]]
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,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}
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))
}
}
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

0 comments on commit 5c6ea34

Please sign in to comment.