當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。