use of org.graylog2.system.jobs.SystemJobManager in project graylog2-server by Graylog2.
the class MongoIndexSetTest method cycleSetsOldIndexToReadOnly.
@Test
public void cycleSetsOldIndexToReadOnly() throws SystemJobConcurrencyException {
final String newIndexName = "graylog_1";
final String oldIndexName = "graylog_0";
final Map<String, Set<String>> indexNameAliases = ImmutableMap.of(oldIndexName, Collections.singleton("graylog_deflector"));
when(indices.getIndexNamesAndAliases(anyString())).thenReturn(indexNameAliases);
when(indices.create(newIndexName, mongoIndexSet)).thenReturn(true);
when(indices.waitForRecovery(newIndexName)).thenReturn(ClusterHealthStatus.GREEN);
final SetIndexReadOnlyAndCalculateRangeJob rangeJob = mock(SetIndexReadOnlyAndCalculateRangeJob.class);
when(jobFactory.create(oldIndexName)).thenReturn(rangeJob);
final MongoIndexSet mongoIndexSet = new MongoIndexSet(config, indices, nodeId, indexRangeService, auditEventSender, systemJobManager, jobFactory, activityWriter);
mongoIndexSet.cycle();
verify(jobFactory, times(1)).create(oldIndexName);
verify(systemJobManager, times(1)).submitWithDelay(rangeJob, 30L, TimeUnit.SECONDS);
}
use of org.graylog2.system.jobs.SystemJobManager in project graylog2-server by Graylog2.
the class IndexSetsResourceTest method deleteDefaultIndexSet.
@Test
public void deleteDefaultIndexSet() throws Exception {
final IndexSet indexSet = mock(IndexSet.class);
final IndexSetConfig indexSetConfig = mock(IndexSetConfig.class);
when(indexSet.getConfig()).thenReturn(indexSetConfig);
when(indexSetRegistry.getDefault()).thenReturn(indexSet);
when(indexSetRegistry.get("id")).thenReturn(Optional.of(indexSet));
when(indexSetCleanupJobFactory.create(indexSet)).thenReturn(mock(IndexSetCleanupJob.class));
when(indexSetService.delete("id")).thenReturn(1);
expectedException.expect(BadRequestException.class);
indexSetsResource.delete("id", false);
indexSetsResource.delete("id", true);
verify(indexSetService, never()).delete("id");
verify(systemJobManager, never()).submit(any(IndexSetCleanupJob.class));
verifyNoMoreInteractions(indexSetService);
}
use of org.graylog2.system.jobs.SystemJobManager in project graylog2-server by Graylog2.
the class IndexSetsResourceTest method delete.
@Test
public void delete() throws Exception {
final IndexSet indexSet = mock(IndexSet.class);
final IndexSetConfig indexSetConfig = mock(IndexSetConfig.class);
when(indexSet.getConfig()).thenReturn(indexSetConfig);
when(indexSetRegistry.get("id")).thenReturn(Optional.of(indexSet));
when(indexSetCleanupJobFactory.create(indexSet)).thenReturn(mock(IndexSetCleanupJob.class));
when(indexSetRegistry.getDefault()).thenReturn(null);
when(indexSetService.delete("id")).thenReturn(1);
indexSetsResource.delete("id", false);
indexSetsResource.delete("id", true);
verify(indexSetRegistry, times(2)).getDefault();
verify(indexSetService, times(2)).delete("id");
verify(systemJobManager, times(1)).submit(any(IndexSetCleanupJob.class));
verifyNoMoreInteractions(indexSetService);
}
Aggregations