Skip to content

Commit

Permalink
Osquerybeat: Fix the configuration poll interval setting (#26739)
Browse files Browse the repository at this point in the history
* Fix the configuration poll interval setting

* Unit tests
  • Loading branch information
aleksmaus authored Jul 6, 2021
1 parent a7b0110 commit 1e4971f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion x-pack/osquerybeat/internal/osqd/osqueryd.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func WithBinaryPath(binPath string) Option {

func WithConfigRefresh(refreshInterval int) Option {
return func(q *OSQueryD) {
q.extensionsTimeout = refreshInterval
q.configRefreshInterval = refreshInterval
}
}

Expand Down
48 changes: 48 additions & 0 deletions x-pack/osquerybeat/internal/osqd/osqueryd_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package osqd

import (
"testing"

"github.com/google/go-cmp/cmp"
)

func TestNew(t *testing.T) {

socketPath := "/var/run/foobar"

extensionsTimeout := 5
configurationRefreshIntervalSecs := 12
configPluginName := "config_plugin_test"
loggerPluginName := "logger_plugin_test"

osq := New(
socketPath,
WithExtensionsTimeout(extensionsTimeout),
WithConfigRefresh(configurationRefreshIntervalSecs),
WithConfigPlugin(configPluginName),
WithLoggerPlugin(loggerPluginName),
)

diff := cmp.Diff(extensionsTimeout, osq.extensionsTimeout)
if diff != "" {
t.Error(diff)
}

diff = cmp.Diff(configurationRefreshIntervalSecs, osq.configRefreshInterval)
if diff != "" {
t.Error(diff)
}
diff = cmp.Diff(configPluginName, osq.configPlugin)
if diff != "" {
t.Error(diff)
}

diff = cmp.Diff(loggerPluginName, osq.loggerPlugin)
if diff != "" {
t.Error(diff)
}
}

0 comments on commit 1e4971f

Please sign in to comment.