use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class InputFacadeTest method resolveNativeEntityLookupTable.
@Test
@MongoDBFixtures("InputFacadeTest.json")
public void resolveNativeEntityLookupTable() throws NotFoundException {
when(lookupuptableBuilder.lookupTable("whois")).thenReturn(lookupuptableBuilder);
when(lookupuptableBuilder.lookupTable("tor-exit-node-list")).thenReturn(lookupuptableBuilder);
when(lookupuptableBuilder.build()).thenReturn(lookupTable);
when(lookupTableService.newBuilder()).thenReturn(lookupuptableBuilder);
when(lookupTableService.hasTable("whois")).thenReturn(true);
when(lookupTableService.hasTable("tor-exit-node-list")).thenReturn(true);
when(lookupTableWhois.id()).thenReturn("dead-beef");
when(dbLookupTableService.get("whois")).thenReturn(Optional.of(lookupTableWhois));
when(lookupTableTor.id()).thenReturn("dead-feed");
when(dbLookupTableService.get("tor-exit-node-list")).thenReturn(Optional.of(lookupTableTor));
final Input input = inputService.find("5ae2eb0a3d27464477f0fd8b");
EntityDescriptor entityDescriptor = EntityDescriptor.create(ModelId.of(input.getId()), ModelTypes.INPUT_V1);
EntityDescriptor expectedEntitiyDescriptorWhois = EntityDescriptor.create(ModelId.of("dead-beef"), ModelTypes.LOOKUP_TABLE_V1);
EntityDescriptor expectedEntitiyDescriptorTor = EntityDescriptor.create(ModelId.of("dead-feed"), ModelTypes.LOOKUP_TABLE_V1);
Graph<EntityDescriptor> graph = facade.resolveNativeEntity(entityDescriptor);
assertThat(graph.nodes()).contains(expectedEntitiyDescriptorWhois);
assertThat(graph.nodes()).contains(expectedEntitiyDescriptorTor);
}
use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class ContentPackInstallationRequestTest method testSerialisation.
@Test
public void testSerialisation() {
final ImmutableMap<String, ValueReference> parameters = ImmutableMap.of("param1", ValueReference.of("string"), "param2", ValueReference.of(42), "param3", ValueReference.of(3.14d), "param4", ValueReference.of(true));
final ContentPackInstallationRequest request = ContentPackInstallationRequest.create(parameters, "comment");
final JsonNode node = objectMapper.valueToTree(request);
assertThat(node.path("comment").asText()).isEqualTo("comment");
assertThat(node.path("parameters").path("param1").path("@type").asText()).isEqualTo("string");
assertThat(node.path("parameters").path("param1").path("@value").asText()).isEqualTo("string");
assertThat(node.path("parameters").path("param2").path("@type").asText()).isEqualTo("integer");
assertThat(node.path("parameters").path("param2").path("@value").asInt()).isEqualTo(42);
assertThat(node.path("parameters").path("param3").path("@type").asText()).isEqualTo("double");
assertThat(node.path("parameters").path("param3").path("@value").asDouble()).isEqualTo(3.14d);
assertThat(node.path("parameters").path("param4").path("@type").asText()).isEqualTo("boolean");
assertThat(node.path("parameters").path("param4").path("@value").asBoolean()).isEqualTo(true);
}
use of org.graylog2.indexer.cluster.Node in project graylog2-server by Graylog2.
the class LocalKafkaJournalTest method setUp.
@Before
public void setUp() throws IOException {
scheduler = new ScheduledThreadPoolExecutor(1);
scheduler.prestartCoreThread();
journalDirectory = temporaryFolder.newFolder();
final File nodeId = temporaryFolder.newFile("node-id");
Files.write(nodeId.toPath(), UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8));
final Configuration configuration = new Configuration() {
@Override
public String getNodeIdFile() {
return nodeId.getAbsolutePath();
}
};
serverStatus = new ServerStatus(configuration, EnumSet.of(ServerStatus.Capability.SERVER), new EventBus("KafkaJournalTest"), NullAuditEventSender::new);
}
use of org.graylog2.indexer.cluster.Node 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);
}
use of org.graylog2.indexer.cluster.Node 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);
}
Aggregations