Added tests for exists, get_source and mget

This commit is contained in:
Clinton Gormley 2013-07-01 16:03:37 +02:00
parent 660ec31ded
commit 00e520bcf4
24 changed files with 1083 additions and 0 deletions

View File

@ -0,0 +1,35 @@
---
"Basic":
- do:
exists:
index: test_1
type: test
id: 1
- is_false: ''
- do:
index:
index: test_1
type: test
id: 1
body: { "foo": "bar" }
- is_true: ''
- do:
exists:
index: test_1
type: test
id: 1
- is_true: ''
- do:
exists:
index: test_1
id: 1
- is_true: ''

View File

@ -0,0 +1,42 @@
---
"Parent":
- skip:
version: "0 - 0.90.2"
reason: "Parent not supported in exists https://github.com/elasticsearch/elasticsearch/issues/3276"
- do:
indices.create:
index: test_1
body:
mappings:
test:
_parent: { type: "foo" }
- do:
cluster.health:
wait_for_status: yellow
- do:
index:
index: test_1
type: test
id: 1
parent: 5
body: { foo: bar }
- do:
exists:
index: test_1
type: test
id: 1
parent: 5
- is_true: ''
- do:
exists:
index: test_1
type: test
id: 1
- is_false: ''

View File

@ -0,0 +1,29 @@
---
"Routing":
- do:
index:
index: test_1
type: test
id: 1
routing: 5
body: { foo: bar }
- do:
cluster.health:
wait_for_status: yellow
- do:
exists:
index: test_1
type: test
id: 1
routing: 5
- is_true: ''
- do:
exists:
index: test_1
type: test
id: 1
- is_false: ''

View File

@ -0,0 +1,57 @@
---
"Parent with routing":
- skip:
version: "0 - 0.90.2"
reason: "Parent not supported in exists https://github.com/elasticsearch/elasticsearch/issues/3276"
- do:
indices.create:
index: test_1
body:
mappings:
test:
_parent: { type: "foo" }
- do:
cluster.health:
wait_for_status: yellow
- do:
index:
index: test_1
type: test
id: 1
parent: 5
routing: 4
body: { foo: bar }
- is_true: ''
- do:
exists:
index: test_1
type: test
id: 1
parent: 5
routing: 4
- is_true: ''
- do:
exists:
index: test_1
type: test
id: 1
parent: 5
- is_false: ''
- do:
exists:
index: test_1
type: test
id: 1
routing: 4
- is_true: ''

View File

@ -0,0 +1,47 @@
---
"Realtime Refresh":
- do:
indices.create:
index: test_1
body:
settings:
index.refresh_interval: -1
- do:
cluster.health:
wait_for_status: yellow
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
exists:
index: test_1
type: test
id: 1
realtime: 1
- is_true: ''
- do:
exists:
index: test_1
type: test
id: 1
realtime: 0
- is_false: ''
- do:
exists:
index: test_1
type: test
id: 1
realtime: 0
refresh: 1
- is_true: ''

View File

@ -0,0 +1,3 @@
Tests missing for:
# preference

View File

@ -0,0 +1,38 @@
---
"Basic":
- do:
catch: missing
get_source:
index: test_1
type: test
id: 1
- do:
get_source:
index: test_1
type: test
id: 1
ignore_missing: 1
- do:
index:
index: test_1
type: test
id: 1
body: { "foo": "bar" }
- do:
get_source:
index: test_1
type: test
id: 1
- match: { '': { foo: bar } }
- do:
get_source:
index: test_1
id: 1
- match: { '': { foo: bar } }

View File

@ -0,0 +1,38 @@
---
"Parent":
- do:
indices.create:
index: test_1
body:
mappings:
test:
_parent: { type: "foo" }
- do:
cluster.health:
wait_for_status: yellow
- do:
index:
index: test_1
type: test
id: 1
parent: 5
body: { foo: bar }
- do:
get_source:
index: test_1
type: test
id: 1
parent: 5
- match: { '': {foo: bar}}
- do:
catch: missing
get_source:
index: test_1
type: test
id: 1

