func newRedisTestingOutput(t *testing.T, cfg map[string]interface{}) *redisOut {
	params := struct {
		Expire int `config:"topology_expire"`
	}{15}

	config, err := common.NewConfigFrom(cfg)
	if err != nil {
		t.Fatalf("Error reading config: %v", err)
	}

	plugin := outputs.FindOutputPlugin("redis")
	if plugin == nil {
		t.Fatalf("redis output module not registered")
	}

	if err := config.Unpack(&params); err != nil {
		t.Fatalf("Failed to unpack topology_expire: %v", err)
	}

	out, err := plugin("libbeat", config, params.Expire)
	if err != nil {
		t.Fatalf("Failed to initialize redis output: %v", err)
	}

	return out.(*redisOut)
}
Example #2
0
func newTestLumberjackOutput(
	t *testing.T,
	test string,
	config *outputs.MothershipConfig,
) outputs.BulkOutputer {
	if config == nil {
		config = &outputs.MothershipConfig{
			TLS:   nil,
			Hosts: []string{getLogstashHost()},
			Index: testLogstashIndex(test),
		}

	}

	plugin := outputs.FindOutputPlugin("logstash")
	if plugin == nil {
		t.Fatalf("No logstash output plugin found")
	}

	output, err := plugin.NewOutput(config, 0)
	if err != nil {
		t.Fatalf("init logstash output plugin failed: %v", err)
	}

	return output.(outputs.BulkOutputer)
}
Example #3
0
func newTestLumberjackOutput(
	t *testing.T,
	test string,
	config map[string]interface{},
) outputs.BulkOutputer {
	if config == nil {
		config = map[string]interface{}{
			"hosts": []string{getLogstashHost()},
			"index": testLogstashIndex(test),
		}
	}

	plugin := outputs.FindOutputPlugin("logstash")
	if plugin == nil {
		t.Fatalf("No logstash output plugin found")
	}

	cfg, _ := common.NewConfigFrom(config)
	output, err := plugin("", cfg, 0)
	if err != nil {
		t.Fatalf("init logstash output plugin failed: %v", err)
	}

	return output.(outputs.BulkOutputer)
}
func newTestElasticsearchOutput(t *testing.T, test string) *testOutputer {
	plugin := outputs.FindOutputPlugin("elasticsearch")
	if plugin == nil {
		t.Fatalf("No elasticsearch output plugin found")
	}

	index := testElasticsearchIndex(test)
	connection := esConnect(t, index)

	flushInterval := 0
	bulkSize := 0
	config, _ := common.NewConfigFrom(map[string]interface{}{
		"hosts":          []string{getElasticsearchHost()},
		"index":          index,
		"flush_interval": &flushInterval,
		"bulk_max_size":  &bulkSize,
		"username":       os.Getenv("ES_USER"),
		"password":       os.Getenv("ES_PASS"),
	})

	output, err := plugin(config, 10)
	if err != nil {
		t.Fatalf("init elasticsearch output plugin failed: %v", err)
	}

	es := &testOutputer{}
	es.BulkOutputer = output.(outputs.BulkOutputer)
	es.esConnection = connection
	return es
}
func newTestElasticsearchOutput(t *testing.T, test string) *testOutputer {
	plugin := outputs.FindOutputPlugin("elasticsearch")
	if plugin == nil {
		t.Fatalf("No elasticsearch output plugin found")
	}

	index := testElasticsearchIndex(test)
	connection := esConnect(t, index)

	flushInterval := 0
	bulkSize := 0
	config := outputs.MothershipConfig{
		Hosts:         []string{getElasticsearchHost()},
		Index:         index,
		FlushInterval: &flushInterval,
		BulkMaxSize:   &bulkSize,
		Username:      os.Getenv("ES_USER"),
		Password:      os.Getenv("ES_PASS"),
	}

	output, err := plugin.NewOutput(&config, 10)
	if err != nil {
		t.Fatalf("init elasticsearch output plugin failed: %v", err)
	}

	es := &testOutputer{}
	es.BulkOutputer = output.(outputs.BulkOutputer)
	es.esConnection = connection
	return es
}