Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize sleep in test/systemtests #1037

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
59 changes: 18 additions & 41 deletions test/systemtests/aci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func (s *systemtestSuite) TestACIMode(c *C) {
c.Assert(node1.rotateLog("netplugin"), IsNil)
c.Assert(node1.startNetplugin(""), IsNil)
c.Assert(node1.runCommandUntilNoError("pgrep netplugin"), IsNil)
time.Sleep(20 * time.Second)

c.Assert(s.pingTest(containersA), IsNil)
c.Assert(s.pingTest(containersB), IsNil)
Expand Down Expand Up @@ -207,8 +206,7 @@ func (s *systemtestSuite) TestACIPingGateway(c *C) {
TenantName: s.globInfo.Tenant,
EndpointGroups: []string{"epga"},
AppProfileName: "profile1",
}), IsNil)
time.Sleep(5 * time.Second)
}, 2, 5, 1), IsNil)
containers, err := s.runContainersInGroups(s.basicInfo.Containers, s.globInfo.Network, s.globInfo.Tenant, []string{"epga"})
c.Assert(err, IsNil)

Expand All @@ -221,8 +219,7 @@ func (s *systemtestSuite) TestACIPingGateway(c *C) {

c.Assert(s.removeContainers(containersA), IsNil)
containersA = nil
c.Assert(s.cli.AppProfileDelete(s.globInfo.Tenant, "profile1"), IsNil)
time.Sleep(time.Second * 5)
c.Assert(s.cli.AppProfileDelete(s.globInfo.Tenant, "profile1", 2, 5, 0), IsNil)
c.Assert(s.cli.EndpointGroupDelete(s.globInfo.Tenant, "epga"), IsNil)
c.Assert(s.cli.NetworkDelete(s.globInfo.Tenant, s.globInfo.Network), IsNil)
}
Expand Down Expand Up @@ -282,14 +279,11 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
TenantName: s.globInfo.Tenant,
EndpointGroups: []string{"epga", "epgb"},
AppProfileName: "profile1",
}), IsNil)

time.Sleep(5 * time.Second)
}, 2, 5, 1), IsNil)

groups := []string{"epga", "epgb"}
containers, err := s.runContainersInGroups(s.basicInfo.Containers, s.globInfo.Network, s.globInfo.Tenant, groups)
c.Assert(err, IsNil)
time.Sleep(time.Second * 20)
for key, value := range containers {
if value == "epga" {
containersA = append(containersA, key)
Expand Down Expand Up @@ -326,8 +320,7 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
NetworkName: s.globInfo.Network,
Policies: []string{"policyAB"},
GroupName: "epgb",
}), IsNil)
time.Sleep(time.Second * 10)
}, 2, 10, 1), IsNil)

c.Assert(s.checkACILearning(s.globInfo.Tenant,
"profile1",
Expand Down Expand Up @@ -360,8 +353,7 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
Protocol: "tcp",
Port: 8000,
Action: "allow",
}), IsNil)
time.Sleep(time.Second * 10)
}, 2, 10, 1), IsNil)

c.Assert(s.checkACILearning(s.globInfo.Tenant,
"profile1",
Expand Down Expand Up @@ -389,8 +381,7 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
Protocol: "tcp",
Port: 8001,
Action: "allow",
}), IsNil)
time.Sleep(time.Second * 10)
}, 2, 10, 1), IsNil)

