• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang fakelogger.NewFakeLogger函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: defaultConf

func defaultConf() HandlerConf {
	return HandlerConf{
		StoreAdapter: fakestoreadapter.New(),
		Clock:        fakeclock.NewFakeClock(time.Unix(100, 0)),
		Logger:       fakelogger.NewFakeLogger(),
	}
}
开发者ID:nagyistge,项目名称:hm9000,代码行数:7,代码来源:bulk_app_state_test.go


示例2: makeHandlerAndStore

func makeHandlerAndStore(conf HandlerConf) (http.Handler, store.Store, error) {
	config, _ := config.DefaultConfig()

	store := store.NewStore(config, conf.StoreAdapter, fakelogger.NewFakeLogger())

	handler, err := handlers.New(conf.Logger, store, conf.TimeProvider)
	return handler, store, err
}
开发者ID:cgrotz,项目名称:hm9000,代码行数:8,代码来源:bulk_app_state_test.go


示例3: defaultConf

func defaultConf() HandlerConf {
	return HandlerConf{
		StoreAdapter: fakestoreadapter.New(),
		TimeProvider: &faketimeprovider.FakeTimeProvider{
			TimeToProvide: time.Unix(100, 0),
		},
		Logger: fakelogger.NewFakeLogger(),
	}
}
开发者ID:cgrotz,项目名称:hm9000,代码行数:9,代码来源:bulk_app_state_test.go


示例4: PrepForNextTest

func (coordinator *MCATCoordinator) PrepForNextTest() (*CLIRunner, *Simulator, *startstoplistener.StartStopListener) {
	coordinator.StoreRunner.Reset()
	coordinator.startStopListener.Reset()
	coordinator.StateServer.Reset()

	if coordinator.currentCLIRunner != nil {
		coordinator.currentCLIRunner.Cleanup()
	}
	coordinator.currentCLIRunner = NewCLIRunner(coordinator.StoreRunner.NodeURLS(), coordinator.DesiredStateServerBaseUrl, coordinator.NatsPort, coordinator.MetricsServerPort, coordinator.Verbose)
	store := storepackage.NewStore(coordinator.Conf, coordinator.StoreAdapter, fakelogger.NewFakeLogger())
	simulator := NewSimulator(coordinator.Conf, coordinator.StoreRunner, store, coordinator.StateServer, coordinator.currentCLIRunner, coordinator.MessageBus)

	return coordinator.currentCLIRunner, simulator, coordinator.startStopListener
}
开发者ID:philwhln,项目名称:hm9000,代码行数:14,代码来源:mcat_coordinator_test.go


示例5: main

func main() {
	cmdsToStop = []*exec.Cmd{}

	registerSignalHandler()
	nats = natsrunner.NewNATSRunner(4222)
	nats.Start()

	fakeCC := desiredstateserver.NewDesiredStateServer()
	go fakeCC.SpinUp(6001)

	// etcd = storerunner.NewETCDClusterRunner(4001, 1)
	// etcd.Start()
	conf, _ := config.FromFile("./config.json")
	adapter := storeadapter.NewETCDStoreAdapter(conf.StoreURLs, workerpool.NewWorkerPool(30))
	adapter.Connect()
	store = storepackage.NewStore(conf, adapter, fakelogger.NewFakeLogger())

	r := rand.New(rand.NewSource(time.Now().Unix()))
	num, err := strconv.Atoi(os.Args[1])
	if err != nil {
		panic(err)
	}

	sim := simulator.New(num, 10, r, nats.MessageBus, fakeCC)
	//start all the HM components (make them pipe to stdout)
	start("listen", false)
	start("fetch_desired", true)
	start("analyze", true)
	start("send", true)
	start("serve_metrics", false)
	start("serve_api", false)
	time.Sleep(time.Second)
	go Tick(sim)
	go Fetch()
	select {}
}
开发者ID:pivotal-cf-experimental,项目名称:hmperformance,代码行数:36,代码来源:benchmarks.go


示例6:

	"github.com/cloudfoundry/storeadapter/fakestoreadapter"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"time"
)

