Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xpack core and security to INTEG TEST #77632

Merged
merged 6 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ private void commonNodeConfig() {
}
ElasticsearchNode firstNode = null;
for (ElasticsearchNode node : nodes) {
if (node.getTestDistribution().equals(TestDistribution.INTEG_TEST)) {
node.defaultConfig.put("xpack.security.enabled", "false");
}
// Can only configure master nodes if we have node names defined
if (nodeNames != null) {
if (node.getVersion().onOrAfter("7.0.0")) {
Expand Down
4 changes: 2 additions & 2 deletions distribution/archives/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String pla
return copySpec {
into("elasticsearch-${version}") {
into('lib') {
with libFiles(isTestDistro)
with libFiles
}
into('config') {
dirMode 0750
Expand Down Expand Up @@ -65,7 +65,7 @@ CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String pla
distribution_archives {
integTestZip {
content {
archiveFiles(transportModulesFiles, 'zip', null, 'x64', true)
archiveFiles(integTestModulesFiles, 'zip', null, 'x64', true)
}
}

Expand Down
37 changes: 21 additions & 16 deletions distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ tasks.withType(NoticeTask).configureEach {
*****************************************************************************/
String defaultOutputs = 'build/outputs/default'
String systemdOutputs = 'build/outputs/systemd'
String transportOutputs = 'build/outputs/transport-only'
String integTestOutputs = 'build/outputs/integ-test-only'
String externalTestOutputs = 'build/outputs/external-test'

def processDefaultOutputsTaskProvider = tasks.register("processDefaultOutputs", Sync) {
Expand All @@ -101,8 +101,8 @@ def processExternalTestOutputsTaskProvider = tasks.register("processExternalTest

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

def defaultModulesFiles = fileTree("${defaultOutputs}/modules") {
Expand All @@ -120,10 +120,11 @@ def systemdModuleFiles = fileTree("${systemdOutputs}/modules") {
builtBy processSystemdOutputsTaskProvider
}

def buildTransportModulesTaskProvider = tasks.register("buildTransportModules") {
dependsOn processTransportOutputsTaskProvider
outputs.dir "${transportOutputs}/modules"
def buildIntegTestModulesTaskProvider = tasks.register("buildIntegTestModules") {
dependsOn processIntegTestOutputsTaskProvider
outputs.dir "${integTestOutputs}/modules"
}

def buildExternalTestModulesTaskProvider = tasks.register("buildExternalTestModules") {
dependsOn "processExternalTestOutputs"
outputs.dir "${externalTestOutputs}/modules"
Expand Down Expand Up @@ -211,7 +212,7 @@ project.rootProject.subprojects.findAll { it.parent.path == ':modules' }.each {

copyModule(processDefaultOutputsTaskProvider, module)
if (module.name.startsWith('transport-')) {
copyModule(processTransportOutputsTaskProvider, module)
copyModule(processIntegTestOutputsTaskProvider, module)
}

restTestExpansions['expected.modules.count'] += 1
Expand All @@ -228,6 +229,9 @@ xpack.subprojects.findAll { it.parent == xpack }.each { Project xpackModule ->
}
}
copyModule(processDefaultOutputsTaskProvider, xpackModule)
if (xpackModule.name.equals('core') || xpackModule.name.equals('security')) {
copyModule(processIntegTestOutputsTaskProvider, xpackModule)
}
}

copyModule(processSystemdOutputsTaskProvider, project(':modules:systemd'))
Expand Down Expand Up @@ -289,7 +293,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
/*****************************************************************************
* Common files in all distributions *
*****************************************************************************/
libFiles = { testDistro ->
libFiles =
copySpec {
// delay by using closures, since they have not yet been configured, so no jar task exists yet
from(configurations.libs)
Expand All @@ -302,13 +306,11 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
into('tools/keystore-cli') {
from(configurations.libsKeystoreCli)
}
if (testDistro == false) {
into('tools/security-cli') {
from(configurations.libsSecurityCli)
}
into('tools/security-cli') {
from(configurations.libsSecurityCli)
}
}
}


modulesFiles = { platform ->
copySpec {
Expand Down Expand Up @@ -345,8 +347,8 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
}
}

transportModulesFiles = copySpec {
from buildTransportModulesTaskProvider
integTestModulesFiles = copySpec {
from buildIntegTestModulesTaskProvider
}

configFiles = { distributionType, isTestDistro ->
Expand Down Expand Up @@ -388,8 +390,11 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
// module provided bin files
with copySpec {
eachFile { it.setMode(0755) }
if(testDistro == false) {
if (testDistro == false) {
from(defaultBinFiles)
} else {
from(defaultBinFiles)
include 'x-pack-env', 'x-pack-security-env'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this explicit include necessary?

Copy link
Member Author

@jkakavas jkakavas Sep 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to call to ConfigInitialNode and to EnrollNodeToCluster from the startup script (either directly or by calling the bash script ) . Either way, we need x-pack-env and x-pack-security-env as we do in all of our security CLI tools. My original change had us copying all bin files but @mark-vieira commented that we don't need all , so I'm just copying the two that we need.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rjernst did that answer your question? Any additional concerns/thoughts? Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It answered my question, thanks!

}
if (distributionType != 'zip') {
exclude '*.bat'
Expand Down
2 changes: 1 addition & 1 deletion distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def commonPackageConfig(String type, String architecture) {
fileMode 0644
}
into('lib') {
with libFiles(false)
with libFiles
}
into('modules') {
with modulesFiles('linux-' + ((architecture == 'x64') ? 'x86_64' : architecture))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ public static boolean hasXPack() {
*/
private static RestClient adminClient;
private static Boolean hasXPack;
private static Boolean hasIlm;
private static Boolean hasRollups;
private static Boolean hasCcr;
private static Boolean hasShutdown;
private static TreeSet<Version> nodeVersions;

@Before
Expand All @@ -178,6 +182,10 @@ public void initClient() throws IOException {
assert adminClient == null;
assert clusterHosts == null;
assert hasXPack == null;
assert hasIlm == null;
assert hasRollups == null;
assert hasCcr == null;
assert hasShutdown == null;
assert nodeVersions == null;
String cluster = getTestRestCluster();
String[] stringUrls = cluster.split(",");
Expand All @@ -197,6 +205,10 @@ public void initClient() throws IOException {
adminClient = buildClient(restAdminSettings(), clusterHosts.toArray(new HttpHost[clusterHosts.size()]));

hasXPack = false;
hasIlm = false;
hasRollups = false;
hasCcr = false;
hasShutdown = false;
nodeVersions = new TreeSet<>();
Map<?, ?> response = entityAsMap(adminClient.performRequest(new Request("GET", "_nodes/plugins")));
Map<?, ?> nodes = (Map<?, ?>) response.get("nodes");
Expand All @@ -205,16 +217,33 @@ public void initClient() throws IOException {
nodeVersions.add(Version.fromString(nodeInfo.get("version").toString()));
for (Object module: (List<?>) nodeInfo.get("modules")) {
Map<?, ?> moduleInfo = (Map<?, ?>) module;
if (moduleInfo.get("name").toString().startsWith("x-pack-")) {
final String moduleName = moduleInfo.get("name").toString();
if (moduleName.startsWith("x-pack")) {
hasXPack = true;
}
if (moduleName.equals("x-pack-ilm")) {
hasIlm = true;
}
if (moduleName.equals("x-pack-rollup")) {
hasRollups = true;
}
if (moduleName.equals("x-pack-ccr")) {
hasCcr = true;
}
if (moduleName.equals("x-pack-shutdown")) {
hasShutdown = true;
}
}
}
}
assert client != null;
assert adminClient != null;
assert clusterHosts != null;
assert hasXPack != null;
assert hasIlm != null;
assert hasRollups != null;
assert hasCcr != null;
assert hasShutdown != null;
assert nodeVersions != null;
}

Expand Down Expand Up @@ -354,6 +383,10 @@ public static void closeClients() throws IOException {
client = null;
adminClient = null;
hasXPack = null;
hasRollups = null;
hasCcr = null;
hasShutdown = null;
hasIlm = null;
nodeVersions = null;
}
}
Expand Down Expand Up @@ -559,7 +592,7 @@ private void wipeCluster() throws Exception {
// Cleanup rollup before deleting indices. A rollup job might have bulks in-flight,
// so we need to fully shut them down first otherwise a job might stall waiting
// for a bulk to finish against a non-existing index (and then fail tests)
if (hasXPack && false == preserveRollupJobsUponCompletion()) {
if (hasRollups && false == preserveRollupJobsUponCompletion()) {
wipeRollupJobs();
waitForPendingRollupTasks();
}
Expand Down Expand Up @@ -711,11 +744,11 @@ private void wipeCluster() throws Exception {
wipeClusterSettings();
}

if (hasXPack && false == preserveILMPoliciesUponCompletion()) {
if (hasIlm && false == preserveILMPoliciesUponCompletion()) {
deleteAllILMPolicies(preserveILMPolicyIds());
}

if (hasXPack && false == preserveAutoFollowPatternsUponCompletion()) {
if (hasCcr && false == preserveAutoFollowPatternsUponCompletion()) {
deleteAllAutoFollowPatterns();
}

Expand All @@ -729,7 +762,7 @@ private void wipeCluster() throws Exception {
*/
@SuppressWarnings("unchecked")
protected void deleteAllNodeShutdownMetadata() throws IOException {
if (hasXPack() == false || minimumNodeVersion().before(Version.V_7_15_0)) {
if (hasShutdown == false || minimumNodeVersion().before(Version.V_7_15_0)) {
// Node shutdown APIs are only present in xpack
return;
}
Expand Down