示例#1
0
func (s *ProxySuite) SetUpTest(c *C) {
	x := config.DefaultConfig()
	s.r = NewRegistry(x)
	s.p = NewProxy(x, s.r, nullVarz{})

	s.done = make(chan bool)
}
示例#2
0
func SpecConfig(natsPort, statusPort, proxyPort uint16) *config.Config {
	c := config.DefaultConfig()
	c.Port = proxyPort
	c.Index = 2
	c.TraceKey = "my_trace_key"

	// Hardcode the IP to localhost to avoid leaving the machine while running tests
	c.Ip = "127.0.0.1"

	c.StartResponseDelayInterval = 10 * time.Millisecond
	c.PublishStartMessageIntervalInSeconds = 10
	c.PruneStaleDropletsInterval = 0
	c.DropletStaleThreshold = 0
	c.PublishActiveAppsInterval = 0

	c.Status = config.StatusConfig{
		Port: statusPort,
		User: "******",
		Pass: "******",
	}

	c.Nats = config.NatsConfig{
		Host: "localhost",
		Port: natsPort,
		User: "******",
		Pass: "******",
	}

	c.Logging = config.LoggingConfig{
		File:  "/dev/null",
		Level: "info",
	}

	return c
}
示例#3
0
func (s *RegistrySuite) SetUpTest(c *C) {
	var x *config.Config

	x = config.DefaultConfig()
	x.DropletStaleThreshold = 1

	s.Registry = NewRegistry(x)
}
示例#4
0
func (s *ProxySuite) SetUpTest(c *C) {
	x := config.DefaultConfig()
	x.TraceKey = "my_trace_key"

	mocksController := gomock.NewController(c)
	s.r = NewRegistry(x, test.NewMockCFMessageBus(mocksController))
	s.p = NewProxy(x, s.r, nullVarz{})

	s.done = make(chan bool)
}
示例#5
0
文件: main.go 项目: hfeeki/gorouter
func main() {
	c := config.DefaultConfig()
	if configFile != "" {
		c = config.InitConfigFromFile(configFile)
	}

	router.SetupLoggerFromConfig(c)

	router.NewRouter(c).Run()
}
示例#6
0
func (s *RegistrySuite) SetUpTest(c *C) {
	var configObj *config.Config

	configObj = config.DefaultConfig()
	configObj.DropletStaleThreshold = 1

	s.mocksController = gomock.NewController(c)
	s.messageBus = test.NewMockCFMessageBus(s.mocksController)

	s.Registry = NewRegistry(configObj, s.messageBus)
}
示例#7
0
func (s *LoggerSuite) TestSetupLoggerFromConfig(c *C) {
	cfg := config.DefaultConfig()
	cfg.Logging.File = "/tmp/gorouter.log"

	SetupLoggerFromConfig(cfg)

	count := logCounter.GetCount("info")
	logger := steno.NewLogger("test")
	logger.Info("Hello")
	c.Assert(logCounter.GetCount("info"), Equals, count+1)
}
示例#8
0
func BenchmarkRegister(b *testing.B) {
	p := NewProxy(NewVarz(), NewRegistry(config.DefaultConfig()))

	for i := 0; i < b.N; i++ {
		str := strconv.Itoa(i)
		rm := &registerMessage{
			Host: "localhost",
			Port: uint16(i),
			Uris: []Uri{Uri("bench.vcap.me." + str)},
		}
		p.Register(rm)
	}
}
示例#9
0
func BenchmarkRegister(b *testing.B) {
	c := config.DefaultConfig()
	mocksController := gomock.NewController(b)
	r := NewRegistry(c, test.NewMockCFMessageBus(mocksController))
	p := NewProxy(c, r, NewVarz(r))

	for i := 0; i < b.N; i++ {
		str := strconv.Itoa(i)
		rm := &registryMessage{
			Host: "localhost",
			Port: uint16(i),
			Uris: []Uri{Uri("bench.vcap.me." + str)},
		}
		p.Register(rm)
	}
}
示例#10
0
func (s *RouterSuite) SetUpSuite(c *C) {
	natsPort := nextAvailPort()
	s.natsServer = spec.NewNatsServer(natsPort, "/tmp/router_nats_test.pid")
	err := s.natsServer.Start()
	c.Assert(err, IsNil)

	s.proxyPort = nextAvailPort()
	statusPort := nextAvailPort()

	s.Config = config.DefaultConfig()

	s.Config.Port = s.proxyPort
	s.Config.Index = 2
	s.Config.TraceKey = "my_trace_key"

	// Hardcode the IP to localhost to avoid leaving the machine while running tests
	s.Config.Ip = "127.0.0.1"

	s.Config.PublishStartMessageInterval = 10 * time.Millisecond
	s.Config.PruneStaleDropletsInterval = 0
	s.Config.DropletStaleThreshold = 0
	s.Config.PublishActiveAppsInterval = 0

	s.Config.Status = config.StatusConfig{
		Port: statusPort,
		User: "******",
		Pass: "******",
	}

	s.Config.Nats = config.NatsConfig{
		Host: fmt.Sprintf("localhost:%d", natsPort),
	}

	s.Config.Logging = config.LoggingConfig{
		File:  "/dev/null",
		Level: "info",
	}

	s.router = NewRouter(s.Config)
	go s.router.Run()

	s.natsClient = startNATS(fmt.Sprintf("localhost:%d", natsPort), "", "")
}
示例#11
0
func (s *VarzSuite) SetUpTest(c *C) {
	s.Varz = NewVarz()
	s.Varz.Registry = NewRegistry(config.DefaultConfig())
}
示例#12
0
func (s *VarzSuite) SetUpTest(c *C) {
	r := NewRegistry(config.DefaultConfig())
	s.Varz = NewVarz(r)
}
示例#13
0
func (s *VarzSuite) SetUpTest(c *C) {
	mocksController := gomock.NewController(c)
	r := NewRegistry(config.DefaultConfig(), test.NewMockCFMessageBus(mocksController))
	s.Registry = r
	s.Varz = NewVarz(r)
}