本文整理匯總了Golang中github.com/cloudfoundry/gorouter/test_util.NextAvailPort函數的典型用法代碼示例。如果您正苦於以下問題:Golang NextAvailPort函數的具體用法?Golang NextAvailPort怎麽用?Golang NextAvailPort使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NextAvailPort函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
"net/http"
"time"
)
var _ = Describe("Router", func() {
var natsRunner *natsrunner.NATSRunner
var config *cfg.Config
var mbusClient *yagnats.Client
var registry *rregistry.RouteRegistry
var varz vvarz.Varz
var router *Router
var natsPort uint16
BeforeEach(func() {
natsPort = test_util.NextAvailPort()
natsRunner = natsrunner.NewNATSRunner(int(natsPort))
natsRunner.Start()
proxyPort := test_util.NextAvailPort()
statusPort := test_util.NextAvailPort()
config = test_util.SpecConfig(natsPort, statusPort, proxyPort)
config.EndpointTimeout = 5 * time.Second
mbusClient = natsRunner.MessageBus.(*yagnats.Client)
registry = rregistry.NewRouteRegistry(config, mbusClient)
varz = vvarz.NewVarz(registry)
logcounter := vcap.NewLogCounter()
proxy := proxy.NewProxy(proxy.ProxyArgs{
EndpointTimeout: config.EndpointTimeout,
示例2:
gorouterSession = session
return session
}
stopGorouter := func(gorouterSession *Session) {
err := gorouterSession.Command.Process.Signal(syscall.SIGTERM)
Expect(err).ToNot(HaveOccurred())
Eventually(gorouterSession, 5).Should(Exit(0))
}
BeforeEach(func() {
var err error
tmpdir, err = ioutil.TempDir("", "gorouter")
Expect(err).ToNot(HaveOccurred())
natsPort = test_util.NextAvailPort()
natsRunner = test_util.NewNATSRunner(int(natsPort))
natsRunner.Start()
})
AfterEach(func() {
if natsRunner != nil {
natsRunner.Stop()
}
os.RemoveAll(tmpdir)
if gorouterSession != nil && gorouterSession.ExitCode() == -1 {
stopGorouter(gorouterSession)
}
})
示例3:
return session
}
stopGorouter := func(gorouterSession *Session) {
err := gorouterSession.Command.Process.Signal(syscall.SIGTERM)
Expect(err).ToNot(HaveOccurred())
Eventually(gorouterSession, 5).Should(Exit(0))
}
BeforeEach(func() {
var err error
tmpdir, err = ioutil.TempDir("", "gorouter")
Expect(err).ToNot(HaveOccurred())
natsPort = test_util.NextAvailPort()
natsRunner = natsrunner.NewNATSRunner(int(natsPort))
natsRunner.Start()
})
AfterEach(func() {
if natsRunner != nil {
natsRunner.Stop()
}
os.RemoveAll(tmpdir)
if gorouterSession != nil && gorouterSession.ExitCode() == -1 {
stopGorouter(gorouterSession)
}
})
示例4:
serveComponent(component)
req := buildGetRequest(component, "/non-existent-path")
req.SetBasicAuth("username", "password")
code, _, _ := doGetRequest(req)
Expect(code).To(Equal(404))
})
Describe("Register", func() {
var mbusClient *nats.Conn
var natsRunner *test_util.NATSRunner
var logger lager.Logger
BeforeEach(func() {
natsPort := test_util.NextAvailPort()
natsRunner = test_util.NewNATSRunner(int(natsPort))
natsRunner.Start()
mbusClient = natsRunner.MessageBus
logger = lagertest.NewTestLogger("test")
})
AfterEach(func() {
natsRunner.Stop()
})
It("subscribes to vcap.component.discover", func() {
done := make(chan struct{})
members := []string{
"type",