Skip to content

Commit 474efbc

Browse files
committed
bandwidth policy fix for multiTenant test
1 parent 08d92ea commit 474efbc

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

test/systemtests/docker_test.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -257,26 +257,26 @@ func (d *docker) startIperfClient(c *container, ip, limit string, isErr bool) er
257257
var (
258258
bwLimit int64
259259
bwInt64 int64
260-
bw string
260+
bw string
261261
success bool
262262
err error
263263
)
264264

265-
for i := 0; i<10 ;i++ {
266-
bw, err = d.exec(c, fmt.Sprintf("iperf -c %s -u -b 20mbps", ip))
267-
if err != nil {
268-
return err
269-
}
270-
if strings.Contains(bw, "Server Report:") {
271-
success = true
272-
break
273-
}else if strings.Contains(bw, "read failed:") {
274-
time.Sleep(2 * time.Second)
275-
i++
276-
}
277-
}
278-
279-
if success {
265+
for i := 0; i < 3; i++ {
266+
bw, err = d.exec(c, fmt.Sprintf("iperf -c %s -u -b 20mbps", ip))
267+
if err != nil {
268+
return err
269+
}
270+
if strings.Contains(bw, "Server Report:") {
271+
success = true
272+
break
273+
} else if strings.Contains(bw, "read failed:") {
274+
time.Sleep(2 * time.Second)
275+
i++
276+
}
277+
}
278+
279+
if success {
280280
logrus.Infof("starting iperf client on conatiner:%s for server ip: %s", c, ip)
281281
bwFormat := strings.Split(bw, "Server Report:")
282282
bwString := strings.Split(bwFormat[1], "Bytes ")
@@ -292,16 +292,16 @@ func (d *docker) startIperfClient(c *container, ip, limit string, isErr bool) er
292292
}
293293
bwLimit = bwLimit + (bwLimit / 10)
294294
if bwLimit > bwInt64 {
295-
logrus.Infof("Obtained bandwidth :%sbits is less than the limit:%s", newBandwidth[0], limit)
295+
logrus.Infof("Obtained bandwidth:%sbits matches with the limit:%s", newBandwidth[0], limit)
296296
} else if bwLimit < bwInt64 {
297297
if isErr {
298-
logrus.Errorf("Obtained Bandwidth:%sbits is more than the limit: %s",newBandwidth[0], limit)
298+
logrus.Errorf("Obtained Bandwidth:%sbits is more than the limit:%s", newBandwidth[0], limit)
299299
} else {
300-
logrus.Errorf("Obtained bandwidth:%sbits is more than the limit %s", newBandwidth[0], limit)
300+
logrus.Errorf("Obtained bandwidth:%sbits is more than the limit:%s", newBandwidth[0], limit)
301301
return errors.New("Applied bandwidth is more than bandwidth rate!")
302302
}
303303
} else {
304-
logrus.Errorf("Bandwidth rate :%s not applied", limit)
304+
logrus.Errorf("Bandwidth rate:%s not applied", limit)
305305
return errors.New("Bandwidth rate is not applied")
306306
}
307307
} else {

test/systemtests/netprofile_test.go

+12-9
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ func (s *systemtestSuite) testNetprofileMultipleTenant(c *C, encap string) {
315315
bandwidth = make(map[string]string)
316316
npTenant = make(map[string][]string)
317317
networks = make(map[string][]string)
318+
netName = make(map[string]string)
318319
containers = map[string][]*container{}
319320
pktTag = 0
320321
epgName string
@@ -328,9 +329,10 @@ func (s *systemtestSuite) testNetprofileMultipleTenant(c *C, encap string) {
328329
c.Assert(s.cli.TenantPost(&client.Tenant{TenantName: tenantName}), IsNil)
329330

330331
for networkNum := 0; networkNum < (numContainer - 1); networkNum++ {
332+
networkName := fmt.Sprintf("net%d-%s", networkNum, tenantName)
331333
network := &client.Network{
332334
TenantName: tenantName,
333-
NetworkName: fmt.Sprintf("net%d", networkNum),
335+
NetworkName: networkName,
334336
Subnet: fmt.Sprintf("10.%d.%d.1/24", tenantNum, networkNum),
335337
Gateway: fmt.Sprintf("10.%d.%d.254", tenantNum, networkNum),
336338
PktTag: pktTag + 1000,
@@ -343,9 +345,9 @@ func (s *systemtestSuite) testNetprofileMultipleTenant(c *C, encap string) {
343345
networks[tenantName] = append(networks[network.TenantName], network.NetworkName)
344346
pktTag++
345347

346-
profileName := fmt.Sprintf("netprofile%d-%d-%d", tenantNum, networkNum, i)
348+
profileName := fmt.Sprintf("netprofile%d%d-%s", networkNum, tenantNum, tenantName)
347349
bwInt := 10 + tenantNum + networkNum
348-
burst := (bwInt * 15)
350+
burst := (bwInt * 13)
349351
netprofile := &client.Netprofile{
350352
ProfileName: profileName,
351353
DSCP: networkNum + i,
@@ -356,7 +358,7 @@ func (s *systemtestSuite) testNetprofileMultipleTenant(c *C, encap string) {
356358

357359
c.Assert(s.cli.NetprofilePost(netprofile), IsNil)
358360
logrus.Infof("Creating:%s with %s", netprofile.ProfileName, netprofile.TenantName)
359-
epgName = fmt.Sprintf("epg%d-ten%d-%d", networkNum, tenantNum, i)
361+
epgName = fmt.Sprintf("epg%d-%s", networkNum, networkName)
360362
group := &client.EndpointGroup{
361363
GroupName: epgName,
362364
NetworkName: network.NetworkName,
@@ -366,6 +368,7 @@ func (s *systemtestSuite) testNetprofileMultipleTenant(c *C, encap string) {
366368
c.Assert(s.cli.EndpointGroupPost(group), IsNil)
367369
logrus.Infof("Creating %s with %s and %s", group.GroupName, group.NetProfile, group.TenantName)
368370
groupNames[tenantName] = append(groupNames[group.TenantName], group.GroupName)
371+
netName[epgName] = group.NetworkName
369372
groupsInNp[profileName] = append(groupsInNp[group.NetProfile], group.GroupName)
370373
bandwidth[group.NetProfile] = netprofile.Bandwidth
371374
npTenant[tenantName] = append(npTenant[netprofile.TenantName], netprofile.ProfileName)
@@ -375,20 +378,20 @@ func (s *systemtestSuite) testNetprofileMultipleTenant(c *C, encap string) {
375378
for tenant, groups := range groupNames {
376379
endChan := make(chan error)
377380
for _, groupName := range groups {
378-
go func(groupName, tenant string, containers map[string][]*container) {
381+
go func(groupName, tenant string, netName map[string]string, containers map[string][]*container) {
379382
var err error
380383
mutex.Lock()
381384
logrus.Infof("Creating containers in group:%s", groupName)
382-
containers[groupName], err = s.runContainers(numContainer, false, groupName, tenant, nil, nil)
385+
containers[groupName], err = s.runContainersInService(numContainer, groupName, netName[groupName], tenant, nil)
383386
mutex.Unlock()
384387
endChan <- err
385388

386389
if s.fwdMode == "routing" && encap == "vlan" {
387390
_, err := s.CheckBgpRouteDistribution(c, containers[groupName])
388391
c.Assert(err, IsNil)
389392
}
390-
391-
}(groupName, tenant, containers)
393+
394+
}(groupName, tenant, netName, containers)
392395
}
393396
for i := 0; i < len(groups); i++ {
394397
c.Assert(<-endChan, IsNil)
@@ -398,7 +401,7 @@ func (s *systemtestSuite) testNetprofileMultipleTenant(c *C, encap string) {
398401
for netprofiles, groups := range groupsInNp {
399402
for _, group := range groups {
400403
logrus.Infof("Running iperf server on %s", group)
401-
s.startIperfServers(containers[group])
404+
c.Assert(s.startIperfServers(containers[group]), IsNil)
402405
logrus.Infof("running iperf client on %s", group)
403406
c.Assert(s.startIperfClients(containers[group], bandwidth[netprofiles], false), IsNil)
404407
}

0 commit comments

Comments
 (0)