fixing search install plugin

eric-search-upgrade
Safwan Rahman 2018-06-09 08:54:23 +06:00
parent b8f1a063ce
commit 6c430e5c88
3 changed files with 9 additions and 16 deletions

View File

@ -3,6 +3,7 @@ import string
from random import shuffle
import pytest
from django.core.management import call_command
from django_dynamic_fixture import G
from readthedocs.projects.models import Project
@ -17,26 +18,15 @@ def mock_elastic_index(mocker):
@pytest.fixture()
def es_index(mock_elastic_index):
# Create the index.
index = Index()
index_name = index.timestamped_index()
index.create_index(index_name)
index.update_aliases(index_name)
# Update mapping
proj = ProjectIndex()
proj.put_mapping()
page = PageIndex()
page.put_mapping()
sec = SectionIndex()
sec.put_mapping()
def es_index():
call_command('search_index', '--create')
yield index
index.delete_index(index_name=index_name)
yield
call_command('search_index', '--delete')
@pytest.fixture
def all_projects():
def all_projects(es_index):
projects = [G(Project, slug=project_slug, name=project_slug) for project_slug in ALL_PROJECTS]
shuffle(projects)
return projects

View File

@ -28,6 +28,8 @@ class TestProjectSearch(object):
result = page.find('.module-list-wrapper .module-item-title')
return result, page
# TODO: Implement a way to generate unique index name in test
# @pytest.fixture(autouse=True)
# def mock_project_index(self, mocker):

View File

@ -2,5 +2,6 @@ if [ $ES_DOWNLOAD_URL ]
then
wget ${ES_DOWNLOAD_URL}
tar -xzf elasticsearch-${ES_VERSION}.tar.gz
./elasticsearch-${ES_VERSION}/bin/elasticsearch-plugin install analysis-icu
./elasticsearch-${ES_VERSION}/bin/elasticsearch &
fi