|
@@ -88,7 +88,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
assertThat(toStr(client().performRequest(getRequest)), containsString(doc));
|
|
|
}
|
|
|
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
public void testSecurityNativeRealm() throws Exception {
|
|
|
if (isRunningAgainstOldCluster()) {
|
|
|
createUser(true);
|
|
@@ -103,13 +102,11 @@ 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")
|
|
|
- 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 security index needs to be upgraded", SECURITY_EXPECTED_INDEX_FORMAT_VERSION, format);
|
|
|
}
|
|
|
}
|
|
@@ -123,7 +120,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
assertRoleInfo(isRunningAgainstOldCluster());
|
|
|
}
|
|
|
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
public void testWatcher() throws Exception {
|
|
|
if (isRunningAgainstOldCluster()) {
|
|
|
logger.info("Adding a watch on old cluster {}", getOldClusterVersion());
|
|
@@ -173,11 +169,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);
|
|
|
}
|
|
|
}
|
|
@@ -187,9 +183,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")));
|
|
|
});
|
|
|
|
|
@@ -206,9 +201,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")));
|
|
|
});
|
|
|
}
|
|
@@ -285,7 +279,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
public void testSlmPolicyAndStats() throws IOException {
|
|
|
SnapshotLifecyclePolicy slmPolicy = new SnapshotLifecyclePolicy("test-policy", "test-policy", "* * * 31 FEB ? *", "test-repo",
|
|
|
Collections.singletonMap("indices", Collections.singletonList("*")), null);
|
|
@@ -312,7 +305,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
Request getSlmPolicyRequest = new Request("GET", "_slm/policy/test-policy");
|
|
|
Response response = client().performRequest(getSlmPolicyRequest);
|
|
|
Map<String, Object> responseMap = entityAsMap(response);
|
|
|
- Map<String, Object> policy = (Map<String, Object>) ((Map<String, Object>) responseMap.get("test-policy")).get("policy");
|
|
|
+ Map<?, ?> policy = (Map<?, ?>) ((Map<?, ?>) responseMap.get("test-policy")).get("policy");
|
|
|
assertEquals(slmPolicy.getName(), policy.get("name"));
|
|
|
assertEquals(slmPolicy.getRepository(), policy.get("repository"));
|
|
|
assertEquals(slmPolicy.getSchedule(), policy.get("schedule"));
|
|
@@ -338,7 +331,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
assertThat(templates.keySet(), not(hasItems(is("watches"), startsWith("watch-history"), is("triggered_watches"))));
|
|
|
}
|
|
|
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
private void assertWatchIndexContentsWork() throws Exception {
|
|
|
// Fetch a basic watch
|
|
|
Request getRequest = new Request("GET", "_watcher/watch/bwc_watch");
|
|
@@ -348,7 +340,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
logger.error("-----> {}", bwcWatch);
|
|
|
|
|
|
assertThat(bwcWatch.get("found"), equalTo(true));
|
|
|
- Map<String, Object> source = (Map<String, Object>) bwcWatch.get("watch");
|
|
|
+ Map<?, ?> source = (Map<?, ?>) bwcWatch.get("watch");
|
|
|
assertEquals(1000, source.get("throttle_period_in_millis"));
|
|
|
int timeout = (int) timeValueSeconds(100).millis();
|
|
|
assertThat(ObjectPath.eval("input.search.timeout_in_millis", source), equalTo(timeout));
|
|
@@ -361,7 +353,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
|
|
|
bwcWatch = entityAsMap(client().performRequest(getRequest));
|
|
|
assertThat(bwcWatch.get("found"), equalTo(true));
|
|
|
- source = (Map<String, Object>) bwcWatch.get("watch");
|
|
|
+ source = (Map<?, ?>) bwcWatch.get("watch");
|
|
|
assertEquals(timeout, source.get("throttle_period_in_millis"));
|
|
|
assertThat(ObjectPath.eval("actions.index_payload.throttle_period_in_millis", source), equalTo(timeout));
|
|
|
|
|
@@ -371,11 +363,11 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
*/
|
|
|
bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_watcher/watch/bwc_funny_timeout")));
|
|
|
assertThat(bwcWatch.get("found"), equalTo(true));
|
|
|
- source = (Map<String, Object>) bwcWatch.get("watch");
|
|
|
+ source = (Map<?, ?>) bwcWatch.get("watch");
|
|
|
|
|
|
|
|
|
Map<String, Object> attachments = ObjectPath.eval("actions.work.email.attachments", source);
|
|
|
- Map<String, Object> attachment = (Map<String, Object>) attachments.get("test_report.pdf");
|
|
|
+ Map<?, ?> attachment = (Map<?, ?>) attachments.get("test_report.pdf");
|
|
|
Map<String, Object> request = ObjectPath.eval("http.request", attachment);
|
|
|
assertEquals(timeout, request.get("read_timeout_millis"));
|
|
|
assertEquals("https", request.get("scheme"));
|
|
@@ -391,12 +383,11 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
searchRequest.addParameter(RestSearchAction.TOTAL_HITS_AS_INT_PARAM, "true");
|
|
|
}
|
|
|
Map<String, Object> history = entityAsMap(client().performRequest(searchRequest));
|
|
|
- Map<String, Object> hits = (Map<String, Object>) history.get("hits");
|
|
|
- assertThat((int) (hits.get("total")), greaterThanOrEqualTo(2));
|
|
|
+ Map<?, ?> hits = (Map<?, ?>) history.get("hits");
|
|
|
+ assertThat((Integer) hits.get("total"), greaterThanOrEqualTo(2));
|
|
|
}
|
|
|
|
|
|
private void assertBasicWatchInteractions() throws Exception {
|
|
|
-
|
|
|
String watch = "{\"trigger\":{\"schedule\":{\"interval\":\"1s\"}},\"input\":{\"none\":{}}," +
|
|
|
"\"condition\":{\"always\":{}}," +
|
|
|
"\"actions\":{\"awesome\":{\"logging\":{\"level\":\"info\",\"text\":\"test\"}}}}";
|
|
@@ -415,7 +406,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
|
|
|
Map<String, Object> get = entityAsMap(client().performRequest(new Request("GET", "_watcher/watch/new_watch")));
|
|
|
assertThat(get.get("found"), equalTo(true));
|
|
|
- @SuppressWarnings("unchecked") Map<?, ?> source = (Map<String, Object>) get.get("watch");
|
|
|
+ Map<?, ?> source = (Map<?, ?>) get.get("watch");
|
|
|
Map<String, Object> logging = ObjectPath.eval("actions.awesome.logging", source);
|
|
|
assertEquals("info", logging.get("level"));
|
|
|
assertEquals("test", logging.get("text"));
|
|
@@ -431,20 +422,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) {
|
|
@@ -502,7 +492,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
final String user = oldCluster ? "preupgrade_user" : "postupgrade_user";
|
|
|
Request request = new Request("GET", "/_security/user/" + user);;
|
|
|
Map<String, Object> response = entityAsMap(client().performRequest(request));
|
|
|
- @SuppressWarnings("unchecked") Map<String, Object> userInfo = (Map<String, Object>) response.get(user);
|
|
|
+ Map<?, ?> userInfo = (Map<?, ?>) response.get(user);
|
|
|
assertEquals(user + "@example.com", userInfo.get("email"));
|
|
|
assertNotNull(userInfo.get("full_name"));
|
|
|
assertNotNull(userInfo.get("roles"));
|
|
@@ -510,7 +500,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", "/_security/role/" + role))
|
|
|
).get(role);
|
|
|
assertNotNull(response.get("run_as"));
|
|
@@ -518,7 +508,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);
|
|
@@ -526,7 +515,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|
|
// check that the rollup job is started using the RollUp API
|
|
|
final Request getRollupJobRequest = new Request("GET", "_rollup/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);
|
|
|
|
|
@@ -535,10 +524,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
|
|
@@ -568,28 +557,25 @@ 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 {
|
|
|
-
|
|
|
- List<Map<String, Object>> jobs =
|
|
|
- (List<Map<String, Object>>) XContentMapValues.extractValue("jobs", jobsMap);
|
|
|
-
|
|
|
+ private Map<?, ?> getJob(Map<String, Object> jobsMap, String targetJobId) throws IOException {
|
|
|
+ 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;
|
|
|
}
|