github.com/kardianos/nomad@v0.1.3-0.20151022182107-b13df73ee850/client/fingerprint/cpu_test.go (about)

     1  package fingerprint
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/nomad/client/config"
     7  	"github.com/hashicorp/nomad/nomad/structs"
     8  )
     9  
    10  func TestCPUFingerprint(t *testing.T) {
    11  	f := NewCPUFingerprint(testLogger())
    12  	node := &structs.Node{
    13  		Attributes: make(map[string]string),
    14  	}
    15  	ok, err := f.Fingerprint(&config.Config{}, node)
    16  	if err != nil {
    17  		t.Fatalf("err: %v", err)
    18  	}
    19  	if !ok {
    20  		t.Fatalf("should apply")
    21  	}
    22  
    23  	// CPU info
    24  	if node.Attributes["cpu.numcores"] == "" {
    25  		t.Fatalf("Missing Num Cores")
    26  	}
    27  	if node.Attributes["cpu.modelname"] == "" {
    28  		t.Fatalf("Missing Model Name")
    29  	}
    30  
    31  	if node.Attributes["cpu.frequency"] == "" {
    32  		t.Fatalf("Missing CPU Frequency")
    33  	}
    34  	if node.Attributes["cpu.totalcompute"] == "" {
    35  		t.Fatalf("Missing CPU Total Compute")
    36  	}
    37  
    38  	if node.Resources == nil {
    39  		t.Fatalf("Expected resources on node, but got nil")
    40  	}
    41  
    42  }