Skip to content

Commit 960097e

Browse files
committed
Additional tests and fixes for those tests
1 parent e4fbe38 commit 960097e

File tree

2 files changed

+135
-3
lines changed

2 files changed

+135
-3
lines changed

modules/streams/src/yamlRestTest/resources/rest-api-spec/test/streams/logs/30_param_restrictions.yml

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ teardown:
2424
- match: { errors: true }
2525
- match: { items.0.index.status: 400 }
2626
- match: { items.0.index.error.type: "illegal_argument_exception" }
27-
- match: { items.0.index.error.reason: "When writing to a stream, only the following parameters are allowed: [error_trace,timeout]" }
27+
- match: { items.0.index.error.reason: "When writing to a stream, only the following parameters are allowed: [index,op_type,error_trace,timeout]" }
2828
- match: { items.1.index.status: 201 }
2929

3030
---
@@ -42,4 +42,134 @@ teardown:
4242
refresh: true
4343
index: logs
4444
body: { "foo": "bar" }
45-
catch: '/When writing to a stream, only the following parameters are allowed: \[error_trace,timeout\]/'
45+
catch: '/When writing to a stream, only the following parameters are allowed: \[index,op_type,error_trace,timeout\]/'
46+
47+
---
48+
"Allowed Params Only - Bulk Should Succeed":
49+
- do:
50+
streams.logs_enable: { }
51+
- is_true: acknowledged
52+
53+
- do:
54+
bulk:
55+
error_trace: true
56+
timeout: "1m"
57+
body: |
58+
{ "index": { "_index": "logs"} }
59+
{ "foo": "bar" }
60+
- match: { errors: false }
61+
- match: { items.0.index.status: 201 }
62+
63+
---
64+
"Allowed Params Only - Single Doc Should Succeed":
65+
- do:
66+
streams.logs_enable: { }
67+
- is_true: acknowledged
68+
69+
- do:
70+
index:
71+
index: logs
72+
error_trace: true
73+
timeout: "1m"
74+
body: |
75+
{ "foo": "bar" }
76+
- match: { _index: "logs" }
77+
- match: { result: "created" }
78+
79+
---
80+
"No Params - Bulk Should Succeed":
81+
- do:
82+
streams.logs_enable: { }
83+
- is_true: acknowledged
84+
85+
- do:
86+
bulk:
87+
body: |
88+
{ "index": { "_index": "logs"} }
89+
{ "foo": "bar" }
90+
- match: { errors: false }
91+
- match: { items.0.index.status: 201 }
92+
93+
---
94+
"No Params - Single Doc Should Succeed":
95+
- do:
96+
streams.logs_enable: { }
97+
- is_true: acknowledged
98+
-
99+
do:
100+
index:
101+
index: logs
102+
body: { "foo": "bar" }
103+
- match: { _index: "logs" }
104+
- match: { result: "created" }
105+
106+
---
107+
"Mixed Allowed and Disallowed Params - Bulk Should Fail":
108+
- do:
109+
streams.logs_enable: { }
110+
- is_true: acknowledged
111+
112+
- do:
113+
bulk:
114+
error_trace: true
115+
timeout: "1m"
116+
routing: "custom-routing"
117+
refresh: true
118+
body: |
119+
{ "index": { "_index": "logs"} }
120+
{ "foo": "bar" }
121+
- match: { errors: true }
122+
- match: { items.0.index.status: 400 }
123+
- match: { items.0.index.error.type: "illegal_argument_exception" }
124+
- match: { items.0.index.error.reason: "When writing to a stream, only the following parameters are allowed: [index,op_type,error_trace,timeout]" }
125+
126+
---
127+
"Mixed Allowed and Disallowed Params - Single Doc Should Fail":
128+
- do:
129+
streams.logs_enable: { }
130+
- is_true: acknowledged
131+
132+
- do:
133+
index:
134+
index: logs
135+
error_trace: true
136+
timeout: "1m"
137+
routing: "custom-routing"
138+
refresh: true
139+
body: { "foo": "bar" }
140+
catch: '/When writing to a stream, only the following parameters are allowed: \[index,op_type,error_trace,timeout\]/'
141+
142+
---
143+
"Multiple Disallowed Params - Bulk Should Fail":
144+
- do:
145+
streams.logs_enable: { }
146+
- is_true: acknowledged
147+
148+
- do:
149+
bulk:
150+
routing: "custom-routing"
151+
wait_for_active_shards: "2"
152+
refresh: true
153+
body: |
154+
{ "index": { "_index": "logs"} }
155+
{ "foo": "bar" }
156+
- match: { errors: true }
157+
- match: { items.0.index.status: 400 }
158+
- match: { items.0.index.error.type: "illegal_argument_exception" }
159+
- match: { items.0.index.error.reason: "When writing to a stream, only the following parameters are allowed: [index,op_type,error_trace,timeout]" }
160+
161+
---
162+
"Multiple Disallowed Params - Single Doc Should Fail":
163+
- do:
164+
streams.logs_enable: { }
165+
- is_true: acknowledged
166+
167+
- do:
168+
index:
169+
index: logs
170+
routing: "custom-routing"
171+
pipeline: "my-pipeline"
172+
wait_for_active_shards: "2"
173+
refresh: true
174+
body: { "foo": "bar" }
175+
catch: '/When writing to a stream, only the following parameters are allowed: \[index,op_type,error_trace,timeout\]/'

server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ public class RestBulkAction extends BaseRestHandler {
6464

6565
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in bulk requests is deprecated.";
6666
public static final String FAILURE_STORE_STATUS_CAPABILITY = "failure_store_status";
67-
public static final LinkedHashSet<String> STREAMS_ALLOWED_PARAMS = new LinkedHashSet<>(2) {
67+
public static final Set<String> STREAMS_ALLOWED_PARAMS = new LinkedHashSet<>(2) {
6868
{
69+
add("index");
70+
add("op_type");
6971
add("error_trace");
7072
add("timeout");
7173
}

0 commit comments

Comments
 (0)