View File

@ -0,0 +1,29 @@
---
"Routing":
- do:
index:
index: test_1
type: test
id: 1
routing: 5
body: { foo: bar }
- do:
cluster.health:
wait_for_status: yellow
- do:
get_source:
index: test_1
type: test
id: 1
routing: 5
- match: { '': {foo: bar}}
- do:
catch: missing
get_source:
index: test_1
type: test
id: 1

View File

@ -0,0 +1,48 @@
---
"Parent with routing":
- do:
indices.create:
index: test_1
body:
mappings:
test:
_parent: { type: "foo" }
- do:
cluster.health:
wait_for_status: yellow
- do:
index:
index: test_1
type: test
id: 1
parent: 5
routing: 4
body: { foo: bar }
- do:
get_source:
index: test_1
type: test
id: 1
parent: 5
routing: 4
- match: { '': {foo: bar}}
- do:
catch: missing
get_source:
index: test_1
type: test
id: 1
parent: 5
- do:
get_source:
index: test_1
type: test
id: 1
routing: 4

View File

@ -0,0 +1,37 @@
---
"Realtime":
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
get_source:
index: test_1
type: test
id: 1
realtime: 1
- match: { '': {foo: bar}}
- do:
catch: missing
get_source:
index: test_1
type: test
id: 1
realtime: 0
- do:
get_source:
index: test_1
type: test
id: 1
realtime: 0
refresh: 1
- match: { '': {foo: bar}}

View File

@ -0,0 +1,3 @@
Tests missing for:
# preference

View File

@ -0,0 +1,46 @@
---
"Basic multi-get":
- do:
indices.create:
index: test_2
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
cluster.health:
wait_for_status: yellow
- do:
mget:
body:
docs:
- { _index: test_2, _type: test, _id: 1}
- { _index: test_1, _type: none, _id: 1}
- { _index: test_1, _type: test, _id: 2}
- { _index: test_1, _type: test, _id: 1}
- is_false: docs.0.exists
- match: { docs.0._index: test_2 }
- match: { docs.0._type: test }
- match: { docs.0._id: 1 }
- is_false: docs.1.exists
- match: { docs.1._index: test_1 }
- match: { docs.1._type: none }
- match: { docs.1._id: 1 }
- is_false: docs.2.exists
- match: { docs.2._index: test_1 }
- match: { docs.2._type: test }
- match: { docs.2._id: 2 }
- is_true: docs.3.exists
- match: { docs.3._index: test_1 }
- match: { docs.3._type: test }
- match: { docs.3._id: 1 }
- match: { docs.3._version: 1 }
- match: { docs.3._source: { foo: bar }}

View File

@ -0,0 +1,48 @@
---
"Default index/type":
- do:
indices.create:
index: test_2
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
cluster.health:
wait_for_status: yellow
- do:
mget:
index: test_1
type: test
body:
docs:
- { _index: test_2, _id: 1}
- { _type: none, _id: 1}
- { _id: 2}
- { _id: 1}
- is_false: docs.0.exists
- match: { docs.0._index: test_2 }
- match: { docs.0._type: test }
- match: { docs.0._id: 1 }
- is_false: docs.1.exists
- match: { docs.1._index: test_1 }
- match: { docs.1._type: none }
- match: { docs.1._id: 1 }
- is_false: docs.2.exists
- match: { docs.2._index: test_1 }
- match: { docs.2._type: test }
- match: { docs.2._id: 2 }
- is_true: docs.3.exists
- match: { docs.3._index: test_1 }
- match: { docs.3._type: test }
- match: { docs.3._id: 1 }
- match: { docs.3._version: 1 }
- match: { docs.3._source: { foo: bar }}

View File

@ -0,0 +1,40 @@
---
"Non-existent index":
- skip:
version: "0 - 0.90.2"
reason: "See https://github.com/elasticsearch/elasticsearch/issues/3267"
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
cluster.health:
wait_for_status: yellow
- do:
mget:
body:
docs:
- { _index: test_2, _type: test, _id: 1}
- is_false: docs.0.exists
- match: { docs.0._index: test_2 }
- match: { docs.0._type: test }
- match: { docs.0._id: 1 }
- do:
mget:
body:
index: test_2
docs:
- { _index: test_1, _type: test, _id: 1}
- is_true: docs.0.exists
- match: { docs.0._index: test_1 }
- match: { docs.0._type: test }
- match: { docs.0._id: 1 }

View File

@ -0,0 +1,52 @@
---
"Missing metadata":
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
cluster.health:
wait_for_status: yellow
- do:
catch: /ActionRequestValidationException.+ id is missing/
mget:
body:
docs:
- { _index: test_1, _type: test}
- do:
catch: /ActionRequestValidationException.+ index is missing/
mget:
body:
docs:
- { _type: test, _id: 1}
- do:
catch: /ActionRequestValidationException.+ no documents to get/
mget:
body:
docs: []
- do:
catch: /ActionRequestValidationException.+ no documents to get/
mget:
body: {}
- do:
mget:
body:
docs:
- { _index: test_1, _id: 1}
- is_true: docs.0.exists
- match: { docs.0._index: test_1 }
- match: { docs.0._type: test }
- match: { docs.0._id: 1 }
- match: { docs.0._version: 1 }
- match: { docs.0._source: { foo: bar }}

View File

@ -0,0 +1,73 @@
---
"IDs":
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
index:
index: test_1
type: test_2
id: 2
body: { foo: baz }
- do:
cluster.health:
wait_for_status: yellow
- do:
mget:
index: test_1
type: test
body:
ids: [1, 2]
- is_true: docs.0.exists
- match: { docs.0._index: test_1 }
- match: { docs.0._type: test }
- match: { docs.0._id: 1 }
- match: { docs.0._version: 1 }
- match: { docs.0._source: { foo: bar }}
- is_false: docs.1.exists
- match: { docs.1._index: test_1 }
- match: { docs.1._type: test }
- match: { docs.1._id: 2 }
- do:
mget:
index: test_1
body:
ids: [1, 2]
- is_true: docs.0.exists
- match: { docs.0._index: test_1 }
- match: { docs.0._type: test }
- match: { docs.0._id: 1 }
- match: { docs.0._version: 1 }
- match: { docs.0._source: { foo: bar }}
- is_true: docs.1.exists
- match: { docs.1._index: test_1 }
- match: { docs.1._type: test_2 }
- match: { docs.1._id: 2 }
- match: { docs.1._version: 1 }
- match: { docs.1._source: { foo: baz }}
- do:
catch: /ActionRequestValidationException.+ no documents to get/
mget:
index: test_1
body:
ids: []
- do:
catch: /ActionRequestValidationException.+ no documents to get/
mget:
index: test_1
body: {}

View File

@ -0,0 +1,111 @@
---
"Fields":
- skip:
version: "0 - 0.90.2"
reason: "Single string fields not supported pre 0.90.3. See https://github.com/elasticsearch/elasticsearch/issues/3270"
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
cluster.health:
wait_for_status: yellow
- do:
mget:
index: test_1
type: test
body:
docs:
- { _id: 1 }
- { _id: 1, fields: foo }
- { _id: 1, fields: [foo] }
- { _id: 1, fields: [foo, _source] }
- is_false: docs.0.fields
- match: { docs.0._source: { foo: bar }}
- match: { docs.1.fields.foo: bar }
- is_false: docs.1._source
- match: { docs.2.fields.foo: bar }
- is_false: docs.2._source
- match: { docs.3.fields.foo: bar }
- match: { docs.3._source: { foo: bar }}
- do:
mget:
index: test_1
type: test
fields: foo
body:
docs:
- { _id: 1 }
- { _id: 1, fields: foo }
- { _id: 1, fields: [foo] }
- { _id: 1, fields: [foo, _source] }
- match: { docs.0.fields.foo: bar }
- is_false: docs.0._source
- match: { docs.1.fields.foo: bar }
- is_false: docs.1._source
- match: { docs.2.fields.foo: bar }
- is_false: docs.2._source
- match: { docs.3.fields.foo: bar }
- match: { docs.3._source: { foo: bar }}
- do:
mget:
index: test_1
type: test
fields: [foo]
body:
docs:
- { _id: 1 }
- { _id: 1, fields: foo }
- { _id: 1, fields: [foo] }
- { _id: 1, fields: [foo, _source] }
- match: { docs.0.fields.foo: bar }
- is_false: docs.0._source
- match: { docs.1.fields.foo: bar }
- is_false: docs.1._source
- match: { docs.2.fields.foo: bar }
- is_false: docs.2._source
- match: { docs.3.fields.foo: bar }
- match: { docs.3._source: { foo: bar }}
- do:
mget:
index: test_1
type: test
fields: [foo, _source]
body:
docs:
- { _id: 1 }
- { _id: 1, fields: foo }
- { _id: 1, fields: [foo] }
- { _id: 1, fields: [foo, _source] }
- match: { docs.0.fields.foo: bar }
- match: { docs.0._source: { foo: bar }}
- match: { docs.1.fields.foo: bar }
- is_false: docs.1._source
- match: { docs.2.fields.foo: bar }
- is_false: docs.2._source
- match: { docs.3.fields.foo: bar }
- match: { docs.3._source: { foo: bar }}

View File

@ -0,0 +1,113 @@
---
"Fields":
- skip:
version: "0.90.3- 999"
reason: "Tests pre 0.90.2 for single string fields"
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
cluster.health:
wait_for_status: yellow
- do:
mget:
index: test_1
type: test
body:
docs:
- { _id: 1 }
- { _id: 1, fields: foo }
- { _id: 1, fields: [foo] }
- { _id: 1, fields: [foo, _source] }
- is_false: docs.0.fields
- match: { docs.0._source: { foo: bar }}
# - match: { docs.1.fields.foo: bar }
# - is_false: docs.1._source
- match: { docs.2.fields.foo: bar }
- is_false: docs.2._source
- match: { docs.3.fields.foo: bar }
- match: { docs.3._source: { foo: bar }}
- do:
mget:
index: test_1
type: test
fields: foo
body:
docs:
- { _id: 1 }
- { _id: 1, fields: foo }
- { _id: 1, fields: [foo] }
- { _id: 1, fields: [foo, _source] }
- match: { docs.0.fields.foo: bar }
- is_false: docs.0._source
- match: { docs.1.fields.foo: bar }
- is_false: docs.1._source
- match: { docs.2.fields.foo: bar }
- is_false: docs.2._source
- match: { docs.3.fields.foo: bar }
- match: { docs.3._source: { foo: bar }}
- do:
mget:
index: test_1
type: test
fields: [foo]
body:
docs:
- { _id: 1 }
- { _id: 1, fields: foo }
- { _id: 1, fields: [foo] }
- { _id: 1, fields: [foo, _source] }
- match: { docs.0.fields.foo: bar }
- is_false: docs.0._source
- match: { docs.1.fields.foo: bar }
- is_false: docs.1._source
- match: { docs.2.fields.foo: bar }
- is_false: docs.2._source
- match: { docs.3.fields.foo: bar }
- match: { docs.3._source: { foo: bar }}
- do:
mget:
index: test_1
type: test
fields: [foo, _source]
body:
docs:
- { _id: 1 }
- { _id: 1, fields: foo }
- { _id: 1, fields: [foo] }
- { _id: 1, fields: [foo, _source] }
- match: { docs.0.fields.foo: bar }
- match: { docs.0._source: { foo: bar }}
# - match: { docs.1.fields.foo: bar }
# - is_false: docs.1._source
- match: { docs.2.fields.foo: bar }
- is_false: docs.2._source
- match: { docs.3.fields.foo: bar }
- match: { docs.3._source: { foo: bar }}

View File

@ -0,0 +1,62 @@
---
"Parent":
- skip:
version: "0 - 0.90.2"
reason: Parent not supported in mget. https://github.com/elasticsearch/elasticsearch/issues/3274
- do:
indices.create:
index: test_1
body:
mappings:
test:
_parent: { type: "foo" }
- do:
cluster.health:
wait_for_status: yellow
- do:
index:
index: test_1
type: test
id: 1
parent: 4
body: { foo: bar }
- do:
index:
index: test_1
type: test
id: 2
parent: 5
body: { foo: bar }
- do:
mget:
index: test_1
type: test
body:
docs:
- { _id: 1 }
- { _id: 1, parent: 5 }
- { _id: 1, parent: 4 }
- { _id: 2, parent: 5 }
- is_false: docs.0.exists
- is_false: docs.1.exists
- is_true: docs.2.exists
- match: { docs.2._index: test_1 }
- match: { docs.2._type: test }
- match: { docs.2._id: 1 }
- match: { docs.2.fields._parent: 4 }
- match: { docs.2.fields._routing: 4 }
- is_true: docs.3.exists
- match: { docs.3._index: test_1 }
- match: { docs.3._type: test }
- match: { docs.3._id: 2 }
- match: { docs.3.fields._parent: 5 }
- match: { docs.3.fields._routing: 5 }

View File

@ -0,0 +1,32 @@
---
"Routing":
- do:
index:
index: test_1
type: test
id: 1
routing: 5
body: { foo: bar }
- do:
cluster.health:
wait_for_status: yellow
- do:
mget:
index: test_1
type: test
fields: [_routing]
body:
docs:
- { _id: 1 }
- { _id: 1, routing: 4 }
- { _id: 1, routing: 5 }
- is_false: docs.0.exists
- is_false: docs.1.exists
- is_true: docs.2.exists
- match: { docs.2._index: test_1 }
- match: { docs.2._type: test }
- match: { docs.2._id: 1 }
- match: { docs.2.fields._routing: 5 }

View File

@ -0,0 +1,47 @@
---
"Parent":
- skip:
version: "0 - 0.90.2"
reason: Parent not supported in mget. https://github.com/elasticsearch/elasticsearch/issues/3274
- do:
indices.create:
index: test_1
body:
mappings:
test:
_parent: { type: "foo" }
- do:
cluster.health:
wait_for_status: yellow
- do:
index:
index: test_1
type: test
id: 1
parent: 4
routing: 5
body: { foo: bar }
- do:
mget:
index: test_1
type: test
body:
docs:
- { _id: 1 }
- { _id: 1, parent: 4 }
- { _id: 1, parent: 4, routing: 5 }
- is_false: docs.0.exists
- is_false: docs.1.exists
- is_true: docs.2.exists
- match: { docs.2._index: test_1 }
- match: { docs.2._type: test }
- match: { docs.2._id: 1 }
- match: { docs.2.fields._parent: 4 }
- match: { docs.2.fields._routing: 5 }

View File

@ -0,0 +1,50 @@
---
"Realtime Refresh":
- do:
indices.create:
index: test_1
body:
settings:
index.refresh_interval: -1
- do:
cluster.health:
wait_for_status: yellow
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
mget:
index: test_1
type: test
realtime: 0
body:
ids: [1]
- is_false: docs.0.exists
- do:
mget:
index: test_1
type: test
realtime: 1
body:
ids: [1]
- is_true: docs.0.exists
- do:
mget:
index: test_1
type: test
realtime: 0
refresh: 1
body:
ids: [1]
- is_true: docs.0.exists

View File

@ -0,0 +1,3 @@
Tests missing for:
# preference