Skip to content

Commit

Permalink
api: add missing AllocDirStats field in Go API
Browse files Browse the repository at this point in the history
The JSON response for the Read Stats client API includes an `AllocDirStats`
field. This field is missing in the `api` package, so consumers of the Go API
can't use it to read the values we're getting back from the HTTP server.

Fixes: #20246
  • Loading branch information
tgross committed Apr 2, 2024
1 parent 31f53ce commit b8856eb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/20261.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
api: Fixed a bug where `AllocDirStats` field was missing from Reads Stats client API
```
1 change: 1 addition & 0 deletions api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ type HostStats struct {
Memory *HostMemoryStats
CPU []*HostCPUStats
DiskStats []*HostDiskStats
AllocDirStats *HostDiskStats
DeviceStats []*DeviceGroupStats
Uptime uint64
CPUTicksConsumed float64
Expand Down
21 changes: 21 additions & 0 deletions api/nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,27 @@ func TestNodes_Info(t *testing.T) {
must.GreaterEq(t, 1, len(result.Events))
}

func TestNode_Stats(t *testing.T) {
testutil.Parallel(t)

c, s := makeClient(t, nil, func(c *testutil.TestServerConfig) {
c.DevMode = true
})
defer s.Stop()
nodesAPI := c.Nodes()
nodeID := oneNodeFromNodeList(t, nodesAPI).ID

stats, err := nodesAPI.Stats(nodeID, nil)
must.NoError(t, err)

// there isn't much we can reliably check here except that the values are
// populated
must.NotNil(t, stats.Memory)
must.NonZero(t, stats.Memory.Available)
must.NotNil(t, stats.AllocDirStats)
must.NonZero(t, stats.AllocDirStats.Size)
}

func TestNodes_NoSecretID(t *testing.T) {
testutil.Parallel(t)

Expand Down

0 comments on commit b8856eb

Please sign in to comment.