Browse code

Config-reload IT Signed-off-by: Madhu Venugopal <madhu@docker.com>

Madhu Venugopal authored on 2016/02/19 04:00:26
Showing 1 changed files
... ...
@@ -17,6 +17,7 @@ import (
17 17
 	"strconv"
18 18
 	"strings"
19 19
 	"sync"
20
+	"syscall"
20 21
 	"time"
21 22
 
22 23
 	"github.com/docker/docker/pkg/integration/checker"
... ...
@@ -2157,3 +2158,43 @@ func (s *DockerDaemonSuite) TestDaemonDebugLog(c *check.C) {
2157 2157
 	newD.Stop()
2158 2158
 	c.Assert(b.String(), checker.Contains, debugLog)
2159 2159
 }
2160
+
2161
+func (s *DockerSuite) TestDaemonDiscoveryBackendConfigReload(c *check.C) {
2162
+	testRequires(c, SameHostDaemon, DaemonIsLinux)
2163
+
2164
+	// daemon config file
2165
+	daemonConfig := `{ "debug" : false }`
2166
+	configFilePath := "test.json"
2167
+
2168
+	configFile, err := os.Create(configFilePath)
2169
+	c.Assert(err, checker.IsNil)
2170
+	fmt.Fprintf(configFile, "%s", daemonConfig)
2171
+
2172
+	d := NewDaemon(c)
2173
+	err = d.Start(fmt.Sprintf("--config-file=%s", configFilePath))
2174
+	c.Assert(err, checker.IsNil)
2175
+	defer d.Stop()
2176
+
2177
+	// daemon config file
2178
+	daemonConfig = `{
2179
+	      "cluster-store": "consul://consuladdr:consulport/some/path",
2180
+	      "cluster-advertise": "192.168.56.100:0",
2181
+	      "debug" : false
2182
+	}`
2183
+
2184
+	configFile.Close()
2185
+	os.Remove(configFilePath)
2186
+
2187
+	configFile, err = os.Create(configFilePath)
2188
+	c.Assert(err, checker.IsNil)
2189
+	fmt.Fprintf(configFile, "%s", daemonConfig)
2190
+
2191
+	syscall.Kill(d.cmd.Process.Pid, syscall.SIGHUP)
2192
+
2193
+	time.Sleep(3 * time.Second)
2194
+
2195
+	out, err := d.Cmd("info")
2196
+	c.Assert(err, checker.IsNil)
2197
+	c.Assert(out, checker.Contains, fmt.Sprintf("Cluster store: consul://consuladdr:consulport/some/path"))
2198
+	c.Assert(out, checker.Contains, fmt.Sprintf("Cluster advertise: 192.168.56.100:0"))
2199
+}