當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ginkgomon.Interrupt函數代碼示例

本文整理匯總了Golang中github.com/tedsuo/ifrit/ginkgomon.Interrupt函數的典型用法代碼示例。如果您正苦於以下問題:Golang Interrupt函數的具體用法?Golang Interrupt怎麽用?Golang Interrupt使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Interrupt函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: stop

func (etcd *ETCDClusterRunner) stop(nuke bool) {
	etcd.mutex.Lock()
	defer etcd.mutex.Unlock()

	if etcd.running {
		for i := 0; i < etcd.numNodes; i++ {
			ginkgomon.Interrupt(etcd.etcdProcesses[i], 5*time.Second)
			if nuke {
				etcd.nukeArtifacts(i)
			}
		}
		etcd.markAsStopped()
	}
}
開發者ID:idouba,項目名稱:gorouter,代碼行數:14,代碼來源:etcd_cluster_runner.go

示例2: Stop

func (runner *AgentRunner) Stop() {
	runner.mutex.Lock()
	defer runner.mutex.Unlock()

	if !runner.running {
		return
	}

	ginkgomon.Interrupt(runner.consulProcess, 5*time.Second)

	os.RemoveAll(runner.dataDir)
	os.RemoveAll(runner.configDir)
	runner.consulProcess = nil
	runner.running = false
}
開發者ID:keymon,項目名稱:consul-release,代碼行數:15,代碼來源:agent.go

示例3: Stop

func (cr *ClusterRunner) Stop() {
	cr.mutex.Lock()
	defer cr.mutex.Unlock()

	if !cr.running {
		return
	}

	for i := 0; i < cr.numNodes; i++ {
		ginkgomon.Interrupt(cr.consulProcesses[i], 5*time.Second)
	}

	os.RemoveAll(cr.dataDir)
	os.RemoveAll(cr.configDir)
	cr.consulProcesses = nil
	cr.running = false
}
開發者ID:stefanschneider,項目名稱:consuladapter,代碼行數:17,代碼來源:clusterrunner.go

示例4:

			Expect(err).NotTo(HaveOccurred())
			service, ok := services[registration.ID]
			Expect(ok).To(BeTrue())
			Expect(*service).To(Equal(api.AgentService{
				ID:      registration.ID,
				Service: registration.Name,
				Tags:    registration.Tags,
				Port:    registration.Port,
				Address: registration.Address,
			}))
		})
	})

	Context("when signalled", func() {
		It("deregisters the given service before exiting", func() {
			ginkgomon.Interrupt(registrationProcess)
			services, err := consulClient.Agent().Services()
			Expect(err).NotTo(HaveOccurred())
			Expect(services).ToNot(HaveKey(registration.ID))
		})
	})
})

