예제 #1
0
func init() {
	sender = metrics_fakes.NewFakeMetricSender()
	metrics.Initialize(sender, nil)
}
예제 #2
0
	var port int
	var address string
	var fakeMetricSender *fake.FakeMetricSender

	BeforeEach(func() {
		port = 3456 + GinkgoParallelNode()
		address = net.JoinHostPort("127.0.0.1", strconv.Itoa(port))
		writer = mocks.MockByteArrayWriter{}
		reader = networkreader.New(address, "networkReader", &writer, loggertesthelper.Logger())
		readerStopped = make(chan struct{})
	})

	Context("with a reader running", func() {
		BeforeEach(func() {
			loggertesthelper.TestLoggerSink.Clear()
			fakeMetricSender = fake.NewFakeMetricSender()
			metricBatcher := metricbatcher.New(fakeMetricSender, time.Millisecond)
			metrics.Initialize(fakeMetricSender, metricBatcher)

			go func() {
				reader.Start()
				close(readerStopped)
			}()

			expectedLog := fmt.Sprintf("Listening on port %s", address)
			Eventually(loggertesthelper.TestLoggerSink.LogContents).Should(ContainSubstring(expectedLog))
		})

		AfterEach(func() {
			reader.Stop()
			<-readerStopped
예제 #3
0
	var (
		fakeMetricSender *fake_metric_sender.FakeMetricSender

		logger          lager.Logger
		fakeDiegoClient *fake_bbs.FakeClient
		fakeCcClient    *fakes.FakeCcClient
		fakeBackend     *fake_backend.FakeBackend

		responseRecorder *httptest.ResponseRecorder
		handler          handlers.StagingHandler
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")

		fakeMetricSender = fake_metric_sender.NewFakeMetricSender()
		metrics.Initialize(fakeMetricSender, nil)

		fakeCcClient = &fakes.FakeCcClient{}

		fakeBackend = &fake_backend.FakeBackend{}
		fakeBackend.BuildRecipeReturns(&models.TaskDefinition{}, "", "", nil)

		fakeDiegoClient = &fake_bbs.FakeClient{}

		responseRecorder = httptest.NewRecorder()
		handler = handlers.NewStagingHandler(logger, map[string]backend.Backend{"fake-backend": fakeBackend}, fakeCcClient, fakeDiegoClient)
	})

	Describe("Stage", func() {
		var (