test: add 2.4.0 bwc index

Original commit: elastic/x-pack-elasticsearch@58bcf3abaf
This commit is contained in:
jaymode 2016-09-01 09:09:48 -04:00
parent 836e1d3a28
commit c5cde120b7
3 changed files with 28 additions and 3 deletions

View File

@ -15,6 +15,7 @@ import org.elasticsearch.common.io.FileSystemUtils;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.VersionUtils; import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.xpack.security.action.role.GetRolesResponse; import org.elasticsearch.xpack.security.action.role.GetRolesResponse;
@ -30,6 +31,7 @@ import org.elasticsearch.xpack.security.user.User;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -106,6 +108,15 @@ public class OldSecurityIndexBackwardsCompatibilityIT extends SecurityIntegTestC
.put(settings).build(); .put(settings).build();
} }
@Override
protected int maxNumberOfNodes() {
try {
return SecurityIntegTestCase.defaultMaxNumberOfNodes() + loadIndexesList("x-pack", getBwcIndicesPath()).size();
} catch (IOException e) {
throw new RuntimeException("couldn't enumerate bwc indices", e);
}
}
void setupCluster(String pathToZipFile) throws Exception { void setupCluster(String pathToZipFile) throws Exception {
// shutdown any nodes from previous zip files // shutdown any nodes from previous zip files
while (internalCluster().size() > 0) { while (internalCluster().size() > 0) {

View File

@ -66,7 +66,7 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase {
//UnicastZen requires the number of nodes in a cluster to generate the unicast configuration. //UnicastZen requires the number of nodes in a cluster to generate the unicast configuration.
//The number of nodes is randomized though, but we can predict what the maximum number of nodes will be //The number of nodes is randomized though, but we can predict what the maximum number of nodes will be
//and configure them all in unicast.hosts //and configure them all in unicast.hosts
private static int maxNumberOfNodes() { protected static int defaultMaxNumberOfNodes() {
ClusterScope clusterScope = SecurityIntegTestCase.class.getAnnotation(ClusterScope.class); ClusterScope clusterScope = SecurityIntegTestCase.class.getAnnotation(ClusterScope.class);
if (clusterScope == null) { if (clusterScope == null) {
return InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES + return InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES +
@ -82,7 +82,17 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase {
masterNodes = InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES; masterNodes = InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES;
} }
return masterNodes + clusterScope.maxNumDataNodes() + clientNodes; int dataNodes = 0;
if (clusterScope.numDataNodes() < 0) {
if (clusterScope.maxNumDataNodes() < 0) {
dataNodes = InternalTestCluster.DEFAULT_MAX_NUM_DATA_NODES;
} else {
dataNodes = clusterScope.maxNumDataNodes();
}
} else {
dataNodes = clusterScope.numDataNodes();
}
return masterNodes + dataNodes + clientNodes;
} }
} }
@ -109,7 +119,7 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase {
@BeforeClass @BeforeClass
public static void initDefaultSettings() { public static void initDefaultSettings() {
if (SECURITY_DEFAULT_SETTINGS == null) { if (SECURITY_DEFAULT_SETTINGS == null) {
SECURITY_DEFAULT_SETTINGS = new SecuritySettingsSource(maxNumberOfNodes(), randomBoolean(), createTempDir(), Scope.SUITE); SECURITY_DEFAULT_SETTINGS = new SecuritySettingsSource(defaultMaxNumberOfNodes(), randomBoolean(), createTempDir(), Scope.SUITE);
} }
} }
@ -274,6 +284,10 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase {
return randomBoolean(); return randomBoolean();
} }
protected int maxNumberOfNodes() {
return defaultMaxNumberOfNodes();
}
protected Class<? extends XPackPlugin> xpackPluginClass() { protected Class<? extends XPackPlugin> xpackPluginClass() {
return SECURITY_DEFAULT_SETTINGS.xpackPluginClass(); return SECURITY_DEFAULT_SETTINGS.xpackPluginClass();
} }