blob: 728429b505f77cf216436473685d71529ceb7abc [file] [log] [blame]
Adrian Villin3ecd6842024-06-26 09:47:10 +02001package hst
2
3import (
4 "reflect"
5 "runtime"
6 "strings"
7 "time"
8
9 . "github.com/onsi/ginkgo/v2"
10)
11
12type IperfSuite struct {
13 HstSuite
14}
15
16const (
17 ServerIperfContainerName string = "server"
18 ServerIperfInterfaceName string = "hstsrv"
19 ClientIperfContainerName string = "client"
20 ClientIperfInterfaceName string = "hstcln"
21)
22
23var iperfTests = map[string][]func(s *IperfSuite){}
24var iperfSoloTests = map[string][]func(s *IperfSuite){}
25
26func RegisterIperfTests(tests ...func(s *IperfSuite)) {
27 iperfTests[getTestFilename()] = tests
28}
29func RegisterIperfSoloTests(tests ...func(s *IperfSuite)) {
30 iperfSoloTests[getTestFilename()] = tests
31}
32
33func (s *IperfSuite) SetupSuite() {
34 time.Sleep(1 * time.Second)
35 s.HstSuite.SetupSuite()
36 s.ConfigureNetworkTopology("2taps")
37 s.LoadContainerTopology("2containers")
38}
39
40var _ = Describe("IperfSuite", Ordered, ContinueOnFailure, func() {
41 var s IperfSuite
42 BeforeAll(func() {
43 s.SetupSuite()
44 })
45 BeforeEach(func() {
46 s.SetupTest()
47 })
48 AfterAll(func() {
49 s.TearDownSuite()
50 })
51 AfterEach(func() {
52 s.TearDownTest()
53 })
54
55 for filename, tests := range iperfTests {
56 for _, test := range tests {
57 test := test
58 pc := reflect.ValueOf(test).Pointer()
59 funcValue := runtime.FuncForPC(pc)
60 testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2]
61 It(testName, func(ctx SpecContext) {
62 s.Log(testName + ": BEGIN")
63 test(&s)
64 }, SpecTimeout(SuiteTimeout))
65 }
66 }
67})
68
69var _ = Describe("IperfSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
70 var s IperfSuite
71 BeforeAll(func() {
72 s.SetupSuite()
73 })
74 BeforeEach(func() {
75 s.SetupTest()
76 })
77 AfterAll(func() {
78 s.TearDownSuite()
79 })
80 AfterEach(func() {
81 s.TearDownTest()
82 })
83
84 for filename, tests := range iperfSoloTests {
85 for _, test := range tests {
86 test := test
87 pc := reflect.ValueOf(test).Pointer()
88 funcValue := runtime.FuncForPC(pc)
89 testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2]
90 It(testName, Label("SOLO"), func(ctx SpecContext) {
91 s.Log(testName + ": BEGIN")
92 test(&s)
93 }, SpecTimeout(SuiteTimeout))
94 }
95 }
96})