var _ = Describe("Service Registration Unit Tests", func() {
	var (
		client *fakes.FakeClient
		agent  *fakes.FakeAgent
		logger lager.Logger
		clock  *fakeclock.FakeClock

		registration        *api.AgentServiceRegistration
開發者ID:cloudfoundry,項目名稱:locket,代碼行數:31,代碼來源:registration_runner_test.go

示例5:

						Eventually(presenceProcess.Wait()).ShouldNot(Receive())
						clock.WaitForWatcherAndIncrement(6 * time.Second)
						Eventually(logger).Should(Say("recreating-session"))

						consulRunner.Start()
						consulRunner.WaitUntilReady()

						clock.WaitForWatcherAndIncrement(6 * time.Second)
						Eventually(logger).Should(Say("succeeded-recreating-session"))
						Eventually(presenceProcess.Ready()).Should(BeClosed())
					})
				})

				Context("and the process is shutting down", func() {
					It("releases the presence and exits", func() {
						ginkgomon.Interrupt(presenceProcess)
						Eventually(presenceProcess.Wait()).Should(Receive(BeNil()))
						_, err := getPresenceValue()
						Expect(err).To(Equal(consuladapter.NewKeyNotFoundError(presenceKey)))
					})
				})

				Context("and consul goes through a period of instability", func() {
					var serveFiveHundreds chan struct{}
					var fakeConsul *httptest.Server

					BeforeEach(func() {
						serveFiveHundreds = make(chan struct{}, 8)

						consulClusterURL, err := url.Parse(consulRunner.URL())
						Expect(err).NotTo(HaveOccurred())
開發者ID:cloudfoundry,項目名稱:locket,代碼行數:31,代碼來源:presence_test.go

示例6:

		return httpClient.Do(req)
	}

	BeforeEach(func() {
		nsyncPort = 8888 + GinkgoParallelNode()
		nsyncURL := fmt.Sprintf("http://127.0.0.1:%d", nsyncPort)

		requestGenerator = rata.NewRequestGenerator(nsyncURL, nsync.Routes)
		httpClient = http.DefaultClient

		runner := newNSyncRunner(fmt.Sprintf("127.0.0.1:%d", nsyncPort))
		process = ginkgomon.Invoke(runner)
	})

	AfterEach(func() {
		ginkgomon.Interrupt(process, exitDuration)
	})

	Describe("Desire an app", func() {
		BeforeEach(func() {
			response, err = requestDesireWithInstances(3)
		})

		It("desires the app from the bbs", func() {
			Expect(err).NotTo(HaveOccurred())
			Expect(response.StatusCode).To(Equal(http.StatusAccepted))
			Eventually(func() ([]*models.DesiredLRP, error) {
				return bbsClient.DesiredLRPs(models.DesiredLRPFilter{})
			}, 10).Should(HaveLen(1))
			desiredLrps, _ := bbsClient.DesiredLRPs(models.DesiredLRPFilter{})
			newRouteMessage := json.RawMessage([]byte(`[{"hostnames":["route-1"],"port":8080}]`))
開發者ID:cf-routing,項目名稱:nsync,代碼行數:31,代碼來源:main_test.go

示例7:

	var pipelineDBFactory db.PipelineDBFactory

	BeforeEach(func() {
		dbLogger := lagertest.NewTestLogger("test")
		postgresRunner.Truncate()
		dbConn = postgresRunner.Open()
		dbListener = pq.NewListener(postgresRunner.DataSourceName(), time.Second, time.Minute, nil)
		bus := db.NewNotificationsBus(dbListener, dbConn)
		sqlDB = db.NewSQL(dbLogger, dbConn, bus)
		pipelineDBFactory = db.NewPipelineDBFactory(dbLogger, dbConn, bus, sqlDB)

		atcProcess, atcPort = startATC(atcBin, 1)
	})

	AfterEach(func() {
		ginkgomon.Interrupt(atcProcess)

		Expect(dbConn.Close()).To(Succeed())
		Expect(dbListener.Close()).To(Succeed())
	})

	Describe("viewing a list of builds", func() {
		var page *agouti.Page
		var pipelineDB db.PipelineDB

		BeforeEach(func() {
			var err error
			page, err = agoutiDriver.NewPage()
			Expect(err).NotTo(HaveOccurred())
		})
開發者ID:ACPK,項目名稱:atc,代碼行數:30,代碼來源:builds_list_test.go

示例8:

	BeforeEach(func() {
		dbLogger := lagertest.NewTestLogger("test")

		postgresRunner.Truncate()
		dbConn = db.Wrap(postgresRunner.Open())
		dbListener = pq.NewListener(postgresRunner.DataSourceName(), time.Second, time.Minute, nil)
		bus := db.NewNotificationsBus(dbListener, dbConn)
		sqlDB = db.NewSQL(dbLogger, dbConn, bus)

		atcOneProcess, atcOnePort = startATC(atcBin, 1, true, BASIC_AUTH)
		atcTwoProcess, atcTwoPort = startATC(atcBin, 2, true, BASIC_AUTH)
	})

	AfterEach(func() {
		ginkgomon.Interrupt(atcOneProcess)
		ginkgomon.Interrupt(atcTwoProcess)

		Expect(dbConn.Close()).To(Succeed())
		Expect(dbListener.Close()).To(Succeed())
	})

	Describe("Pipes", func() {

		var client *http.Client
		BeforeEach(func() {
			client = &http.Client{
				Transport: &http.Transport{},
			}
		})
開發者ID:pcfdev-forks,項目名稱:atc,代碼行數:29,代碼來源:multiple_atcs_test.go

示例9: Stop

func (m *MetronRunner) Stop() {
	ginkgomon.Interrupt(m.Process, 2)
}
開發者ID:kei-yamazaki,項目名稱:loggregator,代碼行數:3,代碼來源:metron.go

示例10: newCellPresence

		const cell1 = "cell-id-1"
		const cell2 = "cell-id-2"

		Context("when there is a single cell", func() {
			var maintainers ifrit.Process

			BeforeEach(func() {
				Expect(serviceClient.Cells(logger)).To(HaveLen(0))
				maintainers = ifrit.Invoke(grouper.NewParallel(os.Interrupt, grouper.Members{
					{cell1, serviceClient.NewCellPresenceRunner(logger, newCellPresence(cell1), locket.RetryInterval, locket.LockTTL)},
					{cell2, serviceClient.NewCellPresenceRunner(logger, newCellPresence(cell2), locket.RetryInterval, locket.LockTTL)},
				}))
			})

			AfterEach(func() {
				ginkgomon.Interrupt(maintainers)
			})

			It("returns only one cell", func() {
				Eventually(func() (models.CellSet, error) { return serviceClient.Cells(logger) }).Should(HaveLen(2))
				Expect(serviceClient.Cells(logger)).To(HaveKey(cell1))
				Expect(serviceClient.Cells(logger)).To(HaveKey(cell2))
			})
		})
	})
})

func newCellPresence(cellID string) *models.CellPresence {
	presence := models.NewCellPresence(
		cellID,
		"cell.example.com",
開發者ID:cfibmers,項目名稱:bbs,代碼行數:31,代碼來源:service_client_test.go

示例11:

				registrations = make(chan *nats.Msg, 1)
				natsClient.Subscribe("router.register", func(msg *nats.Msg) {
					registrations <- msg
				})
			})

			It("starts announcing its location again", func() {
				Eventually(registrations).Should(Receive())
			})
		})
	})

	Context("when a server is sent SIGINT after the hearbeat has started", func() {
		JustBeforeEach(func() {
			Eventually(receptorRunner).Should(gbytes.Say("nats-heartbeat.started"))
			ginkgomon.Interrupt(receptorProcess)
		})

		Context("and NATS is accessible", func() {
			var unregistrations chan *nats.Msg

			BeforeEach(func() {
				unregistrations = make(chan *nats.Msg, 1)
				natsClient.Subscribe("router.unregister", func(msg *nats.Msg) {
					unregistrations <- msg
				})
			})

			It("broadcasts an unregister message", func() {
				Eventually(unregistrations).Should(Receive())
			})
開發者ID:davidwadden,項目名稱:lattice-release,代碼行數:31,代碼來源:router_registration_test.go

示例12:

			)

			tsaRunner := ginkgomon.New(ginkgomon.Config{
				Command:       tsaCommand,
				Name:          "tsa",
				StartCheck:    "tsa.listening",
				AnsiColorCode: "32m",
			})

			tsaProcess = ginkgomon.Invoke(tsaRunner)
		})

		AfterEach(func() {
			atcServer.Close()
			gardenServer.Stop()
			ginkgomon.Interrupt(tsaProcess)
		})

		Describe("SSHing", func() {
			var sshSess *gexec.Session
			var sshStdin io.Writer
			var sshArgv []string

			BeforeEach(func() {
				sshArgv = []string{
					"127.0.0.1",
					"-p", strconv.Itoa(tsaPort),
					"-o", "UserKnownHostsFile=" + userKnownHostsFile,
				}
			})
開發者ID:savaki,項目名稱:tsa,代碼行數:30,代碼來源:main_test.go

示例13: primeEventStream

			Expect(delta).To(BeEquivalentTo(1))
		})
	})

	It("cleans up exiting connections when killing the BBS", func(done Done) {
		var err error
		eventSource, err = client.SubscribeToEvents(logger)
		Expect(err).NotTo(HaveOccurred())

		go func() {
			_, err := eventSource.Next()
			Expect(err).To(HaveOccurred())
			close(done)
		}()

		ginkgomon.Interrupt(bbsProcess)
	})
})

