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
SEO Ranking plugin not working - problem with ping? - Fix the random test failures #17919
Comments
That actually seems to fail randomly |
This is more or less expected as it is crawling websites that randomly block or rate limit the requests. |
@Findus23 so it's maybe now also blocked on travis because we run tests more often maybe? Maybe in that case we need to write the tests slightly different to ideally detect rate limit and ignore it (skip test or so) but not fail when the data or URL changes (not fail for any other error). To fix it on cloud maybe we would need to request the data using JavaScript to go directly to the search engines? But I assume then it might be bit harder to test things work? |
But then again I thought we changed the tests to test against a local copy of the HTTP response, but I might be wrong here |
I guess there are still some tests that try to fetch the data from bing, alexa and google to ensure the response doesn't change |
created an internal issue for cloud to fix the rate limiting there where we might simply try to get data using JS directly from search engine or so. Meanwhile as part of this issue be great to look into making the test stable. Like we could force to run into the rate limit and then check if the response code or response message includes rate limit information then we can catch this error specifically and ignore it in tests. |
You are right @sgiehl ! That was the clue. See
I debugged it and it seems it randomly fails on the User Agent that is passed. So, I wrote this script: Ran it and found that it outputs an empty search result on offset So, it seems to be this UA that it does not like:
I'll change it to a different one, as Bing seems to not work with that. Also, I think it should maybe not be completely random and should be different on every subsequent call. But i realise that might be hard to do. Could it be |
@geekdenz nice find. Don't know if |
I think using the same user agent every time would suffice actually. |
@geekdenz The code to query the metrics uses |
* change bogus user agent that fails on bing.com fixes #17919 * only use one user agent for seo test
@sgiehl @geekdenz I think the test should either test a few different UAs or just one rather than random. If we test one, we could use that same one with confidence for the backup useragent to retry with on empty results. Maybe worth making that as a separate issue - I've merged this one for now to prevent the failing test meantime |
@geekdenz this still seems to be failing randomly see https://app.travis-ci.com/github/matomo-org/matomo/jobs/537951969#L1130-L1130 or am I looking wrong? The test ran after the other PR was merged AFAIK |
Yeah. Thanks for pointing it out. I saw this earlier as well but thought it might be an artifact of a merge not having happened somewhere. I think maybe the find I did was just looking like this in Safari. I'll have another look in Chrome. And then I might reinstate the array and make it retry with another UA if the test fails on the first etc. and only have it throw a failure of all fails. |
I think it's possible for this to fail if the actual search results on Bing contains the word "results". It's a rare case, maybe happens occasionally when microsoft.com publishes new company "results" for investors or at random. Perhaps a solution would be to make the regex that searches for the number of search results more restrictive. The change from @geekdenz at least prevents the test failing 1 in 3 times and may also be sufficient to close this. |
I had a discussion with @justinvelluppillai on that one, we suggest printing the IP if tests failed in the travis, if the same IP keeps failing, probably because the IP blocked already. Let me know if there is a security risk of printing the IP of Travis. |
Seeing this in the tests
and an error in the UI
Seems this regressed.
The text was updated successfully, but these errors were encountered: