bug 588131, Sphinx tests run on alternate port
This commit is contained in:
Родитель
abdad564aa
Коммит
91e803e5f6
|
@ -1,4 +1,5 @@
|
|||
from collections import defaultdict
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import socket
|
||||
|
@ -215,7 +216,12 @@ class Client(object):
|
|||
|
||||
def __init__(self):
|
||||
self.sphinx = sphinx.SphinxClient()
|
||||
self.sphinx.SetServer(settings.SPHINX_HOST, settings.SPHINX_PORT)
|
||||
|
||||
if os.environ.get('DJANGO_ENVIRONMENT') == 'test':
|
||||
self.sphinx.SetServer(settings.SPHINX_HOST,
|
||||
settings.TEST_SPHINX_PORT)
|
||||
else:
|
||||
self.sphinx.SetServer(settings.SPHINX_HOST, settings.SPHINX_PORT)
|
||||
|
||||
self.weight_field = ('@weight + IF(addon_status=%d, 3500, 0) + '
|
||||
'IF(locale_ord=%d, 29, 0) + '
|
||||
|
|
|
@ -30,13 +30,13 @@ class SphinxTestCase(amo.test_utils.ExtraSetup,
|
|||
|
||||
os.environ['DJANGO_ENVIRONMENT'] = 'test'
|
||||
|
||||
if os.path.exists(settings.SPHINX_CATALOG_PATH):
|
||||
shutil.rmtree(settings.SPHINX_CATALOG_PATH)
|
||||
if os.path.exists(settings.SPHINX_DATA_PATH):
|
||||
shutil.rmtree(settings.SPHINX_DATA_PATH)
|
||||
if os.path.exists(settings.TEST_SPHINX_CATALOG_PATH):
|
||||
shutil.rmtree(settings.TEST_SPHINX_CATALOG_PATH)
|
||||
if os.path.exists(settings.TEST_SPHINX_LOG_PATH):
|
||||
shutil.rmtree(settings.TEST_SPHINX_LOG_PATH)
|
||||
|
||||
os.makedirs('/tmp/data/sphinx')
|
||||
os.makedirs('/tmp/log/searchd')
|
||||
os.makedirs(settings.TEST_SPHINX_CATALOG_PATH)
|
||||
os.makedirs(settings.TEST_SPHINX_LOG_PATH)
|
||||
reindex()
|
||||
start_sphinx()
|
||||
time.sleep(1)
|
||||
|
|
|
@ -2,10 +2,10 @@ import os
|
|||
import sys
|
||||
|
||||
SETTINGS_DIR = os.path.realpath(
|
||||
os.path.join(os.path.dirname(__file__), os.path.sep.join(('..',)*2)))
|
||||
os.path.join(os.path.dirname(__file__), os.path.sep.join(('..',) * 2)))
|
||||
|
||||
sys.path.append(SETTINGS_DIR)
|
||||
sys.path.append(os.path.join(SETTINGS_DIR,'lib'))
|
||||
sys.path.append(os.path.join(SETTINGS_DIR, 'lib'))
|
||||
|
||||
import settings_local as settings
|
||||
|
||||
|
@ -15,17 +15,19 @@ MYSQL_USER = s['USER']
|
|||
MYSQL_HOST = s.get('HOST', 'localhost')
|
||||
MYSQL_NAME = s['NAME']
|
||||
|
||||
CATALOG_PATH = settings.SPHINX_CATALOG_PATH
|
||||
LOG_PATH = settings.SPHINX_LOG_PATH
|
||||
ETC_PATH = os.path.dirname(settings.SPHINX_CONFIG_PATH)
|
||||
LISTEN_PORT = settings.SPHINX_PORT
|
||||
MYSQL_LISTEN_PORT = settings.SPHINXQL_PORT
|
||||
MYSQL_LISTEN_HOST = 'localhost'
|
||||
|
||||
if MYSQL_HOST.endswith('.sock'):
|
||||
MYSQL_HOST = 'localhost'
|
||||
|
||||
if os.environ.get('DJANGO_ENVIRONMENT') == 'test':
|
||||
MYSQL_NAME = 'test_' + MYSQL_NAME
|
||||
|
||||
|
||||
BASE_PATH = '/tmp'
|
||||
CATALOG_PATH = BASE_PATH + '/data/sphinx'
|
||||
LOG_PATH = BASE_PATH + '/log/searchd'
|
||||
ETC_PATH = BASE_PATH + '/etc'
|
||||
LISTEN_PORT = 3312
|
||||
MYSQL_LISTEN_PORT = 3307
|
||||
MYSQL_LISTEN_HOST = 'localhost'
|
||||
CATALOG_PATH = settings.TEST_SPHINX_CATALOG_PATH
|
||||
LOG_PATH = settings.TEST_SPHINX_LOG_PATH
|
||||
LISTEN_PORT = settings.TEST_SPHINX_PORT
|
||||
MYSQL_LISTEN_PORT = settings.TEST_SPHINXQL_PORT
|
||||
|
|
|
@ -222,7 +222,7 @@ index addons
|
|||
path = %s/addons
|
||||
# morphology = stem_en
|
||||
# symlink sphinx-wordforms.txt to this location:
|
||||
wordforms = %s/sphinx-wordforms.txt
|
||||
wordforms = %s/wordforms.txt
|
||||
|
||||
# Firebug will get indexed as Firebug, Firebu, Fireb, Fire, Fir - equally
|
||||
# We can enable star if necessary.
|
||||
|
@ -278,7 +278,7 @@ index personas
|
|||
source = personas
|
||||
path = %s/personas
|
||||
morphology = stem_en
|
||||
wordforms = %s/sphinx-wordforms.txt
|
||||
wordforms = %s/wordforms.txt
|
||||
%s
|
||||
}
|
||||
""" % (CATALOG_PATH, ETC_PATH, CHARSET_DATA)
|
||||
|
@ -338,7 +338,7 @@ index collections
|
|||
source = collections
|
||||
path = %s/collections
|
||||
morphology = stem_en
|
||||
wordforms = %s/sphinx-wordforms.txt
|
||||
wordforms = %s/wordforms.txt
|
||||
%s
|
||||
}
|
||||
""" % (CATALOG_PATH, ETC_PATH, CHARSET_DATA)
|
||||
|
|
|
@ -41,6 +41,11 @@ DATABASES['default']['TEST_COLLATION'] = 'utf8_general_ci'
|
|||
CACHE_BACKEND = 'caching.backends.locmem://'
|
||||
CELERY_ALWAYS_EAGER = True
|
||||
ADDONS_PATH = '/tmp/warez'
|
||||
|
||||
TEST_SPHINX_CATALOG_PATH = TMP_PATH + '$1/data/sphinx'
|
||||
TEST_SPHINX_LOG_PATH = TMP_PATH + '$1/log/serachd'
|
||||
TEST_SPHINXQL_PORT = 340${EXECUTOR_NUMBER}
|
||||
TEST_SPHINX_PORT = 341${EXECUTOR_NUMBER}
|
||||
SETTINGS
|
||||
|
||||
|
||||
|
|
10
settings.py
10
settings.py
|
@ -408,10 +408,16 @@ CACHE_COUNT_TIMEOUT = 60
|
|||
SPHINX_INDEXER = 'indexer'
|
||||
SPHINX_SEARCHD = 'searchd'
|
||||
SPHINX_CONFIG_PATH = path('configs/sphinx/sphinx.conf')
|
||||
SPHINX_CATALOG_PATH = '/tmp/data/sphinx'
|
||||
SPHINX_DATA_PATH = '/tmp/log/searchd'
|
||||
SPHINX_CATALOG_PATH = TMP_PATH + '/data/sphinx'
|
||||
SPHINX_LOG_PATH = TMP_PATH + '/log/searchd'
|
||||
SPHINX_HOST = '127.0.0.1'
|
||||
SPHINX_PORT = 3312
|
||||
SPHINXQL_PORT = 3307
|
||||
|
||||
TEST_SPHINX_PORT = 3412
|
||||
TEST_SPHINXQL_PORT = 3407
|
||||
TEST_SPHINX_CATALOG_PATH = TMP_PATH + '/test/data/sphinx'
|
||||
TEST_SPHINX_LOG_PATH = TMP_PATH + '/test/log/searchd'
|
||||
|
||||
JAVA_BIN = '/usr/bin/java'
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче