Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly fix "daemon kill" on test failure #10086

Merged
merged 1 commit into from
Jan 14, 2015

Conversation

tianon
Copy link
Member

@tianon tianon commented Jan 14, 2015

Fixes #10074

@tianon
Copy link
Member Author

tianon commented Jan 14, 2015

Wait! This can be even slightly simpler.

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
@tianon tianon force-pushed the properly-fix-daemon-kill-on-failure branch from 6066b59 to c18fdc3 Compare January 14, 2015 04:12
@tianon
Copy link
Member Author

tianon commented Jan 14, 2015

Updated!

@tianon
Copy link
Member Author

tianon commented Jan 14, 2015

I figured we were hiding an issue with the previous fix. 👍

So, to unwrap this a little, when we had a failure before, it wasn't running .integration-daemon-stop, so the daemon wasn't actually getting killed. In our usual case, that was fine because it was backgrounded, so as soon as pid1 died (ie, our test run finished and our script exited and the container finished) the test daemon was killed by Docker for us, which isn't exactly how that ought to work. 😄

We fix it by actually capturing the failure when it happens (in an if block), recording that we failed (so we can bubble that up after cleanup), killing the daemon(s) appropriately, and then bubbling up our failure. If only, if only bash had defer (without resorting to funky trap hacks). 🚀

@LK4D4
Copy link
Contributor

LK4D4 commented Jan 14, 2015

Wait! This can be even slightly simpler.
I don't want to know what was hard way.

@tianon
Copy link
Member Author

tianon commented Jan 14, 2015

Here's my testing notes:

$ cat integration-cli/fail_test.go
package main

import "testing"

func TestFail(t *testing.T) {
    t.Fatal("lolol")
}
$ make TESTFLAGS='-test.run TestFail' test-integration-cli
...
< hangs >
^C
$ # apply PR
$ make TESTFLAGS='-test.run TestFail' test-integration-cli
...
+ go test -test.run TestFail -test.timeout=30m github.com/docker/docker/integration-cli
--- FAIL: TestFail (0.00s)
    fail_test.go:6: lolol
FAIL
coverage: 1.0% of statements
exit status 1
FAIL    github.com/docker/docker/integration-cli    0.007s
++++ cat /go/src/github.com/docker/docker/bundles/1.4.1-dev/test-integration-cli/docker.pid
+++ kill 454
Makefile:71: recipe for target 'test-integration-cli' failed
make: *** [test-integration-cli] Error 1
$ 

@LK4D4
Copy link
Contributor

LK4D4 commented Jan 14, 2015

I tested locally, all okay, but I still want to see what drone think about all this.
@jfrazelle I'm going to ask you to teach me drone-fu.

@LK4D4
Copy link
Contributor

LK4D4 commented Jan 14, 2015

Drone is okay with this - LGTM

@jessfraz
Copy link
Contributor

LGTM

jessfraz pushed a commit that referenced this pull request Jan 14, 2015
…lure

Properly fix "daemon kill" on test failure
@jessfraz jessfraz merged commit 355415d into moby:master Jan 14, 2015
@tianon tianon deleted the properly-fix-daemon-kill-on-failure branch January 14, 2015 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests are hanging if failing
3 participants