Wait for discovery on container start error

This gives discovery a chance to initialize, particularly if the K/V
store being used is in a container.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff
2016-05-04 10:13:23 -04:00
parent 16d0a89593
commit 2dce79e05a
3 changed files with 103 additions and 14 deletions

View File

@@ -381,6 +381,12 @@ func TestDaemonDiscoveryReload(t *testing.T) {
&discovery.Entry{Host: "127.0.0.1", Port: "3333"},
}
select {
case <-time.After(10 * time.Second):
t.Fatal("timeout waiting for discovery")
case <-daemon.discoveryWatcher.ReadyCh():
}
stopCh := make(chan struct{})
defer close(stopCh)
ch, errCh := daemon.discoveryWatcher.Watch(stopCh)
@@ -414,6 +420,13 @@ func TestDaemonDiscoveryReload(t *testing.T) {
if err := daemon.Reload(newConfig); err != nil {
t.Fatal(err)
}
select {
case <-time.After(10 * time.Second):
t.Fatal("timeout waiting for discovery")
case <-daemon.discoveryWatcher.ReadyCh():
}
ch, errCh = daemon.discoveryWatcher.Watch(stopCh)
select {
@@ -450,6 +463,13 @@ func TestDaemonDiscoveryReloadFromEmptyDiscovery(t *testing.T) {
if err := daemon.Reload(newConfig); err != nil {
t.Fatal(err)
}
select {
case <-time.After(10 * time.Second):
t.Fatal("timeout waiting for discovery")
case <-daemon.discoveryWatcher.ReadyCh():
}
stopCh := make(chan struct{})
defer close(stopCh)
ch, errCh := daemon.discoveryWatcher.Watch(stopCh)
@@ -488,6 +508,12 @@ func TestDaemonDiscoveryReloadOnlyClusterAdvertise(t *testing.T) {
if err := daemon.Reload(newConfig); err != nil {
t.Fatal(err)
}
select {
case <-daemon.discoveryWatcher.ReadyCh():
case <-time.After(10 * time.Second):
t.Fatal("Timeout waiting for discovery")
}
stopCh := make(chan struct{})
defer close(stopCh)
ch, errCh := daemon.discoveryWatcher.Watch(stopCh)