Skip to content

Commit 4355afe

Browse files
committed
Add xpack core and security to INTEG TEST (elastic#77632)
This change makes it so x-pack-core and x-pack-security are bundled in the INTEG TEST distribution that we use for testClusters in our tests. There are two reasons for this: - In elastic#77231 where we are looking into enabling and auto-configuring security by default for all nodes, we need to call out to ConfigInitialNode to determine whether we should do the auto-configuration or not. - Since we are enabling security by default, we should be looking into enabling security for all for our tests moving forward, or at least make a conscious decision about which ones run without security. This change is a step towards that direction. # Conflicts: # distribution/archives/build.gradle # distribution/packages/build.gradle
1 parent 284a352 commit 4355afe

File tree

5 files changed

+65
-24
lines changed

5 files changed

+65
-24
lines changed

build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ private void commonNodeConfig() {
332332
}
333333
ElasticsearchNode firstNode = null;
334334
for (ElasticsearchNode node : nodes) {
335+
if (node.getTestDistribution().equals(TestDistribution.INTEG_TEST)) {
336+
node.defaultConfig.put("xpack.security.enabled", "false");
337+
}
335338
// Can only configure master nodes if we have node names defined
336339
if (nodeNames != null) {
337340
commonNodeConfig(node, nodeNames, firstNode);

distribution/archives/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String pla
1515
return copySpec {
1616
into("elasticsearch-${version}") {
1717
into('lib') {
18-
with libFiles(oss)
18+
with libFiles
1919
}
2020
into('config') {
2121
dirMode 0750
@@ -65,7 +65,7 @@ CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String pla
6565
distribution_archives {
6666
integTestZip {
6767
content {
68-
archiveFiles(transportModulesFiles, 'zip', null, 'x64', true, false)
68+
archiveFiles(integTestModulesFiles, 'zip', null, 'x64', true, false)
6969
}
7070
}
7171

distribution/build.gradle

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ tasks.withType(NoticeTask).configureEach {
8989
String ossOutputs = 'build/outputs/oss'
9090
String defaultOutputs = 'build/outputs/default'
9191
String systemdOutputs = 'build/outputs/systemd'
92-
String transportOutputs = 'build/outputs/transport-only'
92+
String integTestOutputs = 'build/outputs/integ-test-only'
9393
String externalTestOutputs = 'build/outputs/external-test'
9494

9595
def processDefaultOutputsTaskProvider = tasks.register("processDefaultOutputs", Sync) {
@@ -106,8 +106,8 @@ def processExternalTestOutputsTaskProvider = tasks.register("processExternalTest
106106

107107
// Integ tests work over the rest http layer, so we need a transport included with the integ test zip.
108108
// All transport modules are included so that they may be randomized for testing
109-
def processTransportOutputsTaskProvider = tasks.register("processTransportOutputs", Sync) {
110-
into transportOutputs
109+
def processIntegTestOutputsTaskProvider = tasks.register("processIntegTestOutputs", Sync) {
110+
into integTestOutputs
111111
}
112112

113113
def defaultModulesFiles = fileTree("${defaultOutputs}/modules") {
@@ -125,10 +125,11 @@ def systemdModuleFiles = fileTree("${systemdOutputs}/modules") {
125125
builtBy processSystemdOutputsTaskProvider
126126
}
127127

128-
def buildTransportModulesTaskProvider = tasks.register("buildTransportModules") {
129-
dependsOn processTransportOutputsTaskProvider
130-
outputs.dir "${transportOutputs}/modules"
128+
def buildIntegTestModulesTaskProvider = tasks.register("buildIntegTestModules") {
129+
dependsOn processIntegTestOutputsTaskProvider
130+
outputs.dir "${integTestOutputs}/modules"
131131
}
132+
132133
def buildExternalTestModulesTaskProvider = tasks.register("buildExternalTestModules") {
133134
dependsOn "processExternalTestOutputs"
134135
outputs.dir "${externalTestOutputs}/modules"
@@ -216,7 +217,7 @@ project.rootProject.subprojects.findAll { it.parent.path == ':modules' }.each {
216217

217218
copyModule(processDefaultOutputsTaskProvider, module)
218219
if (module.name.startsWith('transport-')) {
219-
copyModule(processTransportOutputsTaskProvider, module)
220+
copyModule(processIntegTestOutputsTaskProvider, module)
220221
}
221222

222223
restTestExpansions['expected.modules.count'] += 1
@@ -233,6 +234,9 @@ xpack.subprojects.findAll { it.parent == xpack }.each { Project xpackModule ->
233234
}
234235
}
235236
copyModule(processDefaultOutputsTaskProvider, xpackModule)
237+
if (xpackModule.name.equals('core') || xpackModule.name.equals('security')) {
238+
copyModule(processIntegTestOutputsTaskProvider, xpackModule)
239+
}
236240
}
237241

238242
copyModule(processSystemdOutputsTaskProvider, project(':modules:systemd'))
@@ -294,7 +298,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
294298
/*****************************************************************************
295299
* Common files in all distributions *
296300
*****************************************************************************/
297-
libFiles = { testDistro ->
301+
libFiles =
298302
copySpec {
299303
// delay by using closures, since they have not yet been configured, so no jar task exists yet
300304
from(configurations.libs)
@@ -307,13 +311,11 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
307311
into('tools/keystore-cli') {
308312
from(configurations.libsKeystoreCli)
309313
}
310-
if (testDistro == false) {
311-
into('tools/security-cli') {
312-
from(configurations.libsSecurityCli)
313-
}
314+
into('tools/security-cli') {
315+
from(configurations.libsSecurityCli)
314316
}
315317
}
316-
}
318+
317319

318320
modulesFiles = { platform ->
319321
copySpec {
@@ -350,8 +352,8 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
350352
}
351353
}
352354

353-
transportModulesFiles = copySpec {
354-
from buildTransportModulesTaskProvider
355+
integTestModulesFiles = copySpec {
356+
from buildIntegTestModulesTaskProvider
355357
}
356358

357359
configFiles = { distributionType, testDistro, jdk ->
@@ -393,8 +395,11 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
393395
// module provided bin files
394396
with copySpec {
395397
eachFile { it.setMode(0755) }
396-
if(testDistro == false) {
398+
if (testDistro == false) {
399+
from(defaultBinFiles)
400+
} else {
397401
from(defaultBinFiles)
402+
include 'x-pack-env', 'x-pack-security-env'
398403
}
399404
if (distributionType != 'zip') {
400405
exclude '*.bat'

distribution/packages/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit
158158
fileMode 0644
159159
}
160160
into('lib') {
161-
with libFiles(oss)
161+
with libFiles
162162
}
163163
into('modules') {
164164
with modulesFiles('linux-' + ((architecture == 'x64') ? 'x86_64' : architecture))

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ public static boolean hasXPack() {
173173
*/
174174
private static RestClient adminClient;
175175
private static Boolean hasXPack;
176+
private static Boolean hasIlm;
177+
private static Boolean hasRollups;
178+
private static Boolean hasCcr;
179+
private static Boolean hasShutdown;
176180
private static TreeSet<Version> nodeVersions;
177181

178182
@Before
@@ -181,6 +185,10 @@ public void initClient() throws IOException {
181185
assert adminClient == null;
182186
assert clusterHosts == null;
183187
assert hasXPack == null;
188+
assert hasIlm == null;
189+
assert hasRollups == null;
190+
assert hasCcr == null;
191+
assert hasShutdown == null;
184192
assert nodeVersions == null;
185193
String cluster = getTestRestCluster();
186194
String[] stringUrls = cluster.split(",");
@@ -200,6 +208,10 @@ public void initClient() throws IOException {
200208
adminClient = buildClient(restAdminSettings(), clusterHosts.toArray(new HttpHost[clusterHosts.size()]));
201209

202210
hasXPack = false;
211+
hasIlm = false;
212+
hasRollups = false;
213+
hasCcr = false;
214+
hasShutdown = false;
203215
nodeVersions = new TreeSet<>();
204216
Map<?, ?> response = entityAsMap(adminClient.performRequest(new Request("GET", "_nodes/plugins")));
205217
Map<?, ?> nodes = (Map<?, ?>) response.get("nodes");
@@ -208,16 +220,33 @@ public void initClient() throws IOException {
208220
nodeVersions.add(Version.fromString(nodeInfo.get("version").toString()));
209221
for (Object module: (List<?>) nodeInfo.get("modules")) {
210222
Map<?, ?> moduleInfo = (Map<?, ?>) module;
211-
if (moduleInfo.get("name").toString().startsWith("x-pack-")) {
223+
final String moduleName = moduleInfo.get("name").toString();
224+
if (moduleName.startsWith("x-pack")) {
212225
hasXPack = true;
213226
}
227+
if (moduleName.equals("x-pack-ilm")) {
228+
hasIlm = true;
229+
}
230+
if (moduleName.equals("x-pack-rollup")) {
231+
hasRollups = true;
232+
}
233+
if (moduleName.equals("x-pack-ccr")) {
234+
hasCcr = true;
235+
}
236+
if (moduleName.equals("x-pack-shutdown")) {
237+
hasShutdown = true;
238+
}
214239
}
215240
}
216241
}
217242
assert client != null;
218243
assert adminClient != null;
219244
assert clusterHosts != null;
220245
assert hasXPack != null;
246+
assert hasIlm != null;
247+
assert hasRollups != null;
248+
assert hasCcr != null;
249+
assert hasShutdown != null;
221250
assert nodeVersions != null;
222251
}
223252

@@ -382,6 +411,10 @@ public static void closeClients() throws IOException {
382411
client = null;
383412
adminClient = null;
384413
hasXPack = null;
414+
hasRollups = null;
415+
hasCcr = null;
416+
hasShutdown = null;
417+
hasIlm = null;
385418
nodeVersions = null;
386419
}
387420
}
@@ -587,7 +620,7 @@ private void wipeCluster() throws Exception {
587620
// Cleanup rollup before deleting indices. A rollup job might have bulks in-flight,
588621
// so we need to fully shut them down first otherwise a job might stall waiting
589622
// for a bulk to finish against a non-existing index (and then fail tests)
590-
if (hasXPack && false == preserveRollupJobsUponCompletion()) {
623+
if (hasRollups && false == preserveRollupJobsUponCompletion()) {
591624
wipeRollupJobs();
592625
waitForPendingRollupTasks();
593626
}
@@ -745,11 +778,11 @@ private void wipeCluster() throws Exception {
745778
wipeClusterSettings();
746779
}
747780

748-
if (hasXPack && false == preserveILMPoliciesUponCompletion()) {
781+
if (hasIlm && false == preserveILMPoliciesUponCompletion()) {
749782
deleteAllILMPolicies(preserveILMPolicyIds());
750783
}
751784

752-
if (hasXPack && false == preserveAutoFollowPatternsUponCompletion()) {
785+
if (hasCcr && false == preserveAutoFollowPatternsUponCompletion()) {
753786
deleteAllAutoFollowPatterns();
754787
}
755788

@@ -763,7 +796,7 @@ private void wipeCluster() throws Exception {
763796
*/
764797
@SuppressWarnings("unchecked")
765798
protected void deleteAllNodeShutdownMetadata() throws IOException {
766-
if (hasXPack() == false || minimumNodeVersion().before(Version.V_7_15_0)) {
799+
if (hasShutdown == false || minimumNodeVersion().before(Version.V_7_15_0)) {
767800
// Node shutdown APIs are only present in xpack
768801
return;
769802
}

0 commit comments

Comments
 (0)