Skip to content

Commit

Permalink
fix logging in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry committed Sep 22, 2023
1 parent 9ce2cd5 commit 7d3cd5f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
11 changes: 5 additions & 6 deletions libbeat/idxmgmt/idxmgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ func MakeDefaultSupport(ilmSupport lifecycle.SupportFactory) SupportFactory {

return func(log *logp.Logger, info beat.Info, configRoot *config.C) (Supporter, error) {
const logName = "index-management"
if log == nil {
log = logp.NewLogger(logName)
} else {
log = log.Named(logName)
}

// first fetch the ES output, check if we're running against serverless, use that to set a default config.
// the Supporter only cares about lifecycle config for checking if ILM/DSL is enabled or disabled.
Expand Down Expand Up @@ -151,12 +156,6 @@ func MakeDefaultSupport(ilmSupport lifecycle.SupportFactory) SupportFactory {
}
}

if log == nil {
log = logp.NewLogger(logName)
} else {
log = log.Named(logName)
}

if err := checkTemplateESSettings(cfg.Template, cfg.Output); err != nil {
return nil, err
}
Expand Down
11 changes: 11 additions & 0 deletions libbeat/idxmgmt/std_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ func TestIndexManager_Setup(t *testing.T) {
info := beat.Info{Beat: "test", Version: "9.9.9"}
defaultCfg := template.DefaultConfig(info)
defaultLifecycleConfig := lifecycle.DefaultILMConfig(info)
dslLifecycleConfig := lifecycle.DefaultDSLConfig(info)
cases := map[string]struct {
cfg mapstr.M
loadTemplate, loadILM LoadMode
Expand All @@ -331,6 +332,16 @@ func TestIndexManager_Setup(t *testing.T) {
policy: "test",
ilmCfg: defaultLifecycleConfig,
},
"template-default-dsl-config": {
tmplCfg: cfgWith(template.DefaultConfig(info), map[string]interface{}{
"overwrite": "true",
"name": "test-9.9.9",
"pattern": "test-9.9.9",
"settings.index.lifecycle.name": "test-9.9.9",
}),
policy: "test-9.9.9",
ilmCfg: dslLifecycleConfig,
},
"template default ilm default with policy changed": {
cfg: mapstr.M{
"setup.ilm.policy_name": "policy-keep",
Expand Down
2 changes: 1 addition & 1 deletion libbeat/tests/system/test_ilm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
INTEGRATION_TESTS = os.environ.get('INTEGRATION_TESTS', False)


MSG_ILM_POLICY_LOADED = re.compile('ILM policy .* successfully created.')
MSG_ILM_POLICY_LOADED = re.compile('lifecycle policy .* successfully created.')


class TestRunILM(BaseTest):
Expand Down

0 comments on commit 7d3cd5f

Please sign in to comment.