Search in sources :

Example 81 with Configuration

use of org.graylog2.Configuration in project graylog2-server by Graylog2.

the class InputFacadeTest method resolveEntity.

@Test
@MongoDBFixtures("InputFacadeTest.json")
public void resolveEntity() {
    final Map<String, Object> configuration = new HashMap<>();
    configuration.put("override_source", null);
    configuration.put("recv_buffer_size", 262144);
    configuration.put("bind_address", "127.0.0.1");
    configuration.put("port", 5555);
    configuration.put("number_worker_threads", 8);
    final Entity entity = EntityV1.builder().id(ModelId.of("5acc84f84b900a4ff290d9a7")).type(ModelTypes.INPUT_V1).data(objectMapper.convertValue(InputEntity.create(ValueReference.of("Local Raw UDP"), ReferenceMapUtils.toReferenceMap(configuration), Collections.emptyMap(), ValueReference.of("org.graylog2.inputs.raw.udp.RawUDPInput"), ValueReference.of(false), Collections.emptyList()), JsonNode.class)).build();
    final Graph<Entity> graph = facade.resolveForInstallation(entity, Collections.emptyMap(), Collections.emptyMap());
    assertThat(graph.nodes()).containsOnly(entity);
}
Also used : NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) ConverterEntity(org.graylog2.contentpacks.model.entities.ConverterEntity) InputEntity(org.graylog2.contentpacks.model.entities.InputEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) ExtractorEntity(org.graylog2.contentpacks.model.entities.ExtractorEntity) LookupTableEntity(org.graylog2.contentpacks.model.entities.LookupTableEntity) GrokPatternEntity(org.graylog2.contentpacks.model.entities.GrokPatternEntity) HashMap(java.util.HashMap) MongoDBFixtures(org.graylog.testing.mongodb.MongoDBFixtures) Test(org.junit.Test)

Example 82 with Configuration

use of org.graylog2.Configuration in project graylog2-server by Graylog2.

the class OutputFacadeTest method exportEntity.

@Test
public void exportEntity() {
    final ImmutableMap<String, Object> configuration = ImmutableMap.of("some-setting", "foobar");
    final OutputImpl output = OutputImpl.create("01234567890", "Output Title", "org.graylog2.outputs.LoggingOutput", "admin", configuration, new Date(0L), null);
    final EntityDescriptor descriptor = EntityDescriptor.create(output.getId(), ModelTypes.OUTPUT_V1);
    final EntityDescriptorIds entityDescriptorIds = EntityDescriptorIds.of(descriptor);
    final Entity entity = facade.exportNativeEntity(output, entityDescriptorIds);
    assertThat(entity).isInstanceOf(EntityV1.class);
    assertThat(entity.id()).isEqualTo(ModelId.of(entityDescriptorIds.get(descriptor).orElse(null)));
    assertThat(entity.type()).isEqualTo(ModelTypes.OUTPUT_V1);
    final EntityV1 entityV1 = (EntityV1) entity;
    final OutputEntity outputEntity = objectMapper.convertValue(entityV1.data(), OutputEntity.class);
    assertThat(outputEntity.title()).isEqualTo(ValueReference.of("Output Title"));
    assertThat(outputEntity.type()).isEqualTo(ValueReference.of("org.graylog2.outputs.LoggingOutput"));
    assertThat(outputEntity.configuration()).containsEntry("some-setting", ValueReference.of("foobar"));
}
Also used : EntityV1(org.graylog2.contentpacks.model.entities.EntityV1) EntityDescriptor(org.graylog2.contentpacks.model.entities.EntityDescriptor) NativeEntity(org.graylog2.contentpacks.model.entities.NativeEntity) Entity(org.graylog2.contentpacks.model.entities.Entity) OutputEntity(org.graylog2.contentpacks.model.entities.OutputEntity) EntityDescriptorIds(org.graylog2.contentpacks.EntityDescriptorIds) OutputEntity(org.graylog2.contentpacks.model.entities.OutputEntity) OutputImpl(org.graylog2.streams.OutputImpl) Date(java.util.Date) Test(org.junit.Test)

