SQL: Bundle the CLI into x-pack (elastic/x-pack-elasticsearch#3316)
This adds: * The CLI jar itself into the `bin`. It is an executable jar. * A shell and bat script to start the CLI. This isn't strictly required but folks will appreciate the consistency. * Basic packaging tests for the CLI. Relates to elastic/x-pack-elasticsearch#2979 Original commit: elastic/x-pack-elasticsearch@158f70a530
This commit is contained in:
parent
f5af60c7cf
commit
59e6d34c29
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
# or more contributor license agreements. Licensed under the Elastic License;
|
||||
# you may not use this file except in compliance with the Elastic License.
|
||||
|
||||
source "`dirname "$0"`"/../elasticsearch-env
|
||||
|
||||
source "`dirname "$0"`"/x-pack-env
|
||||
|
||||
CLI_JAR=$(ls $ES_HOME/bin/x-pack/sql-cli-*.jar)
|
||||
|
||||
exec \
|
||||
"$JAVA" \
|
||||
-jar "$CLI_JAR" \
|
||||
"$@"
|
|
@ -0,0 +1,21 @@
|
|||
@echo off
|
||||
|
||||
rem Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
rem or more contributor license agreements. Licensed under the Elastic License;
|
||||
rem you may not use this file except in compliance with the Elastic License.
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
setlocal enableextensions
|
||||
|
||||
call "%~dp0..\elasticsearch-env.bat" || exit /b 1
|
||||
|
||||
call "%~dp0x-pack-env.bat" || exit /b 1
|
||||
|
||||
set CLI_JAR=!ES_CLASSPATH!;!ES_HOME!/plugins/x-pack/bin/sql-cli-*.jar
|
||||
|
||||
%JAVA% ^
|
||||
-jar "%CLI_JAR%" ^
|
||||
%*
|
||||
|
||||
endlocal
|
||||
endlocal
|
|
@ -64,6 +64,7 @@ configurations {
|
|||
}
|
||||
}
|
||||
}
|
||||
bundledBin
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -100,6 +101,9 @@ dependencies {
|
|||
|
||||
// sql's server components and its transitive dependencies
|
||||
compile project(':x-pack-elasticsearch:sql:server')
|
||||
bundledBin(project(':x-pack-elasticsearch:sql:cli')) {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
// common test deps
|
||||
testCompile 'org.elasticsearch:securemock:1.2'
|
||||
|
@ -176,6 +180,12 @@ bundlePlugin {
|
|||
// We don't ship the individual nativeBundle licenses - instead
|
||||
// they get combined into the top level NOTICES file we ship
|
||||
exclude 'platform/licenses/**'
|
||||
|
||||
// Include the SQL CLI jar in the bundled plugin
|
||||
dependsOn configurations.bundledBin
|
||||
from(configurations.bundledBin) {
|
||||
into 'bin'
|
||||
}
|
||||
}
|
||||
|
||||
// add api jar for extension authors to compile against
|
||||
|
|
|
@ -118,6 +118,33 @@ SETUP_OK
|
|||
curl -H "Authorization: Basic $basic" -XGET 'http://127.0.0.1:9200' | grep "You Know, for Search"
|
||||
done
|
||||
set -H
|
||||
}
|
||||
|
||||
@test "[$GROUP] test sql-cli" {
|
||||
password=$(grep "PASSWORD elastic = " /tmp/setup-passwords-output-with-bootstrap | sed "s/PASSWORD elastic = //")
|
||||
curl -s -u "elastic:$password" -H "Content-Type: application/json" -XPUT 'localhost:9200/library/book/1?refresh&pretty' -d'{
|
||||
"name": "Ender'"'"'s Game",
|
||||
"author": "Orson Scott Card",
|
||||
"release_date": "1985-06-01",
|
||||
"page_count": 324
|
||||
}'
|
||||
|
||||
password=$(grep "PASSWORD elastic = " /tmp/setup-passwords-output-with-bootstrap | sed "s/PASSWORD elastic = //")
|
||||
|
||||
run $ESHOME/bin/x-pack/sql-cli --debug true "http://elastic@127.0.0.1:9200" <<SQL
|
||||
$password
|
||||
SELECT * FROM library;
|
||||
SQL
|
||||
[ "$status" -eq 0 ] || {
|
||||
echo "SQL cli failed:\n$output"
|
||||
false
|
||||
}
|
||||
[[ "$output" == *"Card"* ]] || {
|
||||
echo "Failed to find author [Card] in library:$output"
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@test "[$GROUP] stop Elasticsearch" {
|
||||
stop_elasticsearch_service
|
||||
}
|
||||
|
|
|
@ -20,10 +20,11 @@ verify_xpack_installation() {
|
|||
assert_file "$ESHOME/bin/x-pack/extension" f $user $group 755
|
||||
assert_file "$ESHOME/bin/x-pack/migrate" f $user $group 755
|
||||
assert_file "$ESHOME/bin/x-pack/setup-passwords" f $user $group 755
|
||||
assert_file "$ESHOME/bin/x-pack/sql-cli" f $user $group 755
|
||||
assert_file "$ESHOME/bin/x-pack/syskeygen" f $user $group 755
|
||||
assert_file "$ESHOME/bin/x-pack/users" f $user $group 755
|
||||
assert_file "$ESHOME/bin/x-pack/x-pack-env" f $user $group 755
|
||||
assert_number_of_files "$ESHOME/bin/x-pack/" 18
|
||||
assert_number_of_files "$ESHOME/bin/x-pack/" 21
|
||||
|
||||
assert_file "$ESCONFIG/x-pack" d $user elasticsearch 750
|
||||
assert_file "$ESCONFIG/x-pack/users" f $user elasticsearch 660
|
||||
|
|
|
@ -34,6 +34,7 @@ forbiddenApisMain {
|
|||
}
|
||||
|
||||
jar {
|
||||
archivesBaseName = 'sql-cli'
|
||||
// Bundle all dependencies into the jar.
|
||||
from {
|
||||
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
|
|
Loading…
Reference in New Issue