-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add idle timeout support #171
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
Comments
Why? |
@jamestalmage Well, I'm just kinda annoyed of having to change the default timeout in other test frameworks again and again. I'm actually fine with having a global timeout, as long as it is disabled by default. |
Right now AVA hangs forever if you fail to call One thing I am always writing (in mocha) is: if (process.env.TRAVIS) {
this.timeout(fiveTimesWhateverItTakesLocally)
} I dislike having to wait to see my mistake during development, just to accommodate the slower CPU on my CI. It would be cool to build that in to AVA (though maybe not possible to do in a reliable way across all CI implementations out there). Either way, I think AVA needs global and per tests timeouts with sensible defaults. |
What are sensible defaults in your opinion? |
@jamestalmage You changed my mind. :) I agree, in CI defaults do make sense. |
Ooh. That is a hard question. 😄 Locally, I would prefer something really fast. |
Hi, I gathered some data on the default timeouts used by other popular tools. Hopefully it will aid you in reasoning about a "sensible default":
* 240000ms (240s) if As an aside, I think there should be a command-line argument and/or environment variable to configure the timeout value. This'll be useful when running tests in a slow environment. |
@jamestalmage @alexbooker I agree w/ the need for global/local timeouts and for me a faster default would be preferable and, to your point, encourage me to write smaller, faster tests 👍 Maybe it's crazy/overkill, but what about using something like |
@markthethomas - I don't think smart-setting the timeout based on CPU information is helpful. For normal tests, you don't really need timeouts anyway. At least, when I implement timeouts, it's usually because of possible network issues, like "if you can't connect to service X within Y seconds, abort the tests". |
@MarkTiedemann sounds good to me — just a thought I had :) |
@markthethomas AVA is supposed to be fast, but that has nothing to do with user's tests. |
Sorry, the "sounds good" was in reference to using the os module :) Mark Sent from my iPhone @markthethomas everywhere
|
So both defaults kinda make sense, in their own narrow context. So actually they don't: Because how do you know the context? You don't know. But the solution is simple, I think. If the timeout is disabled by default, we don't need to pick a pseudo-reasonable default -- just let the developer decide! If someone wants to run quick AVA tests locally, let him use a timeout option:
And if someone just wants to prevent CI from hanging, let him set his own reasonable timeout: // timeout still disabled
if (process.env.TRAVIS) {
test.setTimeout(30000); // timeout now enabled!
} How about this idea? :) |
I think both cli and api hooks are a given. We are all just bikeshedding over what the defaults will be. |
@jamestalmage Yup. If we were to have a default it would be at least 30sec. The Mocha default at times drove me mad for being too short. |
Me too. I found 2 seconds way too long! 😆 |
Yeah, I know that feeling. In Mocha, I usually set the timeout to
What do you think about not having a default, about having timeouts disabled by default and allowing devs to set one if they need one? |
We need some sort of default, just as a kindness to CI providers. |
Ok, so I think the conclusion is; set a default timeout if |
fyi is-ci |
@sindresorhus: Just my two cents, but that seems rather confusing. I wouldn't want to have to debug tests that magically fail on the CI but don't fail on my dev machine. At the very least, we need to log something about it. |
@ariporad Would you rather have the CI stall indefinitely? We will definitely log why it ended. Happy to hear other suggestions/solutions. |
@sindresorhus: Well, one thing to keep in mind is that Travis stops the test after 10 minutes without output, and caps it at 120 minutes period. AppVeyor has a maximum of 60 minutes. And I personally think it's out of scope for AVA, but it's up to you. |
I would also prefer not having to deal with this in AVA, but I got the impression from this thread that CI's would stall forever. I think I'm changing my opinion to timeout being opt-in no matter what. @vdemedes @jamestalmage ? |
@sindresorhus: I agree. (I hope I didn't imply that there should be no timeouts period, I just meant on the CI). CIs defiantly do not just sit there for years waiting for infinite loops to finish. I'm happy to put together a simple little repo to prove that if you want. |
Would be nice to have it. I've tried ava for the last couple days and not having timeouts is really annoying, the feedback loop is too long and you have no clue of what's broken. I hate having to setup babel + node-tap but I prefer that over hanging tests. |
Since we run many tests concurrently I'm not convinced the timeout should apply to individual tests. Rather it should be an idle timeout, e.g. we're still waiting for at least 1 test and it's been 30 seconds since the last test completed. Further when AVA is interrupted we could print out which tests are still pending. Even without defining a timeout this would let you debug things. This may deal with the CI issue as well, assuming it interrupts AVA when killing the CI run. |
It is actually a very good idea, @novemberborn! |
👍 |
Changed title to "Add idle timeout support". Presumably Would be cool if it could print out which tests were aborted. I've opened #583 to track the interrupt idea. |
Would we measure that globally, or per test file? |
Globally. I only care about lack of progress. I suggested |
👍 to globally and |
@vdemedes You're assigned to this. Still interested or should I unassign you? |
Still interested! |
Done via #654! |
I am lost – what is the current accepted way to set timeout per test? Is it: test((t) => {
setTimeout(t.end, 1000);
}); ? |
There isn't a per test solution. Because we launch all your tests async, and they interleave, a per test timeout wouldn't be very reliable. Instead you just set a global timeout that measures time between test results. That's best used for preventing overlong builds on your CI server. |
Just switched to AVA -- and I love it! -- but, -- and this is really a minor issue -- I also noticed that I kept reusing code like this:
And just to be clear, I don't like global test timeouts -- I think they're a terrible idea.
Yet again, I think something like
t.failAfter(time)
is not too bad.What do you guys think? :)
The text was updated successfully, but these errors were encountered: