Search in sources :

Example 1 with InputLauncher

use of org.graylog2.shared.inputs.InputLauncher in project graylog2-server by Graylog2.

the class InputEventListenerTest method inputCreatedDoesNotStartLocalInputOnAnyNode.

@Test
public void inputCreatedDoesNotStartLocalInputOnAnyNode() 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("other-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, never()).launch(messageInput);
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) Test(org.junit.Test)

Example 2 with InputLauncher

use of org.graylog2.shared.inputs.InputLauncher in project graylog2-server by Graylog2.

the class InputEventListenerTest method inputUpdatedDoesNotStartLocalInputOnLocalNodeIfItWasNotRunning.

@Test
public void inputUpdatedDoesNotStartLocalInputOnLocalNodeIfItWasNotRunning() 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.STOPPED);
    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, never()).launch(messageInput);
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) Test(org.junit.Test)

Example 3 with InputLauncher

use of org.graylog2.shared.inputs.InputLauncher in project graylog2-server by Graylog2.

the class InputEventListenerTest method inputUpdatedDoesNotStartLocalInputOnOtherNode.

@Test
public void inputUpdatedDoesNotStartLocalInputOnOtherNode() 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(nodeId.toString()).thenReturn("node-id");
    when(input.getNodeId()).thenReturn("other-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, never()).launch(messageInput);
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) Test(org.junit.Test)

Example 4 with InputLauncher

use of org.graylog2.shared.inputs.InputLauncher in project graylog2-server by Graylog2.

the class InputEventListenerTest method inputCreatedStartsGlobalInputOnOtherNode.

@Test
public void inputCreatedStartsGlobalInputOnOtherNode() 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("other-node-id");
    when(input.isGlobal()).thenReturn(true);
    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 5 with InputLauncher

use of org.graylog2.shared.inputs.InputLauncher 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)

Aggregations

MessageInput (org.graylog2.plugin.inputs.MessageInput)7 Test (org.junit.Test)7