tests: make a test client/config easier to generate
Sadly can't move the fingerprint timeout tweak into the helper due to circular imports.
This commit is contained in:
parent
1d747048ea
commit
dd4227f84a
23
client/config/testing.go
Normal file
23
client/config/testing.go
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hashicorp/nomad/helper"
|
||||||
|
"github.com/hashicorp/nomad/nomad/structs"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestClientConfig returns a default client configuration for test clients.
|
||||||
|
func TestClientConfig() *Config {
|
||||||
|
conf := DefaultConfig()
|
||||||
|
conf.VaultConfig.Enabled = helper.BoolToPtr(false)
|
||||||
|
conf.DevMode = true
|
||||||
|
conf.Node = &structs.Node{
|
||||||
|
Reserved: &structs.Resources{
|
||||||
|
DiskMB: 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loosen GC threshold
|
||||||
|
conf.GCDiskUsageThreshold = 98.0
|
||||||
|
conf.GCInodeUsageThreshold = 98.0
|
||||||
|
return conf
|
||||||
|
}
|
|
@ -5,9 +5,6 @@ import (
|
||||||
consulApi "github.com/hashicorp/nomad/client/consul"
|
consulApi "github.com/hashicorp/nomad/client/consul"
|
||||||
"github.com/hashicorp/nomad/client/fingerprint"
|
"github.com/hashicorp/nomad/client/fingerprint"
|
||||||
"github.com/hashicorp/nomad/command/agent/consul"
|
"github.com/hashicorp/nomad/command/agent/consul"
|
||||||
"github.com/hashicorp/nomad/helper"
|
|
||||||
"github.com/hashicorp/nomad/helper/testlog"
|
|
||||||
"github.com/hashicorp/nomad/nomad/structs"
|
|
||||||
"github.com/hashicorp/nomad/plugins/shared/catalog"
|
"github.com/hashicorp/nomad/plugins/shared/catalog"
|
||||||
"github.com/hashicorp/nomad/plugins/shared/singleton"
|
"github.com/hashicorp/nomad/plugins/shared/singleton"
|
||||||
"github.com/mitchellh/go-testing-interface"
|
"github.com/mitchellh/go-testing-interface"
|
||||||
|
@ -15,22 +12,10 @@ import (
|
||||||
|
|
||||||
// TestClient creates an in-memory client for testing purposes.
|
// TestClient creates an in-memory client for testing purposes.
|
||||||
func TestClient(t testing.T, cb func(c *config.Config)) *Client {
|
func TestClient(t testing.T, cb func(c *config.Config)) *Client {
|
||||||
conf := config.DefaultConfig()
|
conf := config.TestClientConfig()
|
||||||
logger := testlog.HCLogger(t)
|
|
||||||
conf.Logger = logger
|
|
||||||
conf.VaultConfig.Enabled = helper.BoolToPtr(false)
|
|
||||||
conf.DevMode = true
|
|
||||||
conf.Node = &structs.Node{
|
|
||||||
Reserved: &structs.Resources{
|
|
||||||
DiskMB: 0,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loosen GC threshold
|
// Tighten the fingerprinter timeouts (must be done in client package
|
||||||
conf.GCDiskUsageThreshold = 98.0
|
// to avoid circular dependencies)
|
||||||
conf.GCInodeUsageThreshold = 98.0
|
|
||||||
|
|
||||||
// Tighten the fingerprinter timeouts
|
|
||||||
if conf.Options == nil {
|
if conf.Options == nil {
|
||||||
conf.Options = make(map[string]string)
|
conf.Options = make(map[string]string)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue