Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST test for typeless APIs. #33934

Merged
merged 4 commits into from
Sep 26, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
---
"Array of objects":

- skip:
version: " - 6.99.99"
reason: include_type_name was introduced in 7.0.0

- do:
bulk:
include_type_name: false
refresh: true
body:
- index:
_index: test_index
_type: test_type
_id: test_id
- f1: v1
f2: 42
- index:
_index: test_index
_type: test_type
_id: test_id2
- f1: v2
f2: 47
Expand All @@ -25,23 +29,26 @@

---
"Empty _id":

- skip:
version: " - 6.99.99"
reason: include_type_name was introduced in 7.0.0

- do:
bulk:
include_type_name: false
refresh: true
body:
- index:
_index: test
_type: type
_id: ''
- f: 1
- index:
_index: test
_type: type
_id: id
- f: 2
- index:
_index: test
_type: type
- f: 3
- match: { errors: true }
- match: { items.0.index.status: 400 }
Expand All @@ -59,12 +66,17 @@
---
"empty action":

- skip:
version: " - 6.99.99"
reason: include_type_name was introduced in 7.0.0

- do:
catch: /Malformed action\/metadata line \[3\], expected FIELD_NAME but found \[END_OBJECT\]/
headers:
Content-Type: application/json
bulk:
include_type_name: false
body: |
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}
{"index": {"_index": "test_index", "_id": "test_id"}}
{"f1": "v1", "f2": 42}
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
"Array of objects":
- do:
bulk:
refresh: true
body:
- index:
_index: test_index
_type: test_type
_id: test_id
- f1: v1
f2: 42
- index:
_index: test_index
_type: test_type
_id: test_id2
- f1: v2
f2: 47

- do:
count:
index: test_index

- match: {count: 2}

---
"Empty _id":
- do:
bulk:
refresh: true
body:
- index:
_index: test
_type: type
_id: ''
- f: 1
- index:
_index: test
_type: type
_id: id
- f: 2
- index:
_index: test
_type: type
- f: 3
- match: { errors: true }
- match: { items.0.index.status: 400 }
- match: { items.0.index.error.type: illegal_argument_exception }
- match: { items.0.index.error.reason: if _id is specified it must not be empty }
- match: { items.1.index.result: created }
- match: { items.2.index.result: created }

- do:
count:
index: test

- match: { count: 2 }

---
"empty action":

- do:
catch: /Malformed action\/metadata line \[3\], expected FIELD_NAME but found \[END_OBJECT\]/
headers:
Content-Type: application/json
bulk:
body: |
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}
{"f1": "v1", "f2": 42}
{}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
---
"List of strings":

- skip:
version: " - 6.99.99"
reason: include_type_name was introduced in 7.0.0

- do:
bulk:
include_type_name: false
refresh: true
body:
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}'
- '{"index": {"_index": "test_index", "_id": "test_id"}}'
- '{"f1": "v1", "f2": 42}'
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}'
- '{"index": {"_index": "test_index", "_id": "test_id2"}}'
- '{"f1": "v2", "f2": 47}'

- do:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"List of strings":
- do:
bulk:
refresh: true
body:
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}'
- '{"f1": "v1", "f2": 42}'
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}'
- '{"f1": "v2", "f2": 47}'

- do:
count:
index: test_index

- match: {count: 2}

Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
---
"One big string":

- skip:
version: " - 6.99.99"
reason: include_type_name was introduced in 7.0.0

- do:
bulk:
include_type_name: false
refresh: true
body: |
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}
{"index": {"_index": "test_index", "_id": "test_id"}}
{"f1": "v1", "f2": 42}
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}
{"index": {"_index": "test_index", "_id": "test_id2"}}
{"f1": "v2", "f2": 47}

- do:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"One big string":
- do:
bulk:
refresh: true
body: |
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}
{"f1": "v1", "f2": 42}
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}
{"f1": "v2", "f2": 47}

- do:
count:
index: test_index

- match: {count: 2}

Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
---
"Source filtering":

- skip:
version: " - 6.99.99"
reason: include_type_name was introduced in 7.0.0

- do:
index:
include_type_name: false
refresh: true
index: test_index
type: test_type
id: test_id_1
body: { "foo": "bar", "bar": "foo" }

- do:
index:
include_type_name: false
refresh: true
index: test_index
type: test_type
id: test_id_2
body: { "foo": "qux", "bar": "pux" }

- do:
index:
include_type_name: false
refresh: true
index: test_index
type: test_type
id: test_id_3
body: { "foo": "corge", "bar": "forge" }


- do:
bulk:
include_type_name: false
refresh: true
body: |
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": true } }
{ "update": { "_index": "test_index", "_id": "test_id_1", "_source": true } }
{ "doc": { "foo": "baz" } }
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } }
{ "update": { "_index": "test_index", "_id": "test_id_2" } }
{ "_source": true, "doc": { "foo": "quux" } }

- match: { items.0.update.get._source.foo: baz }
- match: { items.1.update.get._source.foo: quux }

- do:
bulk:
include_type_name: false
index: test_index
type: test_type
_source: true
body: |
{ "update": { "_id": "test_id_3" } }
Expand All @@ -50,11 +56,12 @@

- do:
bulk:
include_type_name: false
refresh: true
body: |
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": {"includes": "bar"} } }
{ "update": { "_index": "test_index", "_id": "test_id_1", "_source": {"includes": "bar"} } }
{ "doc": { "foo": "baz" } }
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } }
{ "update": { "_index": "test_index", "_id": "test_id_2" } }
{ "_source": {"includes": "foo"}, "doc": { "foo": "quux" } }

- match: { items.0.update.get._source.bar: foo }
Expand All @@ -64,8 +71,8 @@

- do:
bulk:
include_type_name: false
index: test_index
type: test_type
_source_include: foo
body: |
{ "update": { "_id": "test_id_3" } }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
"Source filtering":
- do:
index:
refresh: true
index: test_index
type: test_type
id: test_id_1
body: { "foo": "bar", "bar": "foo" }

- do:
index:
refresh: true
index: test_index
type: test_type
id: test_id_2
body: { "foo": "qux", "bar": "pux" }

- do:
index:
refresh: true
index: test_index
type: test_type
id: test_id_3
body: { "foo": "corge", "bar": "forge" }


- do:
bulk:
refresh: true
body: |
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": true } }
{ "doc": { "foo": "baz" } }
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } }
{ "_source": true, "doc": { "foo": "quux" } }

- match: { items.0.update.get._source.foo: baz }
- match: { items.1.update.get._source.foo: quux }

- do:
bulk:
index: test_index
type: test_type
_source: true
body: |
{ "update": { "_id": "test_id_3" } }
{ "doc": { "foo": "garply" } }

- match: { items.0.update.get._source.foo: garply }

- do:
bulk:
refresh: true
body: |
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": {"includes": "bar"} } }
{ "doc": { "foo": "baz" } }
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } }
{ "_source": {"includes": "foo"}, "doc": { "foo": "quux" } }

- match: { items.0.update.get._source.bar: foo }
- is_false: items.0.update.get._source.foo
- match: { items.1.update.get._source.foo: quux }
- is_false: items.1.update.get._source.bar

- do:
bulk:
index: test_index
type: test_type
_source_include: foo
body: |
{ "update": { "_id": "test_id_3" } }
{ "doc": { "foo": "garply" } }

- match: { items.0.update.get._source.foo: garply }
- is_false: items.0.update.get._source.bar

Loading