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

Ignore HTTPKeepAlive in leaktest #29

Merged
merged 4 commits into from
Nov 9, 2018

Conversation

lawrencegripper
Copy link
Contributor

@fortytw2
Copy link
Owner

fortytw2 commented Oct 22, 2018

Thanks for the PR! Pretty fair case to me, can you add a two tests, one that passes without this patch (i.e. using DisableKeepAlive) and another that fails unless this patch is applied (without using DisableKeepAlive) ?

Not sure why travis didn't run on this PR at all either

@lawrencegripper
Copy link
Contributor Author

Sure, I’ll pick this up tomorrow.

Webhooks where disabled while GH had their storage issues today so guessing the build will run when I push the tests up.

@lawrencegripper
Copy link
Contributor Author

lawrencegripper commented Oct 23, 2018

@fortytw2 I've refactored the tests a bit so I can add those in easily.

In order to test nicely (without calling externally) I create a server in the test and call it, this means I've had to remove go 1.7 from the test as its server didn't support the IdleTimeout field - hope that's ok?

@lawrencegripper
Copy link
Contributor Author

@fortytw2 Did you have a chance to look at the PR, happy to fix up any feedback around the additional tests I added.

@fortytw2
Copy link
Owner

fortytw2 commented Nov 6, 2018

I totally missed your update to the PR, my bad 🙈 let me get right on it

Copy link
Owner

@fortytw2 fortytw2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple comments, nothing too huge

leaktest_test.go Outdated
}
}

// TestSlowTest verifies that the timeout works on slow tests: it should
// be based on time after the test finishes rather than time after the test's
// start.
func TestSlowTest(t *testing.T) {
defer CheckTimeout(t, 1000 * time.Millisecond)()
defer CheckTimeout(t, 1000*time.Millisecond)()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a gofmt change?

Copy link
Contributor Author

@lawrencegripper lawrencegripper Nov 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it looks like gofmt is picking that one up.

gofmt -d leaktest_test.go 
diff -u leaktest_test.go.orig leaktest_test.go
--- leaktest_test.go.orig	2018-11-06 16:10:23.301798204 +0000
+++ leaktest_test.go	2018-11-06 16:10:23.305798204 +0000
@@ -138,7 +138,7 @@
 // be based on time after the test finishes rather than time after the test's
 // start.
 func TestSlowTest(t *testing.T) {
-	defer CheckTimeout(t, 1000 * time.Millisecond)()
+	defer CheckTimeout(t, 1000*time.Millisecond)()
 
 	go time.Sleep(1500 * time.Millisecond)
 	time.Sleep(750 * time.Millisecond)

I've rolled it back to keep things simple.

router.Handle("/", index())

server := &http.Server{
Addr: ":8091",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use httptest.NewServer here, so we're not forced to free up :8091 on any machine running this?

Also kill the log statements :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh cool, I'd not worked with the httptest stuff before that has made this much simpler!

@lawrencegripper
Copy link
Contributor Author

@fortytw2 np, hopefully fixed those up. Thanks for the pointers, httptest is one I hadn't come across before but looks like it is really useful so I'm glad you pointed it out.

@fortytw2
Copy link
Owner

fortytw2 commented Nov 6, 2018

@lawrencegripper thanks for the fixes! I'll pull it locally this afternoon and double check, then get it all nice and merged! (need to cut a new tag since we're dropping 1.7 support)

@fortytw2 fortytw2 merged commit 9a23578 into fortytw2:master Nov 9, 2018
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.

2 participants