1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
package main
import (
"fmt"
"reflect"
"runtime"
"strings"
. "github.com/onsi/ginkgo/v2"
)
// These correspond to names used in yaml config
const (
clientInterface = "hclnvpp"
serverInterface = "hsrvvpp"
)
var nsTests = []func(s *NsSuite){}
var nsSoloTests = []func(s *NsSuite){}
type NsSuite struct {
HstSuite
}
func registerNsTests(tests ...func(s *NsSuite)) {
nsTests = append(nsTests, tests...)
}
func registerNsSoloTests(tests ...func(s *NsSuite)) {
nsSoloTests = append(nsSoloTests, tests...)
}
func (s *NsSuite) SetupSuite() {
s.HstSuite.SetupSuite()
s.configureNetworkTopology("ns")
s.loadContainerTopology("ns")
}
func (s *NsSuite) SetupTest() {
s.HstSuite.SetupTest()
// Setup test conditions
var sessionConfig Stanza
sessionConfig.
newStanza("session").
append("enable").
append("use-app-socket-api").
append("evt_qs_memfd_seg").
append("event-queue-length 100000").close()
container := s.getContainerByName("vpp")
vpp, _ := container.newVppInstance(container.allocatedCpus, sessionConfig)
s.assertNil(vpp.start())
idx, err := vpp.createAfPacket(s.getInterfaceByName(serverInterface))
s.assertNil(err, fmt.Sprint(err))
s.assertNotEqual(0, idx)
idx, err = vpp.createAfPacket(s.getInterfaceByName(clientInterface))
s.assertNil(err, fmt.Sprint(err))
s.assertNotEqual(0, idx)
container.exec("chmod 777 -R %s", container.getContainerWorkDir())
}
var _ = Describe("NsSuite", Ordered, ContinueOnFailure, func() {
var s NsSuite
BeforeAll(func() {
s.SetupSuite()
})
BeforeEach(func() {
s.SetupTest()
})
AfterAll(func() {
s.TearDownSuite()
})
AfterEach(func() {
s.TearDownTest()
})
for _, test := range nsTests {
test := test
pc := reflect.ValueOf(test).Pointer()
funcValue := runtime.FuncForPC(pc)
testName := strings.Split(funcValue.Name(), ".")[2]
It(testName, func(ctx SpecContext) {
s.log(testName + ": BEGIN")
test(&s)
}, SpecTimeout(suiteTimeout))
}
})
var _ = Describe("NsSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
var s NsSuite
BeforeAll(func() {
s.SetupSuite()
})
BeforeEach(func() {
s.SetupTest()
})
AfterAll(func() {
s.TearDownSuite()
})
AfterEach(func() {
s.TearDownTest()
})
for _, test := range nsSoloTests {
test := test
pc := reflect.ValueOf(test).Pointer()
funcValue := runtime.FuncForPC(pc)
testName := strings.Split(funcValue.Name(), ".")[2]
It(testName, Label("SOLO"), func(ctx SpecContext) {
s.log(testName + ": BEGIN")
test(&s)
}, SpecTimeout(suiteTimeout))
}
})
|