Beispiel #1
0
func createVolmanServer(logger lager.Logger, atAddress string, driverPaths string) grouper.Members {
	if driverPaths == "" {
		panic("'-volmanDriverPaths' must be provided")
	}

	cfg := vollocal.NewDriverConfig()
	cfg.DriverPaths = filepath.SplitList(driverPaths)
	client, runner := vollocal.NewServer(logger, cfg)

	handler, err := volhttp.NewHandler(logger, client)
	exitOnFailure(logger, err)

	return grouper.Members{
		{"driver-syncer", runner},
		{"http-server", http_server.New(atAddress, handler)},
	}
}
	"code.cloudfoundry.org/volman/volhttp"

	"code.cloudfoundry.org/lager/lagertest"
	"code.cloudfoundry.org/volman/volmanfakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Volman Handlers", func() {

	Context("when generating http handlers", func() {

		It("should produce handler with list drivers route", func() {
			testLogger := lagertest.NewTestLogger("HandlersTest")
			client := &volmanfakes.FakeManager{}
			handler, _ := volhttp.NewHandler(testLogger, client)
			w := httptest.NewRecorder()
			r, _ := http.NewRequest("GET", "http://0.0.0.0/drivers", nil)
			handler.ServeHTTP(w, r)
			Expect(w.Body.String()).Should(Equal("{\"drivers\":null}"))
			Expect(w.Code).Should(Equal(200))
		})

		It("should produce handler with mount route", func() {
			testLogger := lagertest.NewTestLogger("HandlersTest")
			client := &volmanfakes.FakeManager{}
			client.MountReturns(volman.MountResponse{"dummy_path"}, nil)
			handler, _ := volhttp.NewHandler(testLogger, client)
			w := httptest.NewRecorder()
			MountRequest := volman.MountRequest{}