[TEST] Change default close timeout for close job requests in tests.

Original commit: elastic/x-pack-elasticsearch@240bb0561c
This commit is contained in:
Martijn van Groningen 2017-02-21 13:07:25 +01:00
parent c49a17e7ca
commit 0e44683de6
2 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,7 @@ package org.elasticsearch.xpack.ml.integration;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.xpack.ml.action.CloseJobAction;
import org.elasticsearch.xpack.ml.action.GetJobsStatsAction;
import org.elasticsearch.xpack.ml.action.OpenJobAction;
@ -94,6 +95,7 @@ public class TooManyJobsIT extends BaseMlIntegTestCase {
// close the first job and check if the latest job gets opened:
CloseJobAction.Request closeRequest = new CloseJobAction.Request("1");
closeRequest.setTimeout(TimeValue.timeValueSeconds(30L));
CloseJobAction.Response closeResponse = client().execute(CloseJobAction.INSTANCE, closeRequest).actionGet();
assertTrue(closeResponse.isClosed());
client().execute(OpenJobAction.INSTANCE, openJobRequest).get();

View File

@ -9,6 +9,7 @@ import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.SecurityIntegTestCase;
@ -158,8 +159,10 @@ public abstract class BaseMlIntegTestCase extends SecurityIntegTestCase {
for (Map.Entry<String, Job> entry : mlMetadata.getJobs().entrySet()) {
String jobId = entry.getKey();
try {
CloseJobAction.Request closeRequest = new CloseJobAction.Request(jobId);
closeRequest.setTimeout(TimeValue.timeValueSeconds(30L));
CloseJobAction.Response response =
client.execute(CloseJobAction.INSTANCE, new CloseJobAction.Request(jobId)).get();
client.execute(CloseJobAction.INSTANCE, closeRequest).get();
assertTrue(response.isClosed());
} catch (Exception e) {
// CONFLICT is ok, as it means the job has been closed already, which isn't an issue at all.