2022-12-21 08:59:16 +01:00
|
|
|
package main
|
|
|
|
|
2024-03-14 11:42:55 -04:00
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"runtime"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
|
|
)
|
|
|
|
|
2023-02-07 20:40:27 +01:00
|
|
|
const (
|
2024-03-14 11:42:55 -04:00
|
|
|
singleTopoContainerVpp = "vpp"
|
|
|
|
singleTopoContainerNginx = "nginx"
|
|
|
|
tapInterfaceName = "htaphost"
|
2023-02-07 20:40:27 +01:00
|
|
|
)
|
|
|
|
|
2024-03-14 11:42:55 -04:00
|
|
|
var noTopoTests = []func(s *NoTopoSuite){}
|
|
|
|
var noTopoSoloTests = []func(s *NoTopoSuite){}
|
|
|
|
|
2022-12-21 08:59:16 +01:00
|
|
|
type NoTopoSuite struct {
|
|
|
|
HstSuite
|
|
|
|
}
|
|
|
|
|
2024-03-14 11:42:55 -04:00
|
|
|
func registerNoTopoTests(tests ...func(s *NoTopoSuite)) {
|
|
|
|
noTopoTests = append(noTopoTests, tests...)
|
|
|
|
}
|
|
|
|
func registerNoTopoSoloTests(tests ...func(s *NoTopoSuite)) {
|
|
|
|
noTopoSoloTests = append(noTopoSoloTests, tests...)
|
|
|
|
}
|
|
|
|
|
2022-12-21 08:59:16 +01:00
|
|
|
func (s *NoTopoSuite) SetupSuite() {
|
2023-04-28 10:29:47 +02:00
|
|
|
s.HstSuite.SetupSuite()
|
2023-02-23 13:19:15 +01:00
|
|
|
s.loadNetworkTopology("tap")
|
|
|
|
s.loadContainerTopology("single")
|
2023-02-07 20:40:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *NoTopoSuite) SetupTest() {
|
2023-04-28 10:29:47 +02:00
|
|
|
s.HstSuite.SetupTest()
|
2023-02-07 20:40:27 +01:00
|
|
|
|
|
|
|
// Setup test conditions
|
2023-04-28 10:29:47 +02:00
|
|
|
var sessionConfig Stanza
|
|
|
|
sessionConfig.
|
2023-02-28 16:55:01 +01:00
|
|
|
newStanza("session").
|
|
|
|
append("enable").
|
|
|
|
append("use-app-socket-api").close()
|
2023-02-07 20:40:27 +01:00
|
|
|
|
|
|
|
container := s.getContainerByName(singleTopoContainerVpp)
|
2024-05-27 09:52:59 -04:00
|
|
|
vpp, _ := container.newVppInstance(container.allocatedCpus, sessionConfig)
|
2024-01-11 17:17:33 +01:00
|
|
|
s.assertNil(vpp.start())
|
2023-02-07 20:40:27 +01:00
|
|
|
|
2024-02-13 06:00:02 -05:00
|
|
|
tapInterface := s.getInterfaceByName(tapInterfaceName)
|
2023-02-07 20:40:27 +01:00
|
|
|
|
2024-01-11 17:17:33 +01:00
|
|
|
s.assertNil(vpp.createTap(tapInterface), "failed to create tap interface")
|
2022-12-21 08:59:16 +01:00
|
|
|
}
|
2024-03-14 11:42:55 -04:00
|
|
|
|
|
|
|
var _ = Describe("NoTopoSuite", Ordered, ContinueOnFailure, func() {
|
|
|
|
var s NoTopoSuite
|
|
|
|
BeforeAll(func() {
|
|
|
|
s.SetupSuite()
|
|
|
|
})
|
|
|
|
BeforeEach(func() {
|
|
|
|
s.SetupTest()
|
|
|
|
})
|
|
|
|
AfterAll(func() {
|
|
|
|
s.TearDownSuite()
|
|
|
|
})
|
|
|
|
AfterEach(func() {
|
|
|
|
s.TearDownTest()
|
|
|
|
})
|
|
|
|
|
|
|
|
for _, test := range noTopoTests {
|
|
|
|
test := test
|
|
|
|
pc := reflect.ValueOf(test).Pointer()
|
|
|
|
funcValue := runtime.FuncForPC(pc)
|
2024-05-06 06:55:34 -04:00
|
|
|
testName := strings.Split(funcValue.Name(), ".")[2]
|
|
|
|
It(testName, func(ctx SpecContext) {
|
|
|
|
s.log(testName + ": BEGIN")
|
2024-03-14 11:42:55 -04:00
|
|
|
test(&s)
|
2024-05-30 06:10:59 -04:00
|
|
|
}, SpecTimeout(suiteTimeout))
|
2024-03-14 11:42:55 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var _ = Describe("NoTopoSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
|
|
|
|
var s NoTopoSuite
|
|
|
|
BeforeAll(func() {
|
|
|
|
s.SetupSuite()
|
|
|
|
})
|
|
|
|
BeforeEach(func() {
|
|
|
|
s.SetupTest()
|
|
|
|
})
|
|
|
|
AfterAll(func() {
|
|
|
|
s.TearDownSuite()
|
|
|
|
})
|
|
|
|
AfterEach(func() {
|
|
|
|
s.TearDownTest()
|
|
|
|
})
|
|
|
|
|
|
|
|
for _, test := range noTopoSoloTests {
|
|
|
|
test := test
|
|
|
|
pc := reflect.ValueOf(test).Pointer()
|
|
|
|
funcValue := runtime.FuncForPC(pc)
|
2024-05-06 06:55:34 -04:00
|
|
|
testName := strings.Split(funcValue.Name(), ".")[2]
|
|
|
|
It(testName, Label("SOLO"), func(ctx SpecContext) {
|
|
|
|
s.log(testName + ": BEGIN")
|
2024-03-14 11:42:55 -04:00
|
|
|
test(&s)
|
2024-05-30 06:10:59 -04:00
|
|
|
}, SpecTimeout(suiteTimeout))
|
2024-03-14 11:42:55 -04:00
|
|
|
}
|
|
|
|
})
|