Skip to content

Commit

Permalink
Remove x-pack from build, distribution and packaging. (#43)
Browse files Browse the repository at this point in the history
This PR removes references to x-pack from buildSrc, distribution and qa modules.
  • Loading branch information
adnapibar authored Feb 4, 2021
1 parent 7aa4833 commit fa86308
Show file tree
Hide file tree
Showing 14 changed files with 7 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class PluginBuildPlugin implements Plugin<Project> {
PluginPropertiesExtension extension = project.extensions.create(PLUGIN_EXTENSION_NAME, PluginPropertiesExtension, project)
configureDependencies(project)

boolean isXPackModule = project.path.startsWith(':x-pack:plugin')
boolean isModule = project.path.startsWith(':modules:') || isXPackModule
boolean isModule = project.path.startsWith(':modules:')

createBundleTasks(project, extension)

Expand Down Expand Up @@ -103,7 +102,7 @@ class PluginBuildPlugin implements Plugin<Project> {
expand(properties)
inputs.properties(properties)
}
if (isModule == false || isXPackModule) {
if (isModule == false) {
addNoticeGeneration(project, extension1)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,6 @@ public synchronized void start() {
pluginsToInstall.addAll(plugins.stream().map(Provider::get).map(p -> p.toURI().toString()).collect(Collectors.toList()));
}

if (requiresAddingXPack()) {
logToProcessStdout("emulating the " + testDistribution + " flavor for " + getVersion() + " by installing x-pack");
pluginsToInstall.add("x-pack");
}

if (pluginsToInstall.isEmpty() == false) {
if (getVersion().onOrAfter("7.6.0")) {
logToProcessStdout("installing " + pluginsToInstall.size() + " plugins in a single transaction");
Expand Down Expand Up @@ -554,18 +549,10 @@ public synchronized void start() {
startElasticsearchProcess();
}

private boolean requiresAddingXPack() {
return getVersion().before("6.3.0") && testDistribution == TestDistribution.DEFAULT;
}

private boolean canUseSharedDistribution() {
// using original location can be too long due to MAX_PATH restrictions on windows CI
// TODO revisit when moving to shorter paths on CI by using Teamcity
return OS.current() != OS.WINDOWS
&& extraJarFiles.size() == 0
&& modules.size() == 0
&& plugins.size() == 0
&& requiresAddingXPack() == false;
return OS.current() != OS.WINDOWS && extraJarFiles.size() == 0 && modules.size() == 0 && plugins.size() == 0;
}

private void logToProcessStdout(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,6 @@ void execute(Terminal terminal, List<String> pluginIds, boolean isBatch, Environ
for (final String pluginId : pluginIds) {
terminal.println("-> Installing " + pluginId);
try {
if ("x-pack".equals(pluginId)) {
handleInstallXPack(buildFlavor());
}

final List<Path> deleteOnFailure = new ArrayList<>();
deleteOnFailures.put(pluginId, deleteOnFailure);

Expand Down Expand Up @@ -281,24 +277,6 @@ void execute(Terminal terminal, List<String> pluginIds, boolean isBatch, Environ
}
}

Build.Flavor buildFlavor() {
return Build.CURRENT.flavor();
}

private static void handleInstallXPack(final Build.Flavor flavor) throws UserException {
switch (flavor) {
case DEFAULT:
throw new UserException(ExitCodes.CONFIG, "this distribution of Elasticsearch contains X-Pack by default");
case OSS:
throw new UserException(
ExitCodes.CONFIG,
"X-Pack is not available with the oss distribution; to use X-Pack features use the default distribution"
);
case UNKNOWN:
throw new IllegalStateException("your distribution is broken");
}
}

/** Downloads the plugin and returns the file it was downloaded to. */
private Path download(Terminal terminal, String pluginId, Path tmpDir, boolean isBatch) throws Exception {
if (OFFICIAL_PLUGINS.contains(pluginId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,6 @@ public void testBuiltinModule() throws Exception {
assertInstallCleaned(env.v2());
}

public void testBuiltinXpackModule() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp);
Path pluginDir = createPluginDir(temp);
String pluginZip = createPluginUrl("x-pack", pluginDir);
UserException e = expectThrows(UserException.class, () -> installPlugin(pluginZip, env.v1()));
assertTrue(e.getMessage(), e.getMessage().contains("is a system module"));
assertInstallCleaned(env.v2());
}

public void testJarHell() throws Exception {
// jar hell test needs a real filesystem
assumeTrue("real filesystem", isReal);
Expand Down Expand Up @@ -813,33 +804,6 @@ protected boolean addShutdownHook() {
}
}

public void testInstallXPack() throws IOException {
runInstallXPackTest(Build.Flavor.DEFAULT, UserException.class, "this distribution of Elasticsearch contains X-Pack by default");
runInstallXPackTest(
Build.Flavor.OSS,
UserException.class,
"X-Pack is not available with the oss distribution; to use X-Pack features use the default distribution"
);
runInstallXPackTest(Build.Flavor.UNKNOWN, IllegalStateException.class, "your distribution is broken");
}

private <T extends Exception> void runInstallXPackTest(final Build.Flavor flavor, final Class<T> clazz, final String expectedMessage)
throws IOException {
final InstallPluginCommand flavorCommand = new InstallPluginCommand() {
@Override
Build.Flavor buildFlavor() {
return flavor;
}
};

final Environment environment = createEnv(fs, temp).v2();
final T exception = expectThrows(
clazz,
() -> flavorCommand.execute(terminal, Collections.singletonList("x-pack"), false, environment)
);
assertThat(exception, hasToString(containsString(expectedMessage)));
}

public void testInstallMisspelledOfficialPlugins() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp);

Expand Down
25 changes: 1 addition & 24 deletions gradle/formatting.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,7 @@ def projectPathsToExclude = [
':test:fixtures:old-elasticsearch',
':test:fixtures:s3-fixture',
':test:framework',
':test:logger-usage',
':x-pack:license-tools',
':x-pack:plugin:analytics',
':x-pack:plugin:core',
':x-pack:plugin:deprecation',
':x-pack:plugin:frozen-indices',
':x-pack:plugin:identity-provider',
':x-pack:plugin:mapper-constant-keyword',
':x-pack:plugin:mapper-flattened',
':x-pack:plugin:ql',
':x-pack:plugin:search-business-rules',
':x-pack:plugin:spatial',
':x-pack:plugin:vectors',
':x-pack:plugin:voting-only-node',
':x-pack:plugin:wildcard',
':x-pack:qa',
':x-pack:qa:security-example-spi-extension',
':x-pack:snapshot-tool',
':x-pack:snapshot-tool:qa:google-cloud-storage',
':x-pack:snapshot-tool:qa:s3',
':x-pack:test:feature-aware',
':x-pack:test:idp-fixture',
':x-pack:test:smb-fixture',
':x-pack:transport-client'
':test:logger-usage'
]

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -109,20 +108,6 @@ public void test010Install() {
verifyContainerInstallation(installation, distribution());
}

/**
* Check that the /_xpack API endpoint's presence is correct for the type of distribution being tested.
*/
public void test011PresenceOfXpack() throws Exception {
waitForElasticsearch(installation);
final int statusCode = Request.Get("http://localhost:9200/_xpack").execute().returnResponse().getStatusLine().getStatusCode();

if (distribution.isOSS()) {
assertThat(statusCode, greaterThanOrEqualTo(400));
} else {
assertThat(statusCode, equalTo(200));
}
}

/**
* Checks that no plugins are initially active.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ private static void verifyDefaultInstallation(Installation es, Distribution dist
"elasticsearch-saml-metadata",
"elasticsearch-setup-passwords",
"elasticsearch-syskeygen",
"elasticsearch-users",
"x-pack-env",
"x-pack-security-env"
"elasticsearch-users"
).forEach(executable -> {

assertThat(es.bin(executable), file(File, owner, owner, p755));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,7 @@ private static void verifyDefaultInstallation(Installation es) {
"elasticsearch-saml-metadata",
"elasticsearch-setup-passwords",
"elasticsearch-syskeygen",
"elasticsearch-users",
"x-pack-env",
"x-pack-security-env"
"elasticsearch-users"
).forEach(executable -> assertPermissionsAndOwnership(es.bin(executable), p755));

Stream.of("role_mapping.yml", "roles.yml", "users", "users_roles")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ private static void verifyDefaultInstallation(Installation es, Distribution dist
"elasticsearch-saml-metadata",
"elasticsearch-setup-passwords",
"elasticsearch-syskeygen",
"elasticsearch-users",
"x-pack-env",
"x-pack-security-env"
"elasticsearch-users"
).forEach(executable -> assertThat(es.bin(executable), file(File, "root", "root", p755)));

Stream.of("users", "users_roles", "roles.yml", "role_mapping.yml", "log4j2.properties")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
import javax.net.ssl.TrustManagerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.KeyStore;
Expand Down Expand Up @@ -114,26 +112,6 @@ private static HttpResponse execute(Request request, String username, String pas
return executor.execute(request).returnResponse();
}

// polls every second for Elasticsearch to be running on 9200
private static void waitForXpack() {
int retries = 60;
while (retries > 0) {
retries -= 1;
try (Socket s = new Socket(InetAddress.getLoopbackAddress(), 9200)) {
return;
} catch (IOException e) {
// ignore, only want to establish a connection
}
try {
Thread.sleep(1000);
} catch (InterruptedException interrupted) {
Thread.currentThread().interrupt();
return;
}
}
throw new RuntimeException("Elasticsearch (with x-pack) did not start");
}

public static void waitForElasticsearch(String status, String index, Installation installation, String username, String password)
throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,40 +116,4 @@ public void testHAProxyModeConnectionWorks() throws IOException {
assertEquals(2L, cluster1Client().search(
new SearchRequest("haproxynosn:test2"), RequestOptions.DEFAULT).getHits().getTotalHits().value);
}

public void testHAProxyModeConnectionWithSNIToCluster1Works() throws IOException {
assumeThat("test is only supported if the distribution contains xpack", getDistribution(), equalTo("default"));

ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(Settings.builder()
.put("cluster.remote.haproxysni1.mode", "proxy")
.put("cluster.remote.haproxysni1.proxy_address", "haproxy:9600")
.put("cluster.remote.haproxysni1.server_name", "application1.example.com")
.build());
assertTrue(cluster2Client().cluster().putSettings(request, RequestOptions.DEFAULT).isAcknowledged());

RemoteConnectionInfo rci = cluster2Client().cluster().remoteInfo(new RemoteInfoRequest(), RequestOptions.DEFAULT).getInfos().get(0);
logger.info("Connection info: {}", rci);
assertTrue(rci.isConnected());

assertEquals(1L, cluster2Client().search(
new SearchRequest("haproxysni1:test1"), RequestOptions.DEFAULT).getHits().getTotalHits().value);
}

public void testHAProxyModeConnectionWithSNIToCluster2Works() throws IOException {
assumeThat("test is only supported if the distribution contains xpack", getDistribution(), equalTo("default"));

ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(Settings.builder()
.put("cluster.remote.haproxysni2.mode", "proxy")
.put("cluster.remote.haproxysni2.proxy_address", "haproxy:9600")
.put("cluster.remote.haproxysni2.server_name", "application2.example.com")
.build());
assertTrue(cluster1Client().cluster().putSettings(request, RequestOptions.DEFAULT).isAcknowledged());

RemoteConnectionInfo rci = cluster1Client().cluster().remoteInfo(new RemoteInfoRequest(), RequestOptions.DEFAULT).getInfos().get(0);
logger.info("Connection info: {}", rci);
assertTrue(rci.isConnected());

assertEquals(2L, cluster1Client().search(
new SearchRequest("haproxysni2:test2"), RequestOptions.DEFAULT).getHits().getTotalHits().value);
}
}

This file was deleted.

Loading

0 comments on commit fa86308

Please sign in to comment.