예제 #1
0
파일: icmp_test.go 프로젝트: jarpy/beats
func BenchmarkIcmpProcessICMPv4(b *testing.B) {
	if testing.Verbose() {
		logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"icmp", "icmpdetailed"})
	}

	results := &publish.ChanTransactions{make(chan common.MapStr, 10)}
	icmp, err := New(true, results, ucfg.New())
	if err != nil {
		b.Error("Failed to create ICMP processor")
		return
	}

	icmpRequestData := createICMPv4Layer(b, "08"+"00"+"0000"+"ffff"+"0001")
	packetRequestData := new(protos.Packet)

	icmpResponseData := createICMPv4Layer(b, "00"+"00"+"0000"+"ffff"+"0001")
	packetResponseData := new(protos.Packet)

	b.ResetTimer()

	for n := 0; n < b.N; n++ {
		icmp.ProcessICMPv4(nil, icmpRequestData, packetRequestData)
		icmp.ProcessICMPv4(nil, icmpResponseData, packetResponseData)

		client := icmp.results.(*publish.ChanTransactions)
		<-client.Channel
	}
}
예제 #2
0
파일: output_test.go 프로젝트: jarpy/beats
// Test OutputWorker by calling onStop() and onMessage() with various inputs.
func TestOutputWorker(t *testing.T) {
	outputer := &testOutputer{events: make(chan common.MapStr, 10)}
	ow := newOutputWorker(
		ucfg.New(),
		outputer,
		common.NewWorkerSignal(),
		1, 0)

	ow.onStop() // Noop

	var testCases = []message{
		testMessage(newTestSignaler(), nil),
		testMessage(newTestSignaler(), testEvent()),
		testBulkMessage(newTestSignaler(), []common.MapStr{testEvent()}),
	}

	for _, m := range testCases {
		sig := m.context.Signal.(*testSignaler)
		ow.onMessage(m)
		assert.True(t, sig.wait())

		if m.event != nil {
			assert.Equal(t, m.event, <-outputer.events)
		} else {
			for _, e := range m.events {
				assert.Equal(t, e, <-outputer.events)
			}
		}
	}
}
예제 #3
0
파일: http_test.go 프로젝트: jarpy/beats
func httpModForTests() *HTTP {
	results := &publish.ChanTransactions{Channel: make(chan common.MapStr, 10)}
	http, err := New(false, results, ucfg.New())
	if err != nil {
		panic(err)
	}
	return http.(*HTTP)
}
예제 #4
0
파일: config.go 프로젝트: McStork/beats
func NewConfig() *Config {
	return fromConfig(ucfg.New())
}