Skip to content

Commit d56f52f

Browse files
authored
Merge pull request #216 from intel-go/gregory/testing
Fixed all tests to work correctly in current VM setup
2 parents 3e1814f + 10c619c commit d56f52f

File tree

5 files changed

+174
-78
lines changed

5 files changed

+174
-78
lines changed

test/framework/main/stability.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@
1313
},
1414
"tests": [
1515
{
16-
"name": "generate",
16+
"name": "generate1",
1717
"test-time": 60000000000,
1818
"test-type": "TestTypeScenario",
1919
"test-apps": [
2020
{
2121
"image-name": "nff-go-test-resend",
2222
"app-type": "TestAppGo",
2323
"exec-cmd": [
24-
"./testResend", "-testScenario=1", "-inport=1", "-outport=1"
24+
"./testResend", "-number=100000", "-testScenario=1", "-inport=1", "-outport=0"
2525
]
2626
},
2727
{
2828
"image-name": "nff-go-test-resend",
2929
"app-type": "TestAppGo",
3030
"exec-cmd": [
31-
"./testResend", "-testScenario=2", "-inport=0", "-outport=0"
31+
"./testResend", "-testScenario=2", "-inport=0", "-outport=1"
3232
]
3333
}
3434
]
@@ -42,7 +42,7 @@
4242
"image-name": "nff-go-test-merge",
4343
"app-type": "TestAppGo",
4444
"exec-cmd": [
45-
"./testMerge", "-testScenario=1", "-inport1=1", "-outport1=1", "-outport2=0"
45+
"./testMerge", "-speed=1000", "-number=10000", "-testScenario=1", "-inport1=0", "-outport1=1", "-outport2=0"
4646
]
4747
},
4848
{
@@ -63,14 +63,14 @@
6363
"image-name": "nff-go-test-split",
6464
"app-type": "TestAppGo",
6565
"exec-cmd": [
66-
"./testSplit", "-testScenario=1", "-inport1=1", "-outport1=0", "-inport2=0"
66+
"./testSplit", "-speed=1000", "-number=10000", "-testScenario=1", "-inport1=0", "-outport1=0", "-inport2=1"
6767
]
6868
},
6969
{
7070
"image-name": "nff-go-test-split",
7171
"app-type": "TestAppGo",
7272
"exec-cmd": [
73-
"./testSplit", "-testScenario=2", "-inport1=1", "-outport1=0", "-outport2=1"
73+
"./testSplit", "-testScenario=2", "-inport1=0", "-outport1=0", "-outport2=1"
7474
]
7575
}
7676
]
@@ -84,7 +84,7 @@
8484
"image-name": "nff-go-test-separate",
8585
"app-type": "TestAppGo",
8686
"exec-cmd": [
87-
"./testSeparate", "-testScenario=1", "-inport1=1", "-outport1=1", "-inport2=0"
87+
"./testSeparate", "-speed=1000", "-number=10000", "-testScenario=1", "-inport1=0", "-outport1=0", "-inport2=1"
8888
]
8989
},
9090
{
@@ -105,7 +105,7 @@
105105
"image-name": "nff-go-test-partition",
106106
"app-type": "TestAppGo",
107107
"exec-cmd": [
108-
"./testPartition", "-testScenario=1", "-inport1=1", "-outport1=1", "-inport2=0"
108+
"./testPartition", "-speed=1000", "-number=10000", "-testScenario=1", "-inport1=0", "-outport1=0", "-inport2=1"
109109
]
110110
},
111111
{
@@ -118,22 +118,22 @@
118118
]
119119
},
120120
{
121-
"name": "handle2",
121+
"name": "handle1",
122122
"test-time": 60000000000,
123123
"test-type": "TestTypeScenario",
124124
"test-apps": [
125125
{
126126
"image-name": "nff-go-test-handle",
127127
"app-type": "TestAppGo",
128128
"exec-cmd": [
129-
"./testHandle", "-testScenario=1", "-inport=1", "-outport=1"
129+
"./testHandle", "-speed=1000", "-number=10000", "-testScenario=1", "-inport=1", "-outport=0"
130130
]
131131
},
132132
{
133133
"image-name": "nff-go-test-handle",
134134
"app-type": "TestAppGo",
135135
"exec-cmd": [
136-
"./testHandle", "-testScenario=2", "-inport=0", "-outport=0"
136+
"./testHandle", "-testScenario=2", "-inport=0", "-outport=1"
137137
]
138138
}
139139
]
@@ -147,14 +147,14 @@
147147
"image-name": "nff-go-test-cksum",
148148
"app-type": "TestAppGo",
149149
"exec-cmd": [
150-
"./testCksum", "-testScenario=2", "-hwol", "-inport=1", "-outport=1"
150+
"./testCksum", "-testScenario=1", "-ipv4", "-tcp", "-number=10000", "-inport=0", "-outport=1"
151151
]
152152
},
153153
{
154154
"image-name": "nff-go-test-cksum",
155155
"app-type": "TestAppGo",
156156
"exec-cmd": [
157-
"./testCksum", "-testScenario=1", "-ipv4", "-tcp", "-number=10000", "-inport=0", "-outport=0"
157+
"./testCksum", "-testScenario=2", "-hwol", "-inport=1", "-outport=0"
158158
]
159159
}
160160
]
@@ -168,14 +168,14 @@
168168
"image-name": "nff-go-test-cksum",
169169
"app-type": "TestAppGo",
170170
"exec-cmd": [
171-
"./testCksum", "-testScenario=2", "-hwol", "-inport=1", "-outport=1"
171+
"./testCksum", "-testScenario=1", "-ipv4", "-udp", "-number=10000", "-inport=0", "-outport=1"
172172
]
173173
},
174174
{
175175
"image-name": "nff-go-test-cksum",
176176
"app-type": "TestAppGo",
177177
"exec-cmd": [
178-
"./testCksum", "-testScenario=1", "-ipv4", "-udp", "-number=10000", "-inport=0", "-outport=0"
178+
"./testCksum", "-testScenario=2", "-hwol", "-inport=1", "-outport=0"
179179
]
180180
}
181181
]
@@ -189,14 +189,14 @@
189189
"image-name": "nff-go-test-cksum",
190190
"app-type": "TestAppGo",
191191
"exec-cmd": [
192-
"./testCksum", "-testScenario=2", "-hwol", "-inport=1", "-outport=1"
192+
"./testCksum", "-testScenario=1", "-ipv6", "-tcp", "-number=10000", "-inport=0", "-outport=1"
193193
]
194194
},
195195
{
196196
"image-name": "nff-go-test-cksum",
197197
"app-type": "TestAppGo",
198198
"exec-cmd": [
199-
"./testCksum", "-testScenario=1", "-ipv6", "-tcp", "-number=10000", "-inport=0", "-outport=0"
199+
"./testCksum", "-testScenario=2", "-hwol", "-inport=1", "-outport=0"
200200
]
201201
}
202202
]
@@ -210,14 +210,14 @@
210210
"image-name": "nff-go-test-cksum",
211211
"app-type": "TestAppGo",
212212
"exec-cmd": [
213-
"./testCksum", "-testScenario=2", "-hwol", "-inport=1", "-outport=1"
213+
"./testCksum", "-testScenario=1", "-ipv6", "-udp", "-number=10000", "-inport=0", "-outport=1"
214214
]
215215
},
216216
{
217217
"image-name": "nff-go-test-cksum",
218218
"app-type": "TestAppGo",
219219
"exec-cmd": [
220-
"./testCksum", "-testScenario=1", "-ipv6", "-udp", "-number=10000", "-inport=0", "-outport=0"
220+
"./testCksum", "-testScenario=2", "-hwol", "-inport=1", "-outport=0"
221221
]
222222
}
223223
]

