Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-7513: Fix timing issue in SaslAuthenticatorFailureDelayTest #5805

Merged
merged 2 commits into from Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -28,7 +28,6 @@
import org.apache.kafka.common.security.auth.SecurityProtocol;
import org.apache.kafka.common.utils.LogContext;
import org.apache.kafka.common.security.authenticator.CredentialCache;
import org.apache.kafka.common.utils.MockTime;
import org.apache.kafka.common.utils.Time;
import org.apache.kafka.common.utils.Utils;
import org.apache.kafka.test.TestUtils;
Expand Down Expand Up @@ -87,7 +86,7 @@ public static void waitForChannelReady(Selector selector, String node) throws IO
assertTrue(selector.isChannelReady(node));
}

public static ChannelState waitForChannelClose(Selector selector, String node, ChannelState.State channelState, MockTime mockTime)
public static ChannelState waitForChannelClose(Selector selector, String node, ChannelState.State channelState)
throws IOException {
boolean closed = false;
for (int i = 0; i < 300; i++) {
Expand All @@ -96,19 +95,13 @@ public static ChannelState waitForChannelClose(Selector selector, String node, C
closed = true;
break;
}
if (mockTime != null)
mockTime.setCurrentTimeMs(mockTime.milliseconds() + 150);
}
assertTrue("Channel was not closed by timeout", closed);
ChannelState finalState = selector.disconnected().get(node);
assertEquals(channelState, finalState.state());
return finalState;
}

public static ChannelState waitForChannelClose(Selector selector, String node, ChannelState.State channelState) throws IOException {
return waitForChannelClose(selector, node, channelState, null);
}

public static void completeDelayedChannelClose(Selector selector, long currentTimeNanos) {
selector.completeDelayedChannelClose(currentTimeNanos);
}
Expand Down
Expand Up @@ -153,7 +153,7 @@ public void run() {
try {
acceptorThread.start();
while (serverSocketChannel.isOpen()) {
selector.poll(1000);
selector.poll(100);
synchronized (newChannels) {
for (SocketChannel socketChannel : newChannels) {
String id = id(socketChannel);
Expand Down
Expand Up @@ -53,7 +53,7 @@
@RunWith(value = Parameterized.class)
public class SaslAuthenticatorFailureDelayTest {
private static final int BUFFER_SIZE = 4 * 1024;
private static MockTime time = new MockTime(50);
private static MockTime time = new MockTime(10);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why this isn't final?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it final and changed to instance variable like we have in other tests.


private NioEchoServer server;
private Selector selector;
Expand Down Expand Up @@ -221,7 +221,7 @@ private ChannelState createAndCheckClientConnectionFailure(SecurityProtocol secu
throws Exception {
createClientConnection(securityProtocol, node);
ChannelState finalState = NetworkTestUtils.waitForChannelClose(selector, node,
ChannelState.State.AUTHENTICATION_FAILED, time);
ChannelState.State.AUTHENTICATION_FAILED);
selector.close();
selector = null;
return finalState;
Expand Down