[TEST] customize test global cluster for REST tests only if REST tests are enabled

Closes elastic/elasticsearch#107

Original commit: elastic/x-pack-elasticsearch@55eea46460
This commit is contained in:
javanna 2014-10-06 12:08:34 +02:00 committed by Luca Cavanna
parent 0d702c2fbc
commit 6f4acfa93b
1 changed files with 90 additions and 73 deletions

View File

@ -5,8 +5,10 @@
*/ */
package org.elasticsearch.test; package org.elasticsearch.test;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.carrotsearch.randomizedtesting.SysGlobals; import com.carrotsearch.randomizedtesting.SysGlobals;
import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.io.Streams; import org.elasticsearch.common.io.Streams;
@ -57,6 +59,20 @@ public class ShieldRestTests extends ElasticsearchRestTests {
" '.*': ALL\n"; " '.*': ALL\n";
static { static {
TestGroup testGroup = Rest.class.getAnnotation(TestGroup.class);
String sysProperty = TestGroup.Utilities.getSysProperty(Rest.class);
boolean enabled;
try {
enabled = RandomizedTest.systemPropertyAsBoolean(sysProperty, testGroup.enabled());
} catch (IllegalArgumentException e) {
// Ignore malformed system property, disable the group if malformed though.
enabled = false;
}
//customize the global cluster only if rest tests are enabled
//not perfect but good enough as REST tests are supposed to be run only separately on CI
if (enabled) {
final byte[] key; final byte[] key;
try { try {
key = InternalKeyService.generateKey(); key = InternalKeyService.generateKey();
@ -139,6 +155,7 @@ public class ShieldRestTests extends ElasticsearchRestTests {
} }
}; };
} }
}
@ClassRule @ClassRule
public static TemporaryFolder tmpFolder = new TemporaryFolder(); public static TemporaryFolder tmpFolder = new TemporaryFolder();