open-vault/helper/hostutil/hostinfo_test.go
Calvin Leung Huang 3f1c7c86a0
sys: add host-info endpoint (#7330)
* sys: add host-info endpoint, add client API method

* remove old commented handler

* add http tests, fix bugs

* query all partitions for disk usage

* fix Timestamp decoding

* add comments for clarification

* dont append a nil entry on disk usage query error

* remove HostInfo from the sdk api

We can use Logical().Read(...) to query this endpoint since the payload is contained with the data object. All warnings are preserved under Secret.Warnings.

* ensure that we're testing failure case against a standby node

* add and use TestWaitStandby to ensure core is on standby

* remove TestWaitStandby

* respond with local-only error

* move HostInfo into its own helper package

* fix imports; use new no-forward handler

* add cpu times to collection

* emit clearer multierrors/warnings by collection type

* add comments on HostInfo fields
2019-10-03 09:43:52 -07:00

31 lines
570 B
Go

package hostutil
import (
"testing"
)
func TestCollectHostInfo(t *testing.T) {
info, err := CollectHostInfo()
if err != nil {
t.Fatal(err)
}
if info.Timestamp.IsZero() {
t.Fatal("expected non-zero Timestamp")
}
if info.CPU == nil {
t.Fatal("expected non-nil CPU value")
}
if info.CPUTimes == nil {
t.Fatal("expected non-nil CPUTimes value")
}
if info.Disk == nil {
t.Fatal("expected non-nil Disk value")
}
if info.Host == nil {
t.Fatal("expected non-nil Host value")
}
if info.Memory == nil {
t.Fatal("expected non-nil Memory value")
}
}