use of org.graylog2.plugin.inputs.util.ThroughputCounter in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method getChildChannelHandlersFailsIfTempDirIsNotWritable.
@Test
public void getChildChannelHandlersFailsIfTempDirIsNotWritable() throws IOException {
final File tmpDir = temporaryFolder.newFolder();
assumeTrue(tmpDir.setWritable(false));
assumeFalse(tmpDir.canWrite());
System.setProperty("java.io.tmpdir", tmpDir.getAbsolutePath());
final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, eventLoopGroup, eventLoopGroupFactory, nettyTransportConfiguration, tlsConfiguration) {
};
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Couldn't write to temporary directory: " + tmpDir.getAbsolutePath());
transport.getChildChannelHandlers(input);
}
use of org.graylog2.plugin.inputs.util.ThroughputCounter in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method setUp.
@Before
public void setUp() {
eventLoopGroup = new NioEventLoopGroup();
eventLoopGroupFactory = new EventLoopGroupFactory(nettyTransportConfiguration);
throughputCounter = new ThroughputCounter(eventLoopGroup);
localRegistry = new LocalMetricRegistry();
}
use of org.graylog2.plugin.inputs.util.ThroughputCounter in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method getChildChannelHandlersFailsIfTempDirDoesNotExist.
@Test
public void getChildChannelHandlersFailsIfTempDirDoesNotExist() throws IOException {
final File tmpDir = temporaryFolder.newFolder();
assumeTrue(tmpDir.delete());
System.setProperty("java.io.tmpdir", tmpDir.getAbsolutePath());
final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "localhost", "port", 12345, "tls_enable", true));
final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, eventLoopGroup, eventLoopGroupFactory, nettyTransportConfiguration, tlsConfiguration) {
};
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Couldn't write to temporary directory: " + tmpDir.getAbsolutePath());
transport.getChildChannelHandlers(input);
}
use of org.graylog2.plugin.inputs.util.ThroughputCounter in project graylog2-server by Graylog2.
the class AbstractTcpTransportTest method testConnectionCounter.
@Test
@Ignore("Disabled test due to being unreliable. For details see https://github.com/Graylog2/graylog2-server/issues/4791.")
public void testConnectionCounter() throws Exception {
final Configuration configuration = new Configuration(ImmutableMap.of("bind_address", "127.0.0.1", "port", 0));
final AbstractTcpTransport transport = new AbstractTcpTransport(configuration, throughputCounter, localRegistry, eventLoopGroup, eventLoopGroupFactory, nettyTransportConfiguration, tlsConfiguration) {
};
transport.launch(input);
await().atMost(5, TimeUnit.SECONDS).until(() -> transport.getLocalAddress() != null);
final InetSocketAddress localAddress = (InetSocketAddress) transport.getLocalAddress();
assertThat(localAddress).isNotNull();
final ChannelFuture future1 = clientChannel(localAddress.getHostString(), localAddress.getPort()).channel().writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE).syncUninterruptibly();
final ChannelFuture future2 = clientChannel(localAddress.getHostString(), localAddress.getPort()).channel().writeAndFlush(Unpooled.EMPTY_BUFFER).syncUninterruptibly();
// TODO: Get rid of this (arbitrary) wait time
Thread.sleep(100L);
assertThat(future1.channel().isActive()).isFalse();
assertThat(future2.channel().isActive()).isTrue();
assertThat(localRegistry.getGauges().get("open_connections").getValue()).isEqualTo(1);
assertThat(localRegistry.getGauges().get("total_connections").getValue()).isEqualTo(2L);
future2.channel().close().syncUninterruptibly();
// TODO: Get rid of this (arbitrary) wait time
Thread.sleep(100L);
assertThat(future1.channel().isActive()).isFalse();
assertThat(future2.channel().isActive()).isFalse();
assertThat(localRegistry.getGauges().get("open_connections").getValue()).isEqualTo(0);
assertThat(localRegistry.getGauges().get("total_connections").getValue()).isEqualTo(2L);
}
Aggregations