github.com/cloudfoundry-attic/garden-linux@v0.333.2-candidate/integration/lifecycle/lifecycle_suite_test.go (about) 1 package lifecycle_test 2 3 import ( 4 "os" 5 "testing" 6 "time" 7 8 "github.com/cloudfoundry-incubator/garden" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 "github.com/onsi/gomega/gexec" 12 13 "github.com/cloudfoundry-incubator/garden-linux/integration/runner" 14 ) 15 16 var shmTestBin string 17 18 var client *runner.RunningGarden 19 20 func startGarden(argv ...string) *runner.RunningGarden { 21 return runner.Start(argv...) 22 } 23 24 func restartGarden(argv ...string) { 25 Expect(client.Ping()).To(Succeed(), "tried to restart garden while it was not running") 26 Expect(client.Stop()).To(Succeed()) 27 client = startGarden(argv...) 28 } 29 30 func TestLifecycle(t *testing.T) { 31 SynchronizedBeforeSuite(func() []byte { 32 shmPath, err := gexec.Build("github.com/cloudfoundry-incubator/garden-linux/integration/lifecycle/shm_test") 33 Expect(err).ToNot(HaveOccurred()) 34 return []byte(shmPath) 35 }, func(path []byte) { 36 Expect(string(path)).NotTo(BeEmpty()) 37 shmTestBin = string(path) 38 }) 39 40 BeforeEach(func() { 41 if os.Getenv("GARDEN_TEST_ROOTFS") == "" { 42 Skip("GARDEN_TEST_ROOTFS undefined") 43 } 44 }) 45 46 AfterEach(func() { 47 Expect(client.DestroyAndStop()).To(Succeed()) 48 Expect(client.Cleanup()).To(Succeed()) 49 }) 50 51 SynchronizedAfterSuite(func() { 52 //noop 53 }, func() { 54 gexec.CleanupBuildArtifacts() 55 }) 56 57 SetDefaultEventuallyTimeout(5 * time.Second) // CI is sometimes slow 58 59 RegisterFailHandler(Fail) 60 RunSpecs(t, "Lifecycle Suite") 61 } 62 63 func containerIP(ctr garden.Container) string { 64 info, err := ctr.Info() 65 Expect(err).ToNot(HaveOccurred()) 66 return info.ContainerIP 67 }