bug 588131, Sphinx tests run on alternate port

This commit is contained in:
Dave Dash 2010-09-21 10:33:07 -07:00
Родитель abdad564aa
Коммит 91e803e5f6
6 изменённых файлов: 42 добавлений и 23 удалений

Просмотреть файл

@ -1,4 +1,5 @@
from collections import defaultdict from collections import defaultdict
import os
import random import random
import re import re
import socket import socket
@ -215,7 +216,12 @@ class Client(object):
def __init__(self): def __init__(self):
self.sphinx = sphinx.SphinxClient() 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) + ' self.weight_field = ('@weight + IF(addon_status=%d, 3500, 0) + '
'IF(locale_ord=%d, 29, 0) + ' 'IF(locale_ord=%d, 29, 0) + '

Просмотреть файл

@ -30,13 +30,13 @@ class SphinxTestCase(amo.test_utils.ExtraSetup,
os.environ['DJANGO_ENVIRONMENT'] = 'test' os.environ['DJANGO_ENVIRONMENT'] = 'test'
if os.path.exists(settings.SPHINX_CATALOG_PATH): if os.path.exists(settings.TEST_SPHINX_CATALOG_PATH):
shutil.rmtree(settings.SPHINX_CATALOG_PATH) shutil.rmtree(settings.TEST_SPHINX_CATALOG_PATH)
if os.path.exists(settings.SPHINX_DATA_PATH): if os.path.exists(settings.TEST_SPHINX_LOG_PATH):
shutil.rmtree(settings.SPHINX_DATA_PATH) shutil.rmtree(settings.TEST_SPHINX_LOG_PATH)
os.makedirs('/tmp/data/sphinx') os.makedirs(settings.TEST_SPHINX_CATALOG_PATH)
os.makedirs('/tmp/log/searchd') os.makedirs(settings.TEST_SPHINX_LOG_PATH)
reindex() reindex()
start_sphinx() start_sphinx()
time.sleep(1) time.sleep(1)

Просмотреть файл

@ -2,10 +2,10 @@ import os
import sys import sys
SETTINGS_DIR = os.path.realpath( 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(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 import settings_local as settings
@ -15,17 +15,19 @@ MYSQL_USER = s['USER']
MYSQL_HOST = s.get('HOST', 'localhost') MYSQL_HOST = s.get('HOST', 'localhost')
MYSQL_NAME = s['NAME'] 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'): if MYSQL_HOST.endswith('.sock'):
MYSQL_HOST = 'localhost' MYSQL_HOST = 'localhost'
if os.environ.get('DJANGO_ENVIRONMENT') == 'test': if os.environ.get('DJANGO_ENVIRONMENT') == 'test':
MYSQL_NAME = 'test_' + MYSQL_NAME MYSQL_NAME = 'test_' + MYSQL_NAME
CATALOG_PATH = settings.TEST_SPHINX_CATALOG_PATH
LOG_PATH = settings.TEST_SPHINX_LOG_PATH
BASE_PATH = '/tmp' LISTEN_PORT = settings.TEST_SPHINX_PORT
CATALOG_PATH = BASE_PATH + '/data/sphinx' MYSQL_LISTEN_PORT = settings.TEST_SPHINXQL_PORT
LOG_PATH = BASE_PATH + '/log/searchd'
ETC_PATH = BASE_PATH + '/etc'
LISTEN_PORT = 3312
MYSQL_LISTEN_PORT = 3307
MYSQL_LISTEN_HOST = 'localhost'

Просмотреть файл

@ -222,7 +222,7 @@ index addons
path = %s/addons path = %s/addons
# morphology = stem_en # morphology = stem_en
# symlink sphinx-wordforms.txt to this location: # 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 # Firebug will get indexed as Firebug, Firebu, Fireb, Fire, Fir - equally
# We can enable star if necessary. # We can enable star if necessary.
@ -278,7 +278,7 @@ index personas
source = personas source = personas
path = %s/personas path = %s/personas
morphology = stem_en morphology = stem_en
wordforms = %s/sphinx-wordforms.txt wordforms = %s/wordforms.txt
%s %s
} }
""" % (CATALOG_PATH, ETC_PATH, CHARSET_DATA) """ % (CATALOG_PATH, ETC_PATH, CHARSET_DATA)
@ -338,7 +338,7 @@ index collections
source = collections source = collections
path = %s/collections path = %s/collections
morphology = stem_en morphology = stem_en
wordforms = %s/sphinx-wordforms.txt wordforms = %s/wordforms.txt
%s %s
} }
""" % (CATALOG_PATH, ETC_PATH, CHARSET_DATA) """ % (CATALOG_PATH, ETC_PATH, CHARSET_DATA)

Просмотреть файл

@ -41,6 +41,11 @@ DATABASES['default']['TEST_COLLATION'] = 'utf8_general_ci'
CACHE_BACKEND = 'caching.backends.locmem://' CACHE_BACKEND = 'caching.backends.locmem://'
CELERY_ALWAYS_EAGER = True CELERY_ALWAYS_EAGER = True
ADDONS_PATH = '/tmp/warez' 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 SETTINGS

Просмотреть файл

@ -408,10 +408,16 @@ CACHE_COUNT_TIMEOUT = 60
SPHINX_INDEXER = 'indexer' SPHINX_INDEXER = 'indexer'
SPHINX_SEARCHD = 'searchd' SPHINX_SEARCHD = 'searchd'
SPHINX_CONFIG_PATH = path('configs/sphinx/sphinx.conf') SPHINX_CONFIG_PATH = path('configs/sphinx/sphinx.conf')
SPHINX_CATALOG_PATH = '/tmp/data/sphinx' SPHINX_CATALOG_PATH = TMP_PATH + '/data/sphinx'
SPHINX_DATA_PATH = '/tmp/log/searchd' SPHINX_LOG_PATH = TMP_PATH + '/log/searchd'
SPHINX_HOST = '127.0.0.1' SPHINX_HOST = '127.0.0.1'
SPHINX_PORT = 3312 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' JAVA_BIN = '/usr/bin/java'