2015-08-27 19:58:37 +00:00
|
|
|
package fingerprint
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/client/config"
|
2018-01-24 14:09:53 +00:00
|
|
|
cstructs "github.com/hashicorp/nomad/client/structs"
|
2015-08-27 19:58:37 +00:00
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMemoryFingerprint(t *testing.T) {
|
|
|
|
f := NewMemoryFingerprint(testLogger())
|
|
|
|
node := &structs.Node{
|
|
|
|
Attributes: make(map[string]string),
|
|
|
|
}
|
2018-01-24 14:09:53 +00:00
|
|
|
|
|
|
|
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
2018-01-26 16:21:07 +00:00
|
|
|
var response cstructs.FingerprintResponse
|
|
|
|
err := f.Fingerprint(request, &response)
|
2015-08-27 19:58:37 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
|
2018-01-30 17:57:37 +00:00
|
|
|
assertNodeAttributeContains(t, response.Attributes, "memory.totalbytes")
|
2015-08-27 21:01:47 +00:00
|
|
|
|
2018-01-30 17:57:37 +00:00
|
|
|
if response.Resources == nil {
|
|
|
|
t.Fatalf("response resources should not be nil")
|
|
|
|
}
|
|
|
|
if response.Resources.MemoryMB == 0 {
|
|
|
|
t.Fatalf("Expected node.Resources.MemoryMB to be non-zero")
|
2015-11-07 14:14:25 +00:00
|
|
|
}
|
2015-08-27 19:58:37 +00:00
|
|
|
}
|