Merge pull request #1556 from hqhq/fix_flakytest_TestNotifyOnOOM

Fix flaky test TestNotifyOnOOM
This commit is contained in:
Michael Crosby 2017-08-14 10:03:23 -04:00 committed by GitHub
commit 3096b3fc85
2 changed files with 4 additions and 7 deletions

View File

@ -44,9 +44,9 @@ func registerMemoryEvent(cgDir string, evName string, arg string) (<-chan struct
ch := make(chan struct{})
go func() {
defer func() {
close(ch)
eventfd.Close()
evFile.Close()
close(ch)
}()
buf := make([]byte, 8)
for {

View File

@ -53,17 +53,13 @@ func testMemoryNotification(t *testing.T, evName string, notify notifyFunc, targ
t.Fatalf("invalid control data %q: %s", data, err)
}
// re-open the eventfd
// dup the eventfd
efd, err := unix.Dup(eventFd)
if err != nil {
t.Fatal("unable to reopen eventfd:", err)
t.Fatal("unable to dup eventfd:", err)
}
defer unix.Close(efd)
if err != nil {
t.Fatal("unable to dup event fd:", err)
}
buf := make([]byte, 8)
binary.LittleEndian.PutUint64(buf, 1)
@ -93,6 +89,7 @@ func testMemoryNotification(t *testing.T, evName string, notify notifyFunc, targ
t.Fatal("expected no notification to be triggered")
}
case <-time.After(100 * time.Millisecond):
t.Fatal("channel not closed after 100ms")
}
if _, _, err := unix.Syscall(unix.SYS_FCNTL, uintptr(evFd), unix.F_GETFD, 0); err != unix.EBADF {