Skip to content

Commit 44617e2

Browse files
jpountzkcm
authored andcommitted
REST test for typeless APIs. (#33934)
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
1 parent 48b0614 commit 44617e2

File tree

97 files changed

+3200
-771
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+3200
-771
lines changed

rest-api-spec/src/main/resources/rest-api-spec/test/bulk/10_basic.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
---
22
"Array of objects":
3+
4+
- skip:
5+
version: " - 6.99.99"
6+
reason: include_type_name was introduced in 7.0.0
7+
38
- do:
49
bulk:
10+
include_type_name: false
511
refresh: true
612
body:
713
- index:
814
_index: test_index
9-
_type: test_type
1015
_id: test_id
1116
- f1: v1
1217
f2: 42
1318
- index:
1419
_index: test_index
15-
_type: test_type
1620
_id: test_id2
1721
- f1: v2
1822
f2: 47
@@ -25,23 +29,26 @@
2529

2630
---
2731
"Empty _id":
32+
33+
- skip:
34+
version: " - 6.99.99"
35+
reason: include_type_name was introduced in 7.0.0
36+
2837
- do:
2938
bulk:
39+
include_type_name: false
3040
refresh: true
3141
body:
3242
- index:
3343
_index: test
34-
_type: type
3544
_id: ''
3645
- f: 1
3746
- index:
3847
_index: test
39-
_type: type
4048
_id: id
4149
- f: 2
4250
- index:
4351
_index: test
44-
_type: type
4552
- f: 3
4653
- match: { errors: true }
4754
- match: { items.0.index.status: 400 }
@@ -59,12 +66,17 @@
5966
---
6067
"empty action":
6168

69+
- skip:
70+
version: " - 6.99.99"
71+
reason: include_type_name was introduced in 7.0.0
72+
6273
- do:
6374
catch: /Malformed action\/metadata line \[3\], expected FIELD_NAME but found \[END_OBJECT\]/
6475
headers:
6576
Content-Type: application/json
6677
bulk:
78+
include_type_name: false
6779
body: |
68-
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}
80+
{"index": {"_index": "test_index", "_id": "test_id"}}
6981
{"f1": "v1", "f2": 42}
7082
{}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
"Array of objects":
3+
- do:
4+
bulk:
5+
refresh: true
6+
body:
7+
- index:
8+
_index: test_index
9+
_type: test_type
10+
_id: test_id
11+
- f1: v1
12+
f2: 42
13+
- index:
14+
_index: test_index
15+
_type: test_type
16+
_id: test_id2
17+
- f1: v2
18+
f2: 47
19+
20+
- do:
21+
count:
22+
index: test_index
23+
24+
- match: {count: 2}
25+
26+
---
27+
"Empty _id":
28+
- do:
29+
bulk:
30+
refresh: true
31+
body:
32+
- index:
33+
_index: test
34+
_type: type
35+
_id: ''
36+
- f: 1
37+
- index:
38+
_index: test
39+
_type: type
40+
_id: id
41+
- f: 2
42+
- index:
43+
_index: test
44+
_type: type
45+
- f: 3
46+
- match: { errors: true }
47+
- match: { items.0.index.status: 400 }
48+
- match: { items.0.index.error.type: illegal_argument_exception }
49+
- match: { items.0.index.error.reason: if _id is specified it must not be empty }
50+
- match: { items.1.index.result: created }
51+
- match: { items.2.index.result: created }
52+
53+
- do:
54+
count:
55+
index: test
56+
57+
- match: { count: 2 }
58+
59+
---
60+
"empty action":
61+
62+
- do:
63+
catch: /Malformed action\/metadata line \[3\], expected FIELD_NAME but found \[END_OBJECT\]/
64+
headers:
65+
Content-Type: application/json
66+
bulk:
67+
body: |
68+
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}
69+
{"f1": "v1", "f2": 42}
70+
{}

rest-api-spec/src/main/resources/rest-api-spec/test/bulk/20_list_of_strings.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
---
22
"List of strings":
3+
4+
- skip:
5+
version: " - 6.99.99"
6+
reason: include_type_name was introduced in 7.0.0
7+
38
- do:
49
bulk:
10+
include_type_name: false
511
refresh: true
612
body:
7-
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}'
13+
- '{"index": {"_index": "test_index", "_id": "test_id"}}'
814
- '{"f1": "v1", "f2": 42}'
9-
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}'
15+
- '{"index": {"_index": "test_index", "_id": "test_id2"}}'
1016
- '{"f1": "v2", "f2": 47}'
1117

1218
- do:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"List of strings":
3+
- do:
4+
bulk:
5+
refresh: true
6+
body:
7+
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}'
8+
- '{"f1": "v1", "f2": 42}'
9+
- '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}'
10+
- '{"f1": "v2", "f2": 47}'
11+
12+
- do:
13+
count:
14+
index: test_index
15+
16+
- match: {count: 2}
17+

