Exemple #1
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) 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"))
}
Exemple #3
0
func (d *groupHelper) runCmd(name string) error {
	cmd := ""
	if !d.isAll() {
		cmd += "-g "
	}
	cmd += name + " " + d.name
	return helper.RunGonitCmd(cmd, d.suite.dir)
}
Exemple #4
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 #5
0
func (s *WatcherIntSuite) TestStart(c *C) {
	c.Check(s.procs["active"].IsRunning(), Equals, true)
	c.Check(s.procs["manual"].IsRunning(), Equals, false)
	c.Check(s.procs["passive"].IsRunning(), Equals, false)

	helper.RunGonitCmd("start all", s.dir)
	for _, process := range s.procs {
		c.Check(process.IsRunning(), Equals, true)
	}
}
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)
}
Exemple #7
0
func (s *DependsIntSuite) TestProcessDependencies(c *C) {
	var err error
	bosh := s.newGroupHelper("bosh")
	process := s.procs["director"]

	// stop all bosh processes
	err = bosh.runCmd("stop")
	c.Assert(err, IsNil)

	err = bosh.status(bosh.before)
	c.Assert(err, IsNil)

	// check all processes are stopped
	for _, bg := range bosh.before {
		current := bg.Summary
		comment := Commentf("process: %s", current.Name)
		c.Check(current.Running, Equals, false, comment)
	}

	// start director process
	err = helper.RunGonitCmd("start director", s.dir)
	c.Assert(err, IsNil)

	err = bosh.status(bosh.after)
	c.Assert(err, IsNil)

	bosh.compare(func(previous, current *gonit.ProcessSummary) {
		running := false
		delta := 0
		// only director and its dependencies should start
		if current.Name == process.Name || dependsOn(process, current.Name) {
			running = true
			delta = 1
		}
		comment := Commentf("process: %s", current.Name)
		c.Assert(previous.Name, Equals, current.Name)
		c.Check(current.Running, Equals, running, comment)
		c.Check(current.ControlState.Starts, Equals, previous.ControlState.Starts+delta, comment)
	})

	bosh.before = bosh.after
	// restart a director dependency
	err = helper.RunGonitCmd("restart "+process.DependsOn[0], s.dir)
	c.Assert(err, IsNil)

	err = bosh.status(bosh.after)
	c.Assert(err, IsNil)

	bosh.compare(func(previous, current *gonit.ProcessSummary) {
		running := false
		delta := 0
		// only director and its dependencies should be running
		if current.Name == process.Name || dependsOn(process, current.Name) {
			running = true
		}
		// only director and restarted dependency should restart
		if current.Name == process.Name || current.Name == process.DependsOn[0] {
			delta = 1
		}

		comment := Commentf("process: %s", current.Name)
		c.Assert(previous.Name, Equals, current.Name)
		c.Check(current.Running, Equals, running, comment)
		c.Check(current.ControlState.Starts, Equals, previous.ControlState.Starts+delta, comment)
	})

	bosh.before = bosh.after
	// stop director process
	err = helper.RunGonitCmd("stop director", s.dir)
	c.Assert(err, IsNil)

	err = bosh.status(bosh.after)
	c.Assert(err, IsNil)

	bosh.compare(func(previous, current *gonit.ProcessSummary) {
		running := false
		// only director dependencies should still be running
		if dependsOn(process, current.Name) {
			running = true
		}
		comment := Commentf("process: %s", current.Name)
		c.Assert(previous.Name, Equals, current.Name)
		c.Check(current.Running, Equals, running, comment)
		c.Check(current.ControlState.Starts, Equals, previous.ControlState.Starts, comment)
	})
}