Search in sources :

Example 26 with IndexSetService

use of org.graylog2.indexer.indexset.IndexSetService in project graylog2-server by Graylog2.

the class IndexSetsResourceTest method updateFailsWhenDefaultSetIsSetReadOnly.

@Test
public void updateFailsWhenDefaultSetIsSetReadOnly() throws Exception {
    final String defaultIndexSetId = "defaultIndexSet";
    final IndexSetConfig defaultIndexSetConfig = IndexSetConfig.create(defaultIndexSetId, "title", "description", true, "prefix", 1, 0, MessageCountRotationStrategy.class.getCanonicalName(), MessageCountRotationStrategyConfig.create(1000), NoopRetentionStrategy.class.getCanonicalName(), NoopRetentionStrategyConfig.create(1), ZonedDateTime.of(2016, 10, 10, 12, 0, 0, 0, ZoneOffset.UTC), "standard", "index-template", 1, false);
    when(indexSetService.getDefault()).thenReturn(defaultIndexSetConfig);
    when(indexSetService.get(defaultIndexSetId)).thenReturn(Optional.of(defaultIndexSetConfig));
    final IndexSetConfig defaultIndexSetConfigSetReadOnly = defaultIndexSetConfig.toBuilder().isWritable(false).build();
    expectedException.expect(ClientErrorException.class);
    expectedException.expectMessage("Default index set must be writable.");
    try {
        indexSetsResource.update("defaultIndexSet", IndexSetUpdateRequest.fromIndexSetConfig(defaultIndexSetConfigSetReadOnly));
    } finally {
        verify(indexSetService, never()).save(any());
    }
}
Also used : NoopRetentionStrategy(org.graylog2.indexer.retention.strategies.NoopRetentionStrategy) MessageCountRotationStrategy(org.graylog2.indexer.rotation.strategies.MessageCountRotationStrategy) IndexSetConfig(org.graylog2.indexer.indexset.IndexSetConfig) DefaultIndexSetConfig(org.graylog2.indexer.indexset.DefaultIndexSetConfig) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)25 IndexSetConfig (org.graylog2.indexer.indexset.IndexSetConfig)24 DefaultIndexSetConfig (org.graylog2.indexer.indexset.DefaultIndexSetConfig)12 NoopRetentionStrategy (org.graylog2.indexer.retention.strategies.NoopRetentionStrategy)8 MessageCountRotationStrategy (org.graylog2.indexer.rotation.strategies.MessageCountRotationStrategy)8 RetentionStrategyConfig (org.graylog2.plugin.indexer.retention.RetentionStrategyConfig)6 RotationStrategyConfig (org.graylog2.plugin.indexer.rotation.RotationStrategyConfig)6 DeletionRetentionStrategyConfig (org.graylog2.indexer.retention.strategies.DeletionRetentionStrategyConfig)5 MessageCountRotationStrategyConfig (org.graylog2.indexer.rotation.strategies.MessageCountRotationStrategyConfig)5 IndexSet (org.graylog2.indexer.IndexSet)3 IndexSetResponse (org.graylog2.rest.resources.system.indexer.responses.IndexSetResponse)3 IndexSetSummary (org.graylog2.rest.resources.system.indexer.responses.IndexSetSummary)3 IndexSetCreatedEvent (org.graylog2.indexer.indexset.events.IndexSetCreatedEvent)2 IndexSetCleanupJob (org.graylog2.indexer.indices.jobs.IndexSetCleanupJob)2 ClusterConfigServiceImpl (org.graylog2.cluster.ClusterConfigServiceImpl)1 ClusterEventBus (org.graylog2.events.ClusterEventBus)1 IndexSetDeletedEvent (org.graylog2.indexer.indexset.events.IndexSetDeletedEvent)1 ChainingClassLoader (org.graylog2.shared.plugins.ChainingClassLoader)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1