2.0 compatibility
This commit is contained in:
@@ -26,7 +26,7 @@ def fetch_es_repo():
|
||||
return
|
||||
|
||||
# set YAML test dir
|
||||
environ['TEST_ES_YAML_DIR'] = join(repo_path, 'rest-api-spec', 'test')
|
||||
environ['TEST_ES_YAML_DIR'] = join(repo_path, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'test')
|
||||
|
||||
# fetching of yaml tests disabled, we'll run with what's there
|
||||
if environ.get('TEST_ES_NOFETCH', False):
|
||||
|
||||
@@ -259,15 +259,16 @@ YAML_DIR = environ.get(
|
||||
'TEST_ES_YAML_DIR',
|
||||
join(
|
||||
dirname(__file__), pardir, pardir, pardir,
|
||||
'elasticsearch', 'rest-api-spec', 'test'
|
||||
'elasticsearch', 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'test'
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if exists(YAML_DIR):
|
||||
# find all the test definitions in yaml files ...
|
||||
for (path, dirs, files) in walk(YAML_DIR):
|
||||
for filename in files:
|
||||
if not filename.endswith('.yaml'):
|
||||
if not filename.endswith(('.yaml', '.yml')):
|
||||
continue
|
||||
# ... parse them
|
||||
name = ('Test' + ''.join(s.title() for s in path[len(YAML_DIR) + 1:].split('/')) + filename.rsplit('.', 1)[0].title()).replace('_', '').replace('.', '')
|
||||
|
||||
@@ -62,7 +62,7 @@ class TestStreamingBulk(ElasticsearchTestCase):
|
||||
for ok, item in helpers.streaming_bulk(self.client, docs):
|
||||
self.assertTrue(ok)
|
||||
|
||||
self.assertFalse(self.client.exists(index='i', id=45))
|
||||
self.assertFalse(self.client.exists(index='i', doc_type='t', id=45))
|
||||
self.assertEquals({'answer': 42}, self.client.get(index='i', id=42)['_source'])
|
||||
self.assertEquals({'f': 'v'}, self.client.get(index='i', id=47)['_source'])
|
||||
|
||||
@@ -254,7 +254,7 @@ class TestParentChildReindex(ElasticsearchTestCase):
|
||||
'settings': {"number_of_shards": 1, "number_of_replicas": 0},
|
||||
'mappings': {
|
||||
'question': {
|
||||
'_timestamp': {'enabled': True, 'store': True},
|
||||
'_timestamp': {'enabled': True},
|
||||
},
|
||||
'answer': {
|
||||
'_parent': {'type': 'question'},
|
||||
@@ -283,6 +283,14 @@ class TestParentChildReindex(ElasticsearchTestCase):
|
||||
def test_children_are_reindexed_correctly(self):
|
||||
helpers.reindex(self.client, 'test-index', 'real-index')
|
||||
|
||||
q = self.client.get(
|
||||
index='real-index',
|
||||
doc_type='question',
|
||||
id=42,
|
||||
fields=['_source', '_timestamp']
|
||||
)
|
||||
if 'fields' in q:
|
||||
q.update(q.pop('fields'))
|
||||
self.assertEquals(
|
||||
{
|
||||
'_id': '42',
|
||||
@@ -290,16 +298,21 @@ class TestParentChildReindex(ElasticsearchTestCase):
|
||||
'_source': {},
|
||||
'_type': 'question',
|
||||
'_version': 1,
|
||||
'fields': {'_timestamp': 1420070400000},
|
||||
'_timestamp': 1420070400000,
|
||||
'found': True
|
||||
},
|
||||
self.client.get(
|
||||
index='real-index',
|
||||
doc_type='question',
|
||||
id=42,
|
||||
fields=['_source', '_timestamp']
|
||||
)
|
||||
}, q
|
||||
)
|
||||
q = self.client.get(
|
||||
index='test-index',
|
||||
doc_type='answer',
|
||||
id=47,
|
||||
parent=42,
|
||||
fields=['_source', '_parent']
|
||||
)
|
||||
if 'fields' in q:
|
||||
q.update(q.pop('fields'))
|
||||
if '_routing' in q:
|
||||
self.assertEquals(q.pop('_routing'), '42')
|
||||
self.assertEquals(
|
||||
{
|
||||
'_id': '47',
|
||||
@@ -307,14 +320,7 @@ class TestParentChildReindex(ElasticsearchTestCase):
|
||||
'_source': {'some': 'data'},
|
||||
'_type': 'answer',
|
||||
'_version': 1,
|
||||
'fields': {'_parent': '42'},
|
||||
'_parent': '42',
|
||||
'found': True
|
||||
},
|
||||
self.client.get(
|
||||
index='test-index',
|
||||
doc_type='answer',
|
||||
id=47,
|
||||
parent=42,
|
||||
fields=['_source', '_parent']
|
||||
)
|
||||
}, q
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user