Search in sources :

Example 46 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class InputEventListenerTest method inputUpdatedRestartsGlobalInputOnAnyNode.

@Test
public void inputUpdatedRestartsGlobalInputOnAnyNode() throws Exception {
    final String inputId = "input-id";
    final Input input = mock(Input.class);
    @SuppressWarnings("unchecked") final IOState<MessageInput> inputState = mock(IOState.class);
    when(inputState.getState()).thenReturn(IOState.Type.RUNNING);
    when(inputService.find(inputId)).thenReturn(input);
    when(inputRegistry.getInputState(inputId)).thenReturn(inputState);
    when(nodeId.toString()).thenReturn("node-id");
    when(input.getNodeId()).thenReturn("other-node-id");
    when(input.isGlobal()).thenReturn(true);
    final MessageInput messageInput = mock(MessageInput.class);
    when(inputService.getMessageInput(input)).thenReturn(messageInput);
    listener.inputUpdated(InputUpdated.create(inputId));
    verify(inputLauncher, times(1)).launch(messageInput);
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) Test(org.junit.Test)

Example 47 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class InputEventListenerTest method inputCreatedStartsLocalInputOnLocalNode.

@Test
public void inputCreatedStartsLocalInputOnLocalNode() throws Exception {
    final String inputId = "input-id";
    final Input input = mock(Input.class);
    when(inputService.find(inputId)).thenReturn(input);
    when(nodeId.toString()).thenReturn("node-id");
    when(input.getNodeId()).thenReturn("node-id");
    when(input.isGlobal()).thenReturn(false);
    final MessageInput messageInput = mock(MessageInput.class);
    when(inputService.getMessageInput(input)).thenReturn(messageInput);
    listener.inputCreated(InputCreated.create(inputId));
    verify(inputLauncher, times(1)).launch(messageInput);
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) Test(org.junit.Test)

Example 48 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class InputEventListenerTest method inputUpdatedRestartsLocalInputOnLocalNode.

@Test
public void inputUpdatedRestartsLocalInputOnLocalNode() throws Exception {
    final String inputId = "input-id";
    final Input input = mock(Input.class);
    @SuppressWarnings("unchecked") final IOState<MessageInput> inputState = mock(IOState.class);
    when(inputState.getState()).thenReturn(IOState.Type.RUNNING);
    when(inputService.find(inputId)).thenReturn(input);
    when(inputRegistry.getInputState(inputId)).thenReturn(inputState);
    when(nodeId.toString()).thenReturn("node-id");
    when(input.getNodeId()).thenReturn("node-id");
    when(input.isGlobal()).thenReturn(false);
    final MessageInput messageInput = mock(MessageInput.class);
    when(inputService.getMessageInput(input)).thenReturn(messageInput);
    listener.inputUpdated(InputUpdated.create(inputId));
    verify(inputLauncher, times(1)).launch(messageInput);
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) Test(org.junit.Test)

Example 49 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class InputEventListenerTest method inputCreatedStopsInputIfItIsRunning.

@Test
public void inputCreatedStopsInputIfItIsRunning() throws Exception {
    final String inputId = "input-id";
    final Input input = mock(Input.class);
    @SuppressWarnings("unchecked") final IOState<MessageInput> inputState = mock(IOState.class);
    when(inputService.find(inputId)).thenReturn(input);
    when(inputRegistry.getInputState(inputId)).thenReturn(inputState);
    listener.inputCreated(InputCreated.create(inputId));
    verify(inputRegistry, times(1)).remove(inputState);
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) Test(org.junit.Test)

Example 50 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class IOStateTest method testNotEqualIfDifferentState.

@Test
public void testNotEqualIfDifferentState() throws Exception {
    EventBus eventBus = mock(EventBus.class);
    MessageInput messageInput = mock(MessageInput.class);
    IOState<MessageInput> inputState1 = new IOState<>(eventBus, messageInput, IOState.Type.RUNNING);
    IOState<MessageInput> inputState2 = new IOState<>(eventBus, messageInput, IOState.Type.STOPPED);
    assertTrue(inputState1.equals(inputState2));
    assertTrue(inputState2.equals(inputState1));
}
Also used : IOState(org.graylog2.plugin.IOState) EventBus(com.google.common.eventbus.EventBus) Test(org.junit.Test)

Aggregations

MessageInput (org.graylog2.plugin.inputs.MessageInput)47 Test (org.junit.Test)18 Callable (java.util.concurrent.Callable)17 NotFoundException (org.graylog2.database.NotFoundException)10 Configuration (org.graylog2.plugin.configuration.Configuration)9 ChannelHandler (io.netty.channel.ChannelHandler)8 LinkedHashMap (java.util.LinkedHashMap)8 Input (org.graylog2.inputs.Input)8 MisfireException (org.graylog2.plugin.inputs.MisfireException)7 ChannelHandler (org.jboss.netty.channel.ChannelHandler)7 Timed (com.codahale.metrics.annotation.Timed)6 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 EventBus (com.google.common.eventbus.EventBus)5 AuditEvent (org.graylog2.audit.jersey.AuditEvent)5 Subscribe (com.google.common.eventbus.Subscribe)4 Produces (javax.ws.rs.Produces)4 IOState (org.graylog2.plugin.IOState)4 LocalMetricRegistry (org.graylog2.plugin.LocalMetricRegistry)4 Extractor (org.graylog2.plugin.inputs.Extractor)4