本文整理汇总了Golang中github.com/cloudfoundry/gorouter/test.NewGreetApp函数的典型用法代码示例。如果您正苦于以下问题:Golang NewGreetApp函数的具体用法?Golang NewGreetApp怎么用?Golang NewGreetApp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewGreetApp函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestVarz
func (s *RouterSuite) TestVarz(c *C) {
app := test.NewGreetApp([]route.Uri{"count.vcap.me"}, s.Config.Port, s.mbusClient, map[string]string{"framework": "rails"})
app.Listen()
c.Assert(s.waitAppRegistered(app, time.Millisecond*500), Equals, true)
// Send seed request
sendRequests(c, "count.vcap.me", s.Config.Port, 1)
vA := s.readVarz()
// Send requests
sendRequests(c, "count.vcap.me", s.Config.Port, 100)
vB := s.readVarz()
// Verify varz update
RequestsA := int(f(vA, "requests").(float64))
RequestsB := int(f(vB, "requests").(float64))
allRequests := RequestsB - RequestsA
c.Check(allRequests, Equals, 100)
Responses2xxA := int(f(vA, "responses_2xx").(float64))
Responses2xxB := int(f(vB, "responses_2xx").(float64))
allResponses2xx := Responses2xxB - Responses2xxA
c.Check(allResponses2xx, Equals, 100)
app.Unregister()
}
开发者ID:nakaji-s,项目名称:gorouter,代码行数:26,代码来源:router_test.go
示例2: TestVarz
func (s *RouterSuite) TestVarz(c *C) {
app := test.NewGreetApp([]route.Uri{"count.vcap.me"}, s.Config.Port, s.mbusClient, map[string]string{"framework": "rails"})
app.Listen()
additionalRequests := 100
go app.RegisterRepeatedly(100 * time.Millisecond)
c.Assert(s.waitAppRegistered(app, time.Millisecond*500), Equals, true)
// Send seed request
sendRequests(c, "count.vcap.me", s.Config.Port, 1)
initial_varz := s.readVarz()
// Send requests
sendRequests(c, "count.vcap.me", s.Config.Port, additionalRequests)
updated_varz := s.readVarz()
// Verify varz update
initialRequestCount := fetchRecursively(initial_varz, "requests").(float64)
updatedRequestCount := fetchRecursively(updated_varz, "requests").(float64)
requestCount := int(updatedRequestCount - initialRequestCount)
c.Check(requestCount, Equals, additionalRequests)
initialResponse2xxCount := fetchRecursively(initial_varz, "responses_2xx").(float64)
updatedResponse2xxCount := fetchRecursively(updated_varz, "responses_2xx").(float64)
response2xxCount := int(updatedResponse2xxCount - initialResponse2xxCount)
c.Check(response2xxCount, Equals, additionalRequests)
app.Unregister()
}
开发者ID:jackfengibm,项目名称:gorouter,代码行数:27,代码来源:router_test.go
示例3: TestRegistryLastUpdatedVarz
func (s *RouterSuite) TestRegistryLastUpdatedVarz(c *C) {
app1 := test.NewGreetApp([]route.Uri{"test1.vcap.me"}, s.Config.Port, s.mbusClient, nil)
app1.Listen()
c.Assert(s.waitAppRegistered(app1, time.Second*1), Equals, true)
time.Sleep(2 * time.Second)
initialUpdateTime := fetchRecursively(s.readVarz(), "ms_since_last_registry_update").(float64)
// initialUpdateTime should be roughly 2 seconds.
app2 := test.NewGreetApp([]route.Uri{"test2.vcap.me"}, s.Config.Port, s.mbusClient, nil)
app2.Listen()
c.Assert(s.waitAppRegistered(app2, time.Second*1), Equals, true)
// updateTime should be roughly 0 seconds
updateTime := fetchRecursively(s.readVarz(), "ms_since_last_registry_update").(float64)
c.Assert(updateTime < initialUpdateTime, Equals, true)
}
开发者ID:nimbus-cloud,项目名称:gorouter,代码行数:17,代码来源:router_test.go
示例4: TestNatsConnectivity
func (s *IntegrationSuite) TestNatsConnectivity(c *C) {
natsPort := nextAvailPort()
cmd := mbus.StartNats(int(natsPort))
proxyPort := nextAvailPort()
statusPort := nextAvailPort()
s.Config = SpecConfig(natsPort, statusPort, proxyPort)
s.Config.PruneStaleDropletsInterval = 5 * time.Second
s.router = NewRouter(s.Config)
go s.router.Run()
natsConnected := make(chan bool, 1)
go func() {
for {
if s.router.mbusClient.Publish("Ping", []byte("data")) == nil {
break
}
time.Sleep(500 * time.Millisecond)
}
natsConnected <- true
}()
<-natsConnected
s.mbusClient = s.router.mbusClient
heartbeatInterval := 1 * time.Second
staleThreshold := 5 * time.Second
staleCheckInterval := s.router.registry.pruneStaleDropletsInterval
s.router.registry.dropletStaleThreshold = staleThreshold
app := test.NewGreetApp([]string{"test.nats.dying.vcap.me"}, proxyPort, s.mbusClient, nil)
app.Listen()
c.Assert(s.waitAppRegistered(app, time.Second*5), Equals, true)
go func() {
tick := time.Tick(heartbeatInterval)
for {
select {
case <-tick:
app.Register()
}
}
}()
app.VerifyAppStatus(200, c)
mbus.StopNats(cmd)
time.Sleep(staleCheckInterval + staleThreshold + 1*time.Second)
app.VerifyAppStatus(200, c)
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:57,代码来源:integration_test.go
示例5: TestRegisterUnregister
func (s *RouterSuite) TestRegisterUnregister(c *C) {
app := test.NewGreetApp([]route.Uri{"test.vcap.me"}, s.Config.Port, s.mbusClient, nil)
app.Listen()
c.Assert(s.waitAppRegistered(app, time.Second*5), Equals, true)
app.VerifyAppStatus(200, c)
app.Unregister()
c.Assert(s.waitAppUnregistered(app, time.Second*5), Equals, true)
app.VerifyAppStatus(404, c)
}
开发者ID:nakaji-s,项目名称:gorouter,代码行数:11,代码来源:router_test.go
示例6: TestRegistryLastUpdatedVarz
func (s *RouterSuite) TestRegistryLastUpdatedVarz(c *C) {
initialUpdateTime := f(s.readVarz(), "ms_since_last_registry_update").(float64)
app1 := test.NewGreetApp([]route.Uri{"test1.vcap.me"}, s.Config.Port, s.mbusClient, nil)
app1.Listen()
c.Assert(s.waitAppRegistered(app1, time.Second*5), Equals, true)
// varz time should be different
updateTime := f(s.readVarz(), "ms_since_last_registry_update").(float64)
c.Assert(updateTime < initialUpdateTime, Equals, true)
}
开发者ID:nakaji-s,项目名称:gorouter,代码行数:12,代码来源:router_test.go
示例7:
It("has Nats connectivity", func() {
localIP, err := localip.LocalIP()
Expect(err).ToNot(HaveOccurred())
statusPort := test_util.NextAvailPort()
proxyPort := test_util.NextAvailPort()
cfgFile := filepath.Join(tmpdir, "config.yml")
config := createConfig(cfgFile, statusPort, proxyPort)
gorouterSession = startGorouterSession(cfgFile)
mbusClient, err := newMessageBus(config)
zombieApp := test.NewGreetApp([]route.Uri{"zombie.vcap.me"}, proxyPort, mbusClient, nil)
zombieApp.Listen()
runningApp := test.NewGreetApp([]route.Uri{"innocent.bystander.vcap.me"}, proxyPort, mbusClient, nil)
runningApp.Listen()
routesUri := fmt.Sprintf("http://%s:%[email protected]%s:%d/routes", config.Status.User, config.Status.Pass, localIP, statusPort)
Eventually(func() bool { return appRegistered(routesUri, zombieApp) }).Should(BeTrue())
Eventually(func() bool { return appRegistered(routesUri, runningApp) }).Should(BeTrue())
heartbeatInterval := 200 * time.Millisecond
zombieTicker := time.NewTicker(heartbeatInterval)
runningTicker := time.NewTicker(heartbeatInterval)
go func() {
开发者ID:jungle0755,项目名称:gorouter,代码行数:30,代码来源:main_test.go
示例8:
}).Should(BeTrue())
app.VerifyAppStatus(200)
app.Unregister()
Eventually(func() bool {
return appUnregistered(registry, app)
}).Should(BeTrue())
app.VerifyAppStatus(404)
}
Describe("app with no route service", func() {
BeforeEach(func() {
app = test.NewGreetApp([]route.Uri{"test.vcap.me"}, config.Port, mbusClient, nil)
})
It("registers and unregisters", func() {
assertRegisterUnregister()
})
})
Describe("app with an http route service", func() {
BeforeEach(func() {
app = test.NewRouteServiceApp([]route.Uri{"test.vcap.me"}, config.Port, mbusClient, "http://my-insecure-service.me")
})
It("does not register", func() {
app.Listen()
开发者ID:rakutentech,项目名称:gorouter,代码行数:30,代码来源:router_test.go
示例9: TestNatsConnectivity
func (s *IntegrationSuite) TestNatsConnectivity(c *C) {
proxyPort := nextAvailPort()
statusPort := nextAvailPort()
s.Config = SpecConfig(s.natsPort, statusPort, proxyPort)
// ensure the threshold is longer than the interval that we check,
// because we set the route's timestamp to time.Now() on the interval
// as part of pausing
s.Config.PruneStaleDropletsInterval = 1 * time.Second
s.Config.DropletStaleThreshold = 2 * s.Config.PruneStaleDropletsInterval
log.SetupLoggerFromConfig(s.Config)
s.router = NewRouter(s.Config)
s.router.Run()
s.mbusClient = s.router.mbusClient
staleCheckInterval := s.Config.PruneStaleDropletsInterval
staleThreshold := s.Config.DropletStaleThreshold
s.Config.DropletStaleThreshold = staleThreshold
zombieApp := test.NewGreetApp([]route.Uri{"zombie.vcap.me"}, proxyPort, s.mbusClient, nil)
zombieApp.Listen()
runningApp := test.NewGreetApp([]route.Uri{"innocent.bystander.vcap.me"}, proxyPort, s.mbusClient, nil)
runningApp.Listen()
c.Assert(s.waitAppRegistered(zombieApp, 2*time.Second), Equals, true)
c.Assert(s.waitAppRegistered(runningApp, 2*time.Second), Equals, true)
heartbeatInterval := 200 * time.Millisecond
zombieTicker := time.NewTicker(heartbeatInterval)
runningTicker := time.NewTicker(heartbeatInterval)
go func() {
for {
select {
case <-zombieTicker.C:
zombieApp.Register()
case <-runningTicker.C:
runningApp.Register()
}
}
}()
zombieApp.VerifyAppStatus(200, c)
// Give enough time to register multiple times
time.Sleep(heartbeatInterval * 3)
// kill registration ticker => kill app (must be before stopping NATS since app.Register is fake and queues messages in memory)
zombieTicker.Stop()
natsPort := s.natsPort
s.stopNats()
// Give router time to make a bad decision (i.e. prune routes)
time.Sleep(staleCheckInterval + staleThreshold + 250*time.Millisecond)
// While NATS is down no routes should go down
zombieApp.VerifyAppStatus(200, c)
runningApp.VerifyAppStatus(200, c)
s.startNats(natsPort)
// Right after NATS starts up all routes should stay up
zombieApp.VerifyAppStatus(200, c)
runningApp.VerifyAppStatus(200, c)
zombieGone := make(chan bool)
go func() {
for {
// Finally the zombie is cleaned up. Maybe proactively enqueue Unregister events in DEA's.
err := zombieApp.CheckAppStatus(404)
if err != nil {
time.Sleep(100 * time.Millisecond)
continue
}
err = runningApp.CheckAppStatus(200)
if err != nil {
time.Sleep(100 * time.Millisecond)
continue
}
zombieGone <- true
break
}
}()
select {
case <-zombieGone:
case <-time.After(staleCheckInterval + staleThreshold + 5*time.Second):
c.Error("Zombie app was not pruned.")
//.........这里部分代码省略.........
开发者ID:johntdyer,项目名称:golang-devops-stuff,代码行数:101,代码来源:integration_test.go
注:本文中的github.com/cloudfoundry/gorouter/test.NewGreetApp函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论