Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
bug 1401246: Update sample database
Browse files Browse the repository at this point in the history
Updates for a sample DB regen just before the Django 1.11 update:

* Try 7 times for the very slow Midas/Security_Preferences history
* Drop the interactive editor content experiment pages
* Add resources needed by headless testing for CDN headers
* Adjust a headless CDN test to use a real revision
  • Loading branch information
jwhitlock committed Jun 5, 2018
1 parent c6b5b16 commit e86a9c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
8 changes: 7 additions & 1 deletion etc/sample_db.json
@@ -1,7 +1,6 @@
{
"sources": [
["links", "/", {"translations": true, "revisions": 3}],
["links", "/en-US/docs/Experiment:InteractiveEditor", {}],
["document", "/en-US/docs/Mozilla/Firefox", {"revisions": 15}],
["document", "/en-US/docs/Web/Apps", {"translations": true, "revisions": 3}],
["document", "/en-US/docs/MDN_at_ten/History_of_MDN", {}],
Expand All @@ -14,6 +13,13 @@
["document", "/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach", {}],
["document", "/en-US/docs/Web/Guide/CSS/Media_queries", {}],
["document", "/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics", {}],
["document", "/en-US/docs/Learn/CSS/Styling_text/Fundamentals", {}],
["document", "/es/docs/Mozilla/Firefox", {"revisions": 3}],
["document", "/fr/docs/Mozilla/Firefox", {"revisions": 3}],
["document", "/de/docs/Mozilla/Firefox", {"revisions": 3}],
["revision", "/en-US/docs/Web/HTML$revision/1299417", {}],
["revision", "/en-US/docs/Web/HTML$revision/1293895", {}],
["revision", "/en-US/docs/Mozilla/Firefox$revision/1284393", {}],
["user", "Sheppy", {"social": true, "email": "sheppy@mozilla.com"}],
["user", "jwhitlock", {"social": true, "email": "jwhitlock@mozilla.com"}]
],
Expand Down
2 changes: 1 addition & 1 deletion kuma/scrape/scraper.py
Expand Up @@ -19,7 +19,7 @@
class Requester(object):
"""Request pages from a running MDN instance."""

MAX_ATTEMPTS = 4
MAX_ATTEMPTS = 7
TIMEOUT = 1.0

def __init__(self, host, ssl):
Expand Down
16 changes: 6 additions & 10 deletions kuma/scrape/tests/test_scraper.py
Expand Up @@ -99,24 +99,20 @@ def test_connectionerror_success():
@mock.patch('kuma.scrape.scraper.time.sleep')
def test_timeout_failure(mock_sleep):
"""Request fail after too many Timeouts."""
assert Requester.MAX_ATTEMPTS == 4
attempts = 7
assert Requester.MAX_ATTEMPTS == attempts
requester = Requester('example.com', True)
mock_session = mock.Mock(spec_set=['get'])
mock_session.get.side_effect = [requests.exceptions.Timeout] * 4
mock_session.get.side_effect = [requests.exceptions.Timeout] * attempts
requester._session = mock_session

with pytest.raises(requests.exceptions.Timeout):
requester.request('/path', raise_for_status=False)
full_path = 'https://example.com/path'
expected_calls = [
mock.call(full_path, timeout=1.0),
mock.call(full_path, timeout=2.0),
mock.call(full_path, timeout=4.0),
mock.call(full_path, timeout=8.0),
]
times = [2.0 ** attempt for attempt in range(attempts)] # 1, 2, 4, 8...
expected_calls = [mock.call(full_path, timeout=time) for time in times]
assert mock_session.get.call_args_list == expected_calls
expected_sleep_calls = [mock.call(1.0), mock.call(2.0), mock.call(4.0),
mock.call(8.0)]
expected_sleep_calls = [mock.call(time) for time in times]
assert mock_sleep.call_args_list == expected_sleep_calls


Expand Down
12 changes: 2 additions & 10 deletions tests/headless/test_cdn.py
Expand Up @@ -155,7 +155,7 @@ def test_maintenance_mode(base_url, is_behind_cdn, is_maintenance_mode):
'/en-US/Firefox$delete',
'/en-US/Firefox$translate',
'/en-US/Firefox$quick-review',
'/en-US/Firefox$revert/1358677'])
'/en-US/Firefox$revert/1284393'])
def test_not_cached_login_required(base_url, is_behind_cdn, slug):
"""Ensure that these endpoints that require login are not cached."""
url = base_url + slug
Expand Down Expand Up @@ -415,10 +415,6 @@ def test_locale_selection_cached(base_url, is_behind_cdn, is_local_url, slug,
assert expected, "expected must be set to the expected locale prefix."
assert accept, "accept must be set to the Accept-Langauge header value."

if (is_local_url and slug.startswith('/Firefox') and
expected in ('fr', 'es')):
pytest.xfail("/%s/Firefox is not in sample database." % expected)

request_kwargs = {
'headers': {
'X-Requested-With': 'XMLHttpRequest',
Expand Down Expand Up @@ -459,7 +455,7 @@ def test_locale_selection_cached(base_url, is_behind_cdn, is_local_url, slug,
'/Firefox$quick-review',
'/Firefox$subscribe',
'/Firefox$subscribe_to_tree',
'/Firefox$revert/1358677'])
'/Firefox$revert/1284393'])
def test_locale_selection_not_cached(base_url, is_behind_cdn, is_local_url,
slug, expected, accept, cookie, param):
"""
Expand All @@ -473,10 +469,6 @@ def test_locale_selection_not_cached(base_url, is_behind_cdn, is_local_url,
assert expected, "expected must be set to the expected locale prefix."
assert accept, "accept must be set to the Accept-Langauge header value."

if (is_local_url and slug.startswith('/Firefox') and
expected in ('fr', 'es')):
pytest.xfail("/%s/Firefox is not in sample database." % expected)

request_kwargs = {
'headers': {
'X-Requested-With': 'XMLHttpRequest',
Expand Down

0 comments on commit e86a9c4

Please sign in to comment.