Files
vpp/extras/hs-test/infra/suite_iperf_linux.go
Adrian Villin af5fcbfa71 hs-test: replaced container/interface getter func
- replaced s.GetContainerByName("xyz") with s.Containers.Xyz in tests
  and suites
- same thing for interfaces
- each suite has its own structs with containers/interfaces
- structs are initialized in SetupSuite

Type: test

Change-Id: I5bd99605b40921b7b8c844e8650f6fb0915e9e99
Signed-off-by: Adrian Villin <avillin@cisco.com>
2024-12-11 17:47:04 +00:00

102 lines
2.2 KiB
Go

package hst
import (
"reflect"
"runtime"
"strings"
"time"
. "github.com/onsi/ginkgo/v2"
)
type IperfSuite struct {
HstSuite
Interfaces struct {
Server *NetInterface
Client *NetInterface
}
Containers struct {
Server *Container
Client *Container
}
}
var iperfTests = map[string][]func(s *IperfSuite){}
var iperfSoloTests = map[string][]func(s *IperfSuite){}
func RegisterIperfTests(tests ...func(s *IperfSuite)) {
iperfTests[getTestFilename()] = tests
}
func RegisterIperfSoloTests(tests ...func(s *IperfSuite)) {
iperfSoloTests[getTestFilename()] = tests
}
func (s *IperfSuite) SetupSuite() {
time.Sleep(1 * time.Second)
s.HstSuite.SetupSuite()
s.ConfigureNetworkTopology("2taps")
s.LoadContainerTopology("2containers")
s.Interfaces.Client = s.GetInterfaceByName("hstcln")
s.Interfaces.Server = s.GetInterfaceByName("hstsrv")
s.Containers.Server = s.GetContainerByName("server")
s.Containers.Client = s.GetContainerByName("client")
}
var _ = Describe("IperfSuite", Ordered, ContinueOnFailure, func() {
var s IperfSuite
BeforeAll(func() {
s.SetupSuite()
})
BeforeEach(func() {
s.SetupTest()
})
AfterAll(func() {
s.TearDownSuite()
})
AfterEach(func() {
s.TearDownTest()
})
for filename, tests := range iperfTests {
for _, test := range tests {
test := test
pc := reflect.ValueOf(test).Pointer()
funcValue := runtime.FuncForPC(pc)
testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2]
It(testName, func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
}, SpecTimeout(TestTimeout))
}
}
})
var _ = Describe("IperfSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
var s IperfSuite
BeforeAll(func() {
s.SetupSuite()
})
BeforeEach(func() {
s.SetupTest()
})
AfterAll(func() {
s.TearDownSuite()
})
AfterEach(func() {
s.TearDownTest()
})
for filename, tests := range iperfSoloTests {
for _, test := range tests {
test := test
pc := reflect.ValueOf(test).Pointer()
funcValue := runtime.FuncForPC(pc)
testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2]
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.Log(testName + ": BEGIN")
test(&s)
}, SpecTimeout(TestTimeout))
}
}
})