@@ -17,6 +17,7 @@ import (
17
17
"bytes"
18
18
"fmt"
19
19
"io"
20
+ "log"
20
21
"math/rand"
21
22
"net"
22
23
"os"
@@ -60,6 +61,13 @@ var _ = Describe("Basic PTP using cnitool", func() {
60
61
netConfPath , err := filepath .Abs ("./testdata" )
61
62
Expect (err ).NotTo (HaveOccurred ())
62
63
64
+ // Flush ipam stores to avoid conflicts
65
+ err = os .RemoveAll ("/tmp/chained-ptp-bandwidth-test" )
66
+ Expect (err ).NotTo (HaveOccurred ())
67
+
68
+ err = os .RemoveAll ("/tmp/basic-ptp-test" )
69
+ Expect (err ).NotTo (HaveOccurred ())
70
+
63
71
env = TestEnv ([]string {
64
72
"CNI_PATH=" + cniPath ,
65
73
"NETCONFPATH=" + netConfPath ,
@@ -82,6 +90,7 @@ var _ = Describe("Basic PTP using cnitool", func() {
82
90
env .runInNS (hostNS , cnitoolBin , "add" , netName , contNS .LongName ())
83
91
84
92
addrOutput := env .runInNS (contNS , "ip" , "addr" )
93
+
85
94
Expect (addrOutput ).To (ContainSubstring (expectedIPPrefix ))
86
95
87
96
env .runInNS (hostNS , cnitoolBin , "del" , netName , contNS .LongName ())
@@ -145,9 +154,13 @@ var _ = Describe("Basic PTP using cnitool", func() {
145
154
146
155
chainedBridgeBandwidthEnv .runInNS (hostNS , cnitoolBin , "del" , "network-chain-test" , contNS1 .LongName ())
147
156
basicBridgeEnv .runInNS (hostNS , cnitoolBin , "del" , "network-chain-test" , contNS2 .LongName ())
157
+
158
+ contNS1 .Del ()
159
+ contNS2 .Del ()
160
+ hostNS .Del ()
148
161
})
149
162
150
- Measure ("limits traffic only on the restricted bandwidth veth device" , func (b Benchmarker ) {
163
+ It ("limits traffic only on the restricted bandwidth veth device" , func () {
151
164
ipRegexp := regexp .MustCompile (`10\.1[12]\.2\.\d{1,3}` )
152
165
153
166
By (fmt .Sprintf ("adding %s to %s\n \n " , "chained-bridge-bandwidth" , contNS1 .ShortName ()))
@@ -172,17 +185,19 @@ var _ = Describe("Basic PTP using cnitool", func() {
172
185
// balanced by run time.
173
186
174
187
By (fmt .Sprintf ("sending tcp traffic to the chained, bridged, traffic shaped container on ip address '%s:%d'\n \n " , chainedBridgeIP , chainedBridgeBandwidthPort ))
175
- runtimeWithLimit := b .Time ("with chained bridge and bandwidth plugins" , func () {
176
- makeTCPClientInNS (hostNS .ShortName (), chainedBridgeIP , chainedBridgeBandwidthPort , packetInBytes )
177
- })
188
+ start := time .Now ()
189
+ makeTCPClientInNS (hostNS .ShortName (), chainedBridgeIP , chainedBridgeBandwidthPort , packetInBytes )
190
+ runtimeWithLimit := time .Since (start )
191
+ log .Printf ("Runtime with qos limit %.2f seconds" , runtimeWithLimit .Seconds ())
178
192
179
193
By (fmt .Sprintf ("sending tcp traffic to the basic bridged container on ip address '%s:%d'\n \n " , basicBridgeIP , basicBridgePort ))
180
- runtimeWithoutLimit := b .Time ("with basic bridged plugin" , func () {
181
- makeTCPClientInNS (hostNS .ShortName (), basicBridgeIP , basicBridgePort , packetInBytes )
182
- })
194
+ start = time .Now ()
195
+ makeTCPClientInNS (hostNS .ShortName (), basicBridgeIP , basicBridgePort , packetInBytes )
196
+ runtimeWithoutLimit := time .Since (start )
197
+ log .Printf ("Runtime without qos limit %.2f seconds" , runtimeWithoutLimit .Seconds ())
183
198
184
199
Expect (runtimeWithLimit ).To (BeNumerically (">" , runtimeWithoutLimit + 1000 * time .Millisecond ))
185
- }, 1 )
200
+ })
186
201
})
187
202
})
188
203
0 commit comments