var _ = Describe("Metrics Accountant", func() {
	var store storepackage.Store
	var accountant MetricsAccountant
	var fakeStoreAdapter *fakestoreadapter.FakeStoreAdapter

	conf, _ := config.DefaultConfig()

	BeforeEach(func() {
		fakeStoreAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, fakeStoreAdapter, fakelogger.NewFakeLogger())
		accountant = New(store)
	})

	Describe("Getting Metrics", func() {
		Context("when the store is empty", func() {
			It("should return a map of 0s", func() {
				metrics, err := accountant.GetMetrics()
				Ω(err).ShouldNot(HaveOccurred())
				Ω(metrics).Should(Equal(map[string]float64{
					"StartCrashed":                            0,
					"StartMissing":                            0,
					"StartEvacuating":                         0,
					"StopExtra":                               0,
					"StopDuplicate":                           0,
					"StopEvacuationComplete":                  0,
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:31,代码来源:metricsaccountant_test.go


示例7:

var _ = Describe("Analyzer", func() {
	var (
		analyzer     *Analyzer
		storeAdapter *fakestoreadapter.FakeStoreAdapter
		store        storepackage.Store
		clock        *fakeclock.FakeClock
		dea          appfixture.DeaFixture
		app          appfixture.AppFixture
	)

	conf, _ := config.DefaultConfig()

	BeforeEach(func() {
		storeAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())

		clock = fakeclock.NewFakeClock(time.Unix(1000, 0))

		dea = appfixture.NewDeaFixture()
		app = dea.GetApp(0)

		store.BumpActualFreshness(time.Unix(100, 0))
		store.BumpDesiredFreshness(time.Unix(100, 0))

		analyzer = New(store, clock, fakelogger.NewFakeLogger(), conf)
	})

	startMessages := func() []models.PendingStartMessage {
		messages, _ := store.GetPendingStartMessages()
		messagesArr := []models.PendingStartMessage{}
开发者ID:nagyistge,项目名称:hm9000,代码行数:30,代码来源:analyzer_test.go


示例8:

	BeforeEach(func() {
		var err error
		conf, err = config.DefaultConfig()
		Ω(err).ShouldNot(HaveOccured())

		timeProvider = &faketimeprovider.FakeTimeProvider{
			TimeToProvide: time.Now(),
		}

		app = NewApp()
		anotherApp = NewApp()

		store = fakestore.NewFakeStore()
		messageBus = fake_cfmessagebus.NewFakeMessageBus()
		logger = fakelogger.NewFakeLogger()

		listener = New(conf, messageBus, store, timeProvider, logger)
		listener.Start()
	})

	It("should subscribe to the dea.heartbeat subject", func() {
		Ω(messageBus.Subscriptions).Should(HaveKey("dea.heartbeat"))
		Ω(messageBus.Subscriptions["dea.heartbeat"]).Should(HaveLen(1))
	})

	Context("When it receives a simple heartbeat over the message bus", func() {
		BeforeEach(func() {
			messageBus.Subscriptions["dea.heartbeat"][0].Callback(app.Heartbeat(1, 17).ToJson())
		})
开发者ID:Zhann,项目名称:hm9000,代码行数:29,代码来源:actual_state_listener_test.go


示例9:

	var (
		evacuator    *Evacuator
		messageBus   *fakeyagnats.FakeNATSConn
		storeAdapter *fakestoreadapter.FakeStoreAdapter
		timeProvider *faketimeprovider.FakeTimeProvider

		store storepackage.Store
		app   appfixture.AppFixture
	)

	conf, _ := config.DefaultConfig()

	BeforeEach(func() {
		storeAdapter = fakestoreadapter.New()
		messageBus = fakeyagnats.Connect()
		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
		timeProvider = &faketimeprovider.FakeTimeProvider{
			TimeToProvide: time.Unix(100, 0),
		}

		app = appfixture.NewAppFixture()

		evacuator = New(messageBus, store, timeProvider, conf, fakelogger.NewFakeLogger())
		evacuator.Listen()
	})

	It("should be listening on the message bus for droplet.exited", func() {
		Ω(messageBus.SubjectCallbacks("droplet.exited")).ShouldNot(BeNil())
	})

	Context("when droplet.exited is received", func() {
开发者ID:cgrotz,项目名称:hm9000,代码行数:31,代码来源:evacuator_test.go


示例10:

	makeRequest := func(request string) (response string) {
		replyToGuid := models.Guid()
		messageBus.Subscriptions["app.state"][0].Callback(&yagnats.Message{
			Payload: []byte(request),
			ReplyTo: replyToGuid,
		})

		Ω(messageBus.PublishedMessages[replyToGuid]).Should(HaveLen(1))
		return string(messageBus.PublishedMessages[replyToGuid][0].Payload)
	}

	BeforeEach(func() {
		messageBus = fakeyagnats.New()
		storeAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
		timeProvider = &faketimeprovider.FakeTimeProvider{
			TimeToProvide: time.Unix(100, 0),
		}

		server := apiserver.New(messageBus, store, timeProvider, fakelogger.NewFakeLogger())
		server.Listen()
	})

	It("should subscribe on a queue", func() {
		Ω(messageBus.Subscriptions["app.state"]).ShouldNot(BeEmpty())
		subscription := messageBus.Subscriptions["app.state"][0]
		Ω(subscription.Queue).Should(Equal("hm9000"))
	})

	Context("responding to app.state", func() {
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:30,代码来源:apiserver_test.go


示例11:

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

var _ = Describe("Metrics Server", func() {
	var (
		store             storepackage.Store
		storeAdapter      *fakestoreadapter.FakeStoreAdapter
		timeProvider      *fakeclock.FakeClock
		metricsServer     *MetricsServer
		metricsAccountant *fakemetricsaccountant.FakeMetricsAccountant
	)

	BeforeEach(func() {
		conf, _ := config.DefaultConfig()
		storeAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
		timeProvider = fakeclock.NewFakeClock(time.Unix(100, 0))

		metricsAccountant = &fakemetricsaccountant.FakeMetricsAccountant{}

		metricsServer = New(nil, nil, metricsAccountant, fakelogger.NewFakeLogger(), store, timeProvider, conf)
	})

	Describe("message metrics", func() {
		BeforeEach(func() {
			metricsAccountant.GetMetricsReturns(map[string]float64{
				"foo": 1,
				"bar": 2,
			}, nil)
		})
开发者ID:nagyistge,项目名称:hm9000,代码行数:30,代码来源:metricsserver_test.go


示例12:

		defer close(done)

		go func() {
			released := <-adapter.ReleaseNodeChannel
			released <- true
		}()

		callTimes := []float64{}
		startTime := time.Now()
		i := 0
		err := Daemonize("Daemon Test", func() error {
			callTimes = append(callTimes, time.Since(startTime).Seconds())
			i += 1
			time.Sleep(time.Duration(i*10) * time.Millisecond)
			return nil
		}, 20*time.Millisecond, 35*time.Millisecond, fakelogger.NewFakeLogger(), adapter)

		Ω(callTimes).Should(HaveLen(4))

		Ω(callTimes[0]).Should(BeNumerically("~", 0, 0.005), "The first call happens immediately and sleeps for 10 seconds")
		Ω(callTimes[1]).Should(BeNumerically("~", 0.02, 0.005), "The second call happens after PERIOD and sleeps for 20 seconds")
		Ω(callTimes[2]).Should(BeNumerically("~", 0.04, 0.005), "The third call happens after PERIOD and sleeps for 30 seconds")
		Ω(callTimes[3]).Should(BeNumerically("~", 0.07, 0.005), "The fourth call waits for function to finish and happens after 30 seconds (> PERIOD) and sleeps for 40 seconds which...")
		Ω(err).Should(Equal(errors.New("Daemon timed out. Aborting!")), "..causes a timeout")
	})

	It("acquires the lock once", func() {
		go Daemonize(
			"ComponentName",
			func() error { return nil },
			20*time.Millisecond,
开发者ID:philwhln,项目名称:hm9000,代码行数:31,代码来源:daemon_test.go


示例13:

	BeforeEach(func() {
		var err error
		conf, err = config.DefaultConfig()
		Ω(err).ShouldNot(HaveOccurred())

		metricsAccountant = fakemetricsaccountant.New()

		resultChan = make(chan DesiredStateFetcherResult, 1)
		timeProvider = &faketimeprovider.FakeTimeProvider{
			TimeToProvide: time.Unix(100, 0),
		}

		httpClient = fakehttpclient.NewFakeHttpClient()
		storeAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())

		fetcher = New(conf, store, metricsAccountant, httpClient, timeProvider, fakelogger.NewFakeLogger())
		fetcher.Fetch(resultChan)
	})

	Describe("Fetching with an invalid URL", func() {
		BeforeEach(func() {
			conf.CCBaseURL = "http://example.com/#%ZZ"
			fetcher = New(conf, store, metricsAccountant, httpClient, timeProvider, fakelogger.NewFakeLogger())
			fetcher.Fetch(resultChan)
		})

		It("should send an error down the result channel", func(done Done) {
			result := <-resultChan
			Ω(result.Success).Should(BeFalse())
开发者ID:KeyOfSpectator,项目名称:hm9000,代码行数:30,代码来源:desired_state_fetcher_test.go


示例14:

		metricsAccountant *fakemetricsaccountant.FakeMetricsAccountant
	)

	BeforeEach(func() {
		messageBus = fakeyagnats.New()
		dea = appfixture.NewDeaFixture()
		app = dea.GetApp(0)
		conf, _ = config.DefaultConfig()
		metricsAccountant = fakemetricsaccountant.New()

		timeProvider = &faketimeprovider.FakeTimeProvider{
			TimeToProvide: time.Unix(int64(10+conf.ActualFreshnessTTL()), 0),
		}

		storeAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
		sender = New(store, metricsAccountant, conf, messageBus, timeProvider, fakelogger.NewFakeLogger())
		store.BumpActualFreshness(time.Unix(10, 0))
		store.BumpDesiredFreshness(time.Unix(10, 0))
	})

	Context("when the sender fails to pull messages out of the start queue", func() {
		BeforeEach(func() {
			storeAdapter.ListErrInjector = fakestoreadapter.NewFakeStoreAdapterErrorInjector("start", errors.New("oops"))
		})

		It("should return an error and not send any messages", func() {
			err := sender.Send()
			Ω(err).Should(Equal(errors.New("oops")))
			Ω(messageBus.PublishedMessages).Should(BeEmpty())
		})
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:31,代码来源:sender_test.go


示例15:

	BeforeEach(func() {
		storeAdapter = fakestoreadapter.New()
		resultChan = make(chan desiredstatefetcher.DesiredStateFetcherResult, 1)
		a1 = appfixture.NewAppFixture()
		a2 = appfixture.NewAppFixture()
		a3 = appfixture.NewAppFixture()

		stateServer.SetDesiredState([]models.DesiredAppState{
			a1.DesiredState(1),
			a2.DesiredState(1),
			a3.DesiredState(1),
		})

		conf, _ = config.DefaultConfig()

		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())

		fetcher = desiredstatefetcher.New(conf, store, &fakemetricsaccountant.FakeMetricsAccountant{}, httpclient.NewHttpClient(conf.SkipSSLVerification, conf.FetcherNetworkTimeout()), clock.NewClock(), fakelogger.NewFakeLogger())
		fetcher.Fetch(resultChan)
	})

	It("requests for the first set of data from the CC and stores the response", func() {
		var desired map[string]models.DesiredAppState
		var err error
		Eventually(func() interface{} {
			desired, err = store.GetDesiredState()
			return desired
		}, 1, 0.1).ShouldNot(BeEmpty())

		Ω(desired).Should(HaveKey(a1.AppGuid + "," + a1.AppVersion))
		Ω(desired).Should(HaveKey(a2.AppGuid + "," + a2.AppVersion))
开发者ID:nagyistge,项目名称:hm9000,代码行数:31,代码来源:desired_state_fetcher_integration_test.go


示例16:

		dea        appfixture.DeaFixture
		app1       appfixture.AppFixture
		app2       appfixture.AppFixture
		app3       appfixture.AppFixture
		app4       appfixture.AppFixture
		crashCount []models.CrashCount
	)

	conf, _ = config.DefaultConfig()

	BeforeEach(func() {
		storeAdapter = etcdstoreadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), workerpool.NewWorkerPool(conf.StoreMaxConcurrentRequests))
		err := storeAdapter.Connect()
		Ω(err).ShouldNot(HaveOccurred())

		store = NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())

		dea = appfixture.NewDeaFixture()
		app1 = dea.GetApp(0)
		app2 = dea.GetApp(1)
		app3 = dea.GetApp(2)
		app4 = dea.GetApp(3)

		actualState := []models.InstanceHeartbeat{
			app1.InstanceAtIndex(0).Heartbeat(),
			app1.InstanceAtIndex(1).Heartbeat(),
			app1.InstanceAtIndex(2).Heartbeat(),
			app2.InstanceAtIndex(0).Heartbeat(),
		}

		desiredState := []models.DesiredAppState{
开发者ID:KeyOfSpectator,项目名称:hm9000,代码行数:31,代码来源:apps_test.go


示例17:

	BeforeEach(func() {
		storeAdapter = fakestoreadapter.New()
		resultChan = make(chan desiredstatefetcher.DesiredStateFetcherResult, 1)
		a1 = appfixture.NewAppFixture()
		a2 = appfixture.NewAppFixture()
		a3 = appfixture.NewAppFixture()

		stateServer.SetDesiredState([]models.DesiredAppState{
			a1.DesiredState(1),
			a2.DesiredState(1),
			a3.DesiredState(1),
		})

		conf, _ = config.DefaultConfig()

		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())

		fetcher = desiredstatefetcher.New(conf, store, fakemetricsaccountant.New(), httpclient.NewHttpClient(conf.SkipSSLVerification, conf.FetcherNetworkTimeout()), &timeprovider.RealTimeProvider{}, fakelogger.NewFakeLogger())
		fetcher.Fetch(resultChan)
	})

	It("requests for the first set of data from the CC and stores the response", func() {
		var desired map[string]models.DesiredAppState
		var err error
		Eventually(func() interface{} {
			desired, err = store.GetDesiredState()
			return desired
		}, 1, 0.1).ShouldNot(BeEmpty())

		Ω(desired).Should(HaveKey(a1.AppGuid + "," + a1.AppVersion))
		Ω(desired).Should(HaveKey(a2.AppGuid + "," + a2.AppVersion))
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:31,代码来源:desired_state_fetcher_integration_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang loggregator_consumer.New函数代码示例发布时间:2022-05-23
下一篇:
Golang appfixture.DeaFixture类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap