From 22e1056f0d41297e52baee922e0780db293a29aa Mon Sep 17 00:00:00 2001 From: Jack-R-lantern Date: Tue, 18 Jul 2023 14:22:46 +0000 Subject: [PATCH 1/2] connectivity: add bandwidth-manager flag Adding BandWidthManager variable to Parameter structure. Added cmd.Flags().BoolVar for BandWidthManager Signed-off-by: Jack-R-lantern --- connectivity/check/check.go | 2 ++ internal/cli/cmd/connectivity.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/connectivity/check/check.go b/connectivity/check/check.go index fb9416c041..0481f0380f 100644 --- a/connectivity/check/check.go +++ b/connectivity/check/check.go @@ -47,6 +47,8 @@ type Parameters struct { PerfSamples int CurlImage string PerformanceImage string + // BandWidth + BandWidthManager bool JSONMockImage string AgentDaemonSetName string DNSTestServerImage string diff --git a/internal/cli/cmd/connectivity.go b/internal/cli/cmd/connectivity.go index 5fce612c3d..a3fffa34fe 100644 --- a/internal/cli/cmd/connectivity.go +++ b/internal/cli/cmd/connectivity.go @@ -158,6 +158,8 @@ func newCmdConnectivityTest(hooks Hooks) *cobra.Command { cmd.Flags().BoolVar(¶ms.PerfCRR, "perf-crr", false, "Run Netperf CRR Test. --perf-samples and --perf-duration ignored") cmd.Flags().BoolVar(¶ms.PerfHostNet, "host-net", false, "Use host networking during network performance tests") + cmd.Flags().BoolVar(¶ms.BandWidthManager, "bandwidth-manager", false, "Run bandwidth manager tests") + cmd.Flags().StringVar(¶ms.CurlImage, "curl-image", defaults.ConnectivityCheckAlpineCurlImage, "Image path to use for curl") cmd.Flags().StringVar(¶ms.PerformanceImage, "performance-image", defaults.ConnectivityPerformanceImage, "Image path to use for performance") cmd.Flags().StringVar(¶ms.JSONMockImage, "json-mock-image", defaults.ConnectivityCheckJSONMockImage, "Image path to use for json mock") From b5216ea93ac888b3702d8edebf45eb827ea313a1 Mon Sep 17 00:00:00 2001 From: Jack-R-lantern Date: Tue, 18 Jul 2023 14:31:04 +0000 Subject: [PATCH 2/2] connectivity: add bandwidth scenario this commit is temp commit about bandwidth scenario Signed-off-by: Jack-R-lantern --- connectivity/suite.go | 8 +++++++ connectivity/tests/bandwidth.go | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 connectivity/tests/bandwidth.go diff --git a/connectivity/suite.go b/connectivity/suite.go index a0ae2c63d5..a1744c67e3 100644 --- a/connectivity/suite.go +++ b/connectivity/suite.go @@ -206,6 +206,14 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, addExtraTests func(*ch return ct.Run(ctx) } + // BandWidth Manager Test + if ct.Params().BandWidthManager { + ct.NewTest("bandwidth-manager").WithScenarios( + tests.BandWidthManager(""), + ) + return ct.Run(ctx) + } + // Conn disrupt Test if ct.Params().IncludeConnDisruptTest { ct.NewTest("no-interrupted-connections").WithScenarios( diff --git a/connectivity/tests/bandwidth.go b/connectivity/tests/bandwidth.go new file mode 100644 index 0000000000..af2983cb72 --- /dev/null +++ b/connectivity/tests/bandwidth.go @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright Authors of Cilium + +package tests + +import ( + "context" + "fmt" + + "github.com/cilium/cilium-cli/connectivity/check" +) + +// BandWidth Manager +func BandWidthManager(n string) check.Scenario { + return &bandWidthManager{ + name: n, + } +} + +// bandWidthManager implements a Scenario. +type bandWidthManager struct { + name string +} + +func (b *bandWidthManager) Name() string { + tn := "bandwidth-manager" + if b.name == "" { + return tn + } + return fmt.Sprintf("%s:%s", tn, b.name) +} + +func (b *bandWidthManager) Run(ctx context.Context, t *check.Test) { + for _, c := range t.Context().PerfClientPods() { + c := c + for _, server := range t.Context().PerfServerPod() { + action := t.NewAction(b, "bandwidth", &c, server, check.IPFamilyV4) + action.Run(func(a *check.Action) {}) + } + } +}