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