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

     1  package lifecycle_test
     2  
     3  import (
     4  	"os"
     5  	"syscall"
     6  
     7  	"github.com/cloudfoundry-incubator/garden"
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  )
    11  
    12  var _ = Describe("Ping", func() {
    13  	Context("When a garden linux server is started", func() {
    14  		BeforeEach(func() {
    15  			client = startGarden()
    16  		})
    17  
    18  		It("should successfully ping", func() {
    19  			Expect(client.Ping()).To(Succeed())
    20  		})
    21  	})
    22  
    23  	Context("When a garden linux server is started with an untennable graph directory", func() {
    24  		BeforeEach(func() {
    25  			client = startGarden()
    26  			Expect(os.MkdirAll(client.GraphPath, 0755)).To(Succeed())
    27  			Expect(syscall.Mount("tmpfs", client.GraphPath, "tmpfs", syscall.MS_RDONLY, "")).To(Succeed())
    28  		})
    29  
    30  		AfterEach(func() {
    31  			Expect(syscall.Unmount(client.GraphPath, 0)).To(Succeed())
    32  		})
    33  
    34  		It("should fail when pinged", func() {
    35  			err := client.Ping()
    36  			Expect(err).NotTo(BeNil())
    37  			Expect(err).To(BeAssignableToTypeOf(garden.NewUnrecoverableError("")))
    38  			Expect(err.Error()).To(MatchRegexp("graph directory '%s' is not writeable:.*", client.GraphPath))
    39  		})
    40  	})
    41  })