rest-api-spec/src/main/resources/rest-api-spec/test/bulk/30_big_string.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
---
22
"One big string":
3+
4+
- skip:
5+
version: " - 6.99.99"
6+
reason: include_type_name was introduced in 7.0.0
7+
38
- do:
49
bulk:
10+
include_type_name: false
511
refresh: true
612
body: |
7-
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}
13+
{"index": {"_index": "test_index", "_id": "test_id"}}
814
{"f1": "v1", "f2": 42}
9-
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}
15+
{"index": {"_index": "test_index", "_id": "test_id2"}}
1016
{"f1": "v2", "f2": 47}
1117
1218
- do:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"One big string":
3+
- do:
4+
bulk:
5+
refresh: true
6+
body: |
7+
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}
8+
{"f1": "v1", "f2": 42}
9+
{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}
10+
{"f1": "v2", "f2": 47}
11+
12+
- do:
13+
count:
14+
index: test_index
15+
16+
- match: {count: 2}
17+

rest-api-spec/src/main/resources/rest-api-spec/test/bulk/40_source.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,52 @@
11
---
22
"Source filtering":
3+
4+
- skip:
5+
version: " - 6.99.99"
6+
reason: include_type_name was introduced in 7.0.0
7+
38
- do:
49
index:
10+
include_type_name: false
511
refresh: true
612
index: test_index
7-
type: test_type
813
id: test_id_1
914
body: { "foo": "bar", "bar": "foo" }
1015

1116
- do:
1217
index:
18+
include_type_name: false
1319
refresh: true
1420
index: test_index
15-
type: test_type
1621
id: test_id_2
1722
body: { "foo": "qux", "bar": "pux" }
1823

1924
- do:
2025
index:
26+
include_type_name: false
2127
refresh: true
2228
index: test_index
23-
type: test_type
2429
id: test_id_3
2530
body: { "foo": "corge", "bar": "forge" }
2631

2732

2833
- do:
2934
bulk:
35+
include_type_name: false
3036
refresh: true
3137
body: |
32-
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": true } }
38+
{ "update": { "_index": "test_index", "_id": "test_id_1", "_source": true } }
3339
{ "doc": { "foo": "baz" } }
34-
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } }
40+
{ "update": { "_index": "test_index", "_id": "test_id_2" } }
3541
{ "_source": true, "doc": { "foo": "quux" } }
3642
3743
- match: { items.0.update.get._source.foo: baz }
3844
- match: { items.1.update.get._source.foo: quux }
3945

4046
- do:
4147
bulk:
48+
include_type_name: false
4249
index: test_index
43-
type: test_type
4450
_source: true
4551
body: |
4652
{ "update": { "_id": "test_id_3" } }
@@ -50,11 +56,12 @@
5056

5157
- do:
5258
bulk:
59+
include_type_name: false
5360
refresh: true
5461
body: |
55-
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": {"includes": "bar"} } }
62+
{ "update": { "_index": "test_index", "_id": "test_id_1", "_source": {"includes": "bar"} } }
5663
{ "doc": { "foo": "baz" } }
57-
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } }
64+
{ "update": { "_index": "test_index", "_id": "test_id_2" } }
5865
{ "_source": {"includes": "foo"}, "doc": { "foo": "quux" } }
5966
6067
- match: { items.0.update.get._source.bar: foo }
@@ -64,8 +71,8 @@
6471

6572
- do:
6673
bulk:
74+
include_type_name: false
6775
index: test_index
68-
type: test_type
6976
_source_include: foo
7077
body: |
7178
{ "update": { "_id": "test_id_3" } }
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
"Source filtering":
3+
- do:
4+
index:
5+
refresh: true
6+
index: test_index
7+
type: test_type
8+
id: test_id_1
9+
body: { "foo": "bar", "bar": "foo" }
10+
11+
- do:
12+
index:
13+
refresh: true
14+
index: test_index
15+
type: test_type
16+
id: test_id_2
17+
body: { "foo": "qux", "bar": "pux" }
18+
19+
- do:
20+
index:
21+
refresh: true
22+
index: test_index
23+
type: test_type
24+
id: test_id_3
25+
body: { "foo": "corge", "bar": "forge" }
26+
27+
28+
- do:
29+
bulk:
30+
refresh: true
31+
body: |
32+
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": true } }
33+
{ "doc": { "foo": "baz" } }
34+
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } }
35+
{ "_source": true, "doc": { "foo": "quux" } }
36+
37+
- match: { items.0.update.get._source.foo: baz }
38+
- match: { items.1.update.get._source.foo: quux }
39+
40+
- do:
41+
bulk:
42+
index: test_index
43+
type: test_type
44+
_source: true
45+
body: |
46+
{ "update": { "_id": "test_id_3" } }
47+
{ "doc": { "foo": "garply" } }
48+
49+
- match: { items.0.update.get._source.foo: garply }
50+
51+
- do:
52+
bulk:
53+
refresh: true
54+
body: |
55+
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": {"includes": "bar"} } }
56+
{ "doc": { "foo": "baz" } }
57+
{ "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } }
58+
{ "_source": {"includes": "foo"}, "doc": { "foo": "quux" } }
59+
60+
- match: { items.0.update.get._source.bar: foo }
61+
- is_false: items.0.update.get._source.foo
62+
- match: { items.1.update.get._source.foo: quux }
63+
- is_false: items.1.update.get._source.bar
64+
65+
- do:
66+
bulk:
67+
index: test_index
68+
type: test_type
69+
_source_include: foo
70+
body: |
71+
{ "update": { "_id": "test_id_3" } }
72+
{ "doc": { "foo": "garply" } }
73+
74+
- match: { items.0.update.get._source.foo: garply }
75+
- is_false: items.0.update.get._source.bar
76+

0 commit comments

Comments
 (0)