Files
cozystack/pkg/ovnstatus/ovnstatus_test.go
Timofei Larkin 382a9787f4 [kubeovn] Implement the KubeOVN plunger
This patch implements external monitoring of the Kube-OVN cluster. A new
reconciler timed to run its reconcile loop at a fixed interval execs
into the ovn-central pods and collects their cluster info. If the
members' opinions about the cluster disagree, an alert is raised. Other
issues with the distributed consensus are also highlighted.

```release-note
[kubeovn,cozystack-controller] Implement the KubeOVN plunger, an
external monitoring agent for the ovn-central cluster.
```

Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2025-09-11 02:11:58 +03:00

41 lines
1.2 KiB
Go

package ovnstatus
import (
"fmt"
"testing"
"time"
)
var testStdout = `` +
`Last Election started 259684608 ms ago, reason: leadership_transfer
Last Election won: 259684604 ms ago
Election timer: 5000
Log: [20946, 20968]
Entries not yet committed: 0
Entries not yet applied: 0
Connections: ->7bdb ->b007 <-7bdb <-b007
Disconnections: 34130
Servers:
e40d (e40d at ssl:[192.168.100.12]:6643) (self)
7bdb (7bdb at ssl:[192.168.100.11]:6643) last msg 425139 ms ago
b007 (b007 at ssl:[192.168.100.14]:6643) last msg 817 ms ago
`
var expectedServersBlock = `` +
` e40d (e40d at ssl:[192.168.100.12]:6643) (self)
7bdb (7bdb at ssl:[192.168.100.11]:6643) last msg 425139 ms ago
b007 (b007 at ssl:[192.168.100.14]:6643) last msg 817 ms ago
`
func TestExtractServersBlock(t *testing.T) {
if actual := extractServersBlock(testStdout); actual != expectedServersBlock {
fmt.Println([]byte(actual))
fmt.Println([]byte(expectedServersBlock))
t.Errorf("error extracting servers block from following string:\n%s\nexpected:\n%s\ngot:\n%s\n", testStdout, expectedServersBlock, actual)
}
}
func TestParseServersBlock(t *testing.T) {
cs := parseServersFromTextWithThreshold(testStdout, 10*time.Second)
fmt.Printf("%+v\n", cs)
}