66c521ca17
This removes a cyclical dependency when importing client/structs from dependencies of the plugin_loader, specifically, drivers. Due to client/config also depending on the plugin_loader. It also better reflects the ownership of fingerprint structs, as they are fairly internal to the fingerprint manager.
40 lines
1 KiB
Go
40 lines
1 KiB
Go
package fingerprint
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/nomad/client/config"
|
|
"github.com/hashicorp/nomad/helper/testlog"
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
"github.com/hashicorp/nomad/testutil"
|
|
)
|
|
|
|
func TestVaultFingerprint(t *testing.T) {
|
|
tv := testutil.NewTestVault(t)
|
|
defer tv.Stop()
|
|
|
|
fp := NewVaultFingerprint(testlog.HCLogger(t))
|
|
node := &structs.Node{
|
|
Attributes: make(map[string]string),
|
|
}
|
|
|
|
conf := config.DefaultConfig()
|
|
conf.VaultConfig = tv.Config
|
|
|
|
request := &FingerprintRequest{Config: conf, Node: node}
|
|
var response FingerprintResponse
|
|
err := fp.Fingerprint(request, &response)
|
|
if err != nil {
|
|
t.Fatalf("Failed to fingerprint: %s", err)
|
|
}
|
|
|
|
if !response.Detected {
|
|
t.Fatalf("expected response to be applicable")
|
|
}
|
|
|
|
assertNodeAttributeContains(t, response.Attributes, "vault.accessible")
|
|
assertNodeAttributeContains(t, response.Attributes, "vault.version")
|
|
assertNodeAttributeContains(t, response.Attributes, "vault.cluster_id")
|
|
assertNodeAttributeContains(t, response.Attributes, "vault.cluster_name")
|
|
}
|