one meaningless write to the config file to trigger anothe fsnotify (#3492)

pull/3535/head
Krasi Georgiev 2017-12-01 17:32:27 +00:00 committed by Brian Brazil
parent cae4538b3e
commit 29506e0bca
1 changed files with 5 additions and 5 deletions

View File

@ -76,6 +76,7 @@ func testFileSD(t *testing.T, prefix, ext string, expect bool) {
}()
newf, err := os.Create(filepath.Join(testDir, "_test_"+prefix+ext))
defer newf.Close()
if err != nil {
t.Fatal(err)
}
@ -90,14 +91,13 @@ func testFileSD(t *testing.T, prefix, ext string, expect bool) {
t.Fatal(err)
}
// File is written with the config so stop draining the discovery channel.
// It needs to be before the file closing so that fsnotify triggers a new loop of the discovery service.
// Test file is ready so stop draining the discovery channel.
// It contains two target groups.
close(fileReady)
<-drainReady
newf.Close()
newf.WriteString(" ") // One last meaningless write to trigger fsnotify and a new loop of the discovery service.
timeout := time.After(15 * time.Second)
// The files contain two target groups.
retry:
for {
select {
@ -105,7 +105,7 @@ retry:
if expect {
t.Fatalf("Expected new target group but got none")
} else {
// invalid type fsd should always broken down.
// Invalid type fsd should always break down.
break retry
}
case tgs := <-ch: