예제 #1
0
func (s *ApiIntSuite) SetUpSuite(c *C) {
	s.procs = make(map[string]*gonit.Process)
	s.addProcess("sleepy", []string{"-s", "1h"})
	s.addProcess("dopey", []string{"-w", "5s", "-s", "1h"})
	s.addProcess("grumpy", []string{"-x", "1", "-s", "1s"})

	s.dir = c.MkDir()

	s.settings = helper.CreateGonitSettings("", s.dir, s.dir)

	helper.CreateProcessGroupCfg("api_test", s.dir,
		&gonit.ProcessGroup{Processes: s.procs})

	var err error
	s.gonitCmd, _, err = helper.StartGonit(s.dir)
	if err != nil {
		c.Errorf(err.Error())
	}

	s.client, err = jsonrpc.Dial("unix", s.settings.RpcServerUrl)
	if err != nil {
		c.Errorf("rpc.Dial: %v", err)
	}

	pgs, err := s.statusGroup("api_test")
	c.Assert(err, IsNil)
	c.Assert(pgs.Group, HasLen, len(s.procs))
	for _, ps := range pgs.Group {
		c.Assert(ps.Summary.Running, Equals, false)
	}
}
예제 #2
0
func (s *EventIntSuite) SetUpTest(c *C) {
	s.eventCfgDir = integrationDir + "/tmp/process_tmp"
	if err := os.MkdirAll(s.eventCfgDir, 0755); err != nil {
		c.Errorf(err.Error())
	}
	balloonPidFile = s.eventCfgDir + "/balloonmem0.pid"
	err := helper.CreateGonitCfg(1, "balloonmem", "./process_tmp", "./goprocess",
		true)
	if err != nil {
		c.Errorf(err.Error())
	}
	helper.CreateGonitSettings("./gonit.pid", "./", "./process_tmp")
	s.gonitCmd, s.stdout, err = helper.StartGonit(s.eventCfgDir)
	if err != nil {
		c.Errorf(err.Error())
	}
}
예제 #3
0
func (s *DependsIntSuite) SetUpSuite(c *C) {
	s.procs = make(map[string]*gonit.Process)
	s.addProcess("nginx")
	s.addProcess("postgres")
	s.addProcess("redis")
	s.addProcess("nats")

	s.addProcess("director").DependsOn = []string{"postgres", "redis", "nats"}

	for i := 0; i < 3; i++ {
		worker := fmt.Sprintf("worker_%d", i)
		s.addProcess(worker).DependsOn = []string{"director"}
	}

	s.addProcess("aws_registry").DependsOn = []string{"postgres"}

	s.dir = c.MkDir()

	s.settings = helper.CreateGonitSettings("", s.dir, s.dir)

	helper.CreateProcessGroupCfg("bosh", s.dir, &gonit.ProcessGroup{Processes: s.procs})

	vcap := make(map[string]*gonit.Process)
	for _, name := range []string{"dea", "router", "stager"} {
		vcap[name] = s.addProcess(name)
	}

	helper.CreateProcessGroupCfg("vcap", s.dir, &gonit.ProcessGroup{Processes: vcap})

	var err error
	var stdout io.Reader
	s.gonitCmd, stdout, err = helper.StartGonit(s.dir)
	// TODO: log Writes block when the pipe buffer is full,
	// so we must drain the pipe here
	go io.Copy(ioutil.Discard, stdout)

	if err != nil {
		c.Errorf(err.Error())
	}

	s.client, err = jsonrpc.Dial("unix", s.settings.RpcServerUrl)
	if err != nil {
		c.Errorf("rpc.Dial: %v", err)
	}
}
예제 #4
0
func (s *ControlIntSuite) SetUpTest(c *C) {
	s.ctrlCfgDir = integrationDir + "/tmp/process_tmp"
	if err := os.MkdirAll(s.ctrlCfgDir, 0755); err != nil {
		c.Errorf(err.Error())
	}
	controlPidFile1 = s.ctrlCfgDir + "/control0.pid"
	controlPidFile2 = s.ctrlCfgDir + "/control1.pid"
	err := helper.CreateGonitCfg(2, "control", "./process_tmp", "./goprocess",
		false)
	if err != nil {
		c.Errorf(err.Error())
	}
	helper.CreateGonitSettings("./gonit.pid", "./", "./process_tmp")
	s.gonitCmd, _, err = helper.StartGonit(s.ctrlCfgDir)
	if err != nil {
		c.Errorf(err.Error())
	}
}
예제 #5
0
func (s *WatcherIntSuite) SetUpTest(c *C) {
	s.procs = make(map[string]*gonit.Process)
	s.addProcess("active", nil)
	s.addProcess("manual", nil).MonitorMode = gonit.MONITOR_MODE_MANUAL
	s.addProcess("passive", nil).MonitorMode = gonit.MONITOR_MODE_PASSIVE

	s.dir = c.MkDir()
	s.settings = helper.CreateGonitSettings("", s.dir, s.dir)
	os.Remove(s.settings.PersistFile)

	helper.CreateProcessGroupCfg("watch", s.dir,
		&gonit.ProcessGroup{Processes: s.procs})

	var err error
	s.gonitCmd, _, err = helper.StartGonit(s.dir)
	if err != nil {
		c.Errorf(err.Error())
	}
}