summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/chrony/chrony_test.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 08:15:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 08:15:20 +0000
commit87d772a7d708fec12f48cd8adc0dedff6e1025da (patch)
tree1fee344c64cc3f43074a01981e21126c8482a522 /src/go/collectors/go.d.plugin/modules/chrony/chrony_test.go
parentAdding upstream version 1.46.3. (diff)
downloadnetdata-upstream.tar.xz
netdata-upstream.zip
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/go/plugin/go.d/modules/chrony/chrony_test.go (renamed from src/go/collectors/go.d.plugin/modules/chrony/chrony_test.go)33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/chrony/chrony_test.go b/src/go/plugin/go.d/modules/chrony/chrony_test.go
index 03e7dd52e..407724e75 100644
--- a/src/go/collectors/go.d.plugin/modules/chrony/chrony_test.go
+++ b/src/go/plugin/go.d/modules/chrony/chrony_test.go
@@ -9,7 +9,7 @@ import (
"testing"
"time"
- "github.com/netdata/netdata/go/go.d.plugin/agent/module"
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
"github.com/facebook/time/ntp/chrony"
"github.com/stretchr/testify/assert"
@@ -240,9 +240,10 @@ func prepareChronyWithMock(m *mockClient) *Chrony {
}
type mockClient struct {
- errOnTracking bool
- errOnActivity bool
- closeCalled bool
+ errOnTracking bool
+ errOnActivity bool
+ errOnServerStats bool
+ closeCalled bool
}
func (m *mockClient) Tracking() (*chrony.ReplyTracking, error) {
@@ -286,6 +287,30 @@ func (m *mockClient) Activity() (*chrony.ReplyActivity, error) {
return &reply, nil
}
+func (m *mockClient) ServerStats() (*serverStats, error) {
+ if m.errOnServerStats {
+ return nil, errors.New("mockClient.ServerStats call error")
+ }
+
+ reply := serverStats{
+ v3: &chrony.ServerStats3{
+ NTPHits: 10,
+ NKEHits: 10,
+ CMDHits: 10,
+ NTPDrops: 1,
+ NKEDrops: 1,
+ CMDDrops: 1,
+ LogDrops: 1,
+ NTPAuthHits: 10,
+ NTPInterleavedHits: 10,
+ NTPTimestamps: 0,
+ NTPSpanSeconds: 0,
+ },
+ }
+
+ return &reply, nil
+}
+
func (m *mockClient) Close() {
m.closeCalled = true
}