documentcloud / pixel-ping

A Minimalist Pixel Tracker for Node.js

Home Page:http://documentcloud.github.com/pixel-ping

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

test fails when more than five pixels are requested

gka opened this issue · comments

While now the simple test with just 3 requests succeeds, a very similar test with six requests fails

❯ cake test                                                                                                                        
4:  one
8:  two
6:  three
--- flushed ---
Test Failed  { one: 4, two: 8, three: 6 }

Apparently the last requests is timed out, and the flush is only happening after the 60-seconds interval defined in test/config.json has passed. Also note that the counts are completely wrong, the expected result should be either

{ "one": 1, "two": 2, "three": 3 }

or, since the last request failed, at least:

{ "one": 1, "two": 2, "three": 2 }

I could reproduce this multiple counting of single pixel.gif requests in a real server setting, so this is a serious bug.

Hey @gka, I can replicate that the test you've linked there fails. But i wanted to make sure we had a different external check, so i wrote up a little set of ruby scripts just as a sanity check, and things seem to be working as intended there: https://gist.github.com/knowtheory/e3c370ad28a6503a9cf6

I'm looking at this, and yes, it seems the last request in the test isn't going through, but this:

 I could reproduce this multiple counting of single pixel.gif requests in a real server setting, 
 so this is a serious bug.

Seems like a different bug? Are you saying that the requests are being double counted? Cause that is definitely strange.

Yes they are counted multiple times. There are exactly five requests (maybe six), but the resulting JSON data that is flushed to the test endpoint is { one: 4, two: 8, three: 6 }, which indicates 18 requests. I was also testing this on a remote server, and I fired exactly 100 requests but pixel-ping flushed way more than that. It is indeed a strange bug...

I think we need to revisit the test, because all the external checks i've written in ruby have indicated that pixel-ping isn't double counting even across flush boundaries.

I took the scripts from the gist i posted above, upped the sleep to 5 seconds, and did 100 count per threads and got the expected results https://gist.github.com/knowtheory/2accf4151d6cdd07fe7e