func (s *systemtestSuite) SetUpSuite(c *C) { logrus.Infof("Bootstrapping system tests") s.vagrant = vagrantssh.Vagrant{} nodesStr := os.Getenv("CONTIV_NODES") var nodes int if nodesStr == "" { nodes = 2 } else { var err error nodes, err = strconv.Atoi(nodesStr) if err != nil { c.Fatal(err) } } s.nodes = []*node{} c.Assert(s.vagrant.Setup(false, "", nodes), IsNil) for _, nodeObj := range s.vagrant.GetNodes() { s.nodes = append(s.nodes, &node{tbnode: nodeObj, suite: s}) } logrus.Info("Pulling alpine on all nodes") s.vagrant.IterateNodes(func(node vagrantssh.TestbedNode) error { return node.RunCommand("docker pull alpine") }) s.cli, _ = client.NewContivClient("http://localhost:9999") }
func getClient(ctx *cli.Context) *contivClient.ContivClient { cl, err := contivClient.NewContivClient(ctx.GlobalString("netmaster")) if err != nil { errExit(ctx, 1, "Error connecting to netmaster", false) } return cl }
func (s *systemtestSuite) SetUpSuite(c *C) { logrus.Infof("Bootstrapping system tests") s.basicInfo, s.hostInfo, s.globInfo = getInfo("cfg.json") switch s.basicInfo.Platform { case "baremetal": s.SetUpSuiteBaremetal(c) case "vagrant": s.SetUpSuiteVagrant(c) } s.cli, _ = client.NewContivClient("http://localhost:9999") }
// setup the test netmaster REST server and client func TestMain(m *testing.M) { var err error // Setup state store stateStore, err = initStateDriver() if err != nil { log.Fatalf("Error initializing state store. Err: %v", err) } // little hack to clear all state from etcd stateStore.(*state.EtcdStateDriver).Client.Delete("/contiv.io", true) // Setup resource manager if _, err = resources.NewStateResourceManager(stateStore); err != nil { log.Fatalf("Failed to init resource manager. Error: %s", err) } router := mux.NewRouter() // Create a new api controller apiController = NewAPIController(router) ofnetMaster := ofnet.NewOfnetMaster(ofnet.OFNET_MASTER_PORT) if ofnetMaster == nil { log.Fatalf("Error creating ofnet master") } // initialize policy manager mastercfg.InitPolicyMgr(stateStore, ofnetMaster) // Create HTTP server go http.ListenAndServe(netmasterTestListenURL, router) time.Sleep(time.Second) // create a new contiv client contivClient, err = client.NewContivClient(netmasterTestURL) if err != nil { log.Fatalf("Error creating contiv client. Err: %v", err) } // Create default tenant createDefaultTenant() exitCode := m.Run() if exitCode == 0 { cleanupState() } os.Exit(exitCode) }
func (its *integTestSuite) SetUpSuite(c *C) { log.Infof("Bootstrapping integration tests") // clear all etcd state before running the tests exec.Command("etcdctl", "rm", "--recursive", "/contiv.io").Output() npcluster, err := NewNPCluster(its.fwdMode, its.clusterStore) assertNoErr(err, c, "creating cluster") // create a new contiv client contivClient, err := client.NewContivClient("http://localhost:9999") assertNoErr(err, c, "creating contivmodel client") // setup test suite its.npcluster = npcluster its.client = contivClient }
func (s *systemtestSuite) SetUpSuite(c *C) { logrus.Infof("Bootstrapping system tests") s.vagrant = vagrantssh.Vagrant{} nodesStr := os.Getenv("CONTIV_NODES") var contivNodes int if nodesStr == "" { contivNodes = 2 } else { var err error contivNodes, err = strconv.Atoi(nodesStr) if err != nil { c.Fatal(err) } } s.nodes = []*node{} if s.scheduler == "k8" { s.KubeNodeSetup(c) } if s.fwdMode == "routing" { contivL3Nodes := 2 c.Assert(s.vagrant.Setup(false, "CONTIV_NODES=3 CONTIV_L3=2", contivNodes+contivL3Nodes), IsNil) } else { c.Assert(s.vagrant.Setup(false, "", contivNodes), IsNil) } for _, nodeObj := range s.vagrant.GetNodes() { nodeName := nodeObj.GetName() if strings.Contains(nodeName, "netplugin-node") { s.nodes = append(s.nodes, &node{tbnode: nodeObj, suite: s}) } } logrus.Info("Pulling alpine on all nodes") s.vagrant.IterateNodes(func(node vagrantssh.TestbedNode) error { node.RunCommand("sudo rm /tmp/net*") return node.RunCommand("docker pull alpine") }) s.cli, _ = client.NewContivClient("http://localhost:9999") }
func (s *systemtestSuite) SetUpSuite(c *C) { logrus.Infof("Bootstrapping system tests") if os.Getenv("ACI_SYS_TEST_MODE") == "ON" { logrus.Infof("ACI_SYS_TEST_MODE is ON") logrus.Infof("Private keyFile = %s", s.keyFile) logrus.Infof("Binary binpath = %s", s.binpath) logrus.Infof("Interface vlanIf = %s", s.vlanIf) s.baremetal = remotessh.Baremetal{} bm := &s.baremetal // To fill the hostInfo data structure for Baremetal VMs name := "aci-swarm-node" hostIPs := strings.Split(os.Getenv("HOST_IPS"), ",") hostNames := strings.Split(os.Getenv("HOST_USER_NAMES"), ",") hosts := make([]remotessh.HostInfo, 2) for i := range hostIPs { hosts[i].Name = name + strconv.Itoa(i+1) logrus.Infof("Name=%s", hosts[i].Name) hosts[i].SSHAddr = hostIPs[i] logrus.Infof("SHAddr=%s", hosts[i].SSHAddr) hosts[i].SSHPort = "22" hosts[i].User = hostNames[i] logrus.Infof("User=%s", hosts[i].User) hosts[i].PrivKeyFile = s.keyFile logrus.Infof("PrivKeyFile=%s", hosts[i].PrivKeyFile) } c.Assert(bm.Setup(hosts), IsNil) s.nodes = []*node{} for _, nodeObj := range s.baremetal.GetNodes() { s.nodes = append(s.nodes, &node{tbnode: nodeObj, suite: s}) } logrus.Info("Pulling contiv/alpine on all nodes") s.baremetal.IterateNodes(func(node remotessh.TestbedNode) error { node.RunCommand("sudo rm /tmp/*net*") return node.RunCommand("docker pull contiv/alpine") }) //Copying binaries s.copyBinary("netmaster") s.copyBinary("netplugin") s.copyBinary("netctl") s.copyBinary("contivk8s") } else { s.vagrant = remotessh.Vagrant{} nodesStr := os.Getenv("CONTIV_NODES") var contivNodes int if nodesStr == "" { contivNodes = 3 } else { var err error contivNodes, err = strconv.Atoi(nodesStr) if err != nil { c.Fatal(err) } } s.nodes = []*node{} if s.fwdMode == "routing" { contivL3Nodes := 2 if s.scheduler == "k8" { topDir := os.Getenv("GOPATH") //topDir contains the godeps path. hence purging the gopath topDir = strings.Split(topDir, ":")[1] contivNodes = 4 // 3 contiv nodes + 1 k8master c.Assert(s.vagrant.Setup(false, []string{"CONTIV_L3=1 VAGRANT_CWD=" + topDir + "/src/github.com/contiv/netplugin/vagrant/k8s/"}, contivNodes), IsNil) } else { c.Assert(s.vagrant.Setup(false, []string{"CONTIV_NODES=3 CONTIV_L3=1"}, contivNodes+contivL3Nodes), IsNil) } } else { if s.scheduler == "k8" { contivNodes = contivNodes + 1 //k8master topDir := os.Getenv("GOPATH") //topDir may contain the godeps path. hence purging the gopath dirs := strings.Split(topDir, ":") if len(dirs) > 1 { topDir = dirs[1] } else { topDir = dirs[0] } c.Assert(s.vagrant.Setup(false, []string{"VAGRANT_CWD=" + topDir + "/src/github.com/contiv/netplugin/vagrant/k8s/"}, contivNodes), IsNil) } else { c.Assert(s.vagrant.Setup(false, []string{}, contivNodes), IsNil) } } for _, nodeObj := range s.vagrant.GetNodes() { nodeName := nodeObj.GetName() if strings.Contains(nodeName, "netplugin-node") || strings.Contains(nodeName, "k8") { node := &node{} node.tbnode = nodeObj node.suite = s switch s.scheduler { case "k8": node.exec = s.NewK8sExec(node) default: node.exec = s.NewDockerExec(node) } s.nodes = append(s.nodes, node) } } logrus.Info("Pulling contiv/alpine on all nodes") s.vagrant.IterateNodes(func(node remotessh.TestbedNode) error { node.RunCommand("sudo rm /tmp/net*") return node.RunCommand("docker pull contiv/alpine") }) } s.cli, _ = client.NewContivClient("http://localhost:9999") }