test/stability/testHandle/testHandle.go

+77-32
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ import (
3535
// all these actions are made in one pipeline without actual send and receive.
3636

3737
const (
38-
totalPackets = 10000000
39-
4038
// Test expects to receive 33% of packets on 0 port.
4139
// Test is PASSSED, if p1 is in [low1;high1]
4240
eps = 5
@@ -45,10 +43,11 @@ const (
4543
)
4644

4745
var (
48-
l3Rules *packet.L3Rules
46+
totalPackets uint64 = 10000000
47+
l3Rules *packet.L3Rules
4948
// Payload is 16 byte md5 hash sum of headers
50-
payloadSize uint = 16
51-
d uint = 10
49+
payloadSize uint = 16
50+
speed uint64 = 1000000
5251

5352
sentPacketsGroup1 uint64
5453
sentPacketsGroup2 uint64
@@ -63,6 +62,11 @@ var (
6362
dstPort3 uint16 = 333
6463

6564
testDoneEvent *sync.Cond
65+
progStart time.Time
66+
67+
// T second timeout is used to let generator reach required speed
68+
// During timeout packets are skipped and not counted
69+
T = 10 * time.Second
6670

6771
outport uint
6872
inport uint
@@ -73,8 +77,11 @@ var (
7377
func main() {
7478
var testScenario uint
7579
flag.UintVar(&testScenario, "testScenario", 0, "1 to use 1st part scenario, 2 snd, 0 to use one-machine test")
80+
flag.Uint64Var(&speed, "speed", speed, "speed of 1 and 2 generators, Pkts/s")
7681
flag.UintVar(&outport, "outport", 0, "port for sender")
7782
flag.UintVar(&inport, "inport", 0, "port for receiver")
83+
flag.Uint64Var(&totalPackets, "number", totalPackets, "total number of packets to receive by test")
84+
flag.DurationVar(&T, "timeout", T, "test start delay, needed to stabilize speed. Packets sent during timeout do not affect test result")
7885
flag.Parse()
7986

8087
if err := executeTest(testScenario); err != nil {
@@ -88,53 +95,81 @@ func executeTest(testScenario uint) error {
8895
}
8996
// Init NFF-GO system
9097
config := flow.Config{}
91-
if err := flow.SystemInit(&config); err != nil { return err }
98+
if err := flow.SystemInit(&config); err != nil {
99+
return err
100+
}
92101
if testScenario != 1 {
93102
var err error
94103
// Get splitting rules from access control file.
95104
l3Rules, err = packet.GetL3ACLFromORIG(rulesConfig)
96-
if err != nil { return err }
105+
if err != nil {
106+
return err
107+
}
97108
}
98109
if testScenario == 2 {
99110
// Receive packets from 0 port
100111
flow1, err := flow.SetReceiver(uint8(inport))
101-
if err != nil { return err }
112+
if err != nil {
113+
return err
114+
}
102115

103116
// Handle packet flow
104117
// ~33% of packets should left in flow1
105-
if err := flow.SetHandlerDrop(flow1, l3Handler, nil); err != nil { return err }
118+
if err := flow.SetHandlerDrop(flow1, l3Handler, nil); err != nil {
119+
return err
120+
}
106121

107122
// Send each flow to corresponding port. Send queues will be added automatically.
108-
if err := flow.SetSender(flow1, uint8(outport)); err != nil { return err }
123+
if err := flow.SetSender(flow1, uint8(outport)); err != nil {
124+
return err
125+
}
109126

110127
// Begin to process packets.
111-
if err := flow.SystemStart(); err != nil { return err }
128+
if err := flow.SystemStart(); err != nil {
129+
return err
130+
}
112131
} else {
113132
var m sync.Mutex
114133
testDoneEvent = sync.NewCond(&m)
115134

116135
// Create first packet flow
117-
outFlow := flow.SetGenerator(generatePacket, nil)
136+
outFlow, err := flow.SetFastGenerator(generatePacket, speed, nil)
137+
if err != nil {
138+
return err
139+
}
140+
118141
var finalFlow *flow.Flow
119142
if testScenario == 1 {
120143
var err error
121-
if err := flow.SetSender(outFlow, uint8(outport)); err != nil { return err }
144+
if err := flow.SetSender(outFlow, uint8(outport)); err != nil {
145+
return err
146+
}
122147
// Create receiving flows and set a checking function for it
123-
finalFlow, err = flow.SetReceiver(uint8(outport))
124-
if err != nil { return err }
148+
finalFlow, err = flow.SetReceiver(uint8(inport))
149+
if err != nil {
150+
return err
151+
}
125152
} else {
126153
finalFlow = outFlow
127-
if err := flow.SetHandlerDrop(finalFlow, l3Handler, nil); err != nil { return err }
154+
if err := flow.SetHandlerDrop(finalFlow, l3Handler, nil); err != nil {
155+
return err
156+
}
157+
}
158+
if err := flow.SetHandler(finalFlow, checkInputFlow, nil); err != nil {
159+
return err
160+
}
161+
if err := flow.SetStopper(finalFlow); err != nil {
162+
return err
128163
}
129-
if err := flow.SetHandler(finalFlow, checkInputFlow, nil); err != nil { return err }
130-
if err := flow.SetStopper(finalFlow); err != nil { return err }
131164

132-
var err error
133165
// Start pipeline
134166
go func() {
135167
err = flow.SystemStart()
136168
}()
137-
if err != nil { return err }
169+
if err != nil {
170+
return err
171+
}
172+
progStart = time.Now()
138173

139174
// Wait for enough packets to arrive
140175
testDoneEvent.L.Lock()
@@ -155,13 +190,13 @@ func composeStatistics() {
155190
sent1 := sentPacketsGroup1
156191
sent2 := sentPacketsGroup2
157192
sent3 := sentPacketsGroup3
158-
sent := sent1 + sent2 + sent3
193+
sentTotal := sent1 + sent2 + sent3
159194

160195
received := atomic.LoadUint64(&recv)
161196

162197
var p int
163-
if sent != 0 {
164-
p = int(received * 100 / sent)
198+
if sentTotal != 0 {
199+
p = int(received * 100 / sentTotal)
165200
}
166201
broken := atomic.LoadUint64(&brokenPackets)
167202

@@ -188,29 +223,40 @@ func generatePacket(pkt *packet.Packet, context flow.UserContext) {
188223
}
189224
ipv4 := pkt.GetIPv4()
190225
udp := pkt.GetUDPForIPv4()
191-
switch sent % 3 {
226+
t := sent % 3
227+
switch t {
192228
case 0:
193229
udp.DstPort = packet.SwapBytesUint16(dstPort1)
194-
sentPacketsGroup1++
195230
case 1:
196231
udp.DstPort = packet.SwapBytesUint16(dstPort2)
197-
sentPacketsGroup2++
198232
case 2:
199233
udp.DstPort = packet.SwapBytesUint16(dstPort3)
200-
sentPacketsGroup3++
201234
}
202235
sent++
203236

204237
ipv4.HdrChecksum = packet.SwapBytesUint16(packet.CalculateIPv4Checksum(ipv4))
205238
udp.DgramCksum = packet.SwapBytesUint16(packet.CalculateIPv4UDPChecksum(ipv4, udp, pkt.Data))
206239

207-
if sentPacketsGroup1 > totalPackets/3 {
208-
time.Sleep(time.Second * time.Duration(d))
209-
println("TEST FAILED")
240+
// We do not consider the start time of the system in this test
241+
if time.Since(progStart) < T {
242+
return
243+
}
244+
245+
switch t {
246+
case 0:
247+
atomic.AddUint64(&sentPacketsGroup1, 1)
248+
case 1:
249+
atomic.AddUint64(&sentPacketsGroup2, 1)
250+
case 2:
251+
atomic.AddUint64(&sentPacketsGroup3, 1)
210252
}
211253
}
212254

213255
func checkInputFlow(pkt *packet.Packet, context flow.UserContext) {
256+
if time.Since(progStart) < T {
257+
return
258+
}
259+
214260
offset := pkt.ParseData()
215261
if offset < 0 {
216262
println("ParseData returned negative value", offset)
@@ -229,8 +275,7 @@ func checkInputFlow(pkt *packet.Packet, context flow.UserContext) {
229275
}
230276
atomic.AddUint64(&recv, 1)
231277
}
232-
// TODO 80% of requested number of packets.
233-
if recv >= totalPackets/32*8 {
278+
if recv >= totalPackets {
234279
testDoneEvent.Signal()
235280
}
236281
}

0 commit comments

Comments
 (0)