Exemple #1
0
func (s *ControlIntSuite) TestStartStop(c *C) {
	if err := helper.RunGonitCmd("start all", s.ctrlCfgDir); err != nil {
		c.Errorf(err.Error())
	}

	pid1, err := helper.ProxyReadPidFile(controlPidFile1)
	c.Check(err, IsNil)
	pid2, err := helper.ProxyReadPidFile(controlPidFile2)
	c.Check(err, IsNil)

	c.Check(helper.DoesProcessExist(pid1), Equals, true)
	c.Check(helper.DoesProcessExist(pid2), Equals, true)
	if err := helper.RunGonitCmd("stop all", s.ctrlCfgDir); err != nil {
		c.Errorf(err.Error())
	}
	c.Check(helper.DoesProcessExist(pid1), Equals, false)
	c.Check(helper.DoesProcessExist(pid2), Equals, false)
}
Exemple #2
0
func (s *ControlIntSuite) TestRestart(c *C) {
	if err := helper.RunGonitCmd("start all", s.ctrlCfgDir); err != nil {
		c.Errorf(err.Error())
	}

	firstPid1, err := helper.ProxyReadPidFile(controlPidFile1)
	c.Check(err, IsNil)
	firstPid2, err := helper.ProxyReadPidFile(controlPidFile2)
	c.Check(err, IsNil)

	c.Check(helper.DoesProcessExist(firstPid1), Equals, true)
	c.Check(helper.DoesProcessExist(firstPid2), Equals, true)
	if err := helper.RunGonitCmd("restart all", s.ctrlCfgDir); err != nil {
		c.Errorf(err.Error())
	}

	secondPid1, err := helper.ProxyReadPidFile(controlPidFile1)
	c.Check(err, IsNil)
	secondPid2, err := helper.ProxyReadPidFile(controlPidFile2)
	c.Check(err, IsNil)

	c.Check(helper.DoesProcessExist(secondPid1), Equals, true)
	c.Check(helper.DoesProcessExist(secondPid2), Equals, true)
	c.Check(helper.DoesProcessExist(firstPid1), Equals, false)
	c.Check(helper.DoesProcessExist(firstPid2), Equals, false)
	c.Check(firstPid1, Not(Equals), secondPid1)
	c.Check(firstPid2, Not(Equals), secondPid2)
}
func (s *EventIntSuite) TestRestartRule(c *C) {
	if err := helper.RunGonitCmd("start all", s.eventCfgDir); err != nil {
		c.Errorf(err.Error())
	}

	balloonPid, err := helper.ProxyReadPidFile(balloonPidFile)
	c.Check(err, IsNil)
	c.Check(helper.DoesProcessExist(balloonPid), Equals, true)
	pid1, _ := helper.ProxyReadPidFile(balloonPidFile)
	c.Check(true, Equals,
		helper.FindLogLine(s.stdout, "Executing 'restart'", "20s"))
	c.Check(true, Equals,
		helper.FindLogLine(s.stdout, "process \"balloonmem0\" started", "10s"))
	balloonPid, err = helper.ProxyReadPidFile(balloonPidFile)
	c.Check(err, IsNil)
	c.Check(helper.DoesProcessExist(balloonPid), Equals, true)
	pid2, err := helper.ProxyReadPidFile(balloonPidFile)
	if err != nil {
		c.Errorf(err.Error())
	}
	c.Check(pid1, Not(Equals), pid2)
}