Example 83 with Configuration

use of org.graylog2.Configuration in project graylog2-server by Graylog2.

the class FormattedEmailAlertSenderTest method buildBodyUsesCustomBody.

@Test
public void buildBodyUsesCustomBody() throws Exception {
    Configuration pluginConfig = new Configuration(Collections.<String, Object>singletonMap("body", "Test: ${stream.id}"));
    emailAlertSender.initialize(pluginConfig);
    Stream stream = mock(Stream.class);
    when(stream.getId()).thenReturn("123456");
    AlertCondition.CheckResult checkResult = mock(AbstractAlertCondition.CheckResult.class);
    String body = emailAlertSender.buildBody(stream, checkResult, Collections.<Message>emptyList());
    assertThat(body).isEqualTo("Test: 123456");
}
Also used : Configuration(org.graylog2.plugin.configuration.Configuration) EmailConfiguration(org.graylog2.configuration.EmailConfiguration) AlertCondition(org.graylog2.plugin.alarms.AlertCondition) Stream(org.graylog2.plugin.streams.Stream) Test(org.junit.Test)

Example 84 with Configuration

use of org.graylog2.Configuration in project graylog2-server by Graylog2.

the class ExposedConfigurationTest method testSerialization.

@Test
public void testSerialization() throws Exception {
    final Configuration configuration = new Configuration();
    final ExposedConfiguration c = ExposedConfiguration.create(configuration);
    final String json = objectMapper.writeValueAsString(c);
    assertThat((int) JsonPath.read(json, "$.inputbuffer_processors")).isEqualTo(c.inputBufferProcessors());
    assertThat((int) JsonPath.read(json, "$.processbuffer_processors")).isEqualTo(c.processBufferProcessors());
    assertThat((int) JsonPath.read(json, "$.outputbuffer_processors")).isEqualTo(c.outputBufferProcessors());
    assertThat((String) JsonPath.read(json, "$.processor_wait_strategy")).isEqualTo(c.processorWaitStrategy());
    assertThat((String) JsonPath.read(json, "$.inputbuffer_wait_strategy")).isEqualTo(c.inputBufferWaitStrategy());
    assertThat((int) JsonPath.read(json, "$.inputbuffer_ring_size")).isEqualTo(c.inputBufferRingSize());
    assertThat((int) JsonPath.read(json, "$.ring_size")).isEqualTo(c.ringSize());
    assertThat(URI.create(JsonPath.read(json, "$.bin_dir"))).isEqualTo(c.binDir().toUri());
    assertThat(URI.create(JsonPath.read(json, "$.data_dir"))).isEqualTo(c.dataDir().toUri());
    assertThat(URI.create(JsonPath.read(json, "$.plugin_dir"))).isEqualTo(c.pluginDir().toUri());
    assertThat((String) JsonPath.read(json, "$.node_id_file")).isEqualTo(c.nodeIdFile());
    assertThat((boolean) JsonPath.read(json, "$.allow_highlighting")).isEqualTo(c.allowHighlighting());
    assertThat((boolean) JsonPath.read(json, "$.allow_leading_wildcard_searches")).isEqualTo(c.allowLeadingWildcardSearches());
    assertThat((int) JsonPath.read(json, "$.stream_processing_timeout")).isEqualTo((int) c.streamProcessingTimeout());
    assertThat((int) JsonPath.read(json, "$.stream_processing_max_faults")).isEqualTo(c.streamProcessingMaxFaults());
    assertThat((int) JsonPath.read(json, "$.output_module_timeout")).isEqualTo((int) c.outputModuleTimeout());
    assertThat((int) JsonPath.read(json, "$.stale_leader_timeout")).isEqualTo(c.staleLeaderTimeout());
    assertThat((int) JsonPath.read(json, "$.stale_master_timeout")).isEqualTo(c.staleLeaderTimeout());
    assertThat((String) JsonPath.read(json, "$.gc_warning_threshold")).isEqualTo(c.gcWarningThreshold());
}
Also used : Configuration(org.graylog2.Configuration) Test(org.junit.Test)

