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


Golang test_utils.BuildLogger函数代码示例

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


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

示例1: TestTestCollect

func TestTestCollect(t *testing.T) {
	config := make(map[string]interface{})

	testChannel := make(chan metric.Metric)
	testLogger := test_utils.BuildLogger()

	// conforms to the valueGenerator interface in the collector
	mockGen := func() float64 {
		return 4.0
	}

	test := NewTest(testChannel, 123, testLogger)
	test.Configure(config)
	test.generator = mockGen

	go test.Collect()

	select {
	case m := <-test.Channel():
		assert.Equal(t, 4.0, m.Value)
		return
	case <-time.After(2 * time.Second):
		t.Fail()
	}
}
开发者ID:jp2007,项目名称:fullerite,代码行数:25,代码来源:test_test.go

示例2: TestDiamondCollect

func TestDiamondCollect(t *testing.T) {
	config := make(map[string]interface{})
	config["port"] = "0"

	testChannel := make(chan metric.Metric)
	testLog := test_utils.BuildLogger()

	d := newDiamond(testChannel, 123, testLog).(*Diamond)
	d.Configure(config)

	// start collecting Diamond metrics
	go d.Collect()

	conn, err := connectToDiamondCollector(d)
	require.Nil(t, err, "should connect")
	require.NotNil(t, conn, "should connect")

	emitTestMetric(conn)

	select {
	case m := <-d.Channel():
		assert.Equal(t, m.Name, "test")
	case <-time.After(1 * time.Second):
		t.Fail()
	}
}
开发者ID:EvanKrall,项目名称:fullerite,代码行数:26,代码来源:diamond_test.go

示例3: TestProcStatusCollect

func TestProcStatusCollect(t *testing.T) {
	config := make(map[string]interface{})
	config["interval"] = 9999

	dims := map[string]string{
		"module": "(.*)",
	}

	config["generatedDimensions"] = dims

	channel := make(chan metric.Metric)

	testLog := test_utils.BuildLogger()
	ps := NewProcStatus(channel, 12, testLog)
	ps.Configure(config)

	go ps.Collect()

	select {
	case <-ps.Channel():
		return
	case <-time.After(2 * time.Second):
		t.Fail()
	}
}
开发者ID:jp2007,项目名称:fullerite,代码行数:25,代码来源:procstatus_linux_test.go

示例4: TestProcStatusMetrics

func TestProcStatusMetrics(t *testing.T) {
	testLog := test_utils.BuildLogger()

	config := make(map[string]interface{})

	dims := map[string]string{
		"seven":  "(.......)",
		"eleven": "(...........)",
	}
	config["generatedDimensions"] = dims

	ps := NewProcStatus(nil, 12, testLog)
	ps.Configure(config)

	count := 0
	for _, m := range ps.procStatusMetrics() {
		mDims := m.Dimensions
		_, existsSeven := mDims["seven"]
		_, existsEleven := mDims["eleven"]
		if existsSeven == false || existsEleven == false {
			continue
		}
		count++
	}
	if count == 0 {
		t.Fail()
	}
}
开发者ID:jp2007,项目名称:fullerite,代码行数:28,代码来源:procstatus_linux_test.go

示例5: TestCollectorLogsErrors

func TestCollectorLogsErrors(t *testing.T) {
	testLogger := test_utils.BuildLogger()
	testLogger = testLogger.WithField("collector", "Test")

	channel := make(chan metric.Metric)
	config := make(map[string]interface{})

	testCol := collector.NewTest(channel, 123, testLogger)
	testCol.Configure(config)

	timeout := time.Duration(5 * time.Second)
	h := handler.NewTest(channel, 10, 10, timeout, testLogger)

	hook := NewLogErrorHook([]handler.Handler{h})
	testLogger.Logger.Hooks.Add(hook)

	go testCol.Collect()
	testLogger.Error("testing Error log")

	select {
	case m := <-h.Channel():
		assert.Equal(t, "fullerite.collector_errors", m.Name)
		assert.Equal(t, 1.0, m.Value)
		assert.Equal(t, "Test", m.Dimensions["collector"])
		return
	case <-time.After(1 * time.Second):
		t.Fail()
	}
}
开发者ID:Yelp,项目名称:fullerite,代码行数:29,代码来源:collector_hook_test.go

示例6: TestProcStatusCollectMetricTypes

func TestProcStatusCollectMetricTypes(t *testing.T) {
	config := make(map[string]interface{})
	config["interval"] = 9999

	dims := map[string]string{
		"module": "(.*)",
	}

	config["generatedDimensions"] = dims

	channel := make(chan metric.Metric)

	testLog := test_utils.BuildLogger()
	ps := NewProcStatus(channel, 12, testLog)
	ps.Configure(config)

	go ps.Collect()

	select {
	case <-ps.Channel():
		for _, m := range ps.procStatusMetrics() {
			if m.Name == "CPUTime" {
				assert.Equal(t, m.MetricType, metric.CumulativeCounter, "CPUTime is a CumulativeCounter")
			} else {
				assert.Equal(t, m.MetricType, metric.Gauge, "All others are a Gauge")
			}
		}
	}
}
开发者ID:sagar8192,项目名称:fullerite,代码行数:29,代码来源:procstatus_linux_test.go

示例7: TestFulleriteCollect

