Skip to content

Commit

Permalink
Simplify entitlement agent REST tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed Nov 13, 2024
1 parent 7f982fc commit c6f250a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
13 changes: 0 additions & 13 deletions qa/entitlements/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,8 @@ esplugin {
classname 'org.elasticsearch.test.entitlements.EntitlementsCheckPlugin'
}

configurations {
entitlementBridge {
canBeConsumed = false
}
}

dependencies {
clusterPlugins project(':qa:entitlements')
entitlementBridge project(':libs:entitlement:bridge')
}

tasks.named('javaRestTest') {
systemProperty "tests.entitlement-bridge.jar-name", configurations.entitlementBridge.singleFile.getName()
usesDefaultDistribution()
systemProperty "tests.security.manager", "false"
}

tasks.named("javadoc").configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,21 @@
package org.elasticsearch.test.entitlements;

import org.elasticsearch.client.Request;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.junit.ClassRule;

import java.io.IOException;

import static org.hamcrest.Matchers.containsString;

@ESTestCase.WithoutSecurityManager
public class EntitlementsIT extends ESRestTestCase {

private static final String ENTITLEMENT_BRIDGE_JAR_NAME = System.getProperty("tests.entitlement-bridge.jar-name");

@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.INTEG_TEST)
.plugin("entitlement-qa")
.systemProperty("es.entitlements.enabled", "true")
.setting("xpack.security.enabled", "false")
.jvmArg("-Djdk.attach.allowAttachSelf=true")
.jvmArg("-XX:+EnableDynamicAgentLoading")
.jvmArg("--patch-module=java.base=lib/entitlement-bridge/" + ENTITLEMENT_BRIDGE_JAR_NAME)
.jvmArg("--add-exports=java.base/org.elasticsearch.entitlement.bridge=org.elasticsearch.entitlement")
.build();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.function.Predicate.not;
import static org.elasticsearch.test.cluster.local.distribution.DistributionType.DEFAULT;
import static org.elasticsearch.test.cluster.util.OS.WINDOWS;

Expand Down Expand Up @@ -755,18 +757,22 @@ private Map<String, String> getEnvironmentVariables() {
}

String heapSize = System.getProperty("tests.heap.size", "512m");
final String esJavaOpts = Stream.of(
"-Xms" + heapSize,
"-Xmx" + heapSize,
List<String> serverOpts = List.of("-Xms" + heapSize, "-Xmx" + heapSize, debugArgs, featureFlagProperties);
List<String> commonOpts = List.of(
"-ea",
"-esa",
System.getProperty("tests.jvm.argline", ""),
featureFlagProperties,
systemProperties,
jvmArgs,
debugArgs
).filter(s -> s.isEmpty() == false).collect(Collectors.joining(" "));
jvmArgs
);

String esJavaOpts = Stream.concat(serverOpts.stream(), commonOpts.stream())
.filter(not(String::isEmpty))
.collect(Collectors.joining(" "));
String cliJavaOpts = commonOpts.stream().filter(not(String::isEmpty)).collect(Collectors.joining(" "));

environment.put("ES_JAVA_OPTS", esJavaOpts);
environment.put("CLI_JAVA_OPTS", cliJavaOpts);

return environment;
}
Expand Down

0 comments on commit c6f250a

Please sign in to comment.