aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Villin <avillin@cisco.com>2024-06-26 09:47:10 +0200
committerFlorin Coras <florin.coras@gmail.com>2024-09-18 18:09:44 +0000
commit3ecd6840af4f890a11d26628ac34d31786b16758 (patch)
treec87d6a0407460efca5a13fd54afe1850ddbb6376
parent0950830ee9fff7ce62145cab64ed76605487e647 (diff)
hs-test: containerize iperf tests
Type: test Change-Id: I2c0bb76d96ccadd5ecfd6a04565420855043699e Signed-off-by: Adrian Villin <avillin@cisco.com>
-rw-r--r--extras/hs-test/infra/suite_iperf_linux.go (renamed from extras/hs-test/infra/suite_tap.go)38
-rw-r--r--extras/hs-test/iperf_linux_test.go48
-rw-r--r--extras/hs-test/linux_iperf_test.go40
-rw-r--r--extras/hs-test/topo-containers/2containers.yaml4
4 files changed, 75 insertions, 55 deletions
diff --git a/extras/hs-test/infra/suite_tap.go b/extras/hs-test/infra/suite_iperf_linux.go
index c02ab8e8535..728429b505f 100644
--- a/extras/hs-test/infra/suite_tap.go
+++ b/extras/hs-test/infra/suite_iperf_linux.go
@@ -9,28 +9,36 @@ import (
. "github.com/onsi/ginkgo/v2"
)
-type TapSuite struct {
+type IperfSuite struct {
HstSuite
}
-var tapTests = map[string][]func(s *TapSuite){}
-var tapSoloTests = map[string][]func(s *TapSuite){}
+const (
+ ServerIperfContainerName string = "server"
+ ServerIperfInterfaceName string = "hstsrv"
+ ClientIperfContainerName string = "client"
+ ClientIperfInterfaceName string = "hstcln"
+)
+
+var iperfTests = map[string][]func(s *IperfSuite){}
+var iperfSoloTests = map[string][]func(s *IperfSuite){}
-func RegisterTapTests(tests ...func(s *TapSuite)) {
- tapTests[getTestFilename()] = tests
+func RegisterIperfTests(tests ...func(s *IperfSuite)) {
+ iperfTests[getTestFilename()] = tests
}
-func RegisterTapSoloTests(tests ...func(s *TapSuite)) {
- tapSoloTests[getTestFilename()] = tests
+func RegisterIperfSoloTests(tests ...func(s *IperfSuite)) {
+ iperfSoloTests[getTestFilename()] = tests
}
-func (s *TapSuite) SetupSuite() {
+func (s *IperfSuite) SetupSuite() {
time.Sleep(1 * time.Second)
s.HstSuite.SetupSuite()
- s.ConfigureNetworkTopology("tap")
+ s.ConfigureNetworkTopology("2taps")
+ s.LoadContainerTopology("2containers")
}
-var _ = Describe("TapSuite", Ordered, ContinueOnFailure, func() {
- var s TapSuite
+var _ = Describe("IperfSuite", Ordered, ContinueOnFailure, func() {
+ var s IperfSuite
BeforeAll(func() {
s.SetupSuite()
})
@@ -44,7 +52,7 @@ var _ = Describe("TapSuite", Ordered, ContinueOnFailure, func() {
s.TearDownTest()
})
- for filename, tests := range tapTests {
+ for filename, tests := range iperfTests {
for _, test := range tests {
test := test
pc := reflect.ValueOf(test).Pointer()
@@ -58,8 +66,8 @@ var _ = Describe("TapSuite", Ordered, ContinueOnFailure, func() {
}
})
-var _ = Describe("TapSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
- var s TapSuite
+var _ = Describe("IperfSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
+ var s IperfSuite
BeforeAll(func() {
s.SetupSuite()
})
@@ -73,7 +81,7 @@ var _ = Describe("TapSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
s.TearDownTest()
})
- for filename, tests := range tapSoloTests {
+ for filename, tests := range iperfSoloTests {
for _, test := range tests {
test := test
pc := reflect.ValueOf(test).Pointer()
diff --git a/extras/hs-test/iperf_linux_test.go b/extras/hs-test/iperf_linux_test.go
new file mode 100644
index 00000000000..14422fe5efa
--- /dev/null
+++ b/extras/hs-test/iperf_linux_test.go
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "fmt"
+
+ . "fd.io/hs-test/infra"
+ . "github.com/onsi/ginkgo/v2"
+)
+
+func init() {
+ RegisterIperfTests(IperfLinuxTest)
+}
+
+func IperfLinuxTest(s *IperfSuite) {
+ serverContainer := s.GetContainerByName(ServerIperfContainerName)
+ serverIpAddress := s.GetInterfaceByName(ServerIperfInterfaceName).Ip4AddressString()
+ clientContainer := s.GetContainerByName(ClientIperfContainerName)
+ clientIpAddress := s.GetInterfaceByName(ClientIperfInterfaceName).Ip4AddressString()
+
+ clnCh := make(chan error)
+ stopServerCh := make(chan struct{})
+ srvCh := make(chan error, 1)
+ clnRes := make(chan string, 1)
+
+ defer func() {
+ stopServerCh <- struct{}{}
+ }()
+
+ go func() {
+ defer GinkgoRecover()
+ cmd := "iperf3 -4 -s -B " + serverIpAddress + " -p " + s.GetPortFromPpid()
+ s.StartServerApp(serverContainer, "iperf3", cmd, srvCh, stopServerCh)
+ }()
+ err := <-srvCh
+ s.AssertNil(err, fmt.Sprint(err))
+ s.Log("server running")
+
+ go func() {
+ defer GinkgoRecover()
+ cmd := "iperf3 -c " + serverIpAddress + " -B " + clientIpAddress +
+ " -u -l 1460 -b 10g -p " + s.GetPortFromPpid()
+ s.StartClientApp(clientContainer, cmd, clnCh, clnRes)
+ }()
+
+ s.Log(<-clnRes)
+ err = <-clnCh
+ s.AssertNil(err, "err: '%s'", err)
+}
diff --git a/extras/hs-test/linux_iperf_test.go b/extras/hs-test/linux_iperf_test.go
deleted file mode 100644
index 9342e862f04..00000000000
--- a/extras/hs-test/linux_iperf_test.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package main
-
-import (
- . "fd.io/hs-test/infra"
- "fmt"
- . "github.com/onsi/ginkgo/v2"
-)
-
-func init() {
- RegisterTapTests(LinuxIperfTest)
-}
-
-func LinuxIperfTest(s *TapSuite) {
- clnCh := make(chan error)
- stopServerCh := make(chan struct{})
- srvCh := make(chan error, 1)
- clnRes := make(chan string, 1)
- defer func() {
- stopServerCh <- struct{}{}
- }()
-
- go func() {
- defer GinkgoRecover()
- s.StartIperfServerApp(srvCh, stopServerCh, nil)
- }()
- err := <-srvCh
- s.AssertNil(err, fmt.Sprint(err))
- s.Log("server running")
-
- ipAddress := s.GetInterfaceByName(TapInterfaceName).Ip4AddressString()
- go func() {
- defer GinkgoRecover()
- s.StartIperfClientApp(ipAddress, nil, clnCh, clnRes)
- }()
- s.Log("client running")
- s.Log(<-clnRes)
- err = <-clnCh
- s.AssertNil(err, "err: '%s', ip: '%s'", err, ipAddress)
- s.Log("Test completed")
-}
diff --git a/extras/hs-test/topo-containers/2containers.yaml b/extras/hs-test/topo-containers/2containers.yaml
new file mode 100644
index 00000000000..1217c27d3ed
--- /dev/null
+++ b/extras/hs-test/topo-containers/2containers.yaml
@@ -0,0 +1,4 @@
+---
+containers:
+ - name: "server"
+ - name: "client" \ No newline at end of file