Files
nomad/client/fingerprint/storage_test.go
Seth Hoenig 83720740f5 core: plumbing to support numa aware scheduling (#18681)
* core: plumbing to support numa aware scheduling

* core: apply node resources compatibility upon fsm rstore

Handle the case where an upgraded server dequeus an evaluation before
a client triggers a new fingerprint - which would be needed to cause
the compatibility fix to run. By running the compat fix on restore the
server will immediately have the compatible pseudo topology to use.

* lint: learn how to spell pseudo
2023-10-19 15:09:30 -05:00

50 lines
1.4 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package fingerprint
import (
"strconv"
"testing"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/helper/testlog"
"github.com/hashicorp/nomad/nomad/structs"
)
func TestStorageFingerprint(t *testing.T) {
ci.Parallel(t)
fp := NewStorageFingerprint(testlog.HCLogger(t))
node := &structs.Node{
Attributes: make(map[string]string),
}
response := assertFingerprintOK(t, fp, node)
if !response.Detected {
t.Fatalf("expected response to be applicable")
}
assertNodeAttributeContains(t, response.Attributes, "unique.storage.volume")
assertNodeAttributeContains(t, response.Attributes, "unique.storage.bytestotal")
assertNodeAttributeContains(t, response.Attributes, "unique.storage.bytesfree")
total, err := strconv.ParseInt(response.Attributes["unique.storage.bytestotal"], 10, 64)
if err != nil {
t.Fatalf("Failed to parse unique.storage.bytestotal: %s", err)
}
free, err := strconv.ParseInt(response.Attributes["unique.storage.bytesfree"], 10, 64)
if err != nil {
t.Fatalf("Failed to parse unique.storage.bytesfree: %s", err)
}
if free > total {
t.Fatalf("unique.storage.bytesfree %d is larger than unique.storage.bytestotal %d", free, total)
}
if response.NodeResources == nil || response.NodeResources.Disk.DiskMB == 0 {
t.Errorf("Expected node.Resources.DiskMB to be non-zero")
}
}