diff --git a/x-pack/elastic-agent/CHANGELOG.asciidoc b/x-pack/elastic-agent/CHANGELOG.asciidoc index 5900950e7df..14ca5ccb3a4 100644 --- a/x-pack/elastic-agent/CHANGELOG.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.asciidoc @@ -52,6 +52,7 @@ - Avoid comparing uncomparable types on enroll {issue}19976[19976] - Fix issues with merging of elastic-agent.yml and fleet.yml {pull}20026[20026] - Unzip failures on Windows 8/Windows server 2012 {pull}20088[20088] +- Fix failing unit tests on windows {pull}20127[20127] ==== New features diff --git a/x-pack/elastic-agent/pkg/agent/application/action_store.go b/x-pack/elastic-agent/pkg/agent/application/action_store.go index a0b008d9623..25dbf7a5b82 100644 --- a/x-pack/elastic-agent/pkg/agent/application/action_store.go +++ b/x-pack/elastic-agent/pkg/agent/application/action_store.go @@ -33,6 +33,7 @@ func newActionStore(log *logger.Logger, store storeLoad) (*actionStore, error) { if err != nil { return &actionStore{log: log, store: store}, nil } + defer reader.Close() var action actionConfigChangeSerializer diff --git a/x-pack/elastic-agent/pkg/agent/application/action_store_test.go b/x-pack/elastic-agent/pkg/agent/application/action_store_test.go index a3ccb5b9e48..4205deda8b6 100644 --- a/x-pack/elastic-agent/pkg/agent/application/action_store_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/action_store_test.go @@ -9,7 +9,6 @@ import ( "io/ioutil" "os" "path/filepath" - "runtime" "testing" "github.com/stretchr/testify/require" @@ -20,10 +19,6 @@ import ( ) func TestActionStore(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("Skipping on windows see https://github.com/elastic/beats/issues/19919") - } - log, _ := logger.New("action_store") withFile := func(fn func(t *testing.T, file string)) func(*testing.T) { return func(t *testing.T) { diff --git a/x-pack/elastic-agent/pkg/config/config.go b/x-pack/elastic-agent/pkg/config/config.go index e8845840137..a7620a7f630 100644 --- a/x-pack/elastic-agent/pkg/config/config.go +++ b/x-pack/elastic-agent/pkg/config/config.go @@ -49,6 +49,10 @@ func NewConfigFrom(from interface{}) (*Config, error) { } if in, ok := from.(io.Reader); ok { + if closer, ok := from.(io.Closer); ok { + defer closer.Close() + } + content, err := ioutil.ReadAll(in) if err != nil { return nil, err