Unmuted test with more logging and
removed unchecked suppress warnings. See #48381
This commit is contained in:
parent
b233e93014
commit
716904fab7
|
@ -85,6 +85,7 @@ for (Version bwcVersion : bwcVersions.indexCompatible) {
|
||||||
setting 'xpack.security.transport.ssl.key', 'testnode.pem'
|
setting 'xpack.security.transport.ssl.key', 'testnode.pem'
|
||||||
setting 'xpack.security.transport.ssl.certificate', 'testnode.crt'
|
setting 'xpack.security.transport.ssl.certificate', 'testnode.crt'
|
||||||
keystore 'xpack.security.transport.ssl.secure_key_passphrase', 'testnode'
|
keystore 'xpack.security.transport.ssl.secure_key_passphrase', 'testnode'
|
||||||
|
setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
assertThat(toStr(client().performRequest(getRequest)), containsString(doc));
|
assertThat(toStr(client().performRequest(getRequest)), containsString(doc));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void testSecurityNativeRealm() throws Exception {
|
public void testSecurityNativeRealm() throws Exception {
|
||||||
if (isRunningAgainstOldCluster()) {
|
if (isRunningAgainstOldCluster()) {
|
||||||
createUser(true);
|
createUser(true);
|
||||||
|
@ -125,9 +124,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
fail("The security index does not have the expected setting [index.format]");
|
fail("The security index does not have the expected setting [index.format]");
|
||||||
} else {
|
} else {
|
||||||
concreteSecurityIndex = settingsResponseMap.keySet().iterator().next();
|
concreteSecurityIndex = settingsResponseMap.keySet().iterator().next();
|
||||||
Map<String, Object> indexSettingsMap =
|
Map<?, ?> indexSettingsMap = (Map<?, ?>) settingsResponseMap.get(concreteSecurityIndex);
|
||||||
(Map<String, Object>) settingsResponseMap.get(concreteSecurityIndex);
|
Map<?, ?> settingsMap = (Map<?, ?>) indexSettingsMap.get("settings");
|
||||||
Map<String, Object> settingsMap = (Map<String, Object>) indexSettingsMap.get("settings");
|
|
||||||
logger.info("settings map {}", settingsMap);
|
logger.info("settings map {}", settingsMap);
|
||||||
if (settingsMap.containsKey("index")) {
|
if (settingsMap.containsKey("index")) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -145,8 +143,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
assertRoleInfo(isRunningAgainstOldCluster());
|
assertRoleInfo(isRunningAgainstOldCluster());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/48381")
|
|
||||||
public void testWatcher() throws Exception {
|
public void testWatcher() throws Exception {
|
||||||
if (isRunningAgainstOldCluster()) {
|
if (isRunningAgainstOldCluster()) {
|
||||||
logger.info("Adding a watch on old cluster {}", getOldClusterVersion());
|
logger.info("Adding a watch on old cluster {}", getOldClusterVersion());
|
||||||
|
@ -199,11 +195,11 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
fail("The security index does not have the expected setting [index.format]");
|
fail("The security index does not have the expected setting [index.format]");
|
||||||
} else {
|
} else {
|
||||||
concreteWatchesIndex = settingsResponseMap.keySet().iterator().next();
|
concreteWatchesIndex = settingsResponseMap.keySet().iterator().next();
|
||||||
Map<String, Object> indexSettingsMap = (Map<String, Object>) settingsResponseMap.get(concreteWatchesIndex);
|
Map<?, ?> indexSettingsMap = (Map<?, ?>) settingsResponseMap.get(concreteWatchesIndex);
|
||||||
Map<String, Object> settingsMap = (Map<String, Object>) indexSettingsMap.get("settings");
|
Map<?, ?> settingsMap = (Map<?, ?>) indexSettingsMap.get("settings");
|
||||||
logger.info("settings map {}", settingsMap);
|
logger.info("settings map {}", settingsMap);
|
||||||
if (settingsMap.containsKey("index")) {
|
if (settingsMap.containsKey("index")) {
|
||||||
int format = Integer.parseInt(String.valueOf(((Map<String, Object>)settingsMap.get("index")).get("format")));
|
int format = Integer.parseInt(String.valueOf(((Map<?, ?>)settingsMap.get("index")).get("format")));
|
||||||
assertEquals("The watches index needs to be upgraded", UPGRADE_FIELD_EXPECTED_INDEX_FORMAT_VERSION, format);
|
assertEquals("The watches index needs to be upgraded", UPGRADE_FIELD_EXPECTED_INDEX_FORMAT_VERSION, format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,9 +209,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
assertThat(startWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE));
|
assertThat(startWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE));
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
Map<String, Object> statsWatchResponse = entityAsMap(client().performRequest(new Request("GET", "_watcher/stats")));
|
Map<String, Object> statsWatchResponse = entityAsMap(client().performRequest(new Request("GET", "_watcher/stats")));
|
||||||
@SuppressWarnings("unchecked")
|
List<?> states = ((List<?>) statsWatchResponse.get("stats"))
|
||||||
List<Object> states = ((List<Object>) statsWatchResponse.get("stats"))
|
.stream().map(o -> ((Map<?, ?>) o).get("watcher_state")).collect(Collectors.toList());
|
||||||
.stream().map(o -> ((Map<String, Object>) o).get("watcher_state")).collect(Collectors.toList());
|
|
||||||
assertThat(states, everyItem(is("started")));
|
assertThat(states, everyItem(is("started")));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -232,9 +227,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
Map<String, Object> statsStoppedWatchResponse = entityAsMap(client().performRequest(
|
Map<String, Object> statsStoppedWatchResponse = entityAsMap(client().performRequest(
|
||||||
new Request("GET", "_watcher/stats")));
|
new Request("GET", "_watcher/stats")));
|
||||||
@SuppressWarnings("unchecked")
|
List<?> states = ((List<?>) statsStoppedWatchResponse.get("stats"))
|
||||||
List<Object> states = ((List<Object>) statsStoppedWatchResponse.get("stats"))
|
.stream().map(o -> ((Map<?, ?>) o).get("watcher_state")).collect(Collectors.toList());
|
||||||
.stream().map(o -> ((Map<String, Object>) o).get("watcher_state")).collect(Collectors.toList());
|
|
||||||
assertThat(states, everyItem(is("stopped")));
|
assertThat(states, everyItem(is("stopped")));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -625,20 +619,19 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
assertThat(response.get("timed_out"), equalTo(Boolean.FALSE));
|
assertThat(response.get("timed_out"), equalTo(Boolean.FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void waitForHits(String indexName, int expectedHits) throws Exception {
|
private void waitForHits(String indexName, int expectedHits) throws Exception {
|
||||||
Request request = new Request("GET", "/" + indexName + "/_search");
|
Request request = new Request("GET", "/" + indexName + "/_search");
|
||||||
request.addParameter("size", "0");
|
request.addParameter("size", "0");
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
try {
|
try {
|
||||||
Map<String, Object> response = entityAsMap(client().performRequest(request));
|
Map<String, Object> response = entityAsMap(client().performRequest(request));
|
||||||
Map<String, Object> hits = (Map<String, Object>) response.get("hits");
|
Map<?, ?> hits = (Map<?, ?>) response.get("hits");
|
||||||
logger.info("Hits are: {}", hits);
|
logger.info("Hits are: {}", hits);
|
||||||
int total;
|
Integer total;
|
||||||
if (getOldClusterVersion().onOrAfter(Version.V_7_0_0) || isRunningAgainstOldCluster() == false) {
|
if (getOldClusterVersion().onOrAfter(Version.V_7_0_0) || isRunningAgainstOldCluster() == false) {
|
||||||
total = (int) ((Map<String, Object>) hits.get("total")).get("value");
|
total = (Integer) ((Map<?, ?>) hits.get("total")).get("value");
|
||||||
} else {
|
} else {
|
||||||
total = (int) hits.get("total");
|
total = (Integer) hits.get("total");
|
||||||
}
|
}
|
||||||
assertThat(total, greaterThanOrEqualTo(expectedHits));
|
assertThat(total, greaterThanOrEqualTo(expectedHits));
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
@ -744,7 +737,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
|
|
||||||
private void assertRoleInfo(final boolean oldCluster) throws Exception {
|
private void assertRoleInfo(final boolean oldCluster) throws Exception {
|
||||||
final String role = oldCluster ? "preupgrade_role" : "postupgrade_role";
|
final String role = oldCluster ? "preupgrade_role" : "postupgrade_role";
|
||||||
@SuppressWarnings("unchecked") Map<String, Object> response = (Map<String, Object>) entityAsMap(
|
Map<?, ?> response = (Map<?, ?>) entityAsMap(
|
||||||
client().performRequest(new Request("GET", getSecurityEndpoint() + "/role/" + role))
|
client().performRequest(new Request("GET", getSecurityEndpoint() + "/role/" + role))
|
||||||
).get(role);
|
).get(role);
|
||||||
assertNotNull(response.get("run_as"));
|
assertNotNull(response.get("run_as"));
|
||||||
|
@ -752,7 +745,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
assertNotNull(response.get("indices"));
|
assertNotNull(response.get("indices"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void assertRollUpJob(final String rollupJob) throws Exception {
|
private void assertRollUpJob(final String rollupJob) throws Exception {
|
||||||
final Matcher<?> expectedStates = anyOf(equalTo("indexing"), equalTo("started"));
|
final Matcher<?> expectedStates = anyOf(equalTo("indexing"), equalTo("started"));
|
||||||
waitForRollUpJob(rollupJob, expectedStates);
|
waitForRollUpJob(rollupJob, expectedStates);
|
||||||
|
@ -760,7 +752,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
// check that the rollup job is started using the RollUp API
|
// check that the rollup job is started using the RollUp API
|
||||||
final Request getRollupJobRequest = new Request("GET", getRollupEndpoint() + "/job/" + rollupJob);
|
final Request getRollupJobRequest = new Request("GET", getRollupEndpoint() + "/job/" + rollupJob);
|
||||||
Map<String, Object> getRollupJobResponse = entityAsMap(client().performRequest(getRollupJobRequest));
|
Map<String, Object> getRollupJobResponse = entityAsMap(client().performRequest(getRollupJobRequest));
|
||||||
Map<String, Object> job = getJob(getRollupJobResponse, rollupJob);
|
Map<?, ?> job = getJob(getRollupJobResponse, rollupJob);
|
||||||
assertNotNull(job);
|
assertNotNull(job);
|
||||||
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
|
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
|
||||||
|
|
||||||
|
@ -769,10 +761,10 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
taskRequest.addParameter("detailed", "true");
|
taskRequest.addParameter("detailed", "true");
|
||||||
taskRequest.addParameter("actions", "xpack/rollup/*");
|
taskRequest.addParameter("actions", "xpack/rollup/*");
|
||||||
Map<String, Object> taskResponse = entityAsMap(client().performRequest(taskRequest));
|
Map<String, Object> taskResponse = entityAsMap(client().performRequest(taskRequest));
|
||||||
Map<String, Object> taskResponseNodes = (Map<String, Object>) taskResponse.get("nodes");
|
Map<?, ?> taskResponseNodes = (Map<?, ?>) taskResponse.get("nodes");
|
||||||
Map<String, Object> taskResponseNode = (Map<String, Object>) taskResponseNodes.values().iterator().next();
|
Map<?, ?> taskResponseNode = (Map<?, ?>) taskResponseNodes.values().iterator().next();
|
||||||
Map<String, Object> taskResponseTasks = (Map<String, Object>) taskResponseNode.get("tasks");
|
Map<?, ?> taskResponseTasks = (Map<?, ?>) taskResponseNode.get("tasks");
|
||||||
Map<String, Object> taskResponseStatus = (Map<String, Object>) taskResponseTasks.values().iterator().next();
|
Map<?, ?> taskResponseStatus = (Map<?, ?>) taskResponseTasks.values().iterator().next();
|
||||||
assertThat(ObjectPath.eval("status.job_state", taskResponseStatus), expectedStates);
|
assertThat(ObjectPath.eval("status.job_state", taskResponseStatus), expectedStates);
|
||||||
|
|
||||||
// check that the rollup job is started using the Cluster State API
|
// check that the rollup job is started using the Cluster State API
|
||||||
|
@ -808,28 +800,27 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
Response getRollupJobResponse = client().performRequest(getRollupJobRequest);
|
Response getRollupJobResponse = client().performRequest(getRollupJobRequest);
|
||||||
assertThat(getRollupJobResponse.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus()));
|
assertThat(getRollupJobResponse.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus()));
|
||||||
|
|
||||||
Map<String, Object> job = getJob(getRollupJobResponse, rollupJob);
|
Map<?, ?> job = getJob(getRollupJobResponse, rollupJob);
|
||||||
assertNotNull(job);
|
assertNotNull(job);
|
||||||
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
|
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
|
||||||
}, 30L, TimeUnit.SECONDS);
|
}, 30L, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> getJob(Response response, String targetJobId) throws IOException {
|
private Map<?, ?> getJob(Response response, String targetJobId) throws IOException {
|
||||||
return getJob(ESRestTestCase.entityAsMap(response), targetJobId);
|
return getJob(ESRestTestCase.entityAsMap(response), targetJobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
private Map<?, ?> getJob(Map<String, Object> jobsMap, String targetJobId) throws IOException {
|
||||||
private Map<String, Object> getJob(Map<String, Object> jobsMap, String targetJobId) throws IOException {
|
|
||||||
|
|
||||||
List<Map<String, Object>> jobs =
|
List<?> jobs = (List<?>) XContentMapValues.extractValue("jobs", jobsMap);
|
||||||
(List<Map<String, Object>>) XContentMapValues.extractValue("jobs", jobsMap);
|
|
||||||
|
|
||||||
if (jobs == null) {
|
if (jobs == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map<String, Object> job : jobs) {
|
for (Object entry : jobs) {
|
||||||
String jobId = (String) ((Map<String, Object>) job.get("config")).get("id");
|
Map<?, ?> job = (Map<?, ?>) entry;
|
||||||
|
String jobId = (String) ((Map<?, ?>) job.get("config")).get("id");
|
||||||
if (jobId.equals(targetJobId)) {
|
if (jobId.equals(targetJobId)) {
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue