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