From 83aae92353adb1797fc271e53a90b90912af6004 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sun, 18 Mar 2018 13:06:11 -0400 Subject: [PATCH] Use bash in packaging heredocs (elastic/x-pack-elasticsearch#4145) In some places in the packaging tests we use heredocs to run some scripts, for example, under the root user. However, we were running these heredocs under sh instead of bash. This is confusing since we use bash everywhere and we end up with syntax in the herdocs that expects bash but will not necessarily be run under bash. For example, one circumstance where this arises is the bash syntax [[. This leads to packaging test failures on some systems (e.g., the debian-8 box) that are solely due to this sh/bash distinction. We should really be using bash everywhere, it is the shell that we settled on for all of our scripts everywhere awhile ago and then we can avoid this confusion. This commit replaces the usage of sh in the X-Pack packaging tests with bash. Original commit: elastic/x-pack-elasticsearch@7555bb32c83cf0bf8a0be394a041ef5212c03697 --- .../resources/packaging/tests/bootstrap_password.bash | 6 +++--- .../src/test/resources/packaging/tests/certgen.bash | 8 ++++---- .../test/resources/packaging/tests/setup_passwords.bash | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/qa/vagrant/src/test/resources/packaging/tests/bootstrap_password.bash b/qa/vagrant/src/test/resources/packaging/tests/bootstrap_password.bash index 9446ce1d518..2dde25efb01 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/bootstrap_password.bash +++ b/qa/vagrant/src/test/resources/packaging/tests/bootstrap_password.bash @@ -49,7 +49,7 @@ fi sudo rm -f /tmp/bootstrap.password fi - run sudo -E -u $ESPLUGIN_COMMAND_USER sh <<"NEW_PASS" + run sudo -E -u $ESPLUGIN_COMMAND_USER bash <<"NEW_PASS" if [[ ! -f $ESCONFIG/elasticsearch.keystore ]]; then $ESHOME/bin/elasticsearch-keystore create fi @@ -65,7 +65,7 @@ NEW_PASS } @test "[$GROUP] test bootstrap.password is in setting list" { - run sudo -E -u $ESPLUGIN_COMMAND_USER sh <<"NODE_SETTINGS" + run sudo -E -u $ESPLUGIN_COMMAND_USER bash <<"NODE_SETTINGS" cat >> $ESCONFIG/elasticsearch.yml <<- EOF network.host: 127.0.0.1 http.port: 9200 @@ -92,7 +92,7 @@ NODE_SETTINGS sudo rm -f /tmp/setup-passwords-output-with-bootstrap fi - run sudo -E -u $ESPLUGIN_COMMAND_USER sh <<"SETUP_OK" + run sudo -E -u $ESPLUGIN_COMMAND_USER bash <<"SETUP_OK" echo 'y' | $ESHOME/bin/x-pack/setup-passwords auto SETUP_OK echo "$output" > /tmp/setup-passwords-output-with-bootstrap diff --git a/qa/vagrant/src/test/resources/packaging/tests/certgen.bash b/qa/vagrant/src/test/resources/packaging/tests/certgen.bash index 2848b43a949..9ab475e32a6 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/certgen.bash +++ b/qa/vagrant/src/test/resources/packaging/tests/certgen.bash @@ -152,7 +152,7 @@ start_node_using_package() { # The alternative would be to start the master node, use setup-passwords # and restart the node once ssl/tls is configured. Or use setup-passwords over # 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 bash <<"NEW_PASS" if [[ ! -f $ESCONFIG/elasticsearch.keystore ]]; then $ESHOME/bin/elasticsearch-keystore create fi @@ -166,7 +166,7 @@ NEW_PASS } @test "[$GROUP] create instances file" { - run sudo -E -u $MASTER_USER sh <<"CREATE_INSTANCES_FILE" + run sudo -E -u $MASTER_USER bash <<"CREATE_INSTANCES_FILE" cat > /tmp/instances.yml <<- EOF instances: - name: "node-master" @@ -233,7 +233,7 @@ CREATE_INSTANCES_FILE export ESHOME="$MASTER_HOME" export_elasticsearch_paths - run sudo -E -u $MASTER_USER sh <<"MASTER_SETTINGS" + run sudo -E -u $MASTER_USER bash <<"MASTER_SETTINGS" cat >> $ESCONFIG/elasticsearch.yml <<- EOF node.name: "node-master" node.master: true @@ -316,7 +316,7 @@ MASTER_SETTINGS export ESHOME="$DATA_HOME" export_elasticsearch_paths - run sudo -E -u $DATA_USER sh <<"DATA_SETTINGS" + run sudo -E -u $DATA_USER bash <<"DATA_SETTINGS" cat >> $ESCONFIG/elasticsearch.yml <<- EOF node.name: "node-data" node.master: false diff --git a/qa/vagrant/src/test/resources/packaging/tests/setup_passwords.bash b/qa/vagrant/src/test/resources/packaging/tests/setup_passwords.bash index aa71d93f6e3..3dab1801b9f 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/setup_passwords.bash +++ b/qa/vagrant/src/test/resources/packaging/tests/setup_passwords.bash @@ -49,7 +49,7 @@ fi run_elasticsearch_service 0 wait_for_xpack - run sudo -E -u $ESPLUGIN_COMMAND_USER sh <<"SETUP_AUTO" + run sudo -E -u $ESPLUGIN_COMMAND_USER bash <<"SETUP_AUTO" echo 'y' | $ESHOME/bin/x-pack/setup-passwords auto SETUP_AUTO echo "$output" > /tmp/setup-passwords-output