From fb7118fde27d8ec07d8beee74d168fa1adaf5777 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 28 Aug 2017 20:47:58 -0400 Subject: [PATCH] Add packaging tests for keystore creation This commit adds a packaging test that the keystore is created when X-Pack is installed, and that it has the correct ownership and permissions. Relates elastic/x-pack-elasticsearch#2380 Original commit: elastic/x-pack-elasticsearch@27e181d2f69dee9080308ff16155c48e07479a7d --- .../packaging/tests/20_tar_keystore.bats | 1 + .../packaging/tests/30_package_keystore.bats | 1 + .../resources/packaging/tests/keystore.bash | 55 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 120000 qa/vagrant/src/test/resources/packaging/tests/20_tar_keystore.bats create mode 120000 qa/vagrant/src/test/resources/packaging/tests/30_package_keystore.bats create mode 100644 qa/vagrant/src/test/resources/packaging/tests/keystore.bash diff --git a/qa/vagrant/src/test/resources/packaging/tests/20_tar_keystore.bats b/qa/vagrant/src/test/resources/packaging/tests/20_tar_keystore.bats new file mode 120000 index 00000000000..a3c545a63d0 --- /dev/null +++ b/qa/vagrant/src/test/resources/packaging/tests/20_tar_keystore.bats @@ -0,0 +1 @@ +keystore.bash \ No newline at end of file diff --git a/qa/vagrant/src/test/resources/packaging/tests/30_package_keystore.bats b/qa/vagrant/src/test/resources/packaging/tests/30_package_keystore.bats new file mode 120000 index 00000000000..a3c545a63d0 --- /dev/null +++ b/qa/vagrant/src/test/resources/packaging/tests/30_package_keystore.bats @@ -0,0 +1 @@ +keystore.bash \ No newline at end of file diff --git a/qa/vagrant/src/test/resources/packaging/tests/keystore.bash b/qa/vagrant/src/test/resources/packaging/tests/keystore.bash new file mode 100644 index 00000000000..d3fe102b7c1 --- /dev/null +++ b/qa/vagrant/src/test/resources/packaging/tests/keystore.bash @@ -0,0 +1,55 @@ +#!/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 + +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_and_check_plugin x pack x-pack-*.jar + if [[ "$BATS_TEST_FILENAME" =~ 20_tar_keystore.bats$ ]]; then + assert_file "$ESCONFIG/elasticsearch.keystore" f elasticsearch elasticsearch 660 + else + assert_file "$ESCONFIG/elasticsearch.keystore" f root elasticsearch 660 + fi +} + +