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


Golang fake.FakeMetricSender类代码示例

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


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

示例1:

	"github.com/cloudfoundry/dropsonde/signature"
	"github.com/cloudfoundry/sonde-go/events"
	"github.com/gogo/protobuf/proto"

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

var _ = Describe("UDPWrapper", func() {
	var (
		sender       *fake.FakeMetricSender
		client       *mockClient
		envelope     *events.Envelope
		udpWrapper   *dopplerforwarder.UDPWrapper
		logger       *gosteno.Logger
		message      []byte
		sharedSecret []byte
	)

	BeforeEach(func() {
		sharedSecret = []byte("secret")
		sender = fake.NewFakeMetricSender()
		metrics.Initialize(sender, metricbatcher.New(sender, time.Millisecond*10))
		client = newMockClient()
		envelope = &events.Envelope{
			Origin:     proto.String("fake-origin-1"),
			EventType:  events.Envelope_LogMessage.Enum(),
			LogMessage: factories.NewLogMessage(events.LogMessage_OUT, "message", "appid", "sourceType"),
		}
开发者ID:yingkitw,项目名称:loggregator,代码行数:31,代码来源:udp_wrapper_test.go

示例2:

	"github.com/cloudfoundry-incubator/rep"
	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	"github.com/cloudfoundry/dropsonde/metrics"
	"github.com/pivotal-golang/lager"
	"github.com/pivotal-golang/lager/lagertest"
	"github.com/tedsuo/rata"

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

var _ = Describe("Auction Handlers", func() {
	var (
		logger           *lagertest.TestLogger
		sender           *fake.FakeMetricSender
		runner           *fake_auction_runner.FakeAuctionRunner
		responseRecorder *httptest.ResponseRecorder
		handler          http.Handler
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG))
		runner = new(fake_auction_runner.FakeAuctionRunner)
		responseRecorder = httptest.NewRecorder()

		sender = fake.NewFakeMetricSender()
		metrics.Initialize(sender, nil)

		handler = handlers.New(runner, logger)
	})
开发者ID:cfibmers,项目名称:auctioneer,代码行数:31,代码来源:handlers_test.go

示例3:

	"time"

	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/bbs/models/test/model_helpers"
	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	"github.com/cloudfoundry/dropsonde/metrics"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

const TTL = 0

var _ = Describe("Convergence of Tasks", func() {
	var (
		sender *fake.FakeMetricSender

		kickTasksDurationInSeconds, expirePendingTaskDurationInSeconds            uint64
		kickTasksDuration, expirePendingTaskDuration, expireCompletedTaskDuration time.Duration
	)

	BeforeEach(func() {
		sender = fake.NewFakeMetricSender()
		metrics.Initialize(sender, nil)

		kickTasksDurationInSeconds = 10
		kickTasksDuration = time.Duration(kickTasksDurationInSeconds) * time.Second
		expirePendingTaskDurationInSeconds = 30
		expirePendingTaskDuration = time.Duration(expirePendingTaskDurationInSeconds) * time.Second
		expireCompletedTaskDuration = time.Hour
	})

	Describe("ConvergeTasks", func() {
开发者ID:emc-xchallenge,项目名称:bbs,代码行数:32,代码来源:task_convergence_test.go

示例4:

	"time"

	"github.com/cloudfoundry-incubator/auction/auctiontypes"
	"github.com/cloudfoundry-incubator/auctioneer/auctionmetricemitterdelegate"
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/rep"
	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	"github.com/cloudfoundry/dropsonde/metrics"

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

var _ = Describe("Auction Metric Emitter Delegate", func() {
	var delegate auctiontypes.AuctionMetricEmitterDelegate
	var metricSender *fake.FakeMetricSender

	BeforeEach(func() {
		metricSender = fake.NewFakeMetricSender()
		metrics.Initialize(metricSender, nil)

		delegate = auctionmetricemitterdelegate.New()
	})

	Describe("AuctionCompleted", func() {
		It("should adjust the metric counters", func() {
			resource := rep.NewResource(10, 10, "linux")
			delegate.AuctionCompleted(auctiontypes.AuctionResults{
				SuccessfulLRPs: []auctiontypes.LRPAuction{
					{
						LRP: rep.NewLRP(models.NewActualLRPKey("successful-start", 0, "domain"), resource),
开发者ID:emc-xchallenge,项目名称:auctioneer,代码行数:31,代码来源:auctionmetricemitterdelegate_test.go

示例5:

	"github.com/pivotal-golang/lager"
	"github.com/pivotal-golang/lager/lagertest"
	"github.com/pivotal-golang/operationq"
	"github.com/pivotal-golang/operationq/fake_operationq"
	"github.com/tedsuo/ifrit"
)

var _ = Describe("Bulker", func() {
	var (
		sender *fake.FakeMetricSender

		logger                 *lagertest.TestLogger
		pollInterval           time.Duration
		evacuationPollInterval time.Duration
		fakeClock              *fakeclock.FakeClock
		fakeGenerator          *fake_generator.FakeGenerator
		fakeQueue              *fake_operationq.FakeQueue
		evacuatable            evacuation_context.Evacuatable
		evacuationNotifier     evacuation_context.EvacuationNotifier

		bulker  *harmonizer.Bulker
		process ifrit.Process
	)

	BeforeEach(func() {
		sender = fake.NewFakeMetricSender()
		metrics.Initialize(sender, nil)

		logger = lagertest.NewTestLogger("test")
		pollInterval = 30 * time.Second
		evacuationPollInterval = 10 * time.Second
开发者ID:jiangytcn,项目名称:rep,代码行数:31,代码来源:bulker_test.go

示例6:

	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	"github.com/cloudfoundry/dropsonde/metrics"
	"github.com/pivotal-golang/lager/lagertest"

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

var _ = Describe("DesireAppHandler", func() {
	var (
		logger           *lagertest.TestLogger
		fakeBBS          *fake_bbs.FakeClient
		buildpackBuilder *fakes.FakeRecipeBuilder
		dockerBuilder    *fakes.FakeRecipeBuilder
		desireAppRequest cc_messages.DesireAppRequestFromCC
		metricSender     *fake.FakeMetricSender

		request          *http.Request
		responseRecorder *httptest.ResponseRecorder
	)

	BeforeEach(func() {
		var err error

		logger = lagertest.NewTestLogger("test")
		fakeBBS = new(fake_bbs.FakeClient)
		buildpackBuilder = new(fakes.FakeRecipeBuilder)
		dockerBuilder = new(fakes.FakeRecipeBuilder)

		routingInfo, err := cc_messages.CCHTTPRoutes{
开发者ID:cf-routing,项目名称:nsync,代码行数:31,代码来源:desire_app_handler_test.go

示例7:

package metricbatcher_test

import (
	"time"

	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	"github.com/cloudfoundry/dropsonde/metricbatcher"

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

var _ = Describe("MetricBatcher", func() {
	var (
		fakeMetricSender *fake.FakeMetricSender
		metricBatcher    *metricbatcher.MetricBatcher
	)

	BeforeEach(func() {
		fakeMetricSender = fake.NewFakeMetricSender()
		metricBatcher = metricbatcher.New(fakeMetricSender, 50*time.Millisecond)
	})

	Describe("BatchIncrementCounter", func() {
		It("batches and then sends a single metric", func() {
			metricBatcher.BatchIncrementCounter("count")
			Expect(fakeMetricSender.GetCounter("count")).To(BeEquivalentTo(0)) // should not increment.

			metricBatcher.BatchIncrementCounter("count")
			metricBatcher.BatchIncrementCounter("count")
开发者ID:trainchou,项目名称:gorouter,代码行数:30,代码来源:metricbatcher_test.go

示例8:

	"github.com/cloudfoundry/dropsonde/metricbatcher"
	"github.com/cloudfoundry/dropsonde/metrics"
	"github.com/cloudfoundry/dropsonde/signature"
	"github.com/cloudfoundry/gosteno"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var sharedSecret = []byte("secret")

var _ = Describe("DopplerForwarder", func() {
	var (
		sender     *fake.FakeMetricSender
		clientPool *fakes.FakeClientPool
		client     *fakeclient.FakeClient
		logger     *gosteno.Logger
		forwarder  *dopplerforwarder.DopplerForwarder
		envelope   *events.Envelope
		doneChan   chan struct{}
		bufferSize uint
	)

	BeforeEach(func() {
		sender = fake.NewFakeMetricSender()
		metrics.Initialize(sender, metricbatcher.New(sender, time.Millisecond*10))

		client = &fakeclient.FakeClient{}
		clientPool = &fakes.FakeClientPool{}
		clientPool.RandomClientReturns(client, nil)

		logger = loggertesthelper.Logger()
		loggertesthelper.TestLoggerSink.Clear()
开发者ID:hpcloud,项目名称:loggregator-1,代码行数:32,代码来源:doppler_forwarder_test.go

示例9:

	"code.cloudfoundry.org/bbs/handlers/middleware"
	"code.cloudfoundry.org/lager"
	"code.cloudfoundry.org/lager/lagertest"
	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	dropsonde_metrics "github.com/cloudfoundry/dropsonde/metrics"

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

var _ = Describe("Middleware", func() {
	Describe("EmitLatency", func() {
		var (
			sender  *fake.FakeMetricSender
			handler http.HandlerFunc
		)

		BeforeEach(func() {
			sender = fake.NewFakeMetricSender()
			dropsonde_metrics.Initialize(sender, nil)
			logger := lager.NewLogger("test-session")

			handler = func(w http.ResponseWriter, r *http.Request) { time.Sleep(10) }
			handler = middleware.NewLatencyEmitter(logger).EmitLatency(handler)
		})

		It("reports latency", func() {
			handler.ServeHTTP(nil, nil)

			latency := sender.GetValue("RequestLatency")
开发者ID:cloudfoundry,项目名称:bbs,代码行数:31,代码来源:middleware_test.go

示例10:

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

var _ = Describe("Lock", func() {
	var (
		lockKey              string
		lockHeldMetricName   string
		lockUptimeMetricName string
		lockValue            []byte

		consulClient consuladapter.Client

		lockRunner    ifrit.Runner
		lockProcess   ifrit.Process
		retryInterval time.Duration
		lockTTL       time.Duration
		logger        lager.Logger

		sender *fake.FakeMetricSender
		clock  *fakeclock.FakeClock
	)

	getLockValue := func() ([]byte, error) {
		kvPair, _, err := consulClient.KV().Get(lockKey, nil)
		if err != nil {
			return nil, err
		}
开发者ID:cloudfoundry,项目名称:locket,代码行数:29,代码来源:lock_test.go

示例11:

	"github.com/pivotal-golang/clock/fakeclock"
	"github.com/pivotal-golang/lager"

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

var _ = Describe("StagingCompletedHandler", func() {
	var (
		logger lager.Logger
		appId  string
		taskId string

		fakeCCClient        *fakes.FakeCcClient
		fakeBackend         *fake_backend.FakeBackend
		backendResponse     cc_messages.StagingResponseForCC
		backendError        error
		fakeClock           *fakeclock.FakeClock
		metricSender        *fake.FakeMetricSender
		stagingDurationNano time.Duration

		responseRecorder *httptest.ResponseRecorder
		handler          handlers.CompletionHandler
	)

	BeforeEach(func() {
		logger = lager.NewLogger("fakelogger")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG))

		appId = "my_app_id"
		taskId = "do_this"
开发者ID:cfibmers,项目名称:stager,代码行数:31,代码来源:staging_completed_handler_test.go

示例12:

	"github.com/cloudfoundry-incubator/garden-linux/metrics/fakes"
	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	dropsonde_metrics "github.com/cloudfoundry/dropsonde/metrics"
	"github.com/pivotal-golang/clock/fakeclock"
	"github.com/pivotal-golang/lager/lagertest"

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

var _ = Describe("PeriodicMetronNotifier", func() {
	var (
		sender *fake.FakeMetricSender

		fakeMetrics    *fakes.FakeMetrics
		reportInterval time.Duration
		fakeClock      *fakeclock.FakeClock

		pmn *metrics.PeriodicMetronNotifier
	)

	BeforeEach(func() {
		reportInterval = 100 * time.Millisecond

		fakeMetrics = new(fakes.FakeMetrics)
		fakeMetrics.LoopDevicesReturns(33)
		fakeMetrics.BackingStoresReturns(12)
		fakeMetrics.DepotDirsReturns(3)

		fakeClock = fakeclock.NewFakeClock(time.Unix(123, 456))
开发者ID:timani,项目名称:garden-linux,代码行数:30,代码来源:periodic_metron_notifier_test.go

示例13:

package metrics_test

import (
	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	"github.com/cloudfoundry/dropsonde/metricbatcher"
	"github.com/cloudfoundry/dropsonde/metrics"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"time"
)

var _ = Describe("Metrics", func() {
	var fakeMetricSender *fake.FakeMetricSender

	BeforeEach(func() {
		fakeMetricSender = fake.NewFakeMetricSender()
		metricBatcher := metricbatcher.New(fakeMetricSender, time.Millisecond)
		metrics.Initialize(fakeMetricSender, metricBatcher)
	})

	It("delegates SendValue", func() {
		metrics.SendValue("metric", 42.42, "answers")

		Expect(fakeMetricSender.GetValue("metric").Value).To(Equal(42.42))
		Expect(fakeMetricSender.GetValue("metric").Unit).To(Equal("answers"))
	})

	It("delegates IncrementCounter", func() {
		metrics.IncrementCounter("count")

		Expect(fakeMetricSender.GetCounter("count")).To(BeEquivalentTo(1))
开发者ID:benlaplanche,项目名称:emitter,代码行数:31,代码来源:metrics_test.go

示例14:

	"github.com/cloudfoundry/dropsonde/metrics"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var (
	tmpdir   string
	filePath string
)

var _ = Describe("DeaAgent", func() {
	var (
		task1StdoutListener net.Listener
		task1StderrListener net.Listener
		task2StdoutListener net.Listener
		task2StderrListener net.Listener
		expectedMessage     = "Some Output"
		agent               *deaagent.Agent
		fakeMetricSender    *fake.FakeMetricSender
	)

	BeforeEach(func() {
		fakeLogSender.Reset()

		var err error
		tmpdir, err = ioutil.TempDir("", "testing")
		if err != nil {
			panic(err)
		}
		filePath = tmpdir + "/instances.json"
开发者ID:lyuyun,项目名称:loggregator,代码行数:30,代码来源:agent_test.go

示例15:

	"github.com/cloudfoundry/dropsonde/metricbatcher"
	"github.com/cloudfoundry/dropsonde/metrics"
	"github.com/cloudfoundry/gosteno"
	"github.com/cloudfoundry/loggregatorlib/loggertesthelper"
	"github.com/cloudfoundry/sonde-go/events"
)

var bufferSize uint64

var _ = Describe("Batch Writer", func() {

	var (
		byteWriter      *mockByteWriter
		messageBytes    []byte
		prefixedMessage []byte
		batcher         *batch.Writer
		timeout         time.Duration
		logger          *gosteno.Logger
		sender          *fake.FakeMetricSender
		constructorErr  error
	)

	BeforeEach(func() {
		sender = fake.NewFakeMetricSender()
		metrics.Initialize(sender, metricbatcher.New(sender, time.Millisecond*10))
		byteWriter = newMockByteWriter()
		close(byteWriter.WriteOutput.err)
		messageBytes = []byte("this is a log message")
		timeout = time.Second / 2
		bufferSize = 1024
		logger = loggertesthelper.Logger()
开发者ID:yingkitw,项目名称:loggregator,代码行数:31,代码来源:writer_test.go


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