-
Notifications
You must be signed in to change notification settings - Fork 24.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[test] Introduce strict deprecation mode for REST tests #34338
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c5a4566
[test] Introduce strict deprecation mode for REST tests
lipsill 8f78d5c
clean up
lipsill f59c576
checkStyle fix
lipsill 3211e2f
Merge remote-tracking branch 'origin/master' into strict_deprecation_…
lipsill fc9106d
addressing reviewers comments
lipsill 38e68cd
Merge remote-tracking branch 'origin/master' into strict_deprecation_…
lipsill d44f88d
activate strict mode for the high-level rest client
lipsill 5cfb38b
correct issue introduced by merge...
lipsill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ | |
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.greaterThan; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.hamcrest.Matchers.startsWith; | ||
|
||
/** | ||
* Tests to run before and after a full cluster restart. This is run twice, | ||
|
@@ -75,7 +76,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { | |
private String index; | ||
|
||
@Before | ||
public void setIndex() { | ||
public void setIndex() throws IOException { | ||
index = getTestName().toLowerCase(Locale.ROOT); | ||
} | ||
|
||
|
@@ -283,7 +284,8 @@ public void testClusterState() throws Exception { | |
if (isRunningAgainstOldCluster()) { | ||
XContentBuilder mappingsAndSettings = jsonBuilder(); | ||
mappingsAndSettings.startObject(); | ||
mappingsAndSettings.field("template", index); | ||
mappingsAndSettings.field("index_patterns", index); | ||
mappingsAndSettings.field("order", "1000"); | ||
{ | ||
mappingsAndSettings.startObject("settings"); | ||
mappingsAndSettings.field("number_of_shards", 1); | ||
|
@@ -361,6 +363,7 @@ public void testShrink() throws IOException { | |
client().performRequest(updateSettingsRequest); | ||
|
||
Request shrinkIndexRequest = new Request("PUT", "/" + index + "/_shrink/" + shrunkenIndex); | ||
shrinkIndexRequest.addParameter("copy_settings", "true"); | ||
shrinkIndexRequest.setJsonEntity("{\"settings\": {\"index.number_of_shards\": 1}}"); | ||
client().performRequest(shrinkIndexRequest); | ||
|
||
|
@@ -844,7 +847,7 @@ public void testSnapshotRestore() throws IOException { | |
|
||
// Stick a template into the cluster so we can see it after the restore | ||
XContentBuilder templateBuilder = JsonXContent.contentBuilder().startObject(); | ||
templateBuilder.field("template", "evil_*"); // Don't confuse other tests by applying the template | ||
templateBuilder.field("index_patterns", "evil_*"); // Don't confuse other tests by applying the template | ||
templateBuilder.startObject("settings"); { | ||
templateBuilder.field("number_of_shards", 1); | ||
} | ||
|
@@ -949,9 +952,23 @@ private void checkSnapshot(String snapshotName, int count, Version tookOnVersion | |
assertEquals(singletonList(tookOnVersion.toString()), XContentMapValues.extractValue("snapshots.version", listSnapshotResponse)); | ||
|
||
// Remove the routing setting and template so we can test restoring them. | ||
Request clearRoutingFromSettings = new Request("PUT", "/_cluster/settings"); | ||
clearRoutingFromSettings.setJsonEntity("{\"persistent\":{\"cluster.routing.allocation.exclude.test_attr\": null}}"); | ||
client().performRequest(clearRoutingFromSettings); | ||
try { | ||
Request clearRoutingFromSettings = new Request("PUT", "/_cluster/settings"); | ||
clearRoutingFromSettings.setJsonEntity("{\"persistent\":{\"cluster.routing.allocation.exclude.test_attr\": null}}"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh. So it warns you whenever you update settings if any setting is deprecated? So sometimes this'll fail and sometimes it won't based on the test run order. Fun. |
||
client().performRequest(clearRoutingFromSettings); | ||
} catch (ResponseException e) { | ||
if (e.getResponse().hasWarnings() | ||
&& (isRunningAgainstOldCluster() == false || getOldClusterVersion().onOrAfter(Version.V_6_5_0))) { | ||
e.getResponse().getWarnings().stream().forEach(warning -> { | ||
assertThat(warning, containsString( | ||
"setting was deprecated in Elasticsearch and will be removed in a future release! " | ||
+ "See the breaking changes documentation for the next major version.")); | ||
assertThat(warning, startsWith("[search.remote.")); | ||
}); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
client().performRequest(new Request("DELETE", "/_template/test_template")); | ||
|
||
// Restore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