Example 85 with Configuration

use of org.graylog2.Configuration in project graylog2-server by Graylog2.

the class ExposedConfigurationTest method testCreateWithConfiguration.

@Test
public void testCreateWithConfiguration() throws Exception {
    final Configuration configuration = new Configuration();
    final ExposedConfiguration c = ExposedConfiguration.create(configuration);
    assertThat(c.inputBufferProcessors()).isEqualTo(configuration.getInputbufferProcessors());
    assertThat(c.processBufferProcessors()).isEqualTo(configuration.getProcessBufferProcessors());
    assertThat(c.outputBufferProcessors()).isEqualTo(configuration.getOutputBufferProcessors());
    assertThat(c.processorWaitStrategy()).isEqualTo(configuration.getProcessorWaitStrategy().getClass().getName());
    assertThat(c.inputBufferWaitStrategy()).isEqualTo(configuration.getInputBufferWaitStrategy().getClass().getName());
    assertThat(c.inputBufferRingSize()).isEqualTo(configuration.getInputBufferRingSize());
    assertThat(c.ringSize()).isEqualTo(configuration.getRingSize());
    assertThat(c.binDir()).isEqualTo(configuration.getBinDir());
    assertThat(c.dataDir()).isEqualTo(configuration.getDataDir());
    assertThat(c.pluginDir()).isEqualTo(configuration.getPluginDir());
    assertThat(c.nodeIdFile()).isEqualTo(configuration.getNodeIdFile());
    assertThat(c.allowHighlighting()).isEqualTo(configuration.isAllowHighlighting());
    assertThat(c.allowLeadingWildcardSearches()).isEqualTo(configuration.isAllowLeadingWildcardSearches());
    assertThat(c.streamProcessingTimeout()).isEqualTo(configuration.getStreamProcessingTimeout());
    assertThat(c.streamProcessingMaxFaults()).isEqualTo(configuration.getStreamProcessingMaxFaults());
    assertThat(c.outputModuleTimeout()).isEqualTo(configuration.getOutputModuleTimeout());
    assertThat(c.staleLeaderTimeout()).isEqualTo(configuration.getStaleLeaderTimeout());
    // noinspection deprecation
    assertThat(c.staleMasterTimeout()).isEqualTo(configuration.getStaleLeaderTimeout());
    assertThat(c.gcWarningThreshold()).isEqualTo(configuration.getGcWarningThreshold().toString());
}
Also used : Configuration(org.graylog2.Configuration) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)67 Configuration (org.graylog2.plugin.configuration.Configuration)46 Configuration (org.apache.commons.configuration2.Configuration)35 ApiOperation (io.swagger.annotations.ApiOperation)31 Timed (com.codahale.metrics.annotation.Timed)23 AuditEvent (org.graylog2.audit.jersey.AuditEvent)23 Path (javax.ws.rs.Path)22 BadRequestException (javax.ws.rs.BadRequestException)21 MessageInput (org.graylog2.plugin.inputs.MessageInput)18 ConfigurationRequest (org.graylog2.plugin.configuration.ConfigurationRequest)17 AlertCondition (org.graylog2.plugin.alarms.AlertCondition)15 Stream (org.graylog2.plugin.streams.Stream)15 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)14 File (java.io.File)14 Consumes (javax.ws.rs.Consumes)14 DateTime (org.joda.time.DateTime)14 POST (javax.ws.rs.POST)13 Produces (javax.ws.rs.Produces)13 Configuration (org.graylog2.Configuration)13 ApiResponses (io.swagger.annotations.ApiResponses)12