c.Assert(s.checkACILearning(s.globInfo.Tenant,
"profile1",
Expand All @@ -409,8 +400,7 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
}

// Delete ICMP rule
c.Assert(s.cli.RuleDelete(s.globInfo.Tenant, "policyAB", "1"), IsNil)
time.Sleep(time.Second * 10)
c.Assert(s.cli.RuleDelete(s.globInfo.Tenant, "policyAB", "1", 2, 10, 0), IsNil)

c.Assert(s.checkACILearning(s.globInfo.Tenant,
"profile1",
Expand All @@ -426,8 +416,7 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
c.Assert(s.checkConnectionPairRetry(containersA, containersB, 8000, 1, 3), IsNil)
c.Assert(s.checkConnectionPairRetry(containersA, containersB, 8001, 1, 3), IsNil)
// Delete TCP 8000 rule
c.Assert(s.cli.RuleDelete(s.globInfo.Tenant, "policyAB", "2"), IsNil)
time.Sleep(time.Second * 10)
c.Assert(s.cli.RuleDelete(s.globInfo.Tenant, "policyAB", "2", 2, 10, 0), IsNil)
c.Assert(s.checkACILearning(s.globInfo.Tenant,
"profile1",
"epga",
Expand All @@ -442,8 +431,7 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
c.Assert(s.pingFailureTest(containersA, containersB), IsNil)

// Delete the app profile
c.Assert(s.cli.AppProfileDelete(s.globInfo.Tenant, "profile1"), IsNil)
time.Sleep(time.Second * 5)
c.Assert(s.cli.AppProfileDelete(s.globInfo.Tenant, "profile1", 2, 5, 0), IsNil)

c.Assert(s.checkNoConnectionPairRetry(containersA, containersB, 8000, 1, 3), IsNil)
c.Assert(s.checkNoConnectionPairRetry(containersA, containersB, 8001, 1, 3), IsNil)
Expand All @@ -454,8 +442,7 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
TenantName: s.globInfo.Tenant,
EndpointGroups: []string{"epga", "epgb"},
AppProfileName: "profile2",
}), IsNil)
time.Sleep(time.Second * 10)
}, 2, 10, 1), IsNil)
c.Assert(s.checkACILearning(s.globInfo.Tenant,
"profile2",
"epga",
Expand All @@ -470,7 +457,6 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
containersB = nil
containers, err = s.runContainersInGroups(s.basicInfo.Containers, s.globInfo.Network, s.globInfo.Tenant, groups)
c.Assert(err, IsNil)
time.Sleep(time.Second * 20)
for key, value := range containers {
if value == "epga" {
containersA2 = append(containersA2, key)
Expand All @@ -494,10 +480,9 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
Protocol: "tcp",
Port: 8000,
Action: "allow",
}), IsNil)
}, 2, 10, 1), IsNil)
err = errors.New("forced")
//c.Assert(err, IsNil)
time.Sleep(time.Second * 10)
c.Assert(s.checkACILearning(s.globInfo.Tenant,
"profile2",
"epga",
Expand All @@ -513,8 +498,7 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
c.Assert(s.pingFailureTest(containersA2, containersB2), IsNil)

// Delete the app profile
c.Assert(s.cli.AppProfileDelete(s.globInfo.Tenant, "profile2"), IsNil)
time.Sleep(time.Second * 5)
c.Assert(s.cli.AppProfileDelete(s.globInfo.Tenant, "profile2", 2, 5, 0), IsNil)
c.Assert(s.checkNoConnectionPairRetry(containersA2, containersB2, 8000, 1, 3), IsNil)
c.Assert(s.checkNoConnectionPairRetry(containersA2, containersB2, 8001, 1, 3), IsNil)
c.Assert(s.pingFailureTest(containersA2, containersB2), IsNil)
Expand Down Expand Up @@ -580,14 +564,11 @@ func (s *systemtestSuite) TestACIGWRestart(c *C) {
TenantName: s.globInfo.Tenant,
EndpointGroups: []string{"epga", "epgb"},
AppProfileName: "profile1",
}), IsNil)

time.Sleep(5 * time.Second)
}, 2, 5, 1), IsNil)

groups := []string{"epga", "epgb"}
containers, err := s.runContainersInGroups(s.basicInfo.Containers, s.globInfo.Network, s.globInfo.Tenant, groups)
c.Assert(err, IsNil)
time.Sleep(time.Second * 20)
for key, value := range containers {
if value == "epga" {
containersA = append(containersA, key)
Expand Down Expand Up @@ -626,8 +607,7 @@ func (s *systemtestSuite) TestACIGWRestart(c *C) {
NetworkName: s.globInfo.Network,
Policies: []string{"policyAB"},
GroupName: "epgb",
}), IsNil)
time.Sleep(time.Second * 10)
}, 2, 10, 1), IsNil)

c.Assert(s.checkACILearning(s.globInfo.Tenant,
"profile1",
Expand All @@ -652,8 +632,7 @@ func (s *systemtestSuite) TestACIGWRestart(c *C) {
Protocol: "tcp",
Port: 8000,
Action: "allow",
}), IsNil)
time.Sleep(time.Second * 10)
}, 2, 10, 1), IsNil)

c.Assert(s.checkACILearning(s.globInfo.Tenant,
"profile1",
Expand All @@ -677,7 +656,7 @@ func (s *systemtestSuite) TestACIGWRestart(c *C) {
for iNode := range s.nodes {
s.nodes[iNode].tbnode.RunCommand("sudo service aci-gw restart")
}
time.Sleep(10 * time.Millisecond)
time.Sleep(2 * time.Millisecond)

//Verifying the behavior didn't change after restarting the gateway
for _, cB := range containersB {
Expand All @@ -698,8 +677,7 @@ func (s *systemtestSuite) TestACIGWRestart(c *C) {
Protocol: "tcp",
Port: 8001,
Action: "allow",
}), IsNil)
time.Sleep(time.Second * 10)
}, 2, 10, 1), IsNil)

