Ejemplo n.º 1
0
func (s *S) TestAddBackendRollbackOnError(c *check.C) {
	s.vulcandServer.Close()
	scrollApp := scroll.NewApp()
	var postRequestCount int
	conditionalHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if r.Method == "POST" {
			postRequestCount++
			if postRequestCount > 1 {
				w.WriteHeader(http.StatusInternalServerError)
				return
			}
		}
		scrollApp.GetHandler().ServeHTTP(w, r)
	})
	api.InitProxyController(s.engine, &supervisor.Supervisor{}, scrollApp)
	s.vulcandServer = httptest.NewServer(conditionalHandler)
	config.Set("routers:vulcand:api-url", s.vulcandServer.URL)
	vRouter, err := router.Get("vulcand")
	c.Assert(err, check.IsNil)
	err = vRouter.AddBackend("myapp")
	c.Assert(err, check.NotNil)
	backends, err := s.engine.GetBackends()
	c.Assert(err, check.IsNil)
	c.Assert(backends, check.HasLen, 0)
	frontends, err := s.engine.GetFrontends()
	c.Assert(err, check.IsNil)
	c.Assert(frontends, check.HasLen, 0)
}
Ejemplo n.º 2
0
func (s *S) SetUpTest(c *check.C) {
	var err error
	s.conn, err = db.Conn()
	c.Assert(err, check.IsNil)
	dbtest.ClearAllCollections(s.conn.Collection("router_vulcand_tests").Database)
	s.engine = memng.New(registry.GetRegistry())
	scrollApp := scroll.NewApp()
	api.InitProxyController(s.engine, &supervisor.Supervisor{}, scrollApp)
	s.vulcandServer = httptest.NewServer(scrollApp.GetHandler())
	config.Set("routers:vulcand:api-url", s.vulcandServer.URL)
}
Ejemplo n.º 3
0
func (s *CmdSuite) SetUpTest(c *C) {
	s.ng = memng.New(registry.GetRegistry())

	newProxy := func(id int) (proxy.Proxy, error) {
		return proxy.New(id, stapler.New(), proxy.Options{})
	}

	sv := supervisor.New(newProxy, s.ng, make(chan error), supervisor.Options{})
	sv.Start()
	s.sv = sv

	app := scroll.NewApp()
	api.InitProxyController(s.ng, sv, app)
	s.testServer = httptest.NewServer(app.GetHandler())

	s.out = &bytes.Buffer{}
	s.cmd = &Command{registry: registry.GetRegistry(), out: s.out, vulcanUrl: s.testServer.URL}
}
Ejemplo n.º 4
0
func (s *Service) initApi() error {
	s.apiApp = scroll.NewApp()
	api.InitProxyController(s.ng, s.supervisor, s.apiApp)
	return nil
}
Ejemplo n.º 5
0
func (s *Service) initApi() error {
	s.apiRouter = mux.NewRouter()
	api.InitProxyController(s.backend, adapter.NewAdapter(s.proxy), s.configurator.GetConnWatcher(), s.apiRouter)
	return nil
}
Ejemplo n.º 6
0
func (s *Service) configureApi() error {
	s.apiRouter = mux.NewRouter()
	api.InitProxyController(s.backend, s.apiRouter)
	return nil
}