Skip to content

Commit

Permalink
[fix] fix logging overwrite values (elastic#3577)
Browse files Browse the repository at this point in the history
Ensure logging overwrites do not fail startup when passing 
in -environment option

fixes elastic#3576
  • Loading branch information
simitt committed Mar 31, 2020
1 parent c09ca72 commit 038ad7d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
15 changes: 10 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ package cmd
import (
"fmt"

"github.com/elastic/beats/v7/libbeat/cfgfile"

"github.com/spf13/pflag"

"github.com/elastic/apm-server/beater"
"github.com/elastic/apm-server/idxmgmt"
_ "github.com/elastic/apm-server/include"
"github.com/elastic/beats/v7/libbeat/cfgfile"
"github.com/elastic/beats/v7/libbeat/cmd"
"github.com/elastic/beats/v7/libbeat/cmd/instance"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/monitoring/report"
"github.com/elastic/beats/v7/libbeat/publisher/processing"

"github.com/elastic/apm-server/beater"
"github.com/elastic/apm-server/idxmgmt"

// ensure to include the asset fields
_ "github.com/elastic/apm-server/include"
)

// Name of the beat (apm-server).
Expand All @@ -51,6 +53,9 @@ func init() {
"metrics": map[string]interface{}{
"enabled": false,
},
"files": map[string]interface{}{
"rotateeverybytes": 10 * 1024 * 1024,
},
},
"setup": map[string]interface{}{
"template": map[string]interface{}{
Expand Down
5 changes: 3 additions & 2 deletions tests/system/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_export_config(self):
config = yaml.load(self.command_output)
# logging settings
self.assertDictEqual(
{"metrics": {"enabled": False}}, config["logging"]
{"metrics": {"enabled": False}, 'files': {'rotateeverybytes': 10485760}, }, config["logging"]
)

# template settings
Expand Down Expand Up @@ -72,8 +72,9 @@ def test_export_config(self):
"""
config = yaml.load(self.command_output)
# logging settings
assert "metrics" in config["logging"]
self.assertDictEqual(
{"metrics": {"enabled": True}}, config["logging"]
{"enabled": True}, config["logging"]["metrics"]
)

# template settings
Expand Down
38 changes: 37 additions & 1 deletion tests/system/test_integration_logging.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import requests

from apmserver import ElasticTest, integration_test
from apmserver import ElasticTest, ServerBaseTest, integration_test


@integration_test
Expand Down Expand Up @@ -87,3 +87,39 @@ def test_trace_ids(self):
self.assertIn("trace.id", req)
self.assertIn("transaction.id", req)
self.assertEqual(req["transaction.id"], req["request_id"])


class LoggingToEnvContainer(ServerBaseTest):
def start_args(self):
return {"extra_args": ["-environment", "container"]}

def test_startup(self):
# we only need to check that the server can start up
self.wait_until_started()


class LoggingToEnvSystemd(ServerBaseTest):
def start_args(self):
return {"extra_args": ["-environment", "systemd"]}

def test_startup(self):
# we only need to check that the server can start up
self.wait_until_started()


class LoggingToEnvMacOS(ServerBaseTest):
def start_args(self):
return {"extra_args": ["-environment", "macos_service"]}

def test_startup(self):
# we only need to check that the server can start up
self.wait_until_started()


class LoggingToEnvWindows(ServerBaseTest):
def start_args(self):
return {"extra_args": ["-environment", "windows_service"]}

def test_startup(self):
# we only need to check that the server can start up
self.wait_until_started()

0 comments on commit 038ad7d

Please sign in to comment.