Class SelectorTest

java.lang.Object
org.apache.kafka.common.network.SelectorTest
Direct Known Subclasses:
ReversableSelectorTest, SslSelectorTest

@Timeout(240L) public class SelectorTest extends Object
A set of tests for the selector. These use a test harness that runs a simple socket server that echos back responses.
  • Constructor Details

    • SelectorTest

      public SelectorTest()
  • Method Details

    • setUp

      @BeforeEach public void setUp() throws Exception
      Throws:
      Exception
    • tearDown

      @AfterEach public void tearDown() throws Exception
      Throws:
      Exception
    • testServerDisconnect

      @Test public void testServerDisconnect() throws Exception
      Validate that when the server disconnects, a client send ends up with that node in the disconnected list.
      Throws:
      Exception
    • testCantSendWithInProgress

      @Test public void testCantSendWithInProgress() throws Exception
      Sending a request with one already in flight should result in an exception
      Throws:
      Exception
    • testSendWithoutConnecting

      @Test public void testSendWithoutConnecting()
      Sending a request to a node without an existing connection should result in an exception
    • testNoRouteToHost

      @Test public void testNoRouteToHost()
      Sending a request to a node with a bad hostname should result in an exception during connect
    • testConnectionRefused

      @Test public void testConnectionRefused() throws Exception
      Sending a request to a node not listening on that port should result in disconnection
      Throws:
      Exception
    • testNormalOperation

      @Test public void testNormalOperation() throws Exception
      Send multiple requests to several connections in parallel. Validate that responses are received in the order that requests were sent.
      Throws:
      Exception
    • testSendLargeRequest

      @Test public void testSendLargeRequest() throws Exception
      Validate that we can send and receive a message larger than the receive and send buffer size
      Throws:
      Exception
    • testPartialSendAndReceiveReflectedInMetrics

      @Test public void testPartialSendAndReceiveReflectedInMetrics() throws Exception
      Throws:
      Exception
    • testLargeMessageSequence

      @Test public void testLargeMessageSequence() throws Exception
      Throws:
      Exception
    • testEmptyRequest

      @Test public void testEmptyRequest() throws Exception
      Throws:
      Exception
    • testClearCompletedSendsAndReceives

      @Test public void testClearCompletedSendsAndReceives() throws Exception
      Throws:
      Exception
    • testExistingConnectionId

      @Test public void testExistingConnectionId() throws IOException
      Throws:
      IOException
    • testMute

      @Test public void testMute() throws Exception
      Throws:
      Exception
    • testCloseAllChannels

      @Test public void testCloseAllChannels() throws Exception
      Throws:
      Exception
    • registerFailure

      @Test public void registerFailure() throws Exception
      Throws:
      Exception
    • testCloseOldestConnection

      @Test public void testCloseOldestConnection() throws Exception
      Throws:
      Exception
    • testIdleExpiryWithoutReadyKeys

      @Test public void testIdleExpiryWithoutReadyKeys() throws Exception
      Throws:
      Exception
    • testImmediatelyConnectedCleaned

      @Test public void testImmediatelyConnectedCleaned() throws Exception
      Throws:
      Exception
    • testConnectException

      @Test public void testConnectException() throws Exception
      Verify that if Selector#connect fails and throws an Exception, all related objects are cleared immediately before the exception is propagated.
      Throws:
      Exception
    • testExpireConnectionWithPendingReceives

      @Test public void testExpireConnectionWithPendingReceives() throws Exception
      Throws:
      Exception
    • testExpireClosedConnectionWithPendingReceives

      @Disabled @Test public void testExpireClosedConnectionWithPendingReceives() throws Exception
      Verifies that a muted connection closed by peer is expired on idle timeout even if there are pending receives on the socket.
      Throws:
      Exception
    • testGracefulClose

      @Test public void testGracefulClose() throws Exception
      Tests that graceful close of channel processes remaining data from socket read buffers. Since we cannot determine how much data is available in the buffers, this test verifies that multiple receives are completed after server shuts down connections, with retries to tolerate cases where data may not be available in the socket buffer.
      Throws:
      Exception
    • testPartialReceiveGracefulClose

      @Test public void testPartialReceiveGracefulClose() throws Exception
      Tests that graceful close is not delayed if only part of an incoming receive is available in the socket buffer.
      Throws:
      Exception
    • testMuteOnOOM

      @Test public void testMuteOnOOM() throws Exception
      Throws:
      Exception
    • testConnectDisconnectDuringInSinglePoll

      @Test public void testConnectDisconnectDuringInSinglePoll() throws Exception
      Tests that a connect and disconnect in a single poll invocation results in the channel id being in `disconnected`, but not `connected`.
      Throws:
      Exception
    • testOutboundConnectionsCountInConnectionCreationMetric

      @Test public void testOutboundConnectionsCountInConnectionCreationMetric() throws Exception
      Throws:
      Exception
    • testInboundConnectionsCountInConnectionCreationMetric

      @Test public void testInboundConnectionsCountInConnectionCreationMetric() throws Exception
      Throws:
      Exception
    • testConnectionsByClientMetric

      @Test public void testConnectionsByClientMetric() throws Exception
      Throws:
      Exception
    • testLowestPriorityChannel

      @Test public void testLowestPriorityChannel() throws Exception
      Throws:
      Exception
    • testMetricsCleanupOnSelectorClose

      @Test public void testMetricsCleanupOnSelectorClose() throws Exception
      Throws:
      Exception
    • testWriteCompletesSendWithNoBytesWritten

      @Test public void testWriteCompletesSendWithNoBytesWritten() throws IOException
      Throws:
      IOException
    • testChannelCloseWhileProcessingReceives

      @Test public void testChannelCloseWhileProcessingReceives() throws Exception
      Ensure that no errors are thrown if channels are closed while processing multiple completed receives
      Throws:
      Exception
    • testProxyReadyAndDisconnectInSinglePoll

      @Test public void testProxyReadyAndDisconnectInSinglePoll() throws Exception
      Tests that completing proxy protocol and disconnecting in a single poll invocation results in the channel id being in `disconnected`, but not `connected`.
      Throws:
      Exception
    • testThrottledProxyConnection

      @Test public void testThrottledProxyConnection() throws Exception
      Throws:
      Exception
    • testConnectionMaxIdleMs

      @Test public void testConnectionMaxIdleMs() throws Exception
      Throws:
      Exception
    • testChannelWithInvalidSniHostName

      @Test public void testChannelWithInvalidSniHostName() throws Exception
      Throws:
      Exception
    • testChannelWithMissingSniHostName

      @Test public void testChannelWithMissingSniHostName() throws Exception
      Throws:
      Exception
    • testInvalidSniMetricOnAuthenticatedConnection

      @Test public void testInvalidSniMetricOnAuthenticatedConnection() throws Exception
      Throws:
      Exception
    • testInvalidSniMetricOnUnauthenticatedConnection

      @Test public void testInvalidSniMetricOnUnauthenticatedConnection() throws Exception
      Throws:
      Exception
    • testSniRejectionConnectionClosedMetric

      @Test public void testSniRejectionConnectionClosedMetric() throws Exception
      Throws:
      Exception
    • testMissingSniMetricOnAuthenticatedConnection

      @Test public void testMissingSniMetricOnAuthenticatedConnection() throws Exception
      Throws:
      Exception
    • testMissingSniMetricOnUnauthenticatedConnection

      @Test public void testMissingSniMetricOnUnauthenticatedConnection() throws Exception
      Throws:
      Exception
    • testInvalidSniMetricOnSuccessWithoutMultiTenantPrincipal

      @Test public void testInvalidSniMetricOnSuccessWithoutMultiTenantPrincipal() throws Exception
      Throws:
      Exception
    • testSniMetricsKeyedByTenantAndAuthenticationId

      @Test public void testSniMetricsKeyedByTenantAndAuthenticationId() throws Exception
      Throws:
      Exception
    • testCipherMetricHasNoTenantTagBeforeAuth

      @Test public void testCipherMetricHasNoTenantTagBeforeAuth()
    • testSuccessfulMultiTenantAuthSwapsTenantTag

      @Test public void testSuccessfulMultiTenantAuthSwapsTenantTag()
    • testNoSwapWhenCipherNotTracked

      @Test public void testNoSwapWhenCipherNotTracked()
    • testNoSwapWhenTrackedCiphersEmpty

      @Test public void testNoSwapWhenTrackedCiphersEmpty()
    • testCloseDecrementsResolvedTenantKey

      @Test public void testCloseDecrementsResolvedTenantKey()
    • testCloseDecrementsNoTenantKeyWhenAuthNeverHappened

      @Test public void testCloseDecrementsNoTenantKeyWhenAuthNeverHappened()
    • testFailedAuthLeavesTenantUnresolved

      @Test public void testFailedAuthLeavesTenantUnresolved()
    • testMaybeRecordIdempotentForSameTenant

      @Test public void testMaybeRecordIdempotentForSameTenant()
    • testReauthChangesTenant

      @Test public void testReauthChangesTenant()
    • testMaybeRecordNoOpWhenNoCipher

      @Test public void testMaybeRecordNoOpWhenNoCipher()
    • testMaybeRecordCipherSwapNoOpForNonMultiTenantPrincipal

      @Test public void testMaybeRecordCipherSwapNoOpForNonMultiTenantPrincipal()
    • testReverseAndAddDocumentsExistingBehavior

      @Test public void testReverseAndAddDocumentsExistingBehavior()
    • testSuiteCapacityExhaustionDropsNewTenantSilently

      @Test public void testSuiteCapacityExhaustionDropsNewTenantSilently()
    • testProxyProtocolConnectionMetrics

      @Test public void testProxyProtocolConnectionMetrics() throws Exception
      Throws:
      Exception
    • testErrorDuringConnection

      @Test public void testErrorDuringConnection() throws Exception
      Throws:
      Exception
    • verifySelectorEmpty

      public static void verifySelectorEmpty(org.apache.kafka.common.network.Selector selector) throws Exception
      Throws:
      Exception
    • testEarliestMtlsCertExpirationDefaultValue

      @Test public void testEarliestMtlsCertExpirationDefaultValue()
    • testMtlsCertExpirationTracksMinimum

      @Test public void testMtlsCertExpirationTracksMinimum() throws Exception
      Throws:
      Exception
    • testMtlsCertExpirationResetOnLastClose

      @Test public void testMtlsCertExpirationResetOnLastClose() throws Exception
      Throws:
      Exception
    • testMtlsCertExpirationNotResetWhenNonMtlsClosed

      @Test public void testMtlsCertExpirationNotResetWhenNonMtlsClosed() throws Exception
      Throws:
      Exception
    • testMtlsCertExpirationFreshCacheRejectsHigherValue

      @Test public void testMtlsCertExpirationFreshCacheRejectsHigherValue() throws Exception
      Throws:
      Exception
    • testMtlsCertExpirationStaleCacheOverwrite

      @Test public void testMtlsCertExpirationStaleCacheOverwrite() throws Exception
      Throws:
      Exception
    • testMtlsCertExpirationCounterNotAffectedByNonMtlsClose

      @Test public void testMtlsCertExpirationCounterNotAffectedByNonMtlsClose() throws Exception
      Throws:
      Exception