Beispiel #1
0
func (s *EventIntSuite) TestAlertRule(c *C) {
	if err := helper.RunGonitCmd("start all", s.eventCfgDir); err != nil {
		c.Errorf(err.Error())
	}
	c.Check(true, Equals, helper.FindLogLine(s.stdout,
		"'balloonmem0' triggered 'memory_used > 1mb' for '1s'", "5s"))
}
Beispiel #2
0
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)
}