Commit 20c52ce0 by Oleg Marshev

Remove annotator-store.

parent 10cc35be
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from annotator.annotation import Annotation
class Command(BaseCommand): class Command(BaseCommand):
help = 'Creates the mapping in the index.' help = 'Creates the mapping in the index.'
def handle(self, *args, **options): def handle(self, *args, **options):
Annotation.create_all() #TODO: cretate mapping using elasticutils
pass
...@@ -354,7 +354,7 @@ class AnnotationViewTests(BaseAnnotationViewTests): ...@@ -354,7 +354,7 @@ class AnnotationViewTests(BaseAnnotationViewTests):
@patch('django.conf.settings.DISABLE_TOKEN_CHECK', True) @patch('django.conf.settings.DISABLE_TOKEN_CHECK', True)
class AllowAllAnnotationViewTests(BaseAnnotationViewTests): class AllowAllAnnotationViewTests(BaseAnnotationViewTests):
""" """
Test annotator behavior when authorization is not enforced Test service behavior when authorization is not enforced.
""" """
def test_create_no_payload(self): def test_create_no_payload(self):
......
...@@ -16,9 +16,6 @@ SECRET_KEY = '*^owi*4%!%9=#h@app!l^$jz8(c*q297^)4&4yn^#_m#fq=z#l' ...@@ -16,9 +16,6 @@ SECRET_KEY = '*^owi*4%!%9=#h@app!l^$jz8(c*q297^)4&4yn^#_m#fq=z#l'
CLIENT_ID = 'edx-notes-id' CLIENT_ID = 'edx-notes-id'
CLIENT_SECRET = 'edx-notes-secret' CLIENT_SECRET = 'edx-notes-secret'
ELASTICSEARCH_URL = 'http://127.0.0.1:9200'
ELASTICSEARCH_INDEX = 'edx-notes'
ES_URLS = ['http://localhost:9200'] ES_URLS = ['http://localhost:9200']
ES_INDEXES = {'default': 'notes_index'} ES_INDEXES = {'default': 'notes_index'}
ES_DISABLED = False ES_DISABLED = False
...@@ -92,11 +89,6 @@ LOGGING = { ...@@ -92,11 +89,6 @@ LOGGING = {
'level': 'WARNING', 'level': 'WARNING',
'propagate': True 'propagate': True
}, },
'annotator.elasticsearch': {
'handlers': ['console'],
'level': 'WARNING',
'propagate': True
},
'urllib3': { 'urllib3': {
'handlers': ['console'], 'handlers': ['console'],
'level': 'DEBUG', 'level': 'DEBUG',
......
import annotator
from annotator import es
from .common import * from .common import *
DEBUG = True DEBUG = True
ELASTICSEARCH_INDEX = 'edx-notes-dev' ES_INDEXES = {'default': 'notes_index_dev'}
DATABASES = { DATABASES = {
'default': { 'default': {
...@@ -12,11 +10,3 @@ DATABASES = { ...@@ -12,11 +10,3 @@ DATABASES = {
'NAME': 'default.db', 'NAME': 'default.db',
} }
} }
###############################################################################
# Override default annotator-store elasticsearch settings.
###############################################################################
es.host = ELASTICSEARCH_URL
es.index = ELASTICSEARCH_INDEX
annotator.elasticsearch.RESULTS_MAX_SIZE = RESULTS_MAX_SIZE
###############################################################################
from annotator import es
import annotator
from .common import * from .common import *
DATABASES = { DATABASES = {
...@@ -12,18 +10,8 @@ TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' ...@@ -12,18 +10,8 @@ TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
DISABLE_TOKEN_CHECK = False DISABLE_TOKEN_CHECK = False
INSTALLED_APPS += ('django_nose',) INSTALLED_APPS += ('django_nose',)
###############################################################################
# Override default annotator-store elasticsearch settings.
###############################################################################
es.host = ELASTICSEARCH_URL
es.index = ELASTICSEARCH_INDEX
annotator.elasticsearch.RESULTS_MAX_SIZE = RESULTS_MAX_SIZE
###############################################################################
ES_INDEXES = {'default': 'notes_index_test'} ES_INDEXES = {'default': 'notes_index_test'}
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
'disable_existing_loggers': False, 'disable_existing_loggers': False,
...@@ -52,4 +40,4 @@ LOGGING = { ...@@ -52,4 +40,4 @@ LOGGING = {
'propagate': False, 'propagate': False,
} }
}, },
} }
\ No newline at end of file
import yaml import yaml
import annotator
from annotator import es
from .common import * # pylint: disable=unused-wildcard-import, wildcard-import from .common import * # pylint: disable=unused-wildcard-import, wildcard-import
...@@ -18,11 +16,3 @@ with open(CONFIG_ROOT / "edx-notes-api.yml") as yaml_file: ...@@ -18,11 +16,3 @@ with open(CONFIG_ROOT / "edx-notes-api.yml") as yaml_file:
config_from_yaml = yaml.load(yaml_file) config_from_yaml = yaml.load(yaml_file)
vars().update(config_from_yaml) vars().update(config_from_yaml)
###############################################################################
# Override default annotator-store elasticsearch settings.
###############################################################################
es.host = ELASTICSEARCH_URL
es.index = ELASTICSEARCH_INDEX
annotator.elasticsearch.RESULTS_MAX_SIZE = RESULTS_MAX_SIZE
###############################################################################
...@@ -17,12 +17,12 @@ class OperationalEndpointsTest(APITestCase): ...@@ -17,12 +17,12 @@ class OperationalEndpointsTest(APITestCase):
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
self.assertEquals(response.data, {"OK": True}) self.assertEquals(response.data, {"OK": True})
@patch('annotator.elasticsearch.ElasticSearch.conn') @patch('notesserver.views.get_es')
def test_heartbeat_failure(self, mocked_conn): def test_heartbeat_failure(self, mocked_get_es):
""" """
Elasticsearch is not reachable. Elasticsearch is not reachable.
""" """
mocked_conn.ping.return_value = False mocked_get_es.return_value.ping.return_value = False
response = self.client.get(reverse('heartbeat')) response = self.client.get(reverse('heartbeat'))
self.assertEquals(response.status_code, 500) self.assertEquals(response.status_code, 500)
self.assertEquals(response.data, {"OK": False, "check": "es"}) self.assertEquals(response.data, {"OK": False, "check": "es"})
...@@ -54,13 +54,13 @@ class OperationalAuthEndpointsTest(APITestCase): ...@@ -54,13 +54,13 @@ class OperationalAuthEndpointsTest(APITestCase):
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
@patch('notesserver.views.datetime', datetime=Mock(wraps=datetime.datetime)) @patch('notesserver.views.datetime', datetime=Mock(wraps=datetime.datetime))
@patch('annotator.elasticsearch.ElasticSearch.conn') @patch('notesserver.views.get_es')
def test_selftest_data(self, mocked_conn, mocked_datetime): def test_selftest_data(self, mocked_get_es, mocked_datetime):
""" """
Test returned data on success. Test returned data on success.
""" """
mocked_datetime.datetime.now.return_value = datetime.datetime(2014, 12, 11) mocked_datetime.datetime.now.return_value = datetime.datetime(2014, 12, 11)
mocked_conn.info.return_value = {} mocked_get_es.return_value.info.return_value = {}
response = self.client.get(reverse('selftest')) response = self.client.get(reverse('selftest'))
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
self.assertEquals( self.assertEquals(
...@@ -71,11 +71,11 @@ class OperationalAuthEndpointsTest(APITestCase): ...@@ -71,11 +71,11 @@ class OperationalAuthEndpointsTest(APITestCase):
} }
) )
@patch('annotator.elasticsearch.ElasticSearch.conn') @patch('notesserver.views.get_es')
def test_selftest_failure(self, mocked_conn): def test_selftest_failure(self, mocked_get_es):
""" """
Elasticsearch is not reachable on selftest. Elasticsearch is not reachable on selftest.
""" """
mocked_conn.info.side_effect = TransportError() mocked_get_es.return_value.info.side_effect = TransportError()
response = self.client.get(reverse('selftest')) response = self.client.get(reverse('selftest'))
self.assertEquals(response.status_code, 500) self.assertEquals(response.status_code, 500)
...@@ -7,7 +7,7 @@ from rest_framework.views import APIView ...@@ -7,7 +7,7 @@ from rest_framework.views import APIView
from rest_framework.decorators import api_view, permission_classes, authentication_classes from rest_framework.decorators import api_view, permission_classes, authentication_classes
from elasticsearch.exceptions import TransportError from elasticsearch.exceptions import TransportError
from annotator import es from elasticutils import get_es
@api_view(['GET']) @api_view(['GET'])
...@@ -28,7 +28,7 @@ def heartbeat(request): # pylint: disable=unused-argument ...@@ -28,7 +28,7 @@ def heartbeat(request): # pylint: disable=unused-argument
""" """
ElasticSearch is reachable and ready to handle requests. ElasticSearch is reachable and ready to handle requests.
""" """
if es.conn.ping(): if get_es().ping():
return Response({"OK": True}) return Response({"OK": True})
else: else:
return Response({"OK": False, "check": "es"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response({"OK": False, "check": "es"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
...@@ -42,7 +42,7 @@ def selftest(request): # pylint: disable=unused-argument ...@@ -42,7 +42,7 @@ def selftest(request): # pylint: disable=unused-argument
""" """
start = datetime.datetime.now() start = datetime.datetime.now()
try: try:
es_status = es.conn.info() es_status = get_es().info()
except TransportError: except TransportError:
return Response( return Response(
{"es_error": traceback.format_exc()}, {"es_error": traceback.format_exc()},
......
...@@ -4,8 +4,5 @@ djangorestframework==2.4.4 ...@@ -4,8 +4,5 @@ djangorestframework==2.4.4
django-rest-swagger==0.2.0 django-rest-swagger==0.2.0
elasticutils==0.10 elasticutils==0.10
elasticsearch==1.2.0 elasticsearch==1.2.0
annotator==0.12.0
django-cors-headers==0.13 django-cors-headers==0.13
PyJWT==0.3.0 PyJWT==0.3.0
git+https://github.com/edx/opaque-keys.git@0.1.2#egg=opaque-keys
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment