Skip to content

Commit

Permalink
REST test for typeless APIs. (#33934)
Browse files Browse the repository at this point in the history
This commit duplicates REST tests for the
 - `indices.create`
 - `indices.put_mapping`
 - `indices.get_mapping`
 - `index`
 - `get`
 - `delete`
 - `update`
 - `bulk`
APIs, so that we both test them when used without types (include_type_name=false)
and with types, mostly for mixed-version cluster tests.

Given a suite called `X_test_name.yml`, I first copied it to
`(X+1)_test_name_with_types.yml` and then changed `X_test_name.yml` to set
`include_type_name=false` on every API that supports it.

Relates #15613
  • Loading branch information
jpountz authored and kcm committed Oct 30, 2018
1 parent 48b0614 commit 44617e2
Show file tree
Hide file tree
Showing 97 changed files with 3,200 additions and 771 deletions.
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

0 comments on commit 44617e2

Please sign in to comment.