Skip to content

Commit

Permalink
still fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry committed Sep 22, 2023
1 parent 5d99ee0 commit c57b011
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 9 additions & 4 deletions libbeat/idxmgmt/idxmgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,16 @@ func MakeDefaultSupport(ilmSupport lifecycle.SupportFactory) SupportFactory {
if outCfg.Output.IsSet() && outCfg.Output.Name() == "elasticsearch" {
esClient, err := eslegclient.NewConnectedClient(outCfg.Output.Config(), info.Beat)
if err != nil {
return nil, fmt.Errorf("error creating ES client while setting up index support: %w", err)
}
if esClient.IsServerless() {
defaultLifecycle = lifecycle.DefaultDSLConfig(info)
// this is for the benefit of tests as well as various retry mechanisms;
// if we can't connect to ES, print a warning and fallback to ILM, tests won't care and non-test environments can
// retry the connection
logp.L().Warnf("could not connect to ES to determine ES type during index setup. Will default to ILM.")
} else {
if esClient.IsServerless() {
defaultLifecycle = lifecycle.DefaultDSLConfig(info)
}
}

}

// now that we have the "correct" default, unpack the rest of the config
Expand Down
6 changes: 2 additions & 4 deletions libbeat/tests/integration/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,15 @@ setup.template:

// Test that beat stops in case elasticsearch index is modified and name not
func TestIndexModifiedNoName(t *testing.T) {
cfgRaw := `
cfg := `
mockbeat:
output:
elasticsearch:
hosts: %s
index: test
setup.template:
pattern: test
`
esUrl := GetESURL(t, "http")
cfg := fmt.Sprintf(cfgRaw, esUrl.String())

mockbeat := NewBeat(t, "mockbeat", "../../libbeat.test")
mockbeat.WriteConfigFile(cfg)
mockbeat.Start()
Expand Down

0 comments on commit c57b011

Please sign in to comment.