mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-25 05:02:57 +01:00
daa82936d7
* Created Elasticsearch 2 backend * Added tests for Elasticsearch 2 backend * Split models up into different indices pages, images and documents are now in separate indices * Prefix fields of child models to prevent mapping clashes * Replaced index_analyzer with analyzer/search_analyzer index_analyzer has been removed in Elasticsearch 2.0 https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_20_mapping_changes.html#_analyzer_mappings There's no indication in Elasticsearch's docs that this wouldn't work on Elasticsearch 1.x. However, we found that the new configuration isn't reliable on Elasticsearch 1.6 and below (causes the test_query_analyzer test to fail randomly). * Implemented new way of representing content types in search index Instead of using a long string of model names that is queried using a "prefix" query, we instead use a multi-value string field and query it using a simple "match" query. The only reason why this isn't implemented in the Elasticsearch 1.x backend yet is backwards compatibility * Added another child model of SearchTest with clashing field mapping This checks that the namespacing of fields on child models is working properly (if it doesn't the update_index tests will fail) * Added tests for get_model_root function * fixup! Added tests for get_model_root function * Docs updates for Elasticsearch 2 support Also tweak examples to use elasticsearch2 backend by default * Test against Elasticsearch 2 on travis
75 lines
2.6 KiB
Python
Executable File
75 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import sys
|
|
import os
|
|
import shutil
|
|
import warnings
|
|
import argparse
|
|
|
|
from django.core.management import execute_from_command_line
|
|
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'wagtail.tests.settings'
|
|
|
|
|
|
def make_parser():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--deprecation', choices=['all', 'pending', 'imminent', 'none'], default='pending')
|
|
parser.add_argument('--postgres', action='store_true')
|
|
parser.add_argument('--elasticsearch', action='store_true')
|
|
parser.add_argument('--elasticsearch2', action='store_true')
|
|
parser.add_argument('rest', nargs='*')
|
|
return parser
|
|
|
|
|
|
def parse_args(args=None):
|
|
return make_parser().parse_args(args)
|
|
|
|
|
|
def runtests():
|
|
args = parse_args()
|
|
|
|
only_wagtail = r'^wagtail(\.|$)'
|
|
if args.deprecation == 'all':
|
|
# Show all deprecation warnings from all packages
|
|
warnings.simplefilter('default', DeprecationWarning)
|
|
warnings.simplefilter('default', PendingDeprecationWarning)
|
|
elif args.deprecation == 'pending':
|
|
# Show all deprecation warnings from wagtail
|
|
warnings.filterwarnings('default', category=DeprecationWarning, module=only_wagtail)
|
|
warnings.filterwarnings('default', category=PendingDeprecationWarning, module=only_wagtail)
|
|
elif args.deprecation == 'imminent':
|
|
# Show only imminent deprecation warnings from wagtail
|
|
warnings.filterwarnings('default', category=DeprecationWarning, module=only_wagtail)
|
|
elif args.deprecation == 'none':
|
|
# Deprecation warnings are ignored by default
|
|
pass
|
|
|
|
if args.postgres:
|
|
os.environ['DATABASE_ENGINE'] = 'django.db.backends.postgresql_psycopg2'
|
|
|
|
if args.elasticsearch:
|
|
os.environ.setdefault('ELASTICSEARCH_URL', 'http://localhost:9200')
|
|
os.environ.setdefault('ELASTICSEARCH_VERSION', '1')
|
|
|
|
if args.elasticsearch2:
|
|
raise RuntimeError("You cannot test both Elasticsearch 1 and 2 together")
|
|
elif args.elasticsearch2:
|
|
os.environ.setdefault('ELASTICSEARCH_URL', 'http://localhost:9200')
|
|
os.environ.setdefault('ELASTICSEARCH_VERSION', '2')
|
|
elif 'ELASTICSEARCH_URL' in os.environ:
|
|
# forcibly delete the ELASTICSEARCH_URL setting to skip those tests
|
|
del os.environ['ELASTICSEARCH_URL']
|
|
|
|
argv = [sys.argv[0], 'test'] + args.rest
|
|
try:
|
|
execute_from_command_line(argv)
|
|
finally:
|
|
from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT
|
|
shutil.rmtree(STATIC_ROOT, ignore_errors=True)
|
|
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
runtests()
|