Skip to content

Commit 6ccbbce

Browse files
seanzatzdevCopilot
andauthored
Add Delete Sample Configuration action (elastic#136570)
* Add Delete Sample Configuration action --------- Co-authored-by: Copilot <[email protected]>
1 parent 0bf803b commit 6ccbbce

File tree

11 files changed

+1585
-2
lines changed

11 files changed

+1585
-2
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"indices.delete_sample_configuration": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-sample-configuration",
5+
"description": "Delete sampling configuration 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+
"DELETE"
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+
}
44+
}
45+
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
---
2+
setup:
3+
- requires:
4+
cluster_features: [ "random_sampling" ]
5+
reason: requires feature 'random_sampling' to delete 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 Delete existing sampling configuration":
17+
- do:
18+
indices.create:
19+
index: test-delete-index
20+
body:
21+
settings:
22+
number_of_shards: 1
23+
24+
# First create a sampling configuration
25+
- do:
26+
indices.put_sample_configuration:
27+
index: test-delete-index
28+
body:
29+
rate: 0.5
30+
max_samples: 100
31+
max_size: "10mb"
32+
time_to_live: "1h"
33+
34+
- match: { acknowledged: true }
35+
36+
# Now delete the sampling configuration
37+
- do:
38+
indices.delete_sample_configuration:
39+
index: test-delete-index
40+
41+
- match: { acknowledged: true }
42+
43+
---
44+
"Delete sampling configuration for non-existent index":
45+
- do:
46+
catch: missing
47+
indices.delete_sample_configuration:
48+
index: non-existent-index
49+
50+
---
51+
"Delete non-existent sampling configuration":
52+
- do:
53+
indices.create:
54+
index: test-no-config-index
55+
56+
# Try to delete configuration that doesn't exist
57+
- do:
58+
catch: missing
59+
indices.delete_sample_configuration:
60+
index: test-no-config-index
61+
62+
---
63+
"Delete sampling configuration with custom timeouts":
64+
- do:
65+
indices.create:
66+
index: test-timeout-index
67+
68+
# Create a sampling configuration
69+
- do:
70+
indices.put_sample_configuration:
71+
index: test-timeout-index
72+
body:
73+
rate: 0.3
74+
max_samples: 50
75+
76+
- match: { acknowledged: true }
77+
78+
# Delete with custom timeouts
79+
- do:
80+
indices.delete_sample_configuration:
81+
index: test-timeout-index
82+
master_timeout: "2m"
83+
timeout: "45s"
84+
85+
- match: { acknowledged: true }
86+
87+
---
88+
"Delete one configuration leaves others intact":
89+
- do:
90+
indices.create:
91+
index: test-multi-index-1
92+
93+
- do:
94+
indices.create:
95+
index: test-multi-index-2
96+
97+
# Create sampling configurations for both indices
98+
- do:
99+
indices.put_sample_configuration:
100+
index: test-multi-index-1
101+
body:
102+
rate: 0.4
103+
max_samples: 40
104+
105+
- match: { acknowledged: true }
106+
107+
- do:
108+
indices.put_sample_configuration:
109+
index: test-multi-index-2
110+
body:
111+
rate: 0.6
112+
max_samples: 60
113+
114+
- match: { acknowledged: true }
115+
116+
# Delete configuration for first index only
117+
- do:
118+
indices.delete_sample_configuration:
119+
index: test-multi-index-1
120+
121+
- match: { acknowledged: true }
122+
123+
# Verify second index configuration still exists by trying to delete it
124+
- do:
125+
indices.delete_sample_configuration:
126+
index: test-multi-index-2
127+
128+
- match: { acknowledged: true }
129+
130+
---
131+
"Delete then attempt to delete again":
132+
- do:
133+
indices.create:
134+
index: test-double-delete-index
135+
136+
# Create configuration
137+
- do:
138+
indices.put_sample_configuration:
139+
index: test-double-delete-index
140+
body:
141+
rate: 0.7
142+
max_samples: 70
143+
144+
- match: { acknowledged: true }
145+
146+
# First delete should succeed
147+
- do:
148+
indices.delete_sample_configuration:
149+
index: test-double-delete-index
150+
151+
- match: { acknowledged: true }
152+
153+
# Second delete should fail
154+
- do:
155+
catch: missing
156+
indices.delete_sample_configuration:
157+
index: test-double-delete-index
158+
159+
---
160+
"Delete and recreate workflow":
161+
- do:
162+
indices.create:
163+
index: test-recreate-index
164+
165+
# Create initial configuration
166+
- do:
167+
indices.put_sample_configuration:
168+
index: test-recreate-index
169+
body:
170+
rate: 0.2
171+
max_samples: 20
172+
173+
- match: { acknowledged: true }
174+
175+
# Delete the configuration
176+
- do:
177+
indices.delete_sample_configuration:
178+
index: test-recreate-index
179+
180+
- match: { acknowledged: true }
181+
182+
# Recreate with different configuration
183+
- do:
184+
indices.put_sample_configuration:
185+
index: test-recreate-index
186+
body:
187+
rate: 0.9
188+
max_samples: 90
189+
max_size: "20mb"
190+
191+
- match: { acknowledged: true }
192+
193+
# Delete the new configuration
194+
- do:
195+
indices.delete_sample_configuration:
196+
index: test-recreate-index
197+
198+
- match: { acknowledged: true }

0 commit comments

Comments
 (0)