|
@@ -52,6 +52,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
public void testCreateIndexException() {
|
|
|
+ final var projectId = randomProjectIdOrDefault();
|
|
|
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random(), "foo"), Collections.emptyMap());
|
|
|
|
|
|
ActionListener<AcknowledgedResponse> testListener = ActionListener.wrap(response -> {
|
|
@@ -70,7 +71,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
return null;
|
|
|
}).when(client).execute(eq(TransportCreateIndexAction.TYPE), any(CreateIndexRequest.class), requestCaptor.capture());
|
|
|
|
|
|
- TransportPutRollupJobAction.createIndex(job, testListener, mock(PersistentTasksService.class), client, logger);
|
|
|
+ TransportPutRollupJobAction.createIndex(projectId, job, testListener, mock(PersistentTasksService.class), client, logger);
|
|
|
|
|
|
// ResourceAlreadyExists should trigger a GetMapping next
|
|
|
verify(client).execute(eq(TransportCreateIndexAction.TYPE), any(CreateIndexRequest.class), any());
|
|
@@ -78,6 +79,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
public void testIndexAlreadyExists() {
|
|
|
+ final var projectId = randomProjectIdOrDefault();
|
|
|
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random()), Collections.emptyMap());
|
|
|
|
|
|
ActionListener<AcknowledgedResponse> testListener = ActionListener.wrap(response -> {
|
|
@@ -100,7 +102,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
return null;
|
|
|
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor2.capture());
|
|
|
|
|
|
- TransportPutRollupJobAction.createIndex(job, testListener, mock(PersistentTasksService.class), client, logger);
|
|
|
+ TransportPutRollupJobAction.createIndex(projectId, job, testListener, mock(PersistentTasksService.class), client, logger);
|
|
|
|
|
|
// ResourceAlreadyExists should trigger a GetMapping next
|
|
|
verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
|
|
@@ -108,6 +110,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
public void testIndexMetadata() throws InterruptedException {
|
|
|
+ final var projectId = randomProjectIdOrDefault();
|
|
|
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random()), Collections.emptyMap());
|
|
|
|
|
|
ActionListener<AcknowledgedResponse> testListener = ActionListener.wrap(response -> {
|
|
@@ -140,7 +143,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
return null;
|
|
|
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor2.capture());
|
|
|
|
|
|
- TransportPutRollupJobAction.createIndex(job, testListener, mock(PersistentTasksService.class), client, logger);
|
|
|
+ TransportPutRollupJobAction.createIndex(projectId, job, testListener, mock(PersistentTasksService.class), client, logger);
|
|
|
|
|
|
// ResourceAlreadyExists should trigger a GetMapping next
|
|
|
verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
|
|
@@ -149,6 +152,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
public void testGetMappingFails() {
|
|
|
+ final var projectId = randomProjectIdOrDefault();
|
|
|
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random(), "foo"), Collections.emptyMap());
|
|
|
|
|
|
ActionListener<AcknowledgedResponse> testListener = ActionListener.wrap(response -> {
|
|
@@ -168,6 +172,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture());
|
|
|
|
|
|
TransportPutRollupJobAction.updateMapping(
|
|
|
+ projectId,
|
|
|
job,
|
|
|
testListener,
|
|
|
mock(PersistentTasksService.class),
|
|
@@ -180,6 +185,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
public void testNoMetadataInMapping() {
|
|
|
+ final var projectId = randomProjectIdOrDefault();
|
|
|
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random()), Collections.emptyMap());
|
|
|
|
|
|
ActionListener<AcknowledgedResponse> testListener = ActionListener.wrap(response -> {
|
|
@@ -210,6 +216,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture());
|
|
|
|
|
|
TransportPutRollupJobAction.updateMapping(
|
|
|
+ projectId,
|
|
|
job,
|
|
|
testListener,
|
|
|
mock(PersistentTasksService.class),
|
|
@@ -222,6 +229,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
public void testMetadataButNotRollup() {
|
|
|
+ final var projectId = randomProjectIdOrDefault();
|
|
|
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random()), Collections.emptyMap());
|
|
|
|
|
|
ActionListener<AcknowledgedResponse> testListener = ActionListener.wrap(response -> {
|
|
@@ -254,6 +262,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture());
|
|
|
|
|
|
TransportPutRollupJobAction.updateMapping(
|
|
|
+ projectId,
|
|
|
job,
|
|
|
testListener,
|
|
|
mock(PersistentTasksService.class),
|
|
@@ -266,6 +275,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
public void testJobAlreadyInMapping() {
|
|
|
+ final var projectId = randomProjectIdOrDefault();
|
|
|
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random(), "foo"), Collections.emptyMap());
|
|
|
|
|
|
ActionListener<AcknowledgedResponse> testListener = ActionListener.wrap(response -> {
|
|
@@ -295,6 +305,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture());
|
|
|
|
|
|
TransportPutRollupJobAction.updateMapping(
|
|
|
+ projectId,
|
|
|
job,
|
|
|
testListener,
|
|
|
mock(PersistentTasksService.class),
|
|
@@ -307,6 +318,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
public void testAddJobToMapping() {
|
|
|
+ final var projectId = randomProjectIdOrDefault();
|
|
|
final RollupJobConfig unrelatedJob = ConfigTestHelpers.randomRollupJobConfig(
|
|
|
random(),
|
|
|
ESTestCase.randomAlphaOfLength(10),
|
|
@@ -348,6 +360,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
}).when(client).execute(eq(TransportPutMappingAction.TYPE), any(PutMappingRequest.class), requestCaptor2.capture());
|
|
|
|
|
|
TransportPutRollupJobAction.updateMapping(
|
|
|
+ projectId,
|
|
|
job,
|
|
|
testListener,
|
|
|
mock(PersistentTasksService.class),
|
|
@@ -361,6 +374,7 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
public void testTaskAlreadyExists() {
|
|
|
+ final var projectId = randomProjectIdOrDefault();
|
|
|
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random(), "foo"), Collections.emptyMap());
|
|
|
|
|
|
ActionListener<AcknowledgedResponse> testListener = ActionListener.wrap(response -> {
|
|
@@ -374,14 +388,29 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
requestCaptor.getValue().onFailure(new ResourceAlreadyExistsException(job.getConfig().getRollupIndex()));
|
|
|
return null;
|
|
|
}).when(tasksService)
|
|
|
- .sendStartRequest(eq(job.getConfig().getId()), eq(RollupField.TASK_NAME), eq(job), isNotNull(), requestCaptor.capture());
|
|
|
+ .sendProjectStartRequest(
|
|
|
+ eq(projectId),
|
|
|
+ eq(job.getConfig().getId()),
|
|
|
+ eq(RollupField.TASK_NAME),
|
|
|
+ eq(job),
|
|
|
+ isNotNull(),
|
|
|
+ requestCaptor.capture()
|
|
|
+ );
|
|
|
|
|
|
- TransportPutRollupJobAction.startPersistentTask(job, testListener, tasksService);
|
|
|
- verify(tasksService).sendStartRequest(eq(job.getConfig().getId()), eq(RollupField.TASK_NAME), eq(job), isNotNull(), any());
|
|
|
+ TransportPutRollupJobAction.startPersistentTask(projectId, job, testListener, tasksService);
|
|
|
+ verify(tasksService).sendProjectStartRequest(
|
|
|
+ eq(projectId),
|
|
|
+ eq(job.getConfig().getId()),
|
|
|
+ eq(RollupField.TASK_NAME),
|
|
|
+ eq(job),
|
|
|
+ isNotNull(),
|
|
|
+ any()
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
public void testStartTask() {
|
|
|
+ final var projectId = randomProjectIdOrDefault();
|
|
|
RollupJob job = new RollupJob(ConfigTestHelpers.randomRollupJobConfig(random()), Collections.emptyMap());
|
|
|
|
|
|
ActionListener<AcknowledgedResponse> testListener = ActionListener.wrap(response -> {
|
|
@@ -402,7 +431,14 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
requestCaptor.getValue().onResponse(response);
|
|
|
return null;
|
|
|
}).when(tasksService)
|
|
|
- .sendStartRequest(eq(job.getConfig().getId()), eq(RollupField.TASK_NAME), eq(job), isNotNull(), requestCaptor.capture());
|
|
|
+ .sendProjectStartRequest(
|
|
|
+ eq(projectId),
|
|
|
+ eq(job.getConfig().getId()),
|
|
|
+ eq(RollupField.TASK_NAME),
|
|
|
+ eq(job),
|
|
|
+ isNotNull(),
|
|
|
+ requestCaptor.capture()
|
|
|
+ );
|
|
|
|
|
|
ArgumentCaptor<PersistentTasksService.WaitForPersistentTaskListener> requestCaptor2 = ArgumentCaptor.forClass(
|
|
|
PersistentTasksService.WaitForPersistentTaskListener.class
|
|
@@ -411,11 +447,19 @@ public class PutJobStateMachineTests extends ESTestCase {
|
|
|
// Bail here with an error, further testing will happen through tests of #startPersistentTask
|
|
|
requestCaptor2.getValue().onFailure(new RuntimeException("Ending"));
|
|
|
return null;
|
|
|
- }).when(tasksService).waitForPersistentTaskCondition(eq(job.getConfig().getId()), any(), any(), requestCaptor2.capture());
|
|
|
-
|
|
|
- TransportPutRollupJobAction.startPersistentTask(job, testListener, tasksService);
|
|
|
- verify(tasksService).sendStartRequest(eq(job.getConfig().getId()), eq(RollupField.TASK_NAME), eq(job), isNotNull(), any());
|
|
|
- verify(tasksService).waitForPersistentTaskCondition(eq(job.getConfig().getId()), any(), any(), any());
|
|
|
+ }).when(tasksService)
|
|
|
+ .waitForPersistentTaskCondition(eq(projectId), eq(job.getConfig().getId()), any(), any(), requestCaptor2.capture());
|
|
|
+
|
|
|
+ TransportPutRollupJobAction.startPersistentTask(projectId, job, testListener, tasksService);
|
|
|
+ verify(tasksService).sendProjectStartRequest(
|
|
|
+ eq(projectId),
|
|
|
+ eq(job.getConfig().getId()),
|
|
|
+ eq(RollupField.TASK_NAME),
|
|
|
+ eq(job),
|
|
|
+ isNotNull(),
|
|
|
+ any()
|
|
|
+ );
|
|
|
+ verify(tasksService).waitForPersistentTaskCondition(eq(projectId), eq(job.getConfig().getId()), any(), any(), any());
|
|
|
}
|
|
|
|
|
|
public void testDeprecatedTimeZone() {
|