Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How do you adjust your testing approach to catch cases like this? In my experience, timing related issues are hard to catch and can linger for years unnoticed.


I would mock/hook/monkey patch/whatever the functions to get the current time/elapsed time, simulate a period of time (a day/week/month/year/whatever), make sure the function to download the file is called the correct amount of times. That would probably catch this bug.

Although, after such a fuck up, I would be tempted to make a pre-release check that tests the compiled binary, not any unit test or whatever. Use LD_PRELOAD to hook the system timing functions(a quick google shows that libfaketime[0] exists, but I've never used it), launch the real program and speed up time to make sure it doesn't try to download more than once.

[0] https://github.com/wolfcw/libfaketime


Similar to doix said, consider reading the time as IO and then rewrite the code in sans-IO style so you can inject the time.

Then it's a unit test that looks too obvious to exist until you read the ticket mentioned in the comment above it

No need for monkey patching or hooking or preload

But before that you add a couple checkmarks to the manual pre-release test list: "1 hour soak test" and "check network transfer meters before and after, expect under 50 MB used in 1 hour (see bug #6969)"

In Linux they're under /sys/class/net I think


I imagine they’d have to start testing first…


not to ~dupe my top-level comment, but ETag headers can be used to manage this from a ~caching perspective




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: