Skip to content

Commit

Permalink
Simplify entitlement agent REST tests (elastic#116779)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed Nov 14, 2024
1 parent b3edb3a commit 746d17c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 34 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 @@ -59,6 +59,7 @@
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 +756,16 @@ private Map<String, String> getEnvironmentVariables() {
}

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

Please sign in to comment.