func TestFulleriteCollect(t *testing.T) {
	config := make(map[string]interface{})

	testChannel := make(chan metric.Metric)
	testLog := test_utils.BuildLogger()

	f := NewFullerite(testChannel, 123, testLog)
	f.Configure(config)

	go f.Collect()

	select {
	case <-f.Channel():
		return
	case <-time.After(2 * time.Second):
		t.Fail()
	}
}
开发者ID:sagar8192,项目名称:fullerite,代码行数:18,代码来源:fullerite_test.go

示例8: TestTestConfigureMetricName

func TestTestConfigureMetricName(t *testing.T) {
	config := make(map[string]interface{})
	config["metricName"] = "lala"

	testChannel := make(chan metric.Metric)
	testLogger := test_utils.BuildLogger()

	test := NewTest(testChannel, 123, testLogger)
	test.Configure(config)

	go test.Collect()

	select {
	case m := <-test.Channel():
		// don't test for the value - only metric name
		assert.Equal(t, m.Name, "lala")
	case <-time.After(1 * time.Second):
		t.Fail()
	}
}
开发者ID:jp2007,项目名称:fullerite,代码行数:20,代码来源:test_test.go

示例9: TestCpuInfoCollect

func TestCpuInfoCollect(t *testing.T) {
	config := make(map[string]interface{})
	config["procPath"] = path.Join(test_utils.DirectoryOfCurrentFile(), "/../../fixtures/proc/cpuinfo")
	testChannel := make(chan metric.Metric)
	testLogger := test_utils.BuildLogger()

	cpuInfo := newCPUInfo(testChannel, 100, testLogger)
	cpuInfo.Configure(config)

	go cpuInfo.Collect()

	select {
	case m := <-cpuInfo.Channel():
		assert.Equal(t, 2.0, m.Value)
		assert.Equal(t, "Xeon(R) CPU E5-2630 0 @ 2.30GHz", m.Dimensions["model"])
		return
	case <-time.After(2 * time.Second):
		t.Fail()
	}
}
开发者ID:Yelp,项目名称:fullerite,代码行数:20,代码来源:cpu_info_test.go

示例10: TestProcStatusExtractDimensions

func TestProcStatusExtractDimensions(t *testing.T) {
	testLog := test_utils.BuildLogger()

	config := make(map[string]interface{})

	dims := map[string]string{
		"module": "^python.*?test.*?\\.([^\\.]*)?\\-\\[\\d+\\]$",
		"order":  "^python.*?test.*?\\.[^\\.]*?\\-\\[(\\d+)\\]$",
	}
	config["generatedDimensions"] = dims

	ps := NewProcStatus(nil, 12, testLog)
	ps.Configure(config)

	dim := map[string]string{
		"module": "bond",
		"order":  "007",
	}

	extracted := ps.extractDimensions("python -m test.my.function.bond-[007]")
	assert.Equal(t, dim, extracted)
}
开发者ID:jp2007,项目名称:fullerite,代码行数:22,代码来源:procstatus_linux_test.go

示例11: TestProcStatusMatches

func TestProcStatusMatches(t *testing.T) {
	assert := assert.New(t)
	testLog := test_utils.BuildLogger()
	ps := NewProcStatus(nil, 12, testLog)
	config := make(map[string]interface{})

	commGenerator := func(comm string, err error) func() (string, error) {
		return func() (string, error) {
			return comm, err
		}
	}

	config["pattern"] = ".*"
	config["matchCommandLine"] = true
	ps.Configure(config)

	match := ps.matches([]string{"proc", "status"}, commGenerator("proc", nil))
	assert.True(match)
	match = ps.matches([]string{"proc", "status"}, commGenerator("proc", errors.New("")))
	assert.True(match)

	config["pattern"] = ".*"
	config["matchCommandLine"] = false
	ps.Configure(config)

	match = ps.matches([]string{"proc", "status"}, commGenerator("proc", nil))
	assert.True(match)
	match = ps.matches([]string{"proc", "status"}, commGenerator("proc", errors.New("")))
	assert.False(match)

	config["pattern"] = "sta"
	config["matchCommandLine"] = true
	ps.Configure(config)

	match = ps.matches([]string{"proc", "status"}, commGenerator("proc", nil))
	assert.True(match)
	match = ps.matches([]string{"proc", "butter"}, commGenerator("proc", nil))
	assert.False(match)
	match = ps.matches([]string{"proc", "butter"}, commGenerator("status", nil))
	assert.False(match)
	match = ps.matches([]string{"proc", "status"}, commGenerator("proc", errors.New("")))
	assert.True(match)

	config["pattern"] = "pro"
	config["matchCommandLine"] = false
	ps.Configure(config)

	match = ps.matches([]string{"proc", "status"}, commGenerator("proc", nil))
	assert.True(match)
	match = ps.matches([]string{"peanut", "status"}, commGenerator("peanut", nil))
	assert.False(match)
	match = ps.matches([]string{"proc", "status"}, commGenerator("peanut", nil))
	assert.False(match)
	match = ps.matches([]string{"proc", "status"}, commGenerator("proc", errors.New("")))
	assert.False(match)

	config["pattern"] = "oc sta"
	config["matchCommandLine"] = true
	ps.Configure(config)

	match = ps.matches([]string{"proc", "status"}, commGenerator("proc", nil))
	assert.True(match)
}
开发者ID:jp2007,项目名称:fullerite,代码行数:63,代码来源:procstatus_linux_test.go


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