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) } }
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) } }
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()) } }