Add distribution flavor to startup scripts
This commit adds the distribution flavor (default versus oss) to the build process which is passed through the startup scripts to Elasticsearch. This change will be used to customize the message on attempting to install/remove x-pack based on the distribution flavor.
This commit is contained in:
parent
fab5e21e7d
commit
e64e6d8996
|
@ -42,14 +42,14 @@ task createPluginsDir(type: EmptyDirTask) {
|
|||
dirMode 0755
|
||||
}
|
||||
|
||||
CopySpec archiveFiles(CopySpec modulesFiles) {
|
||||
CopySpec archiveFiles(CopySpec modulesFiles, boolean oss) {
|
||||
return copySpec {
|
||||
into("elasticsearch-${version}") {
|
||||
with libFiles
|
||||
into('config') {
|
||||
dirMode 0750
|
||||
fileMode 0660
|
||||
with configFiles('def', false)
|
||||
with configFiles('def', oss)
|
||||
}
|
||||
into('bin') {
|
||||
with binFiles('def', oss)
|
||||
|
@ -58,7 +58,7 @@ CopySpec archiveFiles(CopySpec modulesFiles) {
|
|||
include '*.bat'
|
||||
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
|
||||
}
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution('def'))
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution('def', oss))
|
||||
}
|
||||
}
|
||||
into('') {
|
||||
|
@ -94,15 +94,15 @@ tasks.withType(AbstractArchiveTask) {
|
|||
}
|
||||
|
||||
task buildIntegTestZip(type: Zip) {
|
||||
with archiveFiles(transportModulesFiles)
|
||||
with archiveFiles(transportModulesFiles, false)
|
||||
}
|
||||
|
||||
task buildZip(type: Zip) {
|
||||
with archiveFiles(modulesFiles(false))
|
||||
with archiveFiles(modulesFiles(false), false)
|
||||
}
|
||||
|
||||
task buildOssZip(type: Zip) {
|
||||
with archiveFiles(modulesFiles(true))
|
||||
with archiveFiles(modulesFiles(true), true)
|
||||
}
|
||||
|
||||
Closure commonTarConfig = {
|
||||
|
@ -114,12 +114,12 @@ Closure commonTarConfig = {
|
|||
|
||||
task buildTar(type: Tar) {
|
||||
configure(commonTarConfig)
|
||||
with archiveFiles(modulesFiles(false))
|
||||
with archiveFiles(modulesFiles(false), false)
|
||||
}
|
||||
|
||||
task buildOssTar(type: Tar) {
|
||||
configure(commonTarConfig)
|
||||
with archiveFiles(modulesFiles(true))
|
||||
with archiveFiles(modulesFiles(true), true)
|
||||
}
|
||||
|
||||
// This configures the default artifact for the distribution specific
|
||||
|
|
|
@ -269,7 +269,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
|||
// main config files, processed with distribution specific substitutions
|
||||
from '../src/config'
|
||||
exclude 'log4j2.properties' // this is handled separately below
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType))
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss))
|
||||
}
|
||||
if (oss) {
|
||||
from project(':distribution').buildOssLog4jConfig
|
||||
|
@ -287,11 +287,10 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
|
|||
// main bin files, processed with distribution specific substitutions
|
||||
// everything except windows files
|
||||
from '../src/bin'
|
||||
exclude '*.bat'
|
||||
exclude '*.exe'
|
||||
exclude '*.bat'
|
||||
eachFile { it.setMode(0755) }
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType))
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution(distributionType, oss))
|
||||
}
|
||||
with copySpec {
|
||||
eachFile { it.setMode(0755) }
|
||||
|
@ -356,7 +355,7 @@ task run(type: RunTask) {
|
|||
* </dl>
|
||||
*/
|
||||
subprojects {
|
||||
ext.expansionsForDistribution = { distributionType ->
|
||||
ext.expansionsForDistribution = { distributionType, oss ->
|
||||
final String defaultHeapSize = "1g"
|
||||
final String packagingPathData = "path.data: /var/lib/elasticsearch"
|
||||
final String pathLogs = "/var/log/elasticsearch"
|
||||
|
@ -427,6 +426,10 @@ subprojects {
|
|||
'deb': "exit 0\n${footer}",
|
||||
'def': footer
|
||||
],
|
||||
|
||||
'es.distribution.flavor': [
|
||||
'def': oss ? 'oss' : 'default'
|
||||
]
|
||||
]
|
||||
Map<String, String> result = [:]
|
||||
expansions = expansions.each { key, value ->
|
||||
|
|
|
@ -69,6 +69,7 @@ void addProcessFilesTask(String type, boolean oss) {
|
|||
into('config') {
|
||||
with configFiles(type, oss)
|
||||
}
|
||||
MavenFilteringHack.filter(it, expansionsForDistribution(type, oss))
|
||||
|
||||
doLast {
|
||||
// create empty dirs, we set the permissions when configuring the packages
|
||||
|
@ -150,7 +151,7 @@ Closure commonPackageConfig(String type, boolean oss) {
|
|||
fileType CONFIG | NOREPLACE
|
||||
from "${packagingFiles}/config"
|
||||
}
|
||||
String envFile = expansionsForDistribution(type)['path.env']
|
||||
String envFile = expansionsForDistribution(type, false)['path.env']
|
||||
configurationFile envFile
|
||||
into(new File(envFile).getParent()) {
|
||||
fileType CONFIG | NOREPLACE
|
||||
|
|
|
@ -28,6 +28,7 @@ if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null;
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.bootstrap.Elasticsearch \
|
||||
"$@"
|
||||
|
@ -37,6 +38,7 @@ else
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.bootstrap.Elasticsearch \
|
||||
"$@" \
|
||||
|
|
|
@ -77,6 +77,8 @@ fi
|
|||
# now make ES_PATH_CONF absolute
|
||||
ES_PATH_CONF=`cd "$ES_PATH_CONF"; pwd`
|
||||
|
||||
ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor}
|
||||
|
||||
if [ -z "$ES_TMPDIR" ]; then
|
||||
set +e
|
||||
mktemp --version 2>&1 | grep coreutils > /dev/null
|
||||
|
|
|
@ -53,6 +53,8 @@ if not defined ES_PATH_CONF (
|
|||
rem now make ES_PATH_CONF absolute
|
||||
for %%I in ("%ES_PATH_CONF%..") do set ES_PATH_CONF=%%~dpfI
|
||||
|
||||
set ES_DISTRIBUTION_FLAVOR=${es.distribution.flavor}
|
||||
|
||||
if not defined ES_TMPDIR (
|
||||
set ES_TMPDIR=!TMP!\elasticsearch
|
||||
)
|
||||
|
|
|
@ -7,6 +7,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.common.settings.KeyStoreCli \
|
||||
"$@"
|
||||
|
|
|
@ -9,6 +9,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.common.settings.KeyStoreCli ^
|
||||
%*
|
||||
|
|
|
@ -7,6 +7,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.plugins.PluginCli \
|
||||
"$@"
|
||||
|
|
|
@ -9,6 +9,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.plugins.PluginCli ^
|
||||
%*
|
||||
|
|
|
@ -159,7 +159,7 @@ if "%JVM_SS%" == "" (
|
|||
goto:eof
|
||||
)
|
||||
|
||||
set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%"
|
||||
set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%";-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%"
|
||||
|
||||
if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual
|
||||
if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0
|
||||
|
|
|
@ -7,6 +7,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.index.translog.TranslogToolCli \
|
||||
"$@"
|
||||
|
|
|
@ -9,6 +9,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.index.translog.TranslogToolCli ^
|
||||
%*
|
||||
|
|
|
@ -51,7 +51,7 @@ if "%MAYBE_JVM_OPTIONS_PARSER_FAILED%" == "jvm_options_parser_failed" (
|
|||
)
|
||||
|
||||
cd /d "%ES_HOME%"
|
||||
%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!
|
||||
%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!
|
||||
|
||||
endlocal
|
||||
endlocal
|
||||
|
|
|
@ -222,6 +222,23 @@ class InstallPluginCommand extends EnvironmentAwareCommand {
|
|||
install(terminal, isBatch, extractedZip, env);
|
||||
}
|
||||
|
||||
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) throws Exception {
|
||||
if (OFFICIAL_PLUGINS.contains(pluginId)) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.google.common.jimfs.Configuration;
|
|||
import com.google.common.jimfs.Jimfs;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.elasticsearch.Build;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cli.ExitCodes;
|
||||
import org.elasticsearch.cli.MockTerminal;
|
||||
|
@ -890,6 +891,29 @@ public class InstallPluginCommandTests extends ESTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
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, "x-pack", false, environment));
|
||||
assertThat(exception, hasToString(containsString(expectedMessage)));
|
||||
}
|
||||
|
||||
public void testInstallMisspelledOfficialPlugins() throws Exception {
|
||||
Tuple<Path, Environment> env = createEnv(fs, temp);
|
||||
|
||||
|
|
|
@ -372,6 +372,7 @@ This command should give you a JSON result:
|
|||
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
|
||||
"version" : {
|
||||
"number" : "{version}",
|
||||
"build_flavor" : "oss",
|
||||
"build_hash" : "f27399d",
|
||||
"build_date" : "2016-03-30T09:51:41.449Z",
|
||||
"build_snapshot" : false,
|
||||
|
|
|
@ -19,6 +19,7 @@ which should give you a response something like this:
|
|||
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
|
||||
"version" : {
|
||||
"number" : "{version}",
|
||||
"build_flavor" : "oss",
|
||||
"build_hash" : "f27399d",
|
||||
"build_date" : "2016-03-30T09:51:41.449Z",
|
||||
"build_snapshot" : false,
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.security.CodeSource;
|
||||
import java.util.Objects;
|
||||
import java.util.jar.JarInputStream;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
|
@ -40,11 +41,45 @@ public class Build {
|
|||
*/
|
||||
public static final Build CURRENT;
|
||||
|
||||
public enum Flavor {
|
||||
|
||||
DEFAULT("default"),
|
||||
OSS("oss"),
|
||||
UNKNOWN("unknown");
|
||||
|
||||
final String displayName;
|
||||
|
||||
Flavor(final String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String displayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public static Flavor fromDisplayName(final String displayName) {
|
||||
switch (displayName) {
|
||||
case "default":
|
||||
return Flavor.DEFAULT;
|
||||
case "oss":
|
||||
return Flavor.OSS;
|
||||
case "unknown":
|
||||
return Flavor.UNKNOWN;
|
||||
default:
|
||||
throw new IllegalStateException("unexpected distribution flavor [" + displayName + "]; your distribution is broken");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static {
|
||||
final Flavor flavor;
|
||||
final String shortHash;
|
||||
final String date;
|
||||
final boolean isSnapshot;
|
||||
|
||||
flavor = Flavor.fromDisplayName(System.getProperty("es.distribution.flavor", "unknown"));
|
||||
|
||||
final String esPrefix = "elasticsearch-" + Version.CURRENT;
|
||||
final URL url = getElasticsearchCodeSourceLocation();
|
||||
final String urlStr = url == null ? "" : url.toString();
|
||||
|
@ -76,14 +111,14 @@ public class Build {
|
|||
}
|
||||
if (shortHash == null) {
|
||||
throw new IllegalStateException("Error finding the build shortHash. " +
|
||||
"Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug.");
|
||||
"Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug.");
|
||||
}
|
||||
if (date == null) {
|
||||
throw new IllegalStateException("Error finding the build date. " +
|
||||
"Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug.");
|
||||
"Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug.");
|
||||
}
|
||||
|
||||
CURRENT = new Build(shortHash, date, isSnapshot);
|
||||
CURRENT = new Build(flavor, shortHash, date, isSnapshot);
|
||||
}
|
||||
|
||||
private final boolean isSnapshot;
|
||||
|
@ -98,10 +133,12 @@ public class Build {
|
|||
return codeSource == null ? null : codeSource.getLocation();
|
||||
}
|
||||
|
||||
private final Flavor flavor;
|
||||
private final String shortHash;
|
||||
private final String date;
|
||||
|
||||
public Build(String shortHash, String date, boolean isSnapshot) {
|
||||
public Build(Flavor flavor, String shortHash, String date, boolean isSnapshot) {
|
||||
this.flavor = flavor;
|
||||
this.shortHash = shortHash;
|
||||
this.date = date;
|
||||
this.isSnapshot = isSnapshot;
|
||||
|
@ -116,25 +153,38 @@ public class Build {
|
|||
}
|
||||
|
||||
public static Build readBuild(StreamInput in) throws IOException {
|
||||
final Flavor flavor;
|
||||
if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
|
||||
flavor = Flavor.fromDisplayName(in.readString());
|
||||
} else {
|
||||
flavor = Flavor.OSS;
|
||||
}
|
||||
String hash = in.readString();
|
||||
String date = in.readString();
|
||||
boolean snapshot = in.readBoolean();
|
||||
return new Build(hash, date, snapshot);
|
||||
return new Build(flavor, hash, date, snapshot);
|
||||
}
|
||||
|
||||
public static void writeBuild(Build build, StreamOutput out) throws IOException {
|
||||
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
|
||||
out.writeString(build.flavor().displayName());
|
||||
}
|
||||
out.writeString(build.shortHash());
|
||||
out.writeString(build.date());
|
||||
out.writeBoolean(build.isSnapshot());
|
||||
}
|
||||
|
||||
public Flavor flavor() {
|
||||
return flavor;
|
||||
}
|
||||
|
||||
public boolean isSnapshot() {
|
||||
return isSnapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + shortHash + "][" + date + "]";
|
||||
return "[" + flavor.displayName() + "][" + shortHash + "][" + date + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,6 +198,10 @@ public class Build {
|
|||
|
||||
Build build = (Build) o;
|
||||
|
||||
if (!flavor.equals(build.flavor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isSnapshot != build.isSnapshot) {
|
||||
return false;
|
||||
}
|
||||
|
@ -160,9 +214,7 @@ public class Build {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (isSnapshot ? 1 : 0);
|
||||
result = 31 * result + shortHash.hashCode();
|
||||
result = 31 * result + date.hashCode();
|
||||
return result;
|
||||
return Objects.hash(flavor, isSnapshot, shortHash, date);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
|
|||
builder.field("cluster_uuid", clusterUuid);
|
||||
builder.startObject("version")
|
||||
.field("number", version.toString())
|
||||
.field("build_flavor", build.flavor().displayName())
|
||||
.field("build_hash", build.shortHash())
|
||||
.field("build_date", build.date())
|
||||
.field("build_snapshot", build.isSnapshot())
|
||||
|
@ -128,8 +129,13 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
|
|||
PARSER.declareString((response, value) -> response.clusterUuid = value, new ParseField("cluster_uuid"));
|
||||
PARSER.declareString((response, value) -> {}, new ParseField("tagline"));
|
||||
PARSER.declareObject((response, value) -> {
|
||||
response.build = new Build((String) value.get("build_hash"), (String) value.get("build_date"),
|
||||
(boolean) value.get("build_snapshot"));
|
||||
final String buildFlavor = (String) value.get("build_flavor");
|
||||
response.build =
|
||||
new Build(
|
||||
buildFlavor == null ? Build.Flavor.UNKNOWN : Build.Flavor.fromDisplayName(buildFlavor),
|
||||
(String) value.get("build_hash"),
|
||||
(String) value.get("build_date"),
|
||||
(boolean) value.get("build_snapshot"));
|
||||
response.version = Version.fromString((String) value.get("number"));
|
||||
}, (parser, context) -> parser.map(), new ParseField("version"));
|
||||
}
|
||||
|
|
|
@ -284,9 +284,10 @@ public class Node implements Closeable {
|
|||
|
||||
final JvmInfo jvmInfo = JvmInfo.jvmInfo();
|
||||
logger.info(
|
||||
"version[{}], pid[{}], build[{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]",
|
||||
"version[{}], pid[{}], build[{}/{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]",
|
||||
Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()),
|
||||
jvmInfo.pid(),
|
||||
Build.CURRENT.flavor().displayName(),
|
||||
Build.CURRENT.shortHash(),
|
||||
Build.CURRENT.date(),
|
||||
Constants.OS_NAME,
|
||||
|
|
|
@ -25,6 +25,9 @@ import org.elasticsearch.test.ESTestCase;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BuildTests extends ESTestCase {
|
||||
|
||||
|
@ -40,17 +43,23 @@ public class BuildTests extends ESTestCase {
|
|||
|
||||
public void testEqualsAndHashCode() {
|
||||
Build build = Build.CURRENT;
|
||||
Build another = new Build(build.shortHash(), build.date(), build.isSnapshot());
|
||||
|
||||
Build another = new Build(build.flavor(), build.shortHash(), build.date(), build.isSnapshot());
|
||||
assertEquals(build, another);
|
||||
assertEquals(build.hashCode(), another.hashCode());
|
||||
|
||||
Build differentHash = new Build(randomAlphaOfLengthBetween(3, 10), build.date(), build.isSnapshot());
|
||||
final Set<Build.Flavor> otherFlavors =
|
||||
Arrays.stream(Build.Flavor.values()).filter(f -> !f.equals(build.flavor())).collect(Collectors.toSet());
|
||||
Build differentFlavor = new Build(randomFrom(otherFlavors), build.shortHash(), build.date(), build.isSnapshot());
|
||||
assertNotEquals(build, differentFlavor);
|
||||
|
||||
Build differentHash = new Build(build.flavor(), randomAlphaOfLengthBetween(3, 10), build.date(), build.isSnapshot());
|
||||
assertNotEquals(build, differentHash);
|
||||
|
||||
Build differentDate = new Build(build.shortHash(), "1970-01-01", build.isSnapshot());
|
||||
Build differentDate = new Build(build.flavor(), build.shortHash(), "1970-01-01", build.isSnapshot());
|
||||
assertNotEquals(build, differentDate);
|
||||
|
||||
Build differentSnapshot = new Build(build.shortHash(), build.date(), !build.isSnapshot());
|
||||
Build differentSnapshot = new Build(build.flavor(), build.shortHash(), build.date(), !build.isSnapshot());
|
||||
assertNotEquals(build, differentSnapshot);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,8 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
|
|||
String clusterUuid = randomAlphaOfLength(10);
|
||||
ClusterName clusterName = new ClusterName(randomAlphaOfLength(10));
|
||||
String nodeName = randomAlphaOfLength(10);
|
||||
Build build = new Build(randomAlphaOfLength(8), new Date(randomNonNegativeLong()).toString(), randomBoolean());
|
||||
Build build =
|
||||
new Build(Build.Flavor.UNKNOWN, randomAlphaOfLength(8), new Date(randomNonNegativeLong()).toString(), randomBoolean());
|
||||
Version version = VersionUtils.randomVersion(random());
|
||||
return new MainResponse(nodeName, version, clusterName, clusterUuid , build);
|
||||
}
|
||||
|
@ -57,7 +58,7 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
|
|||
|
||||
public void testToXContent() throws IOException {
|
||||
String clusterUUID = randomAlphaOfLengthBetween(10, 20);
|
||||
Build build = new Build(Build.CURRENT.shortHash(), Build.CURRENT.date(), Build.CURRENT.isSnapshot());
|
||||
Build build = new Build(Build.CURRENT.flavor(), Build.CURRENT.shortHash(), Build.CURRENT.date(), Build.CURRENT.isSnapshot());
|
||||
Version version = Version.CURRENT;
|
||||
MainResponse response = new MainResponse("nodeName", version, new ClusterName("clusterName"), clusterUUID, build);
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
|
@ -68,6 +69,7 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
|
|||
+ "\"cluster_uuid\":\"" + clusterUUID + "\","
|
||||
+ "\"version\":{"
|
||||
+ "\"number\":\"" + version.toString() + "\","
|
||||
+ "\"build_flavor\":\"" + Build.CURRENT.flavor().displayName() + "\","
|
||||
+ "\"build_hash\":\"" + Build.CURRENT.shortHash() + "\","
|
||||
+ "\"build_date\":\"" + Build.CURRENT.date() + "\","
|
||||
+ "\"build_snapshot\":" + Build.CURRENT.isSnapshot() + ","
|
||||
|
@ -94,7 +96,7 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
|
|||
break;
|
||||
case 2:
|
||||
// toggle the snapshot flag of the original Build parameter
|
||||
build = new Build(build.shortHash(), build.date(), !build.isSnapshot());
|
||||
build = new Build(Build.Flavor.UNKNOWN, build.shortHash(), build.date(), !build.isSnapshot());
|
||||
break;
|
||||
case 3:
|
||||
version = randomValueOtherThan(version, () -> VersionUtils.randomVersion(random()));
|
||||
|
|
|
@ -13,6 +13,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.xpack.core.ssl.CertificateGenerateTool \
|
||||
"$@"
|
||||
|
|
|
@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.xpack.core.ssl.CertificateGenerateTool ^
|
||||
%*
|
||||
|
|
|
@ -13,6 +13,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.xpack.core.ssl.CertificateTool \
|
||||
"$@"
|
||||
|
|
|
@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.xpack.core.ssl.CertificateTool ^
|
||||
%*
|
||||
|
|
|
@ -13,6 +13,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool \
|
||||
"$@"
|
||||
|
|
|
@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool ^
|
||||
%*
|
||||
|
|
|
@ -13,6 +13,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand \
|
||||
"$@"
|
||||
|
|
|
@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand ^
|
||||
%*
|
||||
|
|
|
@ -13,6 +13,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool \
|
||||
"$@"
|
||||
|
|
|
@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool ^
|
||||
%*
|
||||
|
|
|
@ -13,6 +13,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool \
|
||||
"$@"
|
||||
|
|
|
@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool ^
|
||||
%*
|
||||
|
|
|
@ -13,6 +13,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.xpack.security.authc.file.tool.UsersTool \
|
||||
"$@"
|
||||
|
|
|
@ -15,6 +15,7 @@ call "%~dp0x-pack-security-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.xpack.security.authc.file.tool.UsersTool ^
|
||||
%*
|
||||
|
|
|
@ -13,6 +13,7 @@ exec \
|
|||
$ES_JAVA_OPTS \
|
||||
-Des.path.home="$ES_HOME" \
|
||||
-Des.path.conf="$ES_PATH_CONF" \
|
||||
-Des.distribution.flavor="$ES_DISTRIBUTION_FLAVOR" \
|
||||
-cp "$ES_CLASSPATH" \
|
||||
org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool \
|
||||
"$@"
|
||||
|
|
|
@ -15,6 +15,7 @@ call "%~dp0x-pack-watcher-env.bat" || exit /b 1
|
|||
%ES_JAVA_OPTS% ^
|
||||
-Des.path.home="%ES_HOME%" ^
|
||||
-Des.path.conf="%ES_PATH_CONF%" ^
|
||||
-Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" ^
|
||||
-cp "%ES_CLASSPATH%" ^
|
||||
org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool ^
|
||||
%*
|
||||
|
|
Loading…
Reference in New Issue