Skip to content

Commit

Permalink
Merge pull request #749 from unclejack/systemtests_fixes
Browse files Browse the repository at this point in the history
systemtests: fixes and improvements
  • Loading branch information
unclejack committed Feb 21, 2017
2 parents 669de5f + 48a5c91 commit acbb416
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
14 changes: 7 additions & 7 deletions test/systemtests/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ func (s *systemtestSuite) testBasicSvcDiscovery(c *C, encap string) {
logrus.Infof("Creating epg: %s", group2.GroupName)
c.Assert(s.cli.EndpointGroupPost(group2), IsNil)

// create DNS container
dnsContainer, err := s.runContainersOnNode(1, "private", "default", "", s.nodes[0])
c.Assert(err, IsNil)
dnsIpAddr := dnsContainer[0].eth0.ip
// create DNS container
dnsContainer, err := s.runContainersOnNode(1, "private", "default", "", s.nodes[0])
c.Assert(err, IsNil)
dnsIpAddr := dnsContainer[0].eth0.ip

containers1, err := s.runContainersWithDNS(s.basicInfo.Containers, "default", "private",
fmt.Sprintf("svc1%d", i), dnsIpAddr)
fmt.Sprintf("svc1%d", i), dnsIpAddr)
c.Assert(err, IsNil)
containers2, err := s.runContainersWithDNS(s.basicInfo.Containers, "default", "private",
fmt.Sprintf("svc2%d", i), dnsIpAddr)
fmt.Sprintf("svc2%d", i), dnsIpAddr)
c.Assert(err, IsNil)

containers := append(containers1, containers2...)
Expand All @@ -194,7 +194,7 @@ func (s *systemtestSuite) testBasicSvcDiscovery(c *C, encap string) {
c.Assert(s.pingTestByName(containers, fmt.Sprintf("svc2%d", i)), IsNil)

// cleanup
c.Assert(s.removeContainers(dnsContainer), IsNil)
c.Assert(s.removeContainers(dnsContainer), IsNil)
c.Assert(s.removeContainers(containers), IsNil)
c.Assert(s.cli.EndpointGroupDelete(group1.TenantName, group1.GroupName), IsNil)
c.Assert(s.cli.EndpointGroupDelete(group2.TenantName, group2.GroupName), IsNil)
Expand Down
25 changes: 14 additions & 11 deletions test/systemtests/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,22 +451,25 @@ func (d *docker) startNetmaster() error {
func (d *docker) cleanupMaster() {
logrus.Infof("Cleaning up master on %s", d.node.Name())
vNode := d.node.tbnode
vNode.RunCommand("etcdctl rm --recursive /contiv")
vNode.RunCommand("etcdctl rm --recursive /contiv.io")
vNode.RunCommand("etcdctl rm --recursive /docker")
vNode.RunCommand("curl -X DELETE localhost:8500/v1/kv/contiv.io?recurse=true")
vNode.RunCommand("curl -X DELETE localhost:8500/v1/kv/docker?recurse=true")
vNode.RunCommand(`etcdctl rm --recursive /contiv || true &
etcdctl rm --recursive /contiv.io || true &
etcdctl rm --recursive /docker || true &
curl -X DELETE localhost:8500/v1/kv/contiv.io?recurse=true || true &
curl -X DELETE localhost:8500/v1/kv/docker?recurse=true || true &
wait`)
}

func (d *docker) cleanupSlave() {
logrus.Infof("Cleaning up slave on %s", d.node.Name())
vNode := d.node.tbnode
vNode.RunCommand("sudo ovs-vsctl del-br contivVxlanBridge")
vNode.RunCommand("sudo ovs-vsctl del-br contivVlanBridge")
vNode.RunCommand("sudo ovs-vsctl del-br contivHostBridge")
vNode.RunCommand("for p in `ifconfig | grep vport | awk '{print $1}'`; do sudo ip link delete $p type veth; done")
vNode.RunCommand("sudo rm /var/run/docker/plugins/netplugin.sock")
vNode.RunCommand("sudo service docker restart")
vNode.RunCommand(`sudo ovs-vsctl del-br contivVxlanBridge || true &
sudo ovs-vsctl del-br contivVlanBridge || true &
sudo ovs-vsctl del-br contivHostBridge || true &
sudo service docker restart &
interfaces=$(ip link | grep vport | awk '"'"'{ print $2 }'"'"' | tr -d : > /tmp/vports || true)
for p in $interfaces; do sudo ip link delete $p type veth || true; done &
sudo rm /var/run/docker/plugins/netplugin.sock || true &
wait`)
}

func (d *docker) runCommandUntilNoNetpluginError() error {
Expand Down
9 changes: 7 additions & 2 deletions test/systemtests/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package systemtests
import (
"flag"
"fmt"
"os"
"strings"
. "testing"

"github.com/Sirupsen/logrus"
"github.com/contiv/contivmodel/client"
"github.com/contiv/remotessh"
. "gopkg.in/check.v1"
"os"
. "testing"
)

type systemtestSuite struct {
Expand Down Expand Up @@ -136,6 +138,9 @@ func (s *systemtestSuite) TearDownSuite(c *C) {
for _, node := range s.nodes {
logrus.Infof("Checking for errors on %v", node.Name())
out, _ := node.runCommand(`for i in /tmp/net*; do grep "error\|fatal\|panic" $i; done`)
if strings.Contains(out, "No such file or directory") {
continue
}
if out != "" {
logrus.Errorf("Errors in logfiles on %s: \n", node.Name())
fmt.Printf("%s\n==========================\n\n", out)
Expand Down
8 changes: 4 additions & 4 deletions test/systemtests/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ func (s *systemtestSuite) runContainersWithDNS(num int, tenantName, networkName,

errChan := make(chan error)

if len(dnsServer) <= 0 {
logrus.Errorf("no dns specified")
return nil, fmt.Errorf("no dns")
}
if len(dnsServer) <= 0 {
logrus.Errorf("no dns specified")
return nil, fmt.Errorf("no dns")
}

docknetName := fmt.Sprintf("%s/%s", networkName, tenantName)
if tenantName == "default" {
Expand Down

0 comments on commit acbb416

Please sign in to comment.