func primeEventStream(eventChannel chan models.Event, eventType string, primer func(), cleanup func()) {
	primer()

PRIMING:
	for {
		select {
		case <-eventChannel:
			break PRIMING
		case <-time.After(50 * time.Millisecond):
			cleanup()
			primer()
		}
開發者ID:cfibmers,項目名稱:bbs,代碼行數:31,代碼來源:event_stream_test.go

示例14:

		Describe("pinging the server", func() {
			var pingErr error

			Context("when Garden responds to ping", func() {
				JustBeforeEach(func() {
					pingErr = executorClient.Ping()
				})

				It("does not return an error", func() {
					Expect(pingErr).NotTo(HaveOccurred())
				})
			})

			Context("when Garden returns an error", func() {
				JustBeforeEach(func() {
					ginkgomon.Interrupt(gardenProcess)
					pingErr = executorClient.Ping()
				})

				AfterEach(func() {
					gardenProcess = ginkgomon.Invoke(componentMaker.GardenLinux())
				})

				It("should return an error", func() {
					Expect(pingErr).To(HaveOccurred())
					Expect(pingErr.Error()).To(ContainSubstring("connection refused"))
				})
			})
		})

		Describe("getting the total resources", func() {
開發者ID:Gerg,項目名稱:inigo,代碼行數:31,代碼來源:executor_garden_test.go

示例15:

			etcdStoreClient = etcd.NewStoreClient(nil)
		})

		Context("but SQL does not have a version", func() {
			BeforeEach(func() {
				fakeSQLDB.VersionReturns(nil, models.ErrResourceNotFound)
			})

			It("fetches the version from etcd", func() {
				Eventually(fakeSQLDB.VersionCallCount).Should(Equal(1))
				Consistently(fakeSQLDB.VersionCallCount).Should(Equal(1))

				Eventually(fakeETCDDB.VersionCallCount).Should(Equal(1))
				Consistently(fakeETCDDB.VersionCallCount).Should(Equal(1))

				ginkgomon.Interrupt(migrationProcess)
				Eventually(migrationProcess.Wait()).Should(Receive(BeNil()))
			})

			// cross-db migration
			Context("but etcd does", func() {
				var fakeMigrationToSQL *migrationfakes.FakeMigration

				BeforeEach(func() {
					fakeMigrationToSQL = &migrationfakes.FakeMigration{}
					fakeMigrationToSQL.VersionReturns(102)
					fakeMigrationToSQL.RequiresSQLReturns(true)

					dbVersion.CurrentVersion = 99
					dbVersion.TargetVersion = 99
					fakeMigration.VersionReturns(100)
開發者ID:cloudfoundry,項目名稱:bbs,代碼行數:31,代碼來源:manager_test.go


注:本文中的github.com/tedsuo/ifrit/ginkgomon.Interrupt函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。