Skip to content

Commit bd2cb8b

Browse files
committed
Merged in [8970] from olau@iola.dk:
Summary: Enable support for a custom settings file for the test crawl - and add a simple settings file that enables caching to speed up the crawl (shaves ~35% off most pages AFAICT) - Legacy-Id: 8984 Note: SVN reference [8970] has been migrated to Git commit 8d4e1a8
1 parent bf77d1e commit bd2cb8b

2 files changed

Lines changed: 41 additions & 16 deletions

File tree

bin/test-crawl

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,30 @@
22

33
import os, sys, re, datetime, argparse, traceback, tempfile
44

5+
# args
6+
parser = argparse.ArgumentParser(
7+
description="""Perform a test crawl of the project. For each found URL, the HTTP
8+
response status is printed. If it's not OK/redirect, FAIL is
9+
printed - in case of errors, a stacktrace is also included.""")
10+
parser.add_argument('urls', metavar='URL', nargs='*',
11+
help='One or more URLs to start the crawl from')
12+
parser.add_argument('--urls', '-u', dest='url_file',
13+
help='file with URLs to start the crawl from')
14+
parser.add_argument('--slow', dest='slow_threshold', type=float, default=1.0,
15+
help='responses taking longer than this (in seconds) results in SLOW being printed')
16+
parser.add_argument('--settings', dest='settings', help='custom settings file')
17+
18+
args = parser.parse_args()
19+
520
# boilerplate
621
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))
722
sys.path = [ basedir ] + sys.path
8-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ietf.settings")
23+
24+
settings_module = args.settings or "ietf.settings"
25+
26+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
927

1028
import django.test
11-
from django.conf import settings
1229

1330
# prevent memory from leaking when settings.DEBUG=True
1431
from django.db import connection
@@ -19,20 +36,6 @@ connection.queries = DontSaveQueries()
1936

2037
MAX_URL_LENGTH = 500
2138

22-
# args
23-
parser = argparse.ArgumentParser(
24-
description="""Perform a test crawl of the project. For each found URL, the HTTP
25-
response status is printed. If it's not OK/redirect, FAIL is
26-
printed - in case of errors, a stacktrace is also included.""")
27-
parser.add_argument('urls', metavar='URL', nargs='*',
28-
help='One or more URLs to start the crawl from')
29-
parser.add_argument('--urls', '-u', dest='url_file',
30-
help='file with URLs to start the crawl from')
31-
parser.add_argument('--slow', dest='slow_threshold', type=float, default=1.0,
32-
help='responses taking longer than this (in seconds) results in SLOW being printed')
33-
34-
args = parser.parse_args()
35-
3639
slow_threshold = args.slow_threshold
3740

3841
initial_urls = []

ietf/settings_testcrawl.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Standard settings except we enable caching like in the production
2+
# environment, this is useful for speeding up the test crawl, try for
3+
# instance:
4+
#
5+
# bin/test-crawl --settings=ietf.settings_testcrawl
6+
#
7+
8+
from settings import * # pyflakes:ignore
9+
10+
TEMPLATE_LOADERS = (
11+
('django.template.loaders.cached.Loader', (
12+
'django.template.loaders.filesystem.Loader',
13+
'django.template.loaders.app_directories.Loader',
14+
)),
15+
'ietf.dbtemplate.template.Loader',
16+
)
17+
18+
CACHES = {
19+
'default': {
20+
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
21+
}
22+
}

0 commit comments

Comments
 (0)