github.com/cloudfoundry-attic/garden-linux@v0.333.2-candidate/integration/lifecycle/grace_time_test.go (about)

     1  package lifecycle_test
     2  
     3  import (
     4  	"github.com/cloudfoundry-incubator/garden"
     5  	. "github.com/onsi/ginkgo"
     6  	. "github.com/onsi/gomega"
     7  )
     8  
     9  var _ = Describe("A container with a grace time", func() {
    10  	var container garden.Container
    11  
    12  	BeforeEach(func() {
    13  		client = startGarden("--containerGraceTime", "3s")
    14  
    15  		var err error
    16  
    17  		container, err = client.Create(garden.ContainerSpec{})
    18  		Expect(err).ToNot(HaveOccurred())
    19  	})
    20  
    21  	Context("when a request takes longer than the grace time", func() {
    22  		It("is not destroyed after the request is over", func() {
    23  			process, err := container.Run(garden.ProcessSpec{
    24  				User: "alice",
    25  				Path: "sleep",
    26  				Args: []string{"5"},
    27  			}, garden.ProcessIO{})
    28  			Expect(err).ToNot(HaveOccurred())
    29  
    30  			Expect(process.Wait()).To(Equal(0))
    31  
    32  			_, err = container.Info()
    33  			Expect(err).ToNot(HaveOccurred())
    34  		})
    35  	})
    36  
    37  	Context("when no requests are made for longer than the grace time", func() {
    38  		It("is destroyed", func() {
    39  			Eventually(func() error {
    40  				_, err := client.Lookup(container.Handle())
    41  				return err
    42  			}, 10, 1).Should(HaveOccurred())
    43  		})
    44  	})
    45  })