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);
}
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"));
}
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");
}
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());
}
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());
}
Aggregations