mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
* core: plumbing to support numa aware scheduling * core: apply node resources compatibility upon fsm rstore Handle the case where an upgraded server dequeus an evaluation before a client triggers a new fingerprint - which would be needed to cause the compatibility fix to run. By running the compat fix on restore the server will immediately have the compatible pseudo topology to use. * lint: learn how to spell pseudo
155 lines
3.7 KiB
Go
155 lines
3.7 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package client
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/nomad/ci"
|
|
"github.com/hashicorp/nomad/client/config"
|
|
"github.com/shoenig/test/must"
|
|
)
|
|
|
|
func TestFingerprintManager_Run_ResourcesFingerprint(t *testing.T) {
|
|
ci.Parallel(t)
|
|
|
|
testClient, cleanup := TestClient(t, nil)
|
|
defer cleanup()
|
|
|
|
fm := NewFingerprintManager(
|
|
testClient.config.PluginSingletonLoader,
|
|
testClient.GetConfig,
|
|
testClient.config.Node,
|
|
testClient.shutdownCh,
|
|
testClient.updateNodeFromFingerprint,
|
|
testClient.logger,
|
|
)
|
|
|
|
_, err := fm.Run()
|
|
must.NoError(t, err)
|
|
|
|
node := testClient.config.Node
|
|
|
|
must.Positive(t, node.NodeResources.Processors.TotalCompute())
|
|
must.Positive(t, node.NodeResources.Memory.MemoryMB)
|
|
must.Positive(t, node.NodeResources.Disk.DiskMB)
|
|
}
|
|
|
|
func TestFimgerprintManager_Run_InWhitelist(t *testing.T) {
|
|
ci.Parallel(t)
|
|
|
|
testClient, cleanup := TestClient(t, func(c *config.Config) {
|
|
c.Options = map[string]string{
|
|
"test.shutdown_periodic_after": "true",
|
|
"test.shutdown_periodic_duration": "2",
|
|
}
|
|
})
|
|
defer cleanup()
|
|
|
|
fm := NewFingerprintManager(
|
|
testClient.config.PluginSingletonLoader,
|
|
testClient.GetConfig,
|
|
testClient.config.Node,
|
|
testClient.shutdownCh,
|
|
testClient.updateNodeFromFingerprint,
|
|
testClient.logger,
|
|
)
|
|
|
|
_, err := fm.Run()
|
|
must.NoError(t, err)
|
|
|
|
node := testClient.config.Node
|
|
must.NotEq(t, "", node.Attributes["cpu.numcores"])
|
|
}
|
|
|
|
func TestFingerprintManager_Run_InDenylist(t *testing.T) {
|
|
ci.Parallel(t)
|
|
|
|
testClient, cleanup := TestClient(t, func(c *config.Config) {
|
|
c.Options = map[string]string{
|
|
"fingerprint.allowlist": " arch,memory,foo,bar ",
|
|
"fingerprint.denylist": " cpu ",
|
|
}
|
|
})
|
|
defer cleanup()
|
|
|
|
fm := NewFingerprintManager(
|
|
testClient.config.PluginSingletonLoader,
|
|
testClient.GetConfig,
|
|
testClient.config.Node,
|
|
testClient.shutdownCh,
|
|
testClient.updateNodeFromFingerprint,
|
|
testClient.logger,
|
|
)
|
|
|
|
_, err := fm.Run()
|
|
must.NoError(t, err)
|
|
|
|
node := testClient.config.Node
|
|
|
|
must.MapNotContainsKey(t, node.Attributes, "cpu.frequency")
|
|
must.NotEq(t, node.Attributes["memory.totalbytes"], "")
|
|
}
|
|
|
|
func TestFingerprintManager_Run_Combination(t *testing.T) {
|
|
ci.Parallel(t)
|
|
|
|
testClient, cleanup := TestClient(t, func(c *config.Config) {
|
|
c.Options = map[string]string{
|
|
"fingerprint.allowlist": " arch,cpu,memory,foo,bar ",
|
|
"fingerprint.denylist": " memory,host ",
|
|
}
|
|
})
|
|
defer cleanup()
|
|
|
|
fm := NewFingerprintManager(
|
|
testClient.config.PluginSingletonLoader,
|
|
testClient.GetConfig,
|
|
testClient.config.Node,
|
|
testClient.shutdownCh,
|
|
testClient.updateNodeFromFingerprint,
|
|
testClient.logger,
|
|
)
|
|
|
|
_, err := fm.Run()
|
|
must.NoError(t, err)
|
|
|
|
node := testClient.config.Node
|
|
|
|
must.NotEq(t, "", node.Attributes["cpu.numcores"])
|
|
must.NotEq(t, "", node.Attributes["cpu.arch"])
|
|
must.MapNotContainsKey(t, node.Attributes, "memory.totalbytes")
|
|
must.MapNotContainsKey(t, node.Attributes, "os.name")
|
|
}
|
|
|
|
func TestFingerprintManager_Run_CombinationLegacyNames(t *testing.T) {
|
|
ci.Parallel(t)
|
|
|
|
testClient, cleanup := TestClient(t, func(c *config.Config) {
|
|
c.Options = map[string]string{
|
|
"fingerprint.whitelist": " arch,cpu,memory,foo,bar ",
|
|
"fingerprint.blacklist": " memory,host ",
|
|
}
|
|
})
|
|
defer cleanup()
|
|
|
|
fm := NewFingerprintManager(
|
|
testClient.config.PluginSingletonLoader,
|
|
testClient.GetConfig,
|
|
testClient.config.Node,
|
|
testClient.shutdownCh,
|
|
testClient.updateNodeFromFingerprint,
|
|
testClient.logger,
|
|
)
|
|
|
|
_, err := fm.Run()
|
|
must.NoError(t, err)
|
|
|
|
node := testClient.config.Node
|
|
must.NotEq(t, "", node.Attributes["cpu.numcores"])
|
|
must.NotEq(t, "", node.Attributes["cpu.arch"])
|
|
must.MapNotContainsKey(t, node.Attributes, "memory.totalbytes")
|
|
must.MapNotContainsKey(t, node.Attributes, "os.name")
|
|
}
|