Skip to content

Commit

Permalink
Adapt beat root cmd to processor changes.
Browse files Browse the repository at this point in the history
fixes #1846
  • Loading branch information
simitt committed Mar 12, 2019
1 parent 71e7a8b commit 5121f02
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 50 deletions.
35 changes: 15 additions & 20 deletions beater/beater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ import (
"testing"
"time"

"github.com/gofrs/uuid"
"github.com/elastic/beats/libbeat/logp"

"github.com/elastic/beats/libbeat/publisher/processing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
Expand All @@ -39,7 +41,6 @@ import (
"github.com/elastic/beats/libbeat/publisher/pipeline"
"github.com/elastic/beats/libbeat/publisher/queue"
"github.com/elastic/beats/libbeat/publisher/queue/memqueue"
"github.com/elastic/beats/libbeat/version"
)

func TestBeatConfig(t *testing.T) {
Expand Down Expand Up @@ -293,12 +294,19 @@ func (d *DummyOutputClient) Publish(batch pubs.Batch) error {
func (d *DummyOutputClient) Close() error { return nil }
func (d *DummyOutputClient) String() string { return "" }

func DummyPipeline(clients ...outputs.Client) *pipeline.Pipeline {
func DummyPipeline(cfg *common.Config, info beat.Info, clients ...outputs.Client) *pipeline.Pipeline {
if len(clients) == 0 {
clients = []outputs.Client{&DummyOutputClient{}}
}
if cfg == nil {
cfg = common.NewConfig()
}
processors, err := processing.MakeDefaultObserverSupport(false)(info, logp.NewLogger("testbeat"), cfg)
if err != nil {
panic(err)
}
p, err := pipeline.New(
beat.Info{Name: "test-apm-server"},
info,
pipeline.Monitors{},
func(e queue.Eventer) (queue.Queue, error) {
return memqueue.NewBroker(nil, memqueue.Settings{
Expand All @@ -314,6 +322,7 @@ func DummyPipeline(clients ...outputs.Client) *pipeline.Pipeline {
pipeline.Settings{
WaitClose: 0,
WaitCloseMode: pipeline.NoWaitOnClose,
Processors: processors,
},
)
if err != nil {
Expand Down Expand Up @@ -383,21 +392,7 @@ func (bt *beater) smapElasticsearchHosts() []string {
return hosts
}

func setupBeater(t *testing.T, publisher beat.Pipeline, ucfg *common.Config, beatConfig *beat.BeatConfig) (*beater, func(), error) {
beatId, err := uuid.FromString("fbba762a-14dd-412c-b7e9-b79f903eb492")
require.NoError(t, err)
// create a beat
apmBeat := &beat.Beat{
Publisher: publisher,
Info: beat.Info{
Beat: "test-apm-server",
IndexPrefix: "test-apm-server",
Version: version.GetDefaultVersion(),
ID: beatId,
},
Config: beatConfig,
}

func setupBeater(t *testing.T, apmBeat *beat.Beat, ucfg *common.Config, beatConfig *beat.BeatConfig) (*beater, func(), error) {
// create our beater
beatBeater, err := New(apmBeat, ucfg)
assert.NoError(t, err)
Expand Down
26 changes: 23 additions & 3 deletions beater/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import (
"testing"
"time"

"github.com/gofrs/uuid"

"github.com/elastic/beats/libbeat/version"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -505,17 +509,33 @@ func setupServer(t *testing.T, cfg *common.Config, beatConfig *beat.BeatConfig,
require.NoError(t, err)
}

beatId, err := uuid.FromString("fbba762a-14dd-412c-b7e9-b79f903eb492")
require.NoError(t, err)
info := beat.Info{
Beat: "test-apm-server",
IndexPrefix: "test-apm-server",
Version: version.GetDefaultVersion(),
ID: beatId,
}

var pub beat.Pipeline
if events != nil {
// capture events
pubClient := NewChanClientWith(events)
pub = DummyPipeline(pubClient)
pub = DummyPipeline(cfg, info, pubClient)
} else {
// don't capture events
pub = DummyPipeline()
pub = DummyPipeline(cfg, info)
}

// create a beat
apmBeat := &beat.Beat{
Publisher: pub,
Info: info,
Config: beatConfig,
}

btr, stop, err := setupBeater(t, pub, baseConfig, beatConfig)
btr, stop, err := setupBeater(t, apmBeat, baseConfig, beatConfig)
if err == nil {
assert.NotEqual(t, btr.config.Host, "localhost:0", "config.Host unmodified")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"container": {
"id": "container-id"
},
"ecs": {
"version": "1.1.0-dev"
},
"error": {
"culprit": "my.module.function_name",
"custom": {
Expand Down Expand Up @@ -317,6 +320,9 @@
"container": {
"id": "container-id"
},
"ecs": {
"version": "1.1.0-dev"
},
"error": {
"exception": [
{
Expand Down Expand Up @@ -405,6 +411,9 @@
"container": {
"id": "container-id"
},
"ecs": {
"version": "1.1.0-dev"
},
"error": {
"exception": [
{
Expand Down Expand Up @@ -499,6 +508,9 @@
"container": {
"id": "container-id"
},
"ecs": {
"version": "1.1.0-dev"
},
"error": {
"grouping_key": "d6b3f958dfea98dc9ed2b57d5f0c48bb",
"id": "abcdef0123456789",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"container": {
"id": "container-id"
},
"ecs": {
"version": "1.1.0-dev"
},
"error": {
"grouping_key": "d6b3f958dfea98dc9ed2b57d5f0c48bb",
"id": "abcdef0123456789",
Expand Down Expand Up @@ -74,6 +77,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"observer": {
"ephemeral_id": "00000000-0000-0000-0000-000000000000",
"hostname": "",
Expand Down Expand Up @@ -128,6 +134,9 @@
"container": {
"id": "container-id"
},
"ecs": {
"version": "1.1.0-dev"
},
"host": {
"ip": "127.0.0.1"
},
Expand Down Expand Up @@ -198,6 +207,9 @@
"container": {
"id": "container-id"
},
"ecs": {
"version": "1.1.0-dev"
},
"go": {
"memstats": {
"heap": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
}
},
"double_gauge": 3.141592653589793,
"ecs": {
"version": "1.1.0-dev"
},
"float_gauge": 9.16,
"integer_gauge": 42767,
"labels": {
Expand Down Expand Up @@ -78,6 +81,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"go": {
"memstats": {
"heap": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"error": {
"grouping_key": "0b9cba09845a097a271c6beb4c6207f3",
"id": "abcdef0123456789",
Expand Down Expand Up @@ -51,6 +54,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"error": {
"exception": [
{
Expand Down Expand Up @@ -93,6 +99,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"error": {
"exception": [
{
Expand Down Expand Up @@ -135,6 +144,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"observer": {
"ephemeral_id": "00000000-0000-0000-0000-000000000000",
"hostname": "",
Expand Down Expand Up @@ -182,6 +194,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"observer": {
"ephemeral_id": "00000000-0000-0000-0000-000000000000",
"hostname": "",
Expand Down Expand Up @@ -226,6 +241,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"host": {
"ip": "127.0.0.1"
},
Expand Down Expand Up @@ -273,6 +291,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"host": {
"ip": "127.0.0.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"observer": {
"ephemeral_id": "00000000-0000-0000-0000-000000000000",
"hostname": "",
Expand Down Expand Up @@ -60,6 +63,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"observer": {
"ephemeral_id": "00000000-0000-0000-0000-000000000000",
"hostname": "",
Expand Down Expand Up @@ -110,6 +116,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"labels": {
"tag1": "value1",
"tag2": 123,
Expand Down Expand Up @@ -167,6 +176,9 @@
"name": "elastic-node",
"version": "3.14.0"
},
"ecs": {
"version": "1.1.0-dev"
},
"observer": {
"ephemeral_id": "00000000-0000-0000-0000-000000000000",
"hostname": "",
Expand Down Expand Up @@ -217,6 +229,9 @@
"name": "elastic-ruby",
"version": "2.2"
},
"ecs": {
"version": "1.1.0-dev"
},
"observer": {
"ephemeral_id": "00000000-0000-0000-0000-000000000000",
"hostname": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"container": {
"id": "container-id"
},
"ecs": {
"version": "1.1.0-dev"
},
"host": {
"architecture": "x64",
"hostname": "prod1.example.com",
Expand Down Expand Up @@ -110,6 +113,9 @@
"container": {
"id": "container-id"
},
"ecs": {
"version": "1.1.0-dev"
},
"host": {
"architecture": "x64",
"hostname": "prod1.example.com",
Expand Down Expand Up @@ -294,6 +300,9 @@
"container": {
"id": "container-id"
},
"ecs": {
"version": "1.1.0-dev"
},
"host": {
"architecture": "x64",
"hostname": "prod1.example.com",
Expand Down
3 changes: 2 additions & 1 deletion changelogs/7.0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
==== Bugfix
- Ensure setup cmd uses expected configuration {pull}1934[1934].
- Ensure host.name is not added {pull}1934[1934].
- Ensure host.name is not added {pull}1934[1934] {pull}1982[1982].
- Update Go version to 1.11.5 {pull}1840[1840] {pull}1950[1950].
- Ensure enabling user-agent pipeline indexes data at the same key by default {pull}1966[1966].
- Request and Response headers are stored in a canonicalized way {pull}1966[1966].
- Use changed processor handling from libbeat {pull}1982[1982].
[[release-notes-7.7.0-rc1]]
=== APM Server version 7.0.0-rc1
Expand Down
Loading

0 comments on commit 5121f02

Please sign in to comment.