open-nomad/client/fingerprint/host_test.go

37 lines
934 B
Go
Raw Normal View History

2015-08-26 21:27:44 +00:00
package fingerprint
import (
"testing"
"github.com/hashicorp/nomad/client/config"
cstructs "github.com/hashicorp/nomad/client/structs"
2015-08-26 21:27:44 +00:00
"github.com/hashicorp/nomad/nomad/structs"
)
func TestHostFingerprint(t *testing.T) {
f := NewHostFingerprint(testLogger())
node := &structs.Node{
Attributes: make(map[string]string),
}
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
response := &cstructs.FingerprintResponse{
Attributes: make(map[string]string, 0),
Links: make(map[string]string, 0),
Resources: &structs.Resources{},
}
err := f.Fingerprint(request, response)
2015-08-26 21:27:44 +00:00
if err != nil {
t.Fatalf("err: %v", err)
}
if len(response.Attributes) == 0 {
t.Fatalf("should generate a diff of node attributes")
2015-08-26 21:27:44 +00:00
}
// Host info
2016-06-23 15:28:17 +00:00
for _, key := range []string{"os.name", "os.version", "unique.hostname", "kernel.name"} {
assertNodeAttributeContains(t, response.Attributes, key)
2015-08-26 21:27:44 +00:00
}
}