Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13262 from nik9000/package_test_for_script_and_te…
…mplate Packaging test for filesystem scripts
- Loading branch information
Showing
12 changed files
with
209 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
qa/vagrant/src/test/resources/packaging/scripts/example/scripts/is_guide.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_source['title'] == 'Elasticsearch - The Definitive Guide' |
7 changes: 7 additions & 0 deletions
7
qa/vagrant/src/test/resources/packaging/scripts/example/scripts/is_guide.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"query": { | ||
"script": { | ||
"script_file": "is_guide" | ||
} | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
qa/vagrant/src/test/resources/packaging/scripts/os_package.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/bin/sh | ||
|
||
# This file contains some utilities to test the elasticsearch scripts with | ||
# the .deb/.rpm packages. | ||
|
||
# WARNING: This testing file must be executed as root and can | ||
# dramatically change your system. It removes the 'elasticsearch' | ||
# user/group and also many directories. Do not execute this file | ||
# unless you know exactly what you are doing. | ||
|
||
# Licensed to Elasticsearch under one or more contributor | ||
# license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright | ||
# ownership. Elasticsearch licenses this file to you under | ||
# the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
|
||
# Export some useful paths. | ||
export_elasticsearch_paths() { | ||
export ESHOME="/usr/share/elasticsearch" | ||
export ESPLUGINS="$ESHOME/plugins" | ||
export ESCONFIG="/etc/elasticsearch" | ||
export ESSCRIPTS="$ESCONFIG/scripts" | ||
export ESDATA="/var/lib/elasticsearch" | ||
export ESLOG="/var/log/elasticsearch" | ||
export ESPIDDIR="/var/run/elasticsearch" | ||
} | ||
|
||
# Install the rpm or deb package. | ||
# -u upgrade rather than install. This only matters for rpm. | ||
# -v the version to upgrade to. Defaults to the version under test. | ||
install_package() { | ||
local version=$(cat version) | ||
local rpmCommand='-i' | ||
while getopts ":uv:" opt; do | ||
case $opt in | ||
u) | ||
rpmCommand='-U' | ||
;; | ||
v) | ||
version=$OPTARG | ||
;; | ||
\?) | ||
echo "Invalid option: -$OPTARG" >&2 | ||
;; | ||
esac | ||
done | ||
if is_rpm; then | ||
rpm $rpmCommand elasticsearch-$version.rpm | ||
elif is_dpkg; then | ||
dpkg -i elasticsearch-$version.deb | ||
else | ||
skip "Only rpm or deb supported" | ||
fi | ||
} | ||
|
||
# Checks that all directories & files are correctly installed after a deb or | ||
# rpm install. | ||
verify_package_installation() { | ||
id elasticsearch | ||
|
||
getent group elasticsearch | ||
|
||
assert_file "$ESHOME" d root 755 | ||
assert_file "$ESHOME/bin" d root 755 | ||
assert_file "$ESHOME/lib" d root 755 | ||
assert_file "$ESCONFIG" d root 755 | ||
assert_file "$ESCONFIG/elasticsearch.yml" f root 644 | ||
assert_file "$ESCONFIG/logging.yml" f root 644 | ||
assert_file "$ESDATA" d elasticsearch 755 | ||
assert_file "$ESLOG" d elasticsearch 755 | ||
assert_file "$ESPLUGINS" d elasticsearch 755 | ||
assert_file "$ESPIDDIR" d elasticsearch 755 | ||
assert_file "$ESHOME/NOTICE.txt" f root 644 | ||
assert_file "$ESHOME/README.textile" f root 644 | ||
|
||
if is_dpkg; then | ||
# Env file | ||
assert_file "/etc/default/elasticsearch" f root 644 | ||
|
||
# Doc files | ||
assert_file "/usr/share/doc/elasticsearch" d root 755 | ||
assert_file "/usr/share/doc/elasticsearch/copyright" f root 644 | ||
fi | ||
|
||
if is_rpm; then | ||
# Env file | ||
assert_file "/etc/sysconfig/elasticsearch" f root 644 | ||
# License file | ||
assert_file "/usr/share/elasticsearch/LICENSE.txt" f root 644 | ||
fi | ||
|
||
if is_systemd; then | ||
assert_file "/usr/lib/systemd/system/elasticsearch.service" f root 644 | ||
assert_file "/usr/lib/tmpfiles.d/elasticsearch.conf" f root 644 | ||
assert_file "/usr/lib/sysctl.d/elasticsearch.conf" f root 644 | ||
fi | ||
} |
Oops, something went wrong.