Beispiel #1
0
func (s *SystemTestSuite) waitForStatToFail(c *C, nut vagrantssh.TestbedNode, file string) {
	out, err := tutils.WaitForDone(func() (string, bool) {
		cmdStr := fmt.Sprintf("stat -t %s", file)
		out, err := nut.RunCommandWithOutput(cmdStr)
		if err == nil {
			return out, false
		}
		return out, true
	}, 1*time.Second, 10*time.Second, fmt.Sprintf("file %q still seems to exist", file))
	s.Assert(c, err, IsNil, Commentf("output: %s", out))
}
Beispiel #2
0
func (s *SystemTestSuite) waitForSerfMembership(c *C, nut vagrantssh.TestbedNode, nodeName, state string) {
	out, err := tutils.WaitForDone(func() (string, bool) {
		out, err := nut.RunCommandWithOutput(`serf members`)
		if err != nil {
			return out, false
		}
		stateStr := fmt.Sprintf(`%s.*%s.*`, nodeName, state)
		if match, err := regexp.MatchString(stateStr, out); err != nil || !match {
			return out, false
		}
		return out, true
	}, 1*time.Second, time.Duration(10)*time.Second,
		fmt.Sprintf("%s's serf membership is not in %s state", nodeName, state))
	s.Assert(c, err, IsNil, Commentf("output: %s", out))
}
Beispiel #3
0
func (s *SystemTestSuite) checkProvisionStatus(c *C, tbn1 vagrantssh.TestbedNode, nodeName, exptdStatus string) {
	exptdStr := fmt.Sprintf(`.*"status".*"%s".*`, exptdStatus)
	out, err := tutils.WaitForDone(func() (string, bool) {
		cmdStr := fmt.Sprintf("clusterctl node get %s --json", nodeName)
		out, err := tbn1.RunCommandWithOutput(cmdStr)
		if err != nil {
			return out, false
			//replace newline with empty string for regex to match properly
		} else if match, err := regexp.MatchString(exptdStr,
			strings.Replace(out, "\n", "", -1)); err == nil && match {
			return out, true
		}
		return out, false
	}, 1*time.Second, 30*time.Second, fmt.Sprintf("node is still not in %q status", exptdStatus))
	s.Assert(c, err, IsNil, Commentf("output: %s", out))
}