Skip to content

Commit 637cb8d

Browse files
aleksmausmergify-bot
authored andcommitted
Osquerybeat: Fix the configuration poll interval setting (#26739)
* Fix the configuration poll interval setting * Unit tests (cherry picked from commit 1e4971f)
1 parent 70218bc commit 637cb8d

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

x-pack/osquerybeat/internal/osqd/osqueryd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func WithBinaryPath(binPath string) Option {
6565

6666
func WithConfigRefresh(refreshInterval int) Option {
6767
return func(q *OSQueryD) {
68-
q.extensionsTimeout = refreshInterval
68+
q.configRefreshInterval = refreshInterval
6969
}
7070
}
7171

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+
// or more contributor license agreements. Licensed under the Elastic License;
3+
// you may not use this file except in compliance with the Elastic License.
4+
5+
package osqd
6+
7+
import (
8+
"testing"
9+
10+
"github.com/google/go-cmp/cmp"
11+
)
12+
13+
func TestNew(t *testing.T) {
14+
15+
socketPath := "/var/run/foobar"
16+
17+
extensionsTimeout := 5
18+
configurationRefreshIntervalSecs := 12
19+
configPluginName := "config_plugin_test"
20+
loggerPluginName := "logger_plugin_test"
21+
22+
osq := New(
23+
socketPath,
24+
WithExtensionsTimeout(extensionsTimeout),
25+
WithConfigRefresh(configurationRefreshIntervalSecs),
26+
WithConfigPlugin(configPluginName),
27+
WithLoggerPlugin(loggerPluginName),
28+
)
29+
30+
diff := cmp.Diff(extensionsTimeout, osq.extensionsTimeout)
31+
if diff != "" {
32+
t.Error(diff)
33+
}
34+
35+
diff = cmp.Diff(configurationRefreshIntervalSecs, osq.configRefreshInterval)
36+
if diff != "" {
37+
t.Error(diff)
38+
}
39+
diff = cmp.Diff(configPluginName, osq.configPlugin)
40+
if diff != "" {
41+
t.Error(diff)
42+
}
43+
44+
diff = cmp.Diff(loggerPluginName, osq.loggerPlugin)
45+
if diff != "" {
46+
t.Error(diff)
47+
}
48+
}

0 commit comments

Comments
 (0)