c.Assert(s.checkACILearning(s.globInfo.Tenant,
"profile1",
Expand All @@ -714,8 +692,7 @@ func (s *systemtestSuite) TestACIGWRestart(c *C) {
c.Assert(s.checkConnectionPairRetry(containersA, containersB, 8001, 1, 3), IsNil)

// Delete the app profile
c.Assert(s.cli.AppProfileDelete(s.globInfo.Tenant, "profile1"), IsNil)
time.Sleep(time.Second * 5)
c.Assert(s.cli.AppProfileDelete(s.globInfo.Tenant, "profile1", 2, 5, 0), IsNil)

c.Assert(s.removeContainers(append(containersA, containersB...)), IsNil)
containersA = nil
Expand Down
37 changes: 27 additions & 10 deletions test/systemtests/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (s *systemtestSuite) testBasicSvcDiscovery(c *C, encap string) {
c.Assert(err, IsNil)
}
if s.fwdMode == "routing" && encap == "vlan" {
time.Sleep(5 * time.Second)
time.Sleep(2 * time.Second)
}

// Check name resolution
Expand Down Expand Up @@ -249,42 +249,59 @@ func (s *systemtestSuite) TestBasicNetmasterPortListen(c *C) {
// Requests to port other than masterListenPort(:XXXX) should not be honored
logrus.Infof("Checking case: --listen-url :XXXX (:XXXX is not default port :9999)")
c.Assert(masterNode.startNetmaster(fmt.Sprintf("--listen-url=:%s", masterListenPort)), IsNil)
time.Sleep(40 * time.Second)
c.Assert(checkNetmasterPortListener(masterDefaultPort), NotNil)
c.Assert(checkNetmasterPortListener(masterListenPort), IsNil)

for i := 0; i < 90; i++ {
err = checkNetmasterPortListener(masterListenPort)
if err == nil {
break
} else {
time.Sleep(2 * time.Second)
if i == 89 {
c.Assert(err, IsNil)
}
}
}

c.Assert(checkNetmasterPortListener(masterCtrlPort), NotNil)
c.Assert(masterNode.stopNetmaster(), IsNil)
time.Sleep(5 * time.Second)

// Case: --listen-url A.B.C.D:XXXX --control-url :YYYY
// Control port with non default port and wildcard IP is not valid
logrus.Infof("Checking case: --listen-url A.B.C.D:XXXX --control-url :YYYY")
c.Assert(masterNode.startNetmaster(fmt.Sprintf("--listen-url=%s:%s --control-url=:%s", masterIP, masterListenPort, masterCtrlPort)), IsNil)
time.Sleep(5 * time.Second)
c.Assert(masterNode.exec.runCommandUntilNoNetmasterError(), NotNil)

// Case: --listen-url :YYYY --control-url A.B.C.D:YYYY
// Requests to port other than YYYY(masterCtrlPort) should not be honored
logrus.Infof("Checking case: --listen-url :YYYY --control-url A.B.C.D:YYYY")
c.Assert(masterNode.startNetmaster(fmt.Sprintf("--listen-url=:%s --control-url=%s:%s", masterCtrlPort, masterIP, masterCtrlPort)), IsNil)
time.Sleep(40 * time.Second)
c.Assert(checkNetmasterPortListener(masterDefaultPort), NotNil)
c.Assert(checkNetmasterPortListener(masterListenPort), NotNil)
c.Assert(checkNetmasterPortListener(masterCtrlPort), IsNil)

for i := 0; i < 90; i++ {
err = checkNetmasterPortListener(masterCtrlPort)
if err == nil {
break
} else {
time.Sleep(2 * time.Second)
if i == 89 {
c.Assert(err, IsNil)
}
}
}

c.Assert(masterNode.stopNetmaster(), IsNil)
time.Sleep(5 * time.Second)

// Case: --listen-url :XXXX --control-url=A.B.C.D:YYYY
// Requests to port other than masterListenPort should not be honored
// masterCtrlPort is accessible only within the cluster for control pkts
logrus.Infof("Checking case: --listen-url :XXXX --control-url=A.B.C.D:YYYY")
c.Assert(masterNode.startNetmaster(fmt.Sprintf("--listen-url=:%s --control-url=%s:%s", masterListenPort, masterIP, masterCtrlPort)), IsNil)
time.Sleep(40 * time.Second)
c.Assert(checkNetmasterPortListener(masterDefaultPort), NotNil)
c.Assert(checkNetmasterPortListener(masterListenPort), IsNil)
c.Assert(checkNetmasterPortListener(masterCtrlPort), NotNil)
c.Assert(masterNode.stopNetmaster(), IsNil)
time.Sleep(5 * time.Second)
}

}
Expand Down
Loading