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

Fix not waiting for Netty ThreadDeathWatcher in IT #31758

Merged
merged 1 commit into from
Jul 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
package org.elasticsearch.smoketest;

import io.netty.util.ThreadDeathWatcher;
import io.netty.util.concurrent.GlobalEventExecutor;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
import org.elasticsearch.common.network.NetworkAddress;
Expand All @@ -19,12 +21,15 @@
import org.elasticsearch.xpack.core.security.SecurityField;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.rules.ExternalResource;

import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -42,6 +47,36 @@
* indexed in the cluster.
*/
public class SmokeTestMonitoringWithSecurityIT extends ESIntegTestCase {

/**
* A JUnit class level rule that runs after the AfterClass method in {@link ESIntegTestCase},
* which stops the cluster. After the cluster is stopped, there are a few netty threads that
* can linger, so we wait for them to finish otherwise these lingering threads can intermittently
* trigger the thread leak detector
*/
@ClassRule
public static final ExternalResource STOP_NETTY_RESOURCE = new ExternalResource() {
@Override
protected void after() {
try {
GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (IllegalStateException e) {
if (e.getMessage().equals("thread was not started") == false) {
throw e;
}
// ignore since the thread was never started
}

try {
ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
};

private static final String USER = "test_user";
private static final String PASS = "x-pack-test-password";
private static final String MONITORING_PATTERN = ".monitoring-*";
Expand Down