open-nomad/client/fingerprint/cpu_test.go

43 lines
871 B
Go
Raw Normal View History

2015-08-26 21:27:44 +00:00
package fingerprint
import (
"testing"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/nomad/structs"
)
func TestCPUFingerprint(t *testing.T) {
f := NewCPUFingerprint(testLogger())
node := &structs.Node{
Attributes: make(map[string]string),
}
ok, err := f.Fingerprint(&config.Config{}, node)
if err != nil {
t.Fatalf("err: %v", err)
}
if !ok {
t.Fatalf("should apply")
}
// CPU info
if node.Attributes["cpu.numcores"] == "" {
t.Fatalf("Missing Num Cores")
}
if node.Attributes["cpu.modelname"] == "" {
t.Fatalf("Missing Model Name")
}
2015-08-27 14:19:53 +00:00
if node.Attributes["cpu.frequency"] == "" {
t.Fatalf("Missing CPU Frequency")
}
if node.Attributes["cpu.totalcompute"] == "" {
t.Fatalf("Missing CPU Total Compute")
}
2015-11-07 14:14:25 +00:00
if node.Resources == nil || node.Resources.CPU == 0 {
t.Fatalf("Expected to find CPU Resources")
2015-08-27 19:15:56 +00:00
}
2015-08-26 21:27:44 +00:00
}