mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
tests: enable raw_exec driver
This commit is contained in:
@@ -32,6 +32,12 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
}
|
||||
|
||||
func newEnabledRawExecDriver(t *testing.T) *Driver {
|
||||
d := NewRawExecDriver(testlog.HCLogger(t)).(*Driver)
|
||||
d.config.Enabled = true
|
||||
return d
|
||||
}
|
||||
|
||||
func TestRawExecDriver_SetConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
@@ -73,7 +79,7 @@ func TestRawExecDriver_Fingerprint(t *testing.T) {
|
||||
fingerprintTest := func(config *Config, expected *drivers.Fingerprint) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
require := require.New(t)
|
||||
d := NewRawExecDriver(testlog.HCLogger(t)).(*Driver)
|
||||
d := newEnabledRawExecDriver(t)
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
defer harness.Kill()
|
||||
|
||||
@@ -133,7 +139,7 @@ func TestRawExecDriver_StartWait(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
d := NewRawExecDriver(testlog.HCLogger(t))
|
||||
d := newEnabledRawExecDriver(t)
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
defer harness.Kill()
|
||||
task := &drivers.TaskConfig{
|
||||
@@ -175,12 +181,12 @@ func TestRawExecDriver_StartWaitRecoverWaitStop(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
d := NewRawExecDriver(testlog.HCLogger(t))
|
||||
d := newEnabledRawExecDriver(t)
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
defer harness.Kill()
|
||||
|
||||
// Disable cgroups so test works without root
|
||||
config := &Config{NoCgroups: true}
|
||||
config := &Config{NoCgroups: true, Enabled: true}
|
||||
var data []byte
|
||||
require.NoError(basePlug.MsgPackEncode(&data, config))
|
||||
bconfig := &basePlug.Config{PluginConfig: data}
|
||||
@@ -219,7 +225,7 @@ func TestRawExecDriver_StartWaitRecoverWaitStop(t *testing.T) {
|
||||
originalStatus, err := d.InspectTask(task.ID)
|
||||
require.NoError(err)
|
||||
|
||||
d.(*Driver).tasks.Delete(task.ID)
|
||||
d.tasks.Delete(task.ID)
|
||||
|
||||
wg.Wait()
|
||||
require.True(waitDone)
|
||||
@@ -258,7 +264,7 @@ func TestRawExecDriver_Start_Wait_AllocDir(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
d := NewRawExecDriver(testlog.HCLogger(t))
|
||||
d := newEnabledRawExecDriver(t)
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
defer harness.Kill()
|
||||
|
||||
@@ -313,7 +319,7 @@ func TestRawExecDriver_Start_Kill_Wait_Cgroup(t *testing.T) {
|
||||
require := require.New(t)
|
||||
pidFile := "pid"
|
||||
|
||||
d := NewRawExecDriver(testlog.HCLogger(t))
|
||||
d := newEnabledRawExecDriver(t)
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
defer harness.Kill()
|
||||
|
||||
@@ -403,7 +409,7 @@ func TestRawExecDriver_Exec(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
d := NewRawExecDriver(testlog.HCLogger(t))
|
||||
d := newEnabledRawExecDriver(t)
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
defer harness.Kill()
|
||||
|
||||
@@ -476,8 +482,8 @@ func TestRawExecDriver_Disabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
d := NewRawExecDriver(testlog.HCLogger(t))
|
||||
d.(*Driver).config.Enabled = false
|
||||
d := newEnabledRawExecDriver(t)
|
||||
d.config.Enabled = false
|
||||
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
defer harness.Kill()
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/helper/testtask"
|
||||
"github.com/hashicorp/nomad/helper/uuid"
|
||||
basePlug "github.com/hashicorp/nomad/plugins/base"
|
||||
@@ -31,7 +30,7 @@ func TestRawExecDriver_User(t *testing.T) {
|
||||
}
|
||||
require := require.New(t)
|
||||
|
||||
d := NewRawExecDriver(testlog.HCLogger(t))
|
||||
d := newEnabledRawExecDriver(t)
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
|
||||
task := &drivers.TaskConfig{
|
||||
@@ -63,7 +62,7 @@ func TestRawExecDriver_Signal(t *testing.T) {
|
||||
}
|
||||
require := require.New(t)
|
||||
|
||||
d := NewRawExecDriver(testlog.HCLogger(t))
|
||||
d := newEnabledRawExecDriver(t)
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
|
||||
task := &drivers.TaskConfig{
|
||||
@@ -134,12 +133,12 @@ func TestRawExecDriver_StartWaitStop(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
d := NewRawExecDriver(testlog.HCLogger(t))
|
||||
d := newEnabledRawExecDriver(t)
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
defer harness.Kill()
|
||||
|
||||
// Disable cgroups so test works without root
|
||||
config := &Config{NoCgroups: true}
|
||||
config := &Config{NoCgroups: true, Enabled: true}
|
||||
var data []byte
|
||||
require.NoError(basePlug.MsgPackEncode(&data, config))
|
||||
bconfig := &basePlug.Config{PluginConfig: data}
|
||||
@@ -204,7 +203,7 @@ func TestRawExec_ExecTaskStreaming(t *testing.T) {
|
||||
}
|
||||
require := require.New(t)
|
||||
|
||||
d := NewRawExecDriver(testlog.HCLogger(t))
|
||||
d := newEnabledRawExecDriver(t)
|
||||
harness := dtestutil.NewDriverHarness(t, d)
|
||||
defer harness.Kill()
|
||||
|
||||
|
||||
@@ -10,7 +10,15 @@ import (
|
||||
|
||||
// TestPluginLoader returns a plugin loader populated only with internal plugins
|
||||
func TestPluginLoader(t testing.T) loader.PluginCatalog {
|
||||
return TestPluginLoaderWithOptions(t, "", nil, nil)
|
||||
driverConfigs := []*config.PluginConfig{
|
||||
{
|
||||
Name: "raw_exec",
|
||||
Config: map[string]interface{}{
|
||||
"enabled": true,
|
||||
},
|
||||
},
|
||||
}
|
||||
return TestPluginLoaderWithOptions(t, "", nil, driverConfigs)
|
||||
}
|
||||
|
||||
// TestPluginLoaderWithOptions allows configuring the plugin loader fully.
|
||||
|
||||
Reference in New Issue
Block a user