Adapt tests to package keystore creation (elastic/x-pack-elasticsearch#4068)
This commit adapts the X-Pack packaging tests to the change in Elasticsearch to create the keystore on package installation. Original commit: elastic/x-pack-elasticsearch@e86c98fa83
This commit is contained in:
parent
4bce53a1ad
commit
839a776dad
|
@ -273,7 +273,7 @@ public class ClusterStatsMonitoringDocTests extends BaseMonitoringDocTestCase<Cl
|
||||||
final PluginsAndModules mockPluginsAndModules = mock(PluginsAndModules.class);
|
final PluginsAndModules mockPluginsAndModules = mock(PluginsAndModules.class);
|
||||||
when(mockNodeInfo.getPlugins()).thenReturn(mockPluginsAndModules);
|
when(mockNodeInfo.getPlugins()).thenReturn(mockPluginsAndModules);
|
||||||
final PluginInfo pluginInfo = new PluginInfo("_plugin", "_plugin_desc", "_plugin_version", Version.CURRENT,
|
final PluginInfo pluginInfo = new PluginInfo("_plugin", "_plugin_desc", "_plugin_version", Version.CURRENT,
|
||||||
"1.8", "_plugin_class", Collections.emptyList(), false, false);
|
"1.8", "_plugin_class", Collections.emptyList(), false);
|
||||||
when(mockPluginsAndModules.getPluginInfos()).thenReturn(singletonList(pluginInfo));
|
when(mockPluginsAndModules.getPluginInfos()).thenReturn(singletonList(pluginInfo));
|
||||||
|
|
||||||
final OsInfo mockOsInfo = mock(OsInfo.class);
|
final OsInfo mockOsInfo = mock(OsInfo.class);
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
keystore.bash
|
|
|
@ -1 +0,0 @@
|
||||||
keystore.bash
|
|
|
@ -19,7 +19,7 @@ setup() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$BATS_TEST_FILENAME" =~ 40_tar_bootstrap_password.bats$ ]]; then
|
if [[ "$BATS_TEST_FILENAME" =~ 20_tar_bootstrap_password.bats$ ]]; then
|
||||||
load $BATS_UTILS/tar.bash
|
load $BATS_UTILS/tar.bash
|
||||||
GROUP='TAR BOOTSTRAP PASSWORD'
|
GROUP='TAR BOOTSTRAP PASSWORD'
|
||||||
install() {
|
install() {
|
||||||
|
@ -50,6 +50,9 @@ fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run sudo -E -u $ESPLUGIN_COMMAND_USER sh <<"NEW_PASS"
|
run sudo -E -u $ESPLUGIN_COMMAND_USER sh <<"NEW_PASS"
|
||||||
|
if [[ ! -f $ESCONFIG/elasticsearch.keystore ]]; then
|
||||||
|
$ESHOME/bin/elasticsearch-keystore create
|
||||||
|
fi
|
||||||
cat /dev/urandom | tr -dc "[a-zA-Z0-9]" | fold -w 20 | head -n 1 > /tmp/bootstrap.password
|
cat /dev/urandom | tr -dc "[a-zA-Z0-9]" | fold -w 20 | head -n 1 > /tmp/bootstrap.password
|
||||||
cat /tmp/bootstrap.password | $ESHOME/bin/elasticsearch-keystore add --stdin bootstrap.password
|
cat /tmp/bootstrap.password | $ESHOME/bin/elasticsearch-keystore add --stdin bootstrap.password
|
||||||
NEW_PASS
|
NEW_PASS
|
||||||
|
|
|
@ -28,7 +28,7 @@ DEFAULT_PACKAGE_USER=root
|
||||||
DEFAULT_PACKAGE_ESHOME="/usr/share/elasticsearch"
|
DEFAULT_PACKAGE_ESHOME="/usr/share/elasticsearch"
|
||||||
DEFAULT_PACKAGE_UTILS=$BATS_UTILS/packages.bash
|
DEFAULT_PACKAGE_UTILS=$BATS_UTILS/packages.bash
|
||||||
|
|
||||||
if [[ "$BATS_TEST_FILENAME" =~ 60_tar_certgen.bats$ ]]; then
|
if [[ "$BATS_TEST_FILENAME" =~ 40_tar_certgen.bats$ ]]; then
|
||||||
GROUP='TAR CERTGEN'
|
GROUP='TAR CERTGEN'
|
||||||
|
|
||||||
MASTER_USER=$DEFAULT_ARCHIVE_USER
|
MASTER_USER=$DEFAULT_ARCHIVE_USER
|
||||||
|
@ -153,6 +153,9 @@ start_node_using_package() {
|
||||||
# and restart the node once ssl/tls is configured. Or use setup-passwords over
|
# and restart the node once ssl/tls is configured. Or use setup-passwords over
|
||||||
# HTTPS with the right cacerts imported into a Java keystore.
|
# HTTPS with the right cacerts imported into a Java keystore.
|
||||||
run sudo -E -u $MASTER_USER sh <<"NEW_PASS"
|
run sudo -E -u $MASTER_USER sh <<"NEW_PASS"
|
||||||
|
if [[ ! -f $ESCONFIG/elasticsearch.keystore ]]; then
|
||||||
|
$ESHOME/bin/elasticsearch-keystore create
|
||||||
|
fi
|
||||||
echo "changeme" | $ESHOME/bin/elasticsearch-keystore add --stdin bootstrap.password
|
echo "changeme" | $ESHOME/bin/elasticsearch-keystore add --stdin bootstrap.password
|
||||||
NEW_PASS
|
NEW_PASS
|
||||||
[ "$status" -eq 0 ] || {
|
[ "$status" -eq 0 ] || {
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
#!/usr/bin/env bats
|
|
||||||
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
load $BATS_UTILS/utils.bash
|
|
||||||
load $BATS_UTILS/plugins.bash
|
|
||||||
load $BATS_UTILS/xpack.bash
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
if [ $BATS_TEST_NUMBER == 1 ]; then
|
|
||||||
clean_before_test
|
|
||||||
install
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ "$BATS_TEST_FILENAME" =~ 20_tar_keystore.bats$ ]]; then
|
|
||||||
load $BATS_UTILS/tar.bash
|
|
||||||
GROUP='TAR KEYSTORE'
|
|
||||||
install() {
|
|
||||||
install_archive
|
|
||||||
verify_archive_installation
|
|
||||||
}
|
|
||||||
export ESHOME=/tmp/elasticsearch
|
|
||||||
export_elasticsearch_paths
|
|
||||||
export ESPLUGIN_COMMAND_USER=elasticsearch
|
|
||||||
else
|
|
||||||
load $BATS_UTILS/packages.bash
|
|
||||||
if is_rpm; then
|
|
||||||
GROUP='RPM KEYSTORE'
|
|
||||||
elif is_dpkg; then
|
|
||||||
GROUP='DEB KEYSTORE'
|
|
||||||
fi
|
|
||||||
export_elasticsearch_paths
|
|
||||||
export ESPLUGIN_COMMAND_USER=root
|
|
||||||
install() {
|
|
||||||
install_package
|
|
||||||
verify_package_installation
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
@test "[$GROUP] keystore does not exist" {
|
|
||||||
assert_file_not_exist /etc/elasticsearch/elasticsearch.keystore
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "[$GROUP] keystore exists after install" {
|
|
||||||
install_xpack
|
|
||||||
verify_xpack_installation
|
|
||||||
}
|
|
|
@ -20,7 +20,7 @@ setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if [[ "$BATS_TEST_FILENAME" =~ 50_tar_setup_passwords.bats$ ]]; then
|
if [[ "$BATS_TEST_FILENAME" =~ 30_tar_setup_passwords.bats$ ]]; then
|
||||||
load $BATS_UTILS/tar.bash
|
load $BATS_UTILS/tar.bash
|
||||||
GROUP='TAR SETUP PASSWORD'
|
GROUP='TAR SETUP PASSWORD'
|
||||||
install() {
|
install() {
|
||||||
|
|
|
@ -69,9 +69,6 @@ verify_xpack_installation() {
|
||||||
done
|
done
|
||||||
assert_number_of_files "$ESCONFIG/$name/" $configFilesCount
|
assert_number_of_files "$ESCONFIG/$name/" $configFilesCount
|
||||||
|
|
||||||
# Verify keystore creation
|
|
||||||
assert_file "$ESCONFIG/elasticsearch.keystore" f $user elasticsearch 660
|
|
||||||
|
|
||||||
# Read the $name.expected file that contains all the expected
|
# Read the $name.expected file that contains all the expected
|
||||||
# plugins for the meta plugin
|
# plugins for the meta plugin
|
||||||
while read plugin; do
|
while read plugin; do
|
||||||
|
|
Loading…
Reference in New Issue