-
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
Changes from 3 commits
c5a4566
8f78d5c
f59c576
3211e2f
fc9106d
38e68cd
d44f88d
5cfb38b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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,8 +76,24 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { | |
private String index; | ||
|
||
@Before | ||
public void setIndex() { | ||
public void setIndex() throws IOException { | ||
index = getTestName().toLowerCase(Locale.ROOT); | ||
// TODO prevents 6.x warnings; remove in 8.0 | ||
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. Two things here:
|
||
if (isRunningAgainstOldCluster()) { | ||
XContentBuilder template = jsonBuilder(); | ||
template.startObject(); | ||
{ | ||
template.field("index_patterns", "*"); | ||
template.field("order", "0"); | ||
template.startObject("settings"); | ||
template.field("number_of_shards", 5); | ||
template.endObject(); | ||
} | ||
template.endObject(); | ||
Request createTemplate = new Request("PUT", "/_template/template"); | ||
createTemplate.setJsonEntity(Strings.toString(template)); | ||
client().performRequest(createTemplate); | ||
} | ||
} | ||
|
||
public void testSearch() throws Exception { | ||
|
@@ -283,7 +300,8 @@ public void testClusterState() throws Exception { | |
if (isRunningAgainstOldCluster()) { | ||
XContentBuilder mappingsAndSettings = jsonBuilder(); | ||
mappingsAndSettings.startObject(); | ||
mappingsAndSettings.field("template", index); | ||
mappingsAndSettings.field("index_patterns", index); | ||
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. 👍 |
||
mappingsAndSettings.field("order", "1000"); | ||
{ | ||
mappingsAndSettings.startObject("settings"); | ||
mappingsAndSettings.field("number_of_shards", 1); | ||
|
@@ -361,6 +379,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); | ||
|
||
|
@@ -843,7 +862,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); | ||
} | ||
|
@@ -948,9 +967,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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,16 @@ | |
|
||
import org.apache.http.util.EntityUtils; | ||
import org.elasticsearch.common.Booleans; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; | ||
|
||
/** | ||
* Basic test that indexed documents survive the rolling restart. See | ||
* {@link RecoveryIT} for much more in depth testing of the mechanism | ||
|
@@ -60,6 +64,20 @@ public void testIndexing() throws IOException { | |
} | ||
|
||
if (CLUSTER_TYPE == ClusterType.OLD) { | ||
// TODO prevents 6.x warnings; remove in 8.0 | ||
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. Same note as above. |
||
XContentBuilder template = jsonBuilder(); | ||
template.startObject(); | ||
{ | ||
template.field("index_patterns", "*"); | ||
template.startObject("settings"); | ||
template.field("number_of_shards", 5); | ||
template.endObject(); | ||
} | ||
template.endObject(); | ||
Request createTemplate = new Request("PUT", "/_template/template"); | ||
createTemplate.setJsonEntity(Strings.toString(template)); | ||
client().performRequest(createTemplate); | ||
|
||
Request createTestIndex = new Request("PUT", "/test_index"); | ||
createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}"); | ||
client().performRequest(createTestIndex); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ | |
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.client.ResponseException; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.util.concurrent.ThreadContext; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.common.xcontent.XContentType; | ||
import org.elasticsearch.common.xcontent.support.XContentMapValues; | ||
import org.elasticsearch.rest.RestStatus; | ||
|
@@ -41,6 +43,7 @@ | |
import java.util.stream.Collectors; | ||
|
||
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; | ||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; | ||
import static org.hamcrest.Matchers.anyOf; | ||
import static org.hamcrest.Matchers.containsInAnyOrder; | ||
import static org.hamcrest.Matchers.containsString; | ||
|
@@ -59,6 +62,22 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { | |
@Before | ||
public void waitForMlTemplates() throws Exception { | ||
XPackRestTestHelper.waitForMlTemplates(client()); | ||
// TODO prevents 6.x warnings; remove in 8.0 | ||
if (isRunningAgainstOldCluster()) { | ||
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. Same note as above about the checking if the version is in range and asserting the index compatible version. |
||
XContentBuilder template = jsonBuilder(); | ||
template.startObject(); | ||
{ | ||
template.field("index_patterns", "*"); | ||
template.field("order", "0"); | ||
template.startObject("settings"); | ||
template.field("number_of_shards", 5); | ||
template.endObject(); | ||
} | ||
template.endObject(); | ||
Request createTemplate = new Request("PUT", "/_template/template"); | ||
createTemplate.setJsonEntity(Strings.toString(template)); | ||
client().performRequest(createTemplate); | ||
} | ||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,16 @@ | |
|
||
import org.apache.http.util.EntityUtils; | ||
import org.elasticsearch.common.Booleans; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; | ||
|
||
/** | ||
* Basic test that indexed documents survive the rolling restart. | ||
* <p> | ||
|
@@ -45,6 +49,21 @@ public void testIndexing() throws IOException { | |
} | ||
|
||
if (CLUSTER_TYPE == ClusterType.OLD) { | ||
// TODO prevents 6.x warnings; remove in 8.0 | ||
XContentBuilder template = jsonBuilder(); | ||
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. Same comment as above. |
||
template.startObject(); | ||
{ | ||
template.field("index_patterns", "*"); | ||
template.field("order", "0"); | ||
template.startObject("settings"); | ||
template.field("number_of_shards", 5); | ||
template.endObject(); | ||
} | ||
template.endObject(); | ||
Request createTemplate = new Request("PUT", "/_template/template"); | ||
createTemplate.setJsonEntity(Strings.toString(template)); | ||
client().performRequest(createTemplate); | ||
|
||
Request createTestIndex = new Request("PUT", "/test_index"); | ||
createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}"); | ||
client().performRequest(createTestIndex); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,17 +13,35 @@ | |
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.client.ResponseException; | ||
import org.elasticsearch.client.RestClient; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.test.rest.yaml.ObjectPath; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; | ||
|
||
public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase { | ||
|
||
public void testGeneratingTokenInOldCluster() throws Exception { | ||
assumeTrue("this test should only run against the old cluster", CLUSTER_TYPE == ClusterType.OLD); | ||
|
||
XContentBuilder template = jsonBuilder(); | ||
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. Same comment as above. |
||
template.startObject(); | ||
{ | ||
template.field("index_patterns", "*"); | ||
template.startObject("settings"); | ||
template.field("number_of_shards", 5); | ||
template.endObject(); | ||
} | ||
template.endObject(); | ||
Request createTemplate = new Request("PUT", "/_template/template"); | ||
createTemplate.setJsonEntity(Strings.toString(template)); | ||
client().performRequest(createTemplate); | ||
|
||
Request createTokenRequest = new Request("POST", "_xpack/security/oauth2/token"); | ||
createTokenRequest.setJsonEntity( | ||
"{\n" + | ||
|
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.
Do you think we should turn this to
true
now that I've merged #34338?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.
I would love to! But in the mean time #34135 got merged and it added a deprecated setting:
elasticsearch/client/rest-high-level/build.gradle
Line 93 in 55eaf7a
I think this is the reason for the two tests below to fail once the strict deprecation mode is on:
I did not see what setting to use instead of
xpack.security.transport.ssl.truststore.password
. TBH I am not really sure if the setting should be deprecated in the first place as I did not find it mentioned in any docs...@nik9000 do you have any ideas / pointers?
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.
@jkakavas, can you comment on this setting being deprecated?
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.
Yes, it is deprecated
elasticsearch/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLConfigurationSettings.java
Lines 92 to 95 in 46c7b5e
and I shouldn't have used it. I'll raise a follow-up PR tomorrow my morning to address this.
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.
❤️
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.
I pushed 6874ee8 that fixes this, sorry for the inconvenience @nik9000, @lipsill