Skip to content

Commit 87afb95

Browse files
committed
merging main
2 parents 5561ac9 + 30e36ff commit 87afb95

File tree

17 files changed

+1748
-2
lines changed

17 files changed

+1748
-2
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"indices.put_sample_configuration": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-sample-configuration",
5+
"description": "Configure sampling for an index or data stream"
6+
},
7+
"stability": "experimental",
8+
"visibility": "public",
9+
"headers": {
10+
"accept": [
11+
"application/json"
12+
],
13+
"content_type": [
14+
"application/json"
15+
]
16+
},
17+
"url": {
18+
"paths": [
19+
{
20+
"path": "/{index}/_sample/config",
21+
"methods": [
22+
"PUT"
23+
],
24+
"parts": {
25+
"index": {
26+
"type": "string",
27+
"description": "The name of a data stream or index"
28+
}
29+
}
30+
}
31+
]
32+
},
33+
"params": {
34+
"master_timeout": {
35+
"type": "time",
36+
"description": "Timeout for connection to master node"
37+
},
38+
"timeout": {
39+
"type": "time",
40+
"description": "Timeout for the request"
41+
}
42+
},
43+
"body": {
44+
"description": "The sampling configuration",
45+
"required": true
46+
}
47+
}
48+
}
49+
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
---
2+
setup:
3+
- requires:
4+
cluster_features: [ "random_sampling" ]
5+
reason: requires feature 'random_sampling' to get random samples
6+
7+
---
8+
teardown:
9+
- do:
10+
indices.delete:
11+
index: "*test*"
12+
ignore_unavailable: true
13+
allow_no_indices: true
14+
15+
---
16+
"Test Put sampling configuration with JSON body":
17+
- do:
18+
indices.create:
19+
index: test-index
20+
body:
21+
settings:
22+
number_of_shards: 1
23+
24+
- do:
25+
indices.put_sample_configuration:
26+
index: test-index
27+
body:
28+
rate: 0.5
29+
max_samples: 100
30+
max_size: "10mb"
31+
time_to_live: "1h"
32+
33+
- match: { acknowledged: true }
34+
35+
---
36+
"Put sampling configuration with condition":
37+
- do:
38+
indices.create:
39+
index: test-condition-index
40+
41+
- do:
42+
indices.put_sample_configuration:
43+
index: test-condition-index
44+
body:
45+
rate: 1.0
46+
max_samples: 50
47+
if: "ctx?.field == 'sample_me'"
48+
49+
- match: { acknowledged: true }
50+
51+
---
52+
"Put sampling configuration with minimal parameters":
53+
- do:
54+
indices.create:
55+
index: test-minimal-index
56+
57+
- do:
58+
indices.put_sample_configuration:
59+
index: test-minimal-index
60+
body:
61+
rate: 0.1
62+
63+
- match: { acknowledged: true }
64+
65+
---
66+
"Put sampling configuration overwrites existing":
67+
- do:
68+
indices.create:
69+
index: test-overwrite-index
70+
71+
# First configuration
72+
- do:
73+
indices.put_sample_configuration:
74+
index: test-overwrite-index
75+
body:
76+
rate: 0.3
77+
max_samples: 25
78+
79+
- match: { acknowledged: true }
80+
81+
# Overwrite with new configuration
82+
- do:
83+
indices.put_sample_configuration:
84+
index: test-overwrite-index
85+
body:
86+
rate: 0.8
87+
max_samples: 75
88+
max_size: "5mb"
89+
90+
- match: { acknowledged: true }
91+
92+
---
93+
"Put sampling configuration for non-existent index":
94+
- do:
95+
catch: missing
96+
indices.put_sample_configuration:
97+
index: non-existent-index
98+
body:
99+
rate: 0.6
100+
max_samples: 150
101+
102+
---
103+
"Put sampling configuration with timeout parameters":
104+
- do:
105+
indices.create:
106+
index: test-timeout-index
107+
108+
- do:
109+
indices.put_sample_configuration:
110+
index: test-timeout-index
111+
master_timeout: "30s"
112+
timeout: "10s"
113+
body:
114+
rate: 0.4
115+
max_samples: 80
116+
117+
- match: { acknowledged: true }
118+
119+
---
120+
"Put sampling configuration with invalid rate fails":
121+
- do:
122+
indices.create:
123+
index: test-invalid-rate-index
124+
125+
- do:
126+
catch: bad_request
127+
indices.put_sample_configuration:
128+
index: test-invalid-rate-index
129+
body:
130+
rate: 1.5 # Invalid rate > 1.0
131+
max_samples: 100
132+
133+
---
134+
"Put sampling configuration with missing rate fails":
135+
- do:
136+
indices.create:
137+
index: test-missing-rate-index
138+
139+
- do:
140+
catch: bad_request
141+
indices.put_sample_configuration:
142+
index: test-missing-rate-index
143+
body:
144+
max_samples: 100 # Missing required rate parameter
145+
146+
---
147+
"Put sampling configuration with human readable values":
148+
- do:
149+
indices.create:
150+
index: test-human-readable-index
151+
152+
- do:
153+
indices.put_sample_configuration:
154+
index: test-human-readable-index
155+
body:
156+
rate: ".05"
157+
max_samples: 1000
158+
max_size: "10mb"
159+
time_to_live: "1d"
160+
161+
- match: { acknowledged: true }
162+
163+
---
164+
"Put sampling configuration rejects multiple indices":
165+
- do:
166+
indices.create:
167+
index: test-multi-index-1
168+
body:
169+
settings:
170+
number_of_shards: 1
171+
172+
- do:
173+
indices.create:
174+
index: test-multi-index-2
175+
body:
176+
settings:
177+
number_of_shards: 1
178+
179+
- do:
180+
catch: bad_request
181+
indices.put_sample_configuration:
182+
index: "test-multi-index-1,test-multi-index-2"
183+
body:
184+
rate: 0.5
185+
max_samples: 100
186+
187+
- match: { error.type: "action_request_validation_exception" }
188+
189+
---
190+
"Put sampling configuration rejects wildcard matching multiple indices":
191+
- do:
192+
indices.create:
193+
index: wildcard-test-1
194+
body:
195+
settings:
196+
number_of_shards: 1
197+
198+
- do:
199+
indices.create:
200+
index: wildcard-test-2
201+
body:
202+
settings:
203+
number_of_shards: 1
204+
205+
- do:
206+
catch: missing
207+
indices.put_sample_configuration:
208+
index: "wildcard-test-*"
209+
body:
210+
rate: 0.3
211+
max_samples: 50

0 commit comments

Comments
 (0)