本文整理匯總了Golang中github.com/tedsuo/ifrit/ginkgomon.Invoke函數的典型用法代碼示例。如果您正苦於以下問題:Golang Invoke函數的具體用法?Golang Invoke怎麽用?Golang Invoke使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Invoke函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: startATC
func startATC(atcBin string, atcServerNumber uint16) (ifrit.Process, uint16) {
atcPort := 5697 + uint16(GinkgoParallelNode()) + (atcServerNumber * 100)
debugPort := 6697 + uint16(GinkgoParallelNode()) + (atcServerNumber * 100)
atcCommand := exec.Command(
atcBin,
"-webListenPort", fmt.Sprintf("%d", atcPort),
"-callbacksURL", fmt.Sprintf("http://127.0.0.1:%d", atcPort),
"-debugListenPort", fmt.Sprintf("%d", debugPort),
"-httpUsername", "admin",
"-httpHashedPassword", "$2a$04$DYaOWeQgyxTCv7QxydTP9u1KnwXWSKipC4BeTuBy.9m.IlkAdqNGG", // "password"
"-publiclyViewable=true",
"-templates", filepath.Join("..", "web", "templates"),
"-public", filepath.Join("..", "web", "public"),
"-sqlDataSource", postgresRunner.DataSourceName(),
)
atcRunner := ginkgomon.New(ginkgomon.Config{
Command: atcCommand,
Name: "atc",
StartCheck: "atc.listening",
AnsiColorCode: "32m",
})
return ginkgomon.Invoke(atcRunner), atcPort
}
示例2: startATC
func startATC(atcBin string, atcServerNumber uint16) (ifrit.Process, uint16) {
atcPort := 5697 + uint16(GinkgoParallelNode()) + (atcServerNumber * 100)
debugPort := 6697 + uint16(GinkgoParallelNode()) + (atcServerNumber * 100)
atcCommand := exec.Command(
atcBin,
"--bind-port", fmt.Sprintf("%d", atcPort),
"--peer-url", fmt.Sprintf("http://127.0.0.1:%d", atcPort),
"--postgres-data-source", postgresRunner.DataSourceName(),
"--debug-bind-port", fmt.Sprintf("%d", debugPort),
"--basic-auth-username", "admin",
"--basic-auth-password", "password",
"--publicly-viewable",
"--templates", filepath.Join("..", "web", "templates"),
"--public", filepath.Join("..", "web", "public"),
)
atcRunner := ginkgomon.New(ginkgomon.Config{
Command: atcCommand,
Name: "atc",
StartCheck: "atc.listening",
AnsiColorCode: "32m",
})
return ginkgomon.Invoke(atcRunner), atcPort
}
示例3: startATC
func startATC(atcBin string, atcServerNumber uint16, publiclyViewable bool, authTypes ...string) (ifrit.Process, uint16) {
atcCommand, atcPort := getATCCommand(atcBin, atcServerNumber, publiclyViewable, authTypes...)
atcRunner := ginkgomon.New(ginkgomon.Config{
Command: atcCommand,
Name: "atc",
StartCheck: "atc.listening",
AnsiColorCode: "32m",
})
return ginkgomon.Invoke(atcRunner), atcPort
}
示例4: Start
func (cr *ClusterRunner) Start() {
cr.mutex.Lock()
defer cr.mutex.Unlock()
if cr.running {
return
}
tmpDir, err := ioutil.TempDir("", defaultDataDirPrefix)
Expect(err).NotTo(HaveOccurred())
cr.dataDir = tmpDir
tmpDir, err = ioutil.TempDir("", defaultConfigDirPrefix)
Expect(err).NotTo(HaveOccurred())
cr.configDir = tmpDir
cr.consulProcesses = make([]ifrit.Process, cr.numNodes)
for i := 0; i < cr.numNodes; i++ {
iStr := fmt.Sprintf("%d", i)
nodeDataDir := path.Join(cr.dataDir, iStr)
os.MkdirAll(nodeDataDir, 0700)
configFilePath := writeConfigFile(
cr.configDir,
nodeDataDir,
iStr,
cr.startingPort,
i,
cr.numNodes,
cr.sessionTTL,
)
process := ginkgomon.Invoke(ginkgomon.New(ginkgomon.Config{
Name: fmt.Sprintf("consul_cluster[%d]", i),
AnsiColorCode: "35m",
StartCheck: "agent: Join completed.",
StartCheckTimeout: 10 * time.Second,
Command: exec.Command(
"consul",
"agent",
"--log-level", "trace",
"--config-file", configFilePath,
),
}))
cr.consulProcesses[i] = process
ready := process.Ready()
Eventually(ready, 10, 0.05).Should(BeClosed(), "Expected consul to be up and running")
}
cr.running = true
}
示例5: Start
func (runner *AgentRunner) Start() {
runner.mutex.Lock()
defer runner.mutex.Unlock()
if runner.running {
return
}
tmpDir, err := ioutil.TempDir("", defaultDataDirPrefix)
Expect(err).NotTo(HaveOccurred())
runner.dataDir = tmpDir
tmpDir, err = ioutil.TempDir("", defaultConfigDirPrefix)
Expect(err).NotTo(HaveOccurred())
runner.configDir = tmpDir
os.MkdirAll(runner.dataDir, 0700)
configFilePath := writeConfigFile(
runner.configDir,
runner.dataDir,
runner.bindAddress,
runner.serverIps,
)
timeout := 1 * time.Minute
process := ginkgomon.Invoke(ginkgomon.New(ginkgomon.Config{
Name: "consul_agent",
AnsiColorCode: "35m",
StartCheck: "agent: Join completed.",
StartCheckTimeout: timeout,
Command: exec.Command(
"consul",
"agent",
"--config-file", configFilePath,
),
}))
runner.consulProcess = process
ready := process.Ready()
Eventually(ready, timeout, 100*time.Millisecond).Should(BeClosed(), "Expected consul to be up and running")
runner.running = true
}
示例6:
package main_test
import (
"github.com/cloudfoundry-incubator/routing-api/db"
"github.com/tedsuo/ifrit/ginkgomon"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Routes API", func() {
BeforeEach(func() {
routingAPIProcess = ginkgomon.Invoke(routingAPIRunner)
})
AfterEach(func() {
ginkgomon.Kill(routingAPIProcess)
})
Describe("Routes", func() {
var routes []db.Route
var getErr error
var route1, route2 db.Route
BeforeEach(func() {
route1 = db.Route{
Route: "a.b.c",
Port: 33,
IP: "1.1.1.1",
TTL: 55,
LogGuid: "potato",
示例7:
var builtArtifacts world.BuiltArtifacts
err := json.Unmarshal(encodedBuiltArtifacts, &builtArtifacts)
Expect(err).NotTo(HaveOccurred())
localIP, err := localip.LocalIP()
Expect(err).NotTo(HaveOccurred())
componentMaker = helpers.MakeComponentMaker(builtArtifacts, localIP)
})
var _ = BeforeEach(func() {
plumbing = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
{"etcd", componentMaker.Etcd()},
{"nats", componentMaker.NATS()},
{"consul", componentMaker.Consul()},
{"bbs", componentMaker.BBS()},
{"receptor", componentMaker.Receptor()},
{"garden-linux", componentMaker.GardenLinux("-denyNetworks=0.0.0.0/0", "-allowHostAccess=true")},
}))
helpers.ConsulWaitUntilReady()
gardenClient = componentMaker.GardenClient()
natsClient = componentMaker.NATSClient()
receptorClient = componentMaker.ReceptorClient()
helpers.UpsertInigoDomain(receptorClient)
inigo_announcement_server.Start(componentMaker.ExternalAddress)
})
示例8:
Zone: "az1",
RetryInterval: 1 * time.Second,
RootFSProviders: []string{"provider-1", "provider-2"},
}
maintainer = maintain.New(config, fakeClient, serviceClient, logger, clock)
})
AfterEach(func() {
logger.Info("test-complete-signaling-maintainer-to-stop")
close(pingErrors)
ginkgomon.Interrupt(maintainProcess)
})
It("pings the executor", func() {
pingErrors <- nil
maintainProcess = ginkgomon.Invoke(maintainer)
Expect(fakeClient.PingCallCount()).To(Equal(1))
})
Context("when pinging the executor fails", func() {
It("keeps pinging until it succeeds, then starts heartbeating the executor's presence", func() {
maintainProcess = ifrit.Background(maintainer)
ready := maintainProcess.Ready()
for i := 1; i <= 4; i++ {
clock.Increment(1 * time.Second)
pingErrors <- errors.New("ping failed")
Eventually(fakeClient.PingCallCount).Should(Equal(i))
Expect(ready).NotTo(BeClosed())
}
示例9:
address string
lrp receptor.DesiredLRPCreateRequest
)
BeforeEach(func() {
processGuid = helpers.GenerateGuid()
address = componentMaker.Addresses.SSHProxy
var fileServer ifrit.Runner
fileServer, fileServerStaticDir = componentMaker.FileServer()
runtime = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
{"router", componentMaker.Router()},
{"file-server", fileServer},
{"rep", componentMaker.Rep()},
{"converger", componentMaker.Converger()},
{"auctioneer", componentMaker.Auctioneer()},
{"route-emitter", componentMaker.RouteEmitter()},
{"ssh-proxy", componentMaker.SSHProxy()},
}))
tgCompressor := compressor.NewTgz()
err := tgCompressor.Compress(componentMaker.Artifacts.Executables["sshd"], filepath.Join(fileServerStaticDir, "sshd.tgz"))
Expect(err).NotTo(HaveOccurred())
sshRoute := routes.SSHRoute{
ContainerPort: 3456,
PrivateKey: componentMaker.SSHConfig.PrivateKeyPem,
HostFingerprint: ssh_helpers.MD5Fingerprint(componentMaker.SSHConfig.HostKey.PublicKey()),
}
示例10:
consulClient := consulRunner.NewClient()
serviceClient = auctioneer.NewServiceClient(consulClient, clock)
})
Describe("AuctioneerAddress", func() {
Context("when able to get an auctioneer presence", func() {
var heartbeater ifrit.Process
var presence auctioneer.Presence
BeforeEach(func() {
presence = auctioneer.NewPresence("auctioneer-id", "auctioneer.example.com")
auctioneerLock, err := serviceClient.NewAuctioneerLockRunner(logger, presence, 100*time.Millisecond, 10*time.Second)
Expect(err).NotTo(HaveOccurred())
heartbeater = ginkgomon.Invoke(auctioneerLock)
})
AfterEach(func() {
ginkgomon.Interrupt(heartbeater)
})
It("returns the address", func() {
address, err := serviceClient.CurrentAuctioneerAddress()
Expect(err).NotTo(HaveOccurred())
Expect(address).To(Equal(presence.AuctioneerAddress))
})
})
Context("when unable to get any auctioneer presences", func() {
It("returns ErrServiceUnavailable", func() {
示例11:
bbsAddress := fmt.Sprintf("127.0.0.1:%d", 13000+GinkgoParallelNode())
bbsURL = &url.URL{
Scheme: "http",
Host: bbsAddress,
}
bbsClient = bbs.NewClient(bbsURL.String())
bbsArgs = bbstestrunner.Args{
Address: bbsAddress,
EtcdCluster: etcdUrl,
}
bbsRunner = bbstestrunner.New(bbsBinPath, bbsArgs)
bbsProcess = ginkgomon.Invoke(bbsRunner)
},
)
var _ = SynchronizedAfterSuite(func() {
ginkgomon.Kill(bbsProcess)
etcdRunner.Stop()
consulRunner.Stop()
}, func() {
gexec.CleanupBuildArtifacts()
})
var _ = BeforeEach(func() {
logger = lagertest.NewTestLogger("test")
etcdRunner.Reset()
示例12:
atcBin,
"-webListenPort", fmt.Sprintf("%d", atcPort),
"-debugListenPort", fmt.Sprintf("%d", debugPort),
"-httpUsername", "admin",
"-httpPassword", "password",
"-templates", filepath.Join("..", "web", "templates"),
"-public", filepath.Join("..", "web", "public"),
"-sqlDataSource", postgresRunner.DataSourceName(),
)
atcRunner := ginkgomon.New(ginkgomon.Config{
Command: atcCommand,
Name: "atc",
StartCheck: "atc.listening",
AnsiColorCode: "32m",
})
atcProcess = ginkgomon.Invoke(atcRunner)
})
AfterEach(func() {
ginkgomon.Interrupt(atcProcess)
Ω(dbConn.Close()).Should(Succeed())
Ω(dbListener.Close()).Should(Succeed())
postgresRunner.DropTestDB()
})
It("can reach the page", func() {
request, err := http.NewRequest("GET", fmt.Sprintf("http://127.0.0.1:%d", atcPort), nil)
resp, err := http.DefaultClient.Do(request)
示例13:
)
var fileServerStaticDir string
BeforeEach(func() {
var fileServerRunner ifrit.Runner
fileServerRunner, fileServerStaticDir = componentMaker.FileServer()
cellGroup := grouper.Members{
{"file-server", fileServerRunner},
{"rep", componentMaker.Rep("-memoryMB", "1024")},
{"auctioneer", componentMaker.Auctioneer()},
{"converger", componentMaker.Converger()},
}
cellProcess = ginkgomon.Invoke(grouper.NewParallel(os.Interrupt, cellGroup))
Eventually(receptorClient.Cells).Should(HaveLen(1))
})
AfterEach(func() {
helpers.StopProcesses(cellProcess)
})
Describe("Running a task", func() {
var guid string
BeforeEach(func() {
guid = helpers.GenerateGuid()
})
示例14:
cellProcess = nil
convergerProcess = nil
})
AfterEach(func() {
helpers.StopProcesses(
auctioneerProcess,
cellProcess,
convergerProcess,
)
})
Context("when a rep, and auctioneer are running", func() {
BeforeEach(func() {
cellProcess = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
{"rep", componentMaker.Rep("-memoryMB", "1024")},
}))
auctioneerProcess = ginkgomon.Invoke(componentMaker.Auctioneer())
})
Context("and a standard Task is desired", func() {
var taskGuid string
var taskSleepSeconds int
var taskRequest receptor.TaskCreateRequest
BeforeEach(func() {
taskSleepSeconds = 10
taskGuid = helpers.GenerateGuid()
示例15: TestDelphos
httpclient *http.Client
)
func TestDelphos(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Delphos Suite")
}
var _ = SynchronizedBeforeSuite(
func() []byte {
delphosConfig, err := gexec.Build("github.com/migdi/delphos-api/cmd/delphos", "-race")
Expect(err).NotTo(HaveOccurred())
return []byte(delphosConfig)
},
func(delphosConfig []byte) {
delphosBinPath = string(delphosConfig)
SetDefaultEventuallyTimeout(15 * time.Second)
delphosPort = 8080 + GinkgoParallelNode()
delphosArgs.Address = fmt.Sprintf("127.0.0.1:%d", delphosPort)
delphosRunner = testrunner.New(delphosBinPath, delphosArgs)
delphosProcess = ginkgomon.Invoke(delphosRunner)
httpclient = &http.Client{}
},
)
var _ = SynchronizedAfterSuite(func() {
ginkgomon.Kill(delphosProcess)
}, func() {
gexec.CleanupBuildArtifacts()
})