Test: don't reset node in ClusterPrivilegeTests
In the ClusterPrivilegeTests class, the code was resetting the node after each test and failures were seen in CI that were HTTP 401 when a 403 was expected. This commit removes the resetting of the node between tests as this was not necessary. Additionally, there is an issue in the SecuritySingleNodeTestCase where the rest client was not torn down afterstopping a node and starting a new node. This means the client used in other tests would not be connected to the right cluster. This change resolves this by tearing down the rest client after the old node is torn down. relates elastic/x-pack-elasticsearch#4383 Original commit: elastic/x-pack-elasticsearch@2f81a4b2e2
This commit is contained in:
parent
da6ff8fddd
commit
13d08f9c42
|
@ -10,7 +10,6 @@ import org.elasticsearch.cluster.SnapshotsInProgress;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.network.NetworkModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
@ -48,7 +47,7 @@ public class ClusterPrivilegeTests extends AbstractPrivilegeTestCase {
|
|||
private static Path repositoryLocation;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupRepostoryPath() {
|
||||
public static void setupRepositoryPath() {
|
||||
repositoryLocation = createTempDir();
|
||||
}
|
||||
|
||||
|
@ -80,11 +79,6 @@ public class ClusterPrivilegeTests extends AbstractPrivilegeTestCase {
|
|||
return super.configUsersRoles() + USERS_ROLES;
|
||||
}
|
||||
|
||||
protected boolean resetNodeAfterTest() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@TestLogging("org.elasticsearch.test.rest.client.http:TRACE")
|
||||
public void testThatClusterPrivilegesWorkAsExpectedViaHttp() throws Exception {
|
||||
// user_a can do all the things
|
||||
assertAccessIsAllowed("user_a", "GET", "/_cluster/state");
|
||||
|
@ -125,7 +119,6 @@ public class ClusterPrivilegeTests extends AbstractPrivilegeTestCase {
|
|||
assertAccessIsDenied("user_c", "PUT", "/_cluster/settings", "{ \"transient\" : { \"search.default_search_timeout\": \"1m\" } }");
|
||||
}
|
||||
|
||||
@AwaitsFix(bugUrl = "https://github.com/elastic/x-pack-elasticsearch/issues/4383")
|
||||
public void testThatSnapshotAndRestore() throws Exception {
|
||||
String repoJson = Strings.toString(jsonBuilder().startObject().field("type", "fs").startObject("settings").field("location",
|
||||
repositoryLocation.toString()).endObject().endObject());
|
||||
|
|
|
@ -77,6 +77,18 @@ public abstract class SecuritySingleNodeTestCase extends ESSingleNodeTestCase {
|
|||
BOOTSTRAP_PASSWORD.close();
|
||||
BOOTSTRAP_PASSWORD = null;
|
||||
}
|
||||
tearDownRestClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
if (resetNodeAfterTest()) {
|
||||
tearDownRestClient();
|
||||
}
|
||||
}
|
||||
|
||||
private static void tearDownRestClient() {
|
||||
if (restClient != null) {
|
||||
IOUtils.closeWhileHandlingException(restClient);
|
||||
restClient = null;
|
||||
|
|
Loading…
Reference in New Issue