func (s *systemtestSuite) CheckBgpNoConnectionForaNode(c *C, node remotessh.TestbedNode) error { for i := 0; i < 100; i++ { time.Sleep(3 * time.Second) out, _ := node.RunCommandWithOutput("/opt/gopath/bin/gobgp neighbor") fmt.Println(out) if !strings.Contains(out, "Establ") { return nil } } return errors.New("BGP connection persists") }
func waitDockerizedServicesHost(node remotessh.TestbedNode) error { services := map[string]string{ "etcd": "etcdctl cluster-health", } for s, cmd := range services { logrus.Infof("Waiting for %s on %q", s, node.GetName()) out, err := WaitForDone( func() (string, bool) { out, err := node.RunCommandWithOutput(cmd) if err != nil { return out, false } return out, true }, 2*time.Second, time.Minute, fmt.Sprintf("service %s is not healthy", s)) if err != nil { logrus.Infof("a dockerized service failed. Output: %s, Error: %v", out, err) return err } } return nil }
//ServiceStatus queries and returns status result of systemd service unit func ServiceStatus(n remotessh.TestbedNode, srv string) (string, error) { return n.RunCommandWithOutput(fmt.Sprintf("systemctl status %s", srv)) }
//ServiceLogs queries and returns upto maxLogLines lines from systemd service unit logs func ServiceLogs(n remotessh.TestbedNode, srv string, maxLogLines int) (string, error) { return n.RunCommandWithOutput(fmt.Sprintf("sudo systemctl status -ln%d %s", maxLogLines, srv)) }
//ServiceRestart restarts a systemd service unit func ServiceRestart(n remotessh.TestbedNode, srv string) (string, error) { return n.RunCommandWithOutput(fmt.Sprintf("sudo systemctl restart %s", srv)) }