func (s *GardenServer) Start() error { s.started = true err := s.removeExistingSocket() if err != nil { return err } err = s.backend.Start() if err != nil { return err } listener, err := net.Listen(s.listenNetwork, s.listenAddr) if err != nil { return err } s.listener = listener if s.listenNetwork == "unix" { os.Chmod(s.listenAddr, 0777) } containers, err := s.backend.Containers(nil) if err != nil { return err } s.bomberman = bomberman.New(s.backend, s.reapContainer) for _, container := range containers { s.bomberman.Strap(container) } go s.server.Serve(listener) return nil }
"time" "code.cloudfoundry.org/garden" fakes "code.cloudfoundry.org/garden/gardenfakes" "code.cloudfoundry.org/garden/server/bomberman" ) var _ = Describe("Bomberman", func() { It("straps a bomb to the given container with the container's grace time as the countdown", func() { detonated := make(chan garden.Container) backend := new(fakes.FakeBackend) backend.GraceTimeReturns(100 * time.Millisecond) bomberman := bomberman.New(backend, func(container garden.Container) { detonated <- container }) container := new(fakes.FakeContainer) container.HandleReturns("doomed") bomberman.Strap(container) select { case <-detonated: case <-time.After(backend.GraceTime(container) + 50*time.Millisecond): Fail("did not detonate!") } }) Context("when the container has a grace time of 0", func() {