当前位置: 首页>>代码示例>>Golang>>正文


Golang fake.FakeEventEmitter类代码示例

本文整理汇总了Golang中github.com/cloudfoundry/dropsonde/emitter/fake.FakeEventEmitter的典型用法代码示例。如果您正苦于以下问题:Golang FakeEventEmitter类的具体用法?Golang FakeEventEmitter怎么用?Golang FakeEventEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FakeEventEmitter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

import (
	"common/monitor"

	"github.com/cloudfoundry/dropsonde/emitter/fake"
	"github.com/cloudfoundry/dropsonde/metric_sender"
	"github.com/cloudfoundry/dropsonde/metricbatcher"
	"github.com/cloudfoundry/dropsonde/metrics"
	"github.com/cloudfoundry/sonde-go/events"
	"github.com/gogo/protobuf/proto"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"time"
)

var (
	fakeEventEmitter *fake.FakeEventEmitter
	uptimeMonitor    monitor.Monitor
)

const (
	interval = 100 * time.Millisecond
)

var _ = Describe("UptimeMonitor", func() {
	BeforeEach(func() {
		fakeEventEmitter = fake.NewFakeEventEmitter("MonitorTest")
		sender := metric_sender.NewMetricSender(fakeEventEmitter)
		batcher := metricbatcher.New(sender, 100*time.Millisecond)

		metrics.Initialize(sender, batcher)

		uptimeMonitor = monitor.NewUptimeMonitor(interval)
开发者ID:lyuyun,项目名称:loggregator,代码行数:32,代码来源:uptime_monitor_test.go

示例2:

	"net"
	"net/http"
	"net/http/httptest"
	"time"

	"github.com/cloudfoundry/dropsonde/emitter/fake"
	"github.com/cloudfoundry/dropsonde/instrumented_handler"
	"github.com/cloudfoundry/sonde-go/events"
	uuid "github.com/nu7hatch/gouuid"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("InstrumentedHandler", func() {
	var fakeEmitter *fake.FakeEventEmitter
	var h http.Handler
	var req *http.Request

	var origin = "testHandler/41"

	BeforeEach(func() {
		fakeEmitter = fake.NewFakeEventEmitter(origin)

		var err error
		fh := fakeHandler{}
		h = instrumented_handler.InstrumentedHandler(fh, fakeEmitter)
		req, err = http.NewRequest("GET", "http://foo.example.com/", nil)
		Expect(err).ToNot(HaveOccurred())
		req.RemoteAddr = "127.0.0.1"
		req.Header.Set("User-Agent", "our-testing-client")
开发者ID:davidwadden,项目名称:lattice-release,代码行数:31,代码来源:instrumented_handler_test.go

示例3:

	"errors"
	"log"
	"runtime"
	"time"

	"github.com/cloudfoundry/dropsonde/emitter/fake"
	"github.com/cloudfoundry/sonde-go/events"
	"github.com/gogo/protobuf/proto"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("RuntimeStats", func() {
	var (
		fakeEventEmitter  *fake.FakeEventEmitter
		runtimeStats      *runtime_stats.RuntimeStats
		stopChan, runDone chan struct{}
	)

	BeforeEach(func() {
		fakeEventEmitter = fake.NewFakeEventEmitter("fake-origin")
		runtimeStats = runtime_stats.NewRuntimeStats(fakeEventEmitter, 10*time.Millisecond)
		stopChan = make(chan struct{})
		runDone = make(chan struct{})
	})

	AfterEach(func() {
		close(stopChan)
		Eventually(runDone).Should(BeClosed())
	})
开发者ID:davidwadden,项目名称:lattice-release,代码行数:30,代码来源:runtime_stats_test.go

示例4:

		It("works like a channel", func() {

			sendLogMessages("message 1", inMessageChan)

			readMessage := <-buffer.GetOutputChannel()
			Expect(readMessage.GetLogMessage().GetMessage()).To(ContainSubstring("message 1"))

			sendLogMessages("message 2", inMessageChan)

			readMessage2 := <-buffer.GetOutputChannel()
			Expect(readMessage2.GetLogMessage().GetMessage()).To(ContainSubstring("message 2"))

		})

		Context("tracking dropped messages", func() {
			var fakeEventEmitter *fake.FakeEventEmitter

			BeforeEach(func() {
				fakeEventEmitter = fake.NewFakeEventEmitter("doppler")
				sender := metric_sender.NewMetricSender(fakeEventEmitter)
				batcher := metricbatcher.New(sender, 100*time.Millisecond)

				metrics.Initialize(sender, batcher)
				fakeEventEmitter.Reset()
			})

			tracksDroppedMessages := func(delta, total int) {
				It("logs the dropped messages", func() {
					logMessageNotification := <-buffer.GetOutputChannel()
					Expect(logMessageNotification.GetEventType()).To(Equal(events.Envelope_LogMessage))
					Expect(logMessageNotification.GetLogMessage().GetMessage()).To(ContainSubstring(fmt.Sprintf("Log message output is too high. %d messages dropped (Total %d messages dropped) to test-sink-name.", delta, total)))
开发者ID:Amit-PivotalLabs,项目名称:loggregator,代码行数:31,代码来源:truncating_buffer_test.go

示例5:

	"github.com/cloudfoundry/dropsonde/events"
	"github.com/cloudfoundry/dropsonde/log_sender"
	"github.com/gogo/protobuf/proto"

	"io"
	"strings"
	"time"

	"github.com/cloudfoundry/loggregatorlib/loggertesthelper"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("LogSender", func() {
	var (
		emitter *fake.FakeEventEmitter
		sender  log_sender.LogSender
	)

	BeforeEach(func() {
		emitter = fake.NewFakeEventEmitter("origin")
		sender = log_sender.NewLogSender(emitter, 50*time.Millisecond, loggertesthelper.Logger())
	})

	AfterEach(func() {
		emitter.Close()
		for !emitter.IsClosed() {
			time.Sleep(10 * time.Millisecond)
		}
	})

	Describe("SendAppLog", func() {
开发者ID:jungle0755,项目名称:gorouter,代码行数:32,代码来源:log_sender_test.go

示例6:

			sendLogMessages("message 1", inMessageChan)

			var readMessage *events.Envelope
			Eventually(buffer.GetOutputChannel).Should(Receive(&readMessage))

			Expect(readMessage.GetLogMessage().GetMessage()).To(ContainSubstring("message 1"))

			sendLogMessages("message 2", inMessageChan)

			Eventually(buffer.GetOutputChannel).Should(Receive(&readMessage))
			Expect(readMessage.GetLogMessage().GetMessage()).To(ContainSubstring("message 2"))

		})

		Context("tracking dropped messages", func() {
			var fakeEventEmitter *fake.FakeEventEmitter

			receiveDroppedMessages := func() uint64 {
				var t uint64
				for i, _ := range fakeEventEmitter.GetMessages() {
					e := fakeEventEmitter.GetMessages()[i].Event.(*events.CounterEvent)

					t += e.GetDelta()
				}

				return t
			}

			tracksDroppedMessagesAnd := func(itMsg string, delta, total int) {
				It(itMsg, func() {
					var logMessageNotification *events.Envelope
开发者ID:yingkitw,项目名称:loggregator,代码行数:31,代码来源:truncating_buffer_test.go

示例7:

package metric_sender_test

import (
	"errors"

	"github.com/cloudfoundry/dropsonde/emitter/fake"
	"github.com/cloudfoundry/dropsonde/events"
	"github.com/cloudfoundry/dropsonde/metric_sender"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("MetricSender", func() {
	var (
		emitter *fake.FakeEventEmitter
		sender  metric_sender.MetricSender
	)

	BeforeEach(func() {
		emitter = fake.NewFakeEventEmitter("origin")
		sender = metric_sender.NewMetricSender(emitter)
	})

	It("sends a metric to its emitter", func() {
		err := sender.SendValue("metric-name", 42, "answers")
		Expect(err).NotTo(HaveOccurred())

		Expect(emitter.GetMessages()).To(HaveLen(1))
		metric := emitter.GetMessages()[0].Event.(*events.ValueMetric)
		Expect(metric.GetName()).To(Equal("metric-name"))
		Expect(metric.GetValue()).To(BeNumerically("==", 42))
开发者ID:trainchou,项目名称:gorouter,代码行数:32,代码来源:metric_sender_test.go

示例8: TestMonitor

import (
	"github.com/cloudfoundry/dropsonde/emitter/fake"
	"github.com/cloudfoundry/dropsonde/metric_sender"
	"github.com/cloudfoundry/dropsonde/metrics"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"testing"
)

func TestMonitor(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Monitor Suite")
}

var (
	fakeEventEmitter *fake.FakeEventEmitter
)

var _ = BeforeSuite(func() {
	fakeEventEmitter = fake.NewFakeEventEmitter("MonitorTest")
	sender := metric_sender.NewMetricSender(fakeEventEmitter)

	metrics.Initialize(sender, nil)
})

var _ = AfterSuite(func() {
	fakeEventEmitter.Close()
})
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:29,代码来源:monitor_suite_test.go

示例9:

package metric_sender_test

import (
	"errors"
	"github.com/cloudfoundry/dropsonde/emitter/fake"
	"github.com/cloudfoundry/dropsonde/events"
	"github.com/cloudfoundry/dropsonde/metric_sender"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("MetricSender", func() {
	var (
		emitter *fake.FakeEventEmitter
		sender  metric_sender.MetricSender
	)

	BeforeEach(func() {
		emitter = fake.NewFakeEventEmitter("origin")
		sender = metric_sender.NewMetricSender(emitter)
	})

	It("sends a metric to its emitter", func() {
		err := sender.SendValue("metric-name", 42, "answers")
		Expect(err).NotTo(HaveOccurred())

		Expect(emitter.Messages).To(HaveLen(1))
		metric := emitter.Messages[0].Event.(*events.ValueMetric)
		Expect(metric.GetName()).To(Equal("metric-name"))
		Expect(metric.GetValue()).To(BeNumerically("==", 42))
开发者ID:johannespetzold,项目名称:gorouter,代码行数:31,代码来源:metric_sender_test.go

示例10:

			var readMessage *events.Envelope
			Eventually(buffer.GetOutputChannel).Should(Receive(&readMessage))

			Expect(readMessage.GetLogMessage().GetMessage()).To(ContainSubstring("message 1"))

			sendLogMessages("message 2", inMessageChan)

			Eventually(buffer.GetOutputChannel).Should(Receive(&readMessage))
			Expect(readMessage.GetLogMessage().GetMessage()).To(ContainSubstring("message 2"))

		})

		Context("tracking dropped messages", func() {
			var (
				fakeEventEmitter *fake.FakeEventEmitter
				mockBatcher      *mockMetricBatcher
			)

			tracksDroppedMessagesAnd := func(itMsg string, delta, total int) {
				It(itMsg, func() {
					var logMessageNotification *events.Envelope
					Eventually(buffer.GetOutputChannel).Should(Receive(&logMessageNotification))
					Expect(logMessageNotification.GetEventType()).To(Equal(events.Envelope_LogMessage))
					Expect(logMessageNotification.GetLogMessage().GetAppId()).To(Equal("fake-app-id"))
					Expect(logMessageNotification.GetLogMessage().GetMessage()).To(
						ContainSubstring(fmt.Sprintf("Log message output is too high. "+
							"%d messages dropped (Total %d messages dropped) from doppler to test-sink-name.", delta, total)),
					)

					var counterEventNotification *events.Envelope
					Eventually(buffer.GetOutputChannel).Should(Receive(&counterEventNotification))
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:31,代码来源:truncating_buffer_test.go

示例11:

	"io"
	"strings"
	"time"

	"github.com/cloudfoundry/dropsonde/metric_sender"
	"github.com/cloudfoundry/dropsonde/metricbatcher"
	"github.com/cloudfoundry/dropsonde/metrics"
	"github.com/cloudfoundry/loggregatorlib/loggertesthelper"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("LogSender", func() {
	var (
		emitter *fake.FakeEventEmitter
		sender  log_sender.LogSender
	)

	BeforeEach(func() {
		emitter = fake.NewFakeEventEmitter("origin")
		metricSender := metric_sender.NewMetricSender(emitter)
		batcher := metricbatcher.New(metricSender, time.Millisecond)
		metrics.Initialize(metricSender, batcher)
		sender = log_sender.NewLogSender(emitter, loggertesthelper.Logger())
	})

	AfterEach(func() {
		emitter.Close()
		for !emitter.IsClosed() {
			time.Sleep(10 * time.Millisecond)
		}
开发者ID:fraenkel,项目名称:dropsonde,代码行数:31,代码来源:log_sender_test.go

示例12:

import (
	"boshhmforwarder/valuemetricsender"

	"time"

	"github.com/cloudfoundry/dropsonde/emitter/fake"
	"github.com/cloudfoundry/dropsonde/envelope_sender"
	"github.com/cloudfoundry/dropsonde/envelopes"
	"github.com/gogo/protobuf/proto"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("ValueMetricSender", func() {
	var (
		fakeEventEmitter *fake.FakeEventEmitter
	)
	BeforeEach(func() {
		fakeEventEmitter = fake.NewFakeEventEmitter("MonitorTest")
		envelopes.Initialize(envelope_sender.NewEnvelopeSender(fakeEventEmitter))
	})

	AfterEach(func() {
		fakeEventEmitter.Close()
	})

	It("emits bosh metrics", func() {
		valueMetricSender := valuemetricsender.NewValueMetricSender()
		timeInSeconds := time.Now().Unix()
		valueMetricSender.SendValueMetric("some-deployment", "some-job", "some-index", "some-event-name", timeInSeconds, 1.23, "some-unit")
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:30,代码来源:value_metric_sender_test.go

示例13:

import (
	"bytes"
	"errors"
	"github.com/cloudfoundry/dropsonde/emitter/fake"
	"github.com/cloudfoundry/dropsonde/events"
	"github.com/cloudfoundry/dropsonde/log_sender"
	"github.com/cloudfoundry/loggregatorlib/loggertesthelper"
	"io"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("LogSender", func() {
	var (
		emitter *fake.FakeEventEmitter
		sender  log_sender.LogSender
	)

	BeforeEach(func() {
		emitter = fake.NewFakeEventEmitter("origin")
		sender = log_sender.NewLogSender(emitter, nil)
	})

	Describe("SendAppLog", func() {
		It("sends a log message event to its emitter", func() {
			err := sender.SendAppLog("app-id", "custom-log-message", "App", "0")
			Expect(err).NotTo(HaveOccurred())

			Expect(emitter.Messages).To(HaveLen(1))
			log := emitter.Messages[0].Event.(*events.LogMessage)
			Expect(log.GetMessageType()).To(Equal(events.LogMessage_OUT))
开发者ID:johannespetzold,项目名称:gorouter,代码行数:32,代码来源:log_sender_test.go

示例14:

import (
	"errors"

	"github.com/cloudfoundry/dropsonde/emitter/fake"

	"github.com/cloudfoundry/dropsonde/envelope_sender"
	"github.com/gogo/protobuf/proto"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("EnvelopeSender", func() {
	var (
		emitter   *fake.FakeEventEmitter
		sender    envelope_sender.EnvelopeSender
		envOrigin string
	)

	BeforeEach(func() {
		envOrigin = "original-origin"
		emitter = fake.NewFakeEventEmitter("origin")
		sender = envelope_sender.NewEnvelopeSender(emitter)
	})

	It("sends an Envelope to its emitter", func() {
		err := sender.SendEnvelope(createTestEnvelope(envOrigin))
		Expect(err).NotTo(HaveOccurred())

		Expect(emitter.GetEnvelopes()).To(HaveLen(1))
		envelope := emitter.GetEnvelopes()[0]
开发者ID:fraenkel,项目名称:dropsonde,代码行数:30,代码来源:envelope_sender_test.go


注:本文中的github.com/cloudfoundry/dropsonde/emitter/fake.FakeEventEmitter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。