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.certificate', 'testnode.crt'
|
||||
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));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSecurityNativeRealm() throws Exception {
|
||||
if (isRunningAgainstOldCluster()) {
|
||||
createUser(true);
|
||||
|
@ -125,9 +124,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
fail("The security index does not have the expected setting [index.format]");
|
||||
} else {
|
||||
concreteSecurityIndex = settingsResponseMap.keySet().iterator().next();
|
||||
Map<String, Object> indexSettingsMap =
|
||||
(Map<String, Object>) settingsResponseMap.get(concreteSecurityIndex);
|
||||
Map<String, Object> settingsMap = (Map<String, Object>) indexSettingsMap.get("settings");
|
||||
Map<?, ?> indexSettingsMap = (Map<?, ?>) settingsResponseMap.get(concreteSecurityIndex);
|
||||
Map<?, ?> settingsMap = (Map<?, ?>) indexSettingsMap.get("settings");
|
||||
logger.info("settings map {}", settingsMap);
|
||||
if (settingsMap.containsKey("index")) {
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -145,8 +143,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
assertRoleInfo(isRunningAgainstOldCluster());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/48381")
|
||||
public void testWatcher() throws Exception {
|
||||
if (isRunningAgainstOldCluster()) {
|
||||
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]");
|
||||
} else {
|
||||
concreteWatchesIndex = settingsResponseMap.keySet().iterator().next();
|
||||
Map<String, Object> indexSettingsMap = (Map<String, Object>) settingsResponseMap.get(concreteWatchesIndex);
|
||||
Map<String, Object> settingsMap = (Map<String, Object>) indexSettingsMap.get("settings");
|
||||
Map<?, ?> indexSettingsMap = (Map<?, ?>) settingsResponseMap.get(concreteWatchesIndex);
|
||||
Map<?, ?> settingsMap = (Map<?, ?>) indexSettingsMap.get("settings");
|
||||
logger.info("settings map {}", settingsMap);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -213,9 +209,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
assertThat(startWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE));
|
||||
assertBusy(() -> {
|
||||
Map<String, Object> statsWatchResponse = entityAsMap(client().performRequest(new Request("GET", "_watcher/stats")));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> states = ((List<Object>) statsWatchResponse.get("stats"))
|
||||
.stream().map(o -> ((Map<String, Object>) o).get("watcher_state")).collect(Collectors.toList());
|
||||
List<?> states = ((List<?>) statsWatchResponse.get("stats"))
|
||||
.stream().map(o -> ((Map<?, ?>) o).get("watcher_state")).collect(Collectors.toList());
|
||||
assertThat(states, everyItem(is("started")));
|
||||
});
|
||||
|
||||
|
@ -232,9 +227,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
assertBusy(() -> {
|
||||
Map<String, Object> statsStoppedWatchResponse = entityAsMap(client().performRequest(
|
||||
new Request("GET", "_watcher/stats")));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> states = ((List<Object>) statsStoppedWatchResponse.get("stats"))
|
||||
.stream().map(o -> ((Map<String, Object>) o).get("watcher_state")).collect(Collectors.toList());
|
||||
List<?> states = ((List<?>) statsStoppedWatchResponse.get("stats"))
|
||||
.stream().map(o -> ((Map<?, ?>) o).get("watcher_state")).collect(Collectors.toList());
|
||||
assertThat(states, everyItem(is("stopped")));
|
||||
});
|
||||
}
|
||||
|
@ -625,20 +619,19 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
assertThat(response.get("timed_out"), equalTo(Boolean.FALSE));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void waitForHits(String indexName, int expectedHits) throws Exception {
|
||||
Request request = new Request("GET", "/" + indexName + "/_search");
|
||||
request.addParameter("size", "0");
|
||||
assertBusy(() -> {
|
||||
try {
|
||||
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);
|
||||
int total;
|
||||
Integer total;
|
||||
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 {
|
||||
total = (int) hits.get("total");
|
||||
total = (Integer) hits.get("total");
|
||||
}
|
||||
assertThat(total, greaterThanOrEqualTo(expectedHits));
|
||||
} catch (IOException ioe) {
|
||||
|
@ -744,7 +737,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
|
||||
private void assertRoleInfo(final boolean oldCluster) throws Exception {
|
||||
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))
|
||||
).get(role);
|
||||
assertNotNull(response.get("run_as"));
|
||||
|
@ -752,7 +745,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
assertNotNull(response.get("indices"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void assertRollUpJob(final String rollupJob) throws Exception {
|
||||
final Matcher<?> expectedStates = anyOf(equalTo("indexing"), equalTo("started"));
|
||||
waitForRollUpJob(rollupJob, expectedStates);
|
||||
|
@ -760,7 +752,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
// check that the rollup job is started using the RollUp API
|
||||
final Request getRollupJobRequest = new Request("GET", getRollupEndpoint() + "/job/" + rollupJob);
|
||||
Map<String, Object> getRollupJobResponse = entityAsMap(client().performRequest(getRollupJobRequest));
|
||||
Map<String, Object> job = getJob(getRollupJobResponse, rollupJob);
|
||||
Map<?, ?> job = getJob(getRollupJobResponse, rollupJob);
|
||||
assertNotNull(job);
|
||||
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
|
||||
|
||||
|
@ -769,10 +761,10 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
taskRequest.addParameter("detailed", "true");
|
||||
taskRequest.addParameter("actions", "xpack/rollup/*");
|
||||
Map<String, Object> taskResponse = entityAsMap(client().performRequest(taskRequest));
|
||||
Map<String, Object> taskResponseNodes = (Map<String, Object>) taskResponse.get("nodes");
|
||||
Map<String, Object> taskResponseNode = (Map<String, Object>) taskResponseNodes.values().iterator().next();
|
||||
Map<String, Object> taskResponseTasks = (Map<String, Object>) taskResponseNode.get("tasks");
|
||||
Map<String, Object> taskResponseStatus = (Map<String, Object>) taskResponseTasks.values().iterator().next();
|
||||
Map<?, ?> taskResponseNodes = (Map<?, ?>) taskResponse.get("nodes");
|
||||
Map<?, ?> taskResponseNode = (Map<?, ?>) taskResponseNodes.values().iterator().next();
|
||||
Map<?, ?> taskResponseTasks = (Map<?, ?>) taskResponseNode.get("tasks");
|
||||
Map<?, ?> taskResponseStatus = (Map<?, ?>) taskResponseTasks.values().iterator().next();
|
||||
assertThat(ObjectPath.eval("status.job_state", taskResponseStatus), expectedStates);
|
||||
|
||||
// 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);
|
||||
assertThat(getRollupJobResponse.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus()));
|
||||
|
||||
Map<String, Object> job = getJob(getRollupJobResponse, rollupJob);
|
||||
Map<?, ?> job = getJob(getRollupJobResponse, rollupJob);
|
||||
assertNotNull(job);
|
||||
assertThat(ObjectPath.eval("status.job_state", job), expectedStates);
|
||||
}, 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);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<String, Object> getJob(Map<String, Object> jobsMap, String targetJobId) throws IOException {
|
||||
private Map<?, ?> getJob(Map<String, Object> jobsMap, String targetJobId) throws IOException {
|
||||
|
||||
List<Map<String, Object>> jobs =
|
||||
(List<Map<String, Object>>) XContentMapValues.extractValue("jobs", jobsMap);
|
||||
List<?> jobs = (List<?>) XContentMapValues.extractValue("jobs", jobsMap);
|
||||
|
||||
if (jobs == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Map<String, Object> job : jobs) {
|
||||
String jobId = (String) ((Map<String, Object>) job.get("config")).get("id");
|
||||
for (Object entry : jobs) {
|
||||
Map<?, ?> job = (Map<?, ?>) entry;
|
||||
String jobId = (String) ((Map<?, ?>) job.get("config")).get("id");
|
||||
if (jobId.equals(targetJobId)) {
|
||||
return job;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue