github.com/cloudfoundry-attic/garden-linux@v0.333.2-candidate/integration/lifecycle/container_info_linux_test.go (about) 1 package lifecycle_test 2 3 import ( 4 "os" 5 "syscall" 6 7 "github.com/cloudfoundry-incubator/garden" 8 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("Container information", func() { 14 15 BeforeEach(func() { 16 client = startGarden() 17 }) 18 19 Describe("for many containers", func() { 20 handles := []string{"handle1", "handle2"} 21 BeforeEach(func() { 22 _, err := client.Create(garden.ContainerSpec{ 23 Handle: "handle1", 24 }) 25 Expect(err).ToNot(HaveOccurred()) 26 _, err = client.Create(garden.ContainerSpec{ 27 Handle: "handle2", 28 }) 29 Expect(err).ToNot(HaveOccurred()) 30 }) 31 32 Describe(".BulkInfo", func() { 33 It("returns container info for the specified handles", func() { 34 bulkInfo, err := client.BulkInfo(handles) 35 Expect(err).ToNot(HaveOccurred()) 36 Expect(bulkInfo).To(HaveLen(2)) 37 for _, containerInfoEntry := range bulkInfo { 38 Expect(containerInfoEntry.Err).ToNot(HaveOccurred()) 39 } 40 }) 41 }) 42 43 Describe(".BulkMetrics", func() { 44 BeforeEach(ensureSysfsMounted) 45 46 It("returns container metrics for the specified handles", func() { 47 bulkInfo, err := client.BulkMetrics(handles) 48 Expect(err).ToNot(HaveOccurred()) 49 Expect(bulkInfo).To(HaveLen(2)) 50 for _, containerMetricsEntry := range bulkInfo { 51 Expect(containerMetricsEntry.Err).ToNot(HaveOccurred()) 52 } 53 }) 54 }) 55 }) 56 }) 57 58 func ensureSysfsMounted() { 59 mntpoint, err := os.Stat("/sys") 60 Expect(err).ToNot(HaveOccurred()) 61 parent, err := os.Stat("/") 62 Expect(err).ToNot(HaveOccurred()) 63 64 if mntpoint.Sys().(*syscall.Stat_t).Dev == parent.Sys().(*syscall.Stat_t).Dev { 65 Expect(syscall.Mount("sysfs", "/sys", "sysfs", uintptr(0), "")).To(Succeed()) 66 } 67 }