Skip to content

Commit 145f035

Browse files
authored
[Backport 7.x] Implement wipe cluster settings for YAML tests (#5531)
* Implement wipe cluster settings for YAML tests (#5527) * Implement wipe cluster settings * Unskip cluster settings tests * Remove redundant skip * Update skip comment * Reuse settings for return * Unskip cluster voting config * Update skip comment * Cleanup file * Unskip a test and add extra comments * Remove ML skip * Remove skip which now passes * Remove skip where file does not exist * Cleanup (cherry picked from commit ddc2801) * Fix namespace
1 parent 7bf5646 commit 145f035

File tree

2 files changed

+32
-45
lines changed

2 files changed

+32
-45
lines changed

tests/Tests.YamlRunner/SkipList.fs

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,24 @@ type SkipFile = SkipFile of string
1010

1111
let SkipList = dict<SkipFile,SkipSection> [
1212

13-
// Need to implement cluster settings cleanup
14-
SkipFile "cluster.put_settings/10_basic.yml", All
15-
13+
// TODO: Needs investigation. "Setting upgrade mode to disabled from enabled" runs in isolation but not with the entire test file
1614
SkipFile "ml/set_upgrade_mode.yml", All
1715
SkipFile "ml/inference_crud.yml", Section "Test update model alias with model id referring to missing model"
16+
17+
// Possible bad test setup, Cannot open job [start-stop-datafeed-job] because it has already been opened
18+
// resource_already_exists_exception, task with id {job-start-stop-datafeed-job-foo-2} already exist
1819
SkipFile "ml/start_stop_datafeed.yml", All
20+
1921
SkipFile "ml/post_data.yml", All
20-
21-
// These send empty strings for required parameters
22-
// TODO i THINK this is now supported
23-
SkipFile "ml/explain_data_frame_analytics.yml", Section "Test neither job id nor body"
24-
22+
2523
// funny looking dispatch /_security/privilege/app?name
2624
SkipFile "privileges/10_basic.yml", All
27-
28-
// 7.x only
29-
// We skip the generation of this API till one of the later minors
30-
SkipFile "indices.upgrade/10_basic.yml", All
25+
3126
// Sets a dictionary to null, we need to see if we can backport this from master
3227
SkipFile "search.aggregation/240_max_buckets.yml", All
3328
SkipFile "search.aggregation/180_percentiles_tdigest_metric.yml", Section "Invalid params test"
3429
SkipFile "search.aggregation/190_percentiles_hdr_metric.yml", Section "Invalid params test"
3530

36-
// - Failed: Assert operation NumericAssert Length invalidated_api_keys "Long" Reason: Expected 2.000000 = 3.000000
37-
SkipFile "api_key/11_invalidation.yml", Section "Test invalidate api key by realm name"
38-
3931
// Test looks for "testnode.crt", but "ca.crt" is returned first
4032
SkipFile "ssl/10_basic.yml", Section "Test get SSL certificates"
4133

@@ -58,7 +50,6 @@ let SkipList = dict<SkipFile,SkipSection> [
5850

5951
// Missing refreshes in the test
6052
SkipFile "data_frame/transforms_start_stop.yml", All
61-
SkipFile "ml/index_layout.yml", All
6253

6354
// Todo investigate
6455
SkipFile "transform/transforms_start_stop.yml", Sections [
@@ -70,12 +61,14 @@ let SkipList = dict<SkipFile,SkipSection> [
7061
"Test get multiple transform stats"
7162
"Test get multiple transform stats where one does not have a task"
7263
]
64+
7365
// More QA tests than API tests
7466
SkipFile "data_frame/transforms_stats.yml", Sections [
7567
"Test get multiple transform stats"
7668
"Test get transform stats on missing transform"
7769
"Test get multiple transform stats where one does not have a task"
7870
]
71+
7972
// Invalid license makes subsequent tests fail
8073
SkipFile "license/20_put_license.yml", All
8174

@@ -103,18 +96,15 @@ let SkipList = dict<SkipFile,SkipSection> [
10396
"Test open and close with non-existent job id"
10497
]
10598
// Failed: Actions custom Setup actions Reason: Setup
106-
SkipFile "ml/stop_data_frame_analytics.yml", Section "Test stop given missing config and allow_no_match is true"
107-
SkipFile "ml/start_stop_datafeed.yml", Section "Test stop given expression"
99+
SkipFile "ml/stop_data_frame_analytics.yml", Sections [
100+
"Test stop given missing config and allow_no_match is true"
101+
"Test stop given missing config and allow_no_match is false"
102+
]
103+
108104
SkipFile "transform/transforms_start_stop.yml", Sections [
109105
"Test start transform"
110106
"Verify start transform reuses destination index"
111107
]
112-
// Possible bad test setup, Cannot open job [start-stop-datafeed-job] because it has already been opened
113-
// resource_already_exists_exception, task with id {job-start-stop-datafeed-job-foo-2} already exist
114-
SkipFile "ml/start_stop_datafeed.yml", Sections [
115-
"Test start datafeed when persistent task allocation disabled"
116-
"Test start given field without mappings"
117-
]
118108
// Indexing step doesn't appear to work (getting total.hits=0)
119109
SkipFile "monitoring/bulk/10_basic.yml",
120110
Section "Bulk indexing of monitoring data on closed indices should throw an export exception"
@@ -130,8 +120,7 @@ let SkipList = dict<SkipFile,SkipSection> [
130120
]
131121
// TEMPORARY: Missing 'body: { indices: "test_index" }' payload, TODO: PR
132122
SkipFile "snapshot/10_basic.yml", Section "Create a source only snapshot and then restore it"
133-
// illegal_argument_exception: Provided password hash uses [NOOP] but the configured hashing algorithm is [BCRYPT]
134-
SkipFile "users/10_basic.yml", Section "Test put user with password hash"
123+
135124
// Slash in index name is not escaped (BUG)
136125
SkipFile "security/authz/13_index_datemath.yml", Section "Test indexing documents with datemath, when permitted"
137126
// Possibly a cluster health color mismatch...
@@ -149,9 +138,6 @@ let SkipList = dict<SkipFile,SkipSection> [
149138
]
150139
// Cannot connect to Docker IP
151140
SkipFile "watcher/execute_watch/60_http_input.yml", All
152-
// Test tries to match on "tagline", which requires "human=false", which doesn't work in the Go API.
153-
// Also test does too much within a single test, so has to be disabled as whole, unfortunately.
154-
SkipFile "xpack/15_basic.yml", All
155141

156142
// Snapshot testing requires local filesystem access
157143
SkipFile "snapshot.create/10_basic.yml", All
@@ -161,24 +147,16 @@ let SkipList = dict<SkipFile,SkipSection> [
161147
SkipFile "snapshot.status/10_basic.yml", All
162148

163149
// Datastreams are currently experimental
164-
SkipFile "indices.data_stream/10_basic.yml", All
150+
//SkipFile "indices.data_stream/10_basic.yml", All
165151

166152
// uses $stashed id in match with object
167153
SkipFile "cluster.reroute/11_explain.yml", Sections [
168154
"Explain API for non-existent node & shard"
169155
]
170-
171-
//These are ignored because they were flagged on a big PR.
172-
173-
//additional enters in regex
174-
SkipFile "cat.templates/10_basic.yml", Sections [ "Multiple template"; "Sort templates"; "No templates" ]
175-
176-
//Replace stashed value in body that is passed as string json
177-
SkipFile "api_key/10_basic.yml", Section "Test get api key"
178156

179-
//new API TODO remove when we regenerate
180-
SkipFile "cluster.voting_config_exclusions/10_basic.yml", All
181-
157+
// Additional entries in regex: Failed cat.templates 10_basic.yml: Assert operation Match $body RegexAssertion
158+
SkipFile "cat.templates/10_basic.yml", Sections [ "Multiple template"; "Sort templates"; "No templates" ]
159+
182160
//TODO has dates without strings which trips up our yaml parser
183161
SkipFile "runtime_fields/40_date.yml", All
184162
// double / int in object comparison
@@ -194,7 +172,7 @@ let SkipList = dict<SkipFile,SkipSection> [
194172

195173
SkipFile "ml/inference_processor.yml", Section "Test simulate"
196174

197-
// TODO investigate post 7.11.0
175+
// TODO: Review again soon once zip includes updated test file from https://github.com/elastic/elasticsearch/pull/71084
198176
SkipFile "nodes.info/10_basic.yml", Section "node_info role test"
199177

200178
// TODO investigate

tests/Tests.YamlRunner/TestSuiteBootstrap.fs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ open Elasticsearch.Net.Specification.CatApi
1111
open Elasticsearch.Net.Specification.IndicesApi
1212
open Tests.YamlRunner.Models
1313
open System.Collections.Generic
14+
open Elasticsearch.Net.Specification.ClusterApi
1415

1516
let DefaultSetup : Operation list = [Actions("Setup", fun (client, suite) ->
1617
let firstFailure (responses:DynamicResponse seq) =
@@ -135,8 +136,17 @@ let DefaultSetup : Operation list = [Actions("Setup", fun (client, suite) ->
135136
let wipeTemplateForXPack () = deleteTemplates() @ deleteComponentTemplates()
136137

137138
let wipeClusterSettings () =
138-
let settings = client.Cluster.GetSettings<DynamicResponse>()
139-
settings
139+
let settings = client.Cluster.GetSettings<DynamicResponse>(ClusterGetSettingsRequestParameters(FlatSettings=true))
140+
let payload =
141+
[
142+
"transient", dict [ for v in settings.Get<DynamicDictionary>("transient").Keys -> v, null ];
143+
"persistent", dict [ for v in settings.Get<DynamicDictionary>("persistent").Keys -> v, null ];
144+
]
145+
|> dict
146+
if payload.["transient"].Values.Count > 0 || payload.["transient"].Values.Count > 0 then
147+
client.Cluster.PutSettings<DynamicResponse>(PostData.Serializable(payload))
148+
else
149+
settings
140150

141151
let deleteAllILMPolicies () =
142152
let preserved = [
@@ -248,7 +258,6 @@ let DefaultSetup : Operation list = [Actions("Setup", fun (client, suite) ->
248258

249259
yield! stopTransforms()
250260

251-
252261
if suite = Platinum then
253262
let data = PostData.String @"{""password"":""x-pack-test-password"", ""roles"":[""superuser""]}"
254263
yield client.Security.PutUser<DynamicResponse>("x_pack_rest_user", data)

0 commit comments

Comments
 (0)