Skip to content

Commit ef076af

Browse files
authored
Merge pull request containernetworking#921 from oOraph/dev/exclude_subnets_from_traffic_shapping2
Dev/exclude subnets from traffic shaping2
2 parents 5974089 + ccc1cfa commit ef076af

9 files changed

Lines changed: 2886 additions & 610 deletions

integration/integration_linux_test.go

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"bytes"
1818
"fmt"
1919
"io"
20+
"log"
2021
"math/rand"
2122
"net"
2223
"os"
@@ -60,6 +61,13 @@ var _ = Describe("Basic PTP using cnitool", func() {
6061
netConfPath, err := filepath.Abs("./testdata")
6162
Expect(err).NotTo(HaveOccurred())
6263

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+
6371
env = TestEnv([]string{
6472
"CNI_PATH=" + cniPath,
6573
"NETCONFPATH=" + netConfPath,
@@ -82,6 +90,7 @@ var _ = Describe("Basic PTP using cnitool", func() {
8290
env.runInNS(hostNS, cnitoolBin, "add", netName, contNS.LongName())
8391

8492
addrOutput := env.runInNS(contNS, "ip", "addr")
93+
8594
Expect(addrOutput).To(ContainSubstring(expectedIPPrefix))
8695

8796
env.runInNS(hostNS, cnitoolBin, "del", netName, contNS.LongName())
@@ -145,9 +154,13 @@ var _ = Describe("Basic PTP using cnitool", func() {
145154

146155
chainedBridgeBandwidthEnv.runInNS(hostNS, cnitoolBin, "del", "network-chain-test", contNS1.LongName())
147156
basicBridgeEnv.runInNS(hostNS, cnitoolBin, "del", "network-chain-test", contNS2.LongName())
157+
158+
contNS1.Del()
159+
contNS2.Del()
160+
hostNS.Del()
148161
})
149162

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() {
151164
ipRegexp := regexp.MustCompile(`10\.1[12]\.2\.\d{1,3}`)
152165

153166
By(fmt.Sprintf("adding %s to %s\n\n", "chained-bridge-bandwidth", contNS1.ShortName()))
@@ -168,21 +181,23 @@ var _ = Describe("Basic PTP using cnitool", func() {
168181
By(fmt.Sprintf("starting echo server in %s\n\n", contNS2.ShortName()))
169182
basicBridgePort, basicBridgeSession = startEchoServerInNamespace(contNS2)
170183

171-
packetInBytes := 20000 // The shaper needs to 'warm'. Send enough to cause it to throttle,
172-
// balanced by run time.
184+
packetInBytes := 3000
173185

174186
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-
})
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())
178192

179193
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", runtimeWithLimit.Seconds())
183198

184199
Expect(runtimeWithLimit).To(BeNumerically(">", runtimeWithoutLimit+1000*time.Millisecond))
185-
}, 1)
200+
})
186201
})
187202
})
188203

integration/testdata/basic-ptp.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"mtu": 512,
77
"ipam": {
88
"type": "host-local",
9-
"subnet": "10.1.2.0/24"
9+
"subnet": "10.1.2.0/24",
10+
"dataDir": "/tmp/basic-ptp-test"
1011
}
1112
}

integration/testdata/chained-ptp-bandwidth.conflist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"mtu": 512,
99
"ipam": {
1010
"type": "host-local",
11-
"subnet": "10.9.2.0/24"
11+
"subnet": "10.9.2.0/24",
12+
"dataDir": "/tmp/chained-ptp-bandwidth-test"
1213
}
1314
},
1415
{

0 commit comments

Comments
 (0)