From 086e1d9daa6fec15c65cc3a30bd77d114277158f Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Fri, 11 Sep 2015 21:25:46 -0700 Subject: [PATCH] testutil: enable dev mode using a config flag. This flag is not normally supported in Nomad, but we really need to use it for testing to lower the timing values for registration retries et. al. Instead of just enabling it on all tests, we provide a bool flag in the config, which just makes the test server pass the extra CLI arg when true. --- testutil/server.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testutil/server.go b/testutil/server.go index f8e30652f..021a8b51a 100644 --- a/testutil/server.go +++ b/testutil/server.go @@ -37,6 +37,7 @@ type TestServerConfig struct { Ports *PortsConfig `json:"ports,omitempty"` Server *ServerConfig `json:"server,omitempty"` Client *ClientConfig `json:"client,omitempty"` + DevMode bool `json:"-"` Stdout, Stderr io.Writer `json:"-"` } @@ -142,8 +143,13 @@ func NewTestServer(t *testing.T, cb ServerConfigCallback) *TestServer { stderr = nomadConfig.Stderr } + args := []string{"agent", "-config", configFile.Name()} + if nomadConfig.DevMode { + args = append(args, "-dev") + } + // Start the server - cmd := exec.Command("nomad", "agent", "-dev", "-config", configFile.Name()) + cmd := exec.Command("nomad", args...) cmd.Stdout = stdout cmd.Stderr = stderr if err := cmd.Start(); err != nil {