Add tests.config support to BootstrapForTesting

Several plugins (e.g. elasticsearch-cloud-aws, elasticsearch-cloud-azure, elasticsearch-cloud-gce)
have integration tests that run with actual credentials to a remote service, so test runs
need access to this file.

These all require the tester (or jenkins) to supply the file with -Dtests.config.
This commit is contained in:
Robert Muir 2015-05-12 21:23:17 -04:00
parent 79023c1e61
commit 5deba7264c
2 changed files with 8 additions and 0 deletions

View File

@ -73,6 +73,8 @@ grant {
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
// needed by groovy engine
permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
// needed by aws core sdk (TODO: look into this)
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.ssl";
// needed by RandomizedRunner
permission java.lang.RuntimePermission "accessDeclaredMembers";

View File

@ -23,8 +23,10 @@ import org.apache.lucene.util.TestSecurityManager;
import org.elasticsearch.bootstrap.Bootstrap;
import org.elasticsearch.bootstrap.ESPolicy;
import org.elasticsearch.bootstrap.Security;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.PathUtils;
import java.io.FilePermission;
import java.nio.file.Path;
import java.security.Permissions;
import java.security.Policy;
@ -68,6 +70,10 @@ public class BootstrapForTesting {
Path javaTmpDir = PathUtils.get(Objects.requireNonNull(System.getProperty("java.io.tmpdir"),
"please set ${java.io.tmpdir} in pom.xml"));
Security.addPath(perms, javaTmpDir, "read,readlink,write,delete");
// custom test config file
if (Strings.hasLength(System.getProperty("tests.config"))) {
perms.add(new FilePermission(System.getProperty("tests.config"), "read,readlink"));
}
Policy.setPolicy(new ESPolicy(perms));
System.setSecurityManager(new TestSecurityManager());
Security.selfTest();