Add visual VM resource bars to the TUI
The TUI should show VM capacity pressure at a glance instead of making users read raw numbers or drill into per-VM details. Add a compact colored status row under the header that renders CPU, RAM, and disk usage as progress bars. CPU and RAM reflect reserved resources for running VMs, while disk reflects actual allocated overlay and work-disk bytes across all VMs against the filesystem backing banger state. Add host resource and filesystem helpers in the system package and cover the new aggregation and rendering behavior with TUI and system tests. Verified with GOCACHE=/tmp/banger-gocache go test ./... and GOCACHE=/tmp/banger-gocache make build.
This commit is contained in:
parent
38d7eac430
commit
9e98445fa2
4 changed files with 387 additions and 21 deletions
|
|
@ -282,6 +282,41 @@ func TestParseProcHelpers(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestParseMemTotal(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
total, err := parseMemTotal("MemTotal: 131900020 kB\nMemFree: 1024 kB\n")
|
||||
if err != nil {
|
||||
t.Fatalf("parseMemTotal: %v", err)
|
||||
}
|
||||
if total != 131900020*1024 {
|
||||
t.Fatalf("total = %d, want %d", total, int64(131900020*1024))
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseMemTotalErrorsWhenMissing(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if _, err := parseMemTotal("MemFree: 123 kB\n"); err == nil {
|
||||
t.Fatal("parseMemTotal() error = nil, want missing MemTotal")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadFilesystemUsage(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
usage, err := ReadFilesystemUsage(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFilesystemUsage: %v", err)
|
||||
}
|
||||
if usage.TotalBytes <= 0 {
|
||||
t.Fatalf("usage.TotalBytes = %d, want positive", usage.TotalBytes)
|
||||
}
|
||||
if usage.FreeBytes < 0 {
|
||||
t.Fatalf("usage.FreeBytes = %d, want non-negative", usage.FreeBytes)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMountTempDirRemovesTempDirWhenMountFails(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue