diff --git a/Vagrantfile b/Vagrantfile index f008b339c3f..a818d666655 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -104,6 +104,12 @@ SOURCE_PROMPT source /etc/profile.d/elasticsearch_prompt.sh SOURCE_PROMPT SHELL + # Creates a file to mark the machine as created by vagrant. Tests check + # for this file and refuse to run if it is not present so that they can't + # be run unexpectedly. + config.vm.provision "markerfile", type: "shell", inline: <<-SHELL + touch /etc/is_vagrant_vm + SHELL end config.config_procs.push ['2', set_prompt] end @@ -263,7 +269,7 @@ def provision(config, echo "==> Installing Gradle" curl -sS -o /tmp/gradle.zip -L https://services.gradle.org/distributions/gradle-3.3-bin.zip unzip /tmp/gradle.zip -d /opt - rm -rf /tmp/gradle.zip + rm -rf /tmp/gradle.zip ln -s /opt/gradle-3.3/bin/gradle /usr/bin/gradle # make nfs mounted gradle home dir writeable chown vagrant:vagrant /home/vagrant/.gradle diff --git a/qa/vagrant/src/test/resources/packaging/tests/20_tar_package.bats b/qa/vagrant/src/test/resources/packaging/tests/20_tar_package.bats index 2d502084a4a..9c5ca24d0a0 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/20_tar_package.bats +++ b/qa/vagrant/src/test/resources/packaging/tests/20_tar_package.bats @@ -3,9 +3,14 @@ # This file is used to test the tar gz package. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # The test case can be executed with the Bash Automated # Testing System tool available at https://github.com/sstephenson/bats diff --git a/qa/vagrant/src/test/resources/packaging/tests/30_deb_package.bats b/qa/vagrant/src/test/resources/packaging/tests/30_deb_package.bats index b7e925f2899..b07825d7f2f 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/30_deb_package.bats +++ b/qa/vagrant/src/test/resources/packaging/tests/30_deb_package.bats @@ -4,9 +4,14 @@ # of a Debian package. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # The test case can be executed with the Bash Automated # Testing System tool available at https://github.com/sstephenson/bats diff --git a/qa/vagrant/src/test/resources/packaging/tests/40_rpm_package.bats b/qa/vagrant/src/test/resources/packaging/tests/40_rpm_package.bats index effd7e27ae9..b92b692401e 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/40_rpm_package.bats +++ b/qa/vagrant/src/test/resources/packaging/tests/40_rpm_package.bats @@ -3,9 +3,14 @@ # This file is used to test the installation of a RPM package. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # The test case can be executed with the Bash Automated # Testing System tool available at https://github.com/sstephenson/bats diff --git a/qa/vagrant/src/test/resources/packaging/tests/60_systemd.bats b/qa/vagrant/src/test/resources/packaging/tests/60_systemd.bats index 10897753ab3..b46fd6786bb 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/60_systemd.bats +++ b/qa/vagrant/src/test/resources/packaging/tests/60_systemd.bats @@ -3,9 +3,14 @@ # This file is used to test the elasticsearch Systemd setup. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # The test case can be executed with the Bash Automated # Testing System tool available at https://github.com/sstephenson/bats diff --git a/qa/vagrant/src/test/resources/packaging/tests/70_sysv_initd.bats b/qa/vagrant/src/test/resources/packaging/tests/70_sysv_initd.bats index 70db8744456..fa6f91498ca 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/70_sysv_initd.bats +++ b/qa/vagrant/src/test/resources/packaging/tests/70_sysv_initd.bats @@ -3,9 +3,14 @@ # This file is used to test the elasticsearch init.d scripts. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # The test case can be executed with the Bash Automated # Testing System tool available at https://github.com/sstephenson/bats @@ -60,11 +65,11 @@ setup() { @test "[INIT.D] elasticsearch fails if startup script is not executable" { local INIT="/etc/init.d/elasticsearch" local DAEMON="$ESHOME/bin/elasticsearch" - + sudo chmod -x "$DAEMON" run "$INIT" sudo chmod +x "$DAEMON" - + [ "$status" -eq 1 ] [[ "$output" == *"The elasticsearch startup script does not exists or it is not executable, tried: $DAEMON"* ]] } diff --git a/qa/vagrant/src/test/resources/packaging/tests/75_bad_data_paths.bats b/qa/vagrant/src/test/resources/packaging/tests/75_bad_data_paths.bats index 0f802a439b7..59747bd6837 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/75_bad_data_paths.bats +++ b/qa/vagrant/src/test/resources/packaging/tests/75_bad_data_paths.bats @@ -4,9 +4,14 @@ # default.data.path setting into the data.path even when it doesn't belong. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # The test case can be executed with the Bash Automated # Testing System tool available at https://github.com/sstephenson/bats diff --git a/qa/vagrant/src/test/resources/packaging/tests/80_upgrade.bats b/qa/vagrant/src/test/resources/packaging/tests/80_upgrade.bats index 9f5bf9c5024..f402305156b 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/80_upgrade.bats +++ b/qa/vagrant/src/test/resources/packaging/tests/80_upgrade.bats @@ -5,9 +5,14 @@ # fancy rolling restarts. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # The test case can be executed with the Bash Automated # Testing System tool available at https://github.com/sstephenson/bats diff --git a/qa/vagrant/src/test/resources/packaging/tests/90_reinstall.bats b/qa/vagrant/src/test/resources/packaging/tests/90_reinstall.bats index 4dd682efbdd..816247f95f9 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/90_reinstall.bats +++ b/qa/vagrant/src/test/resources/packaging/tests/90_reinstall.bats @@ -5,9 +5,14 @@ # fancy rolling restarts. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # The test case can be executed with the Bash Automated # Testing System tool available at https://github.com/sstephenson/bats diff --git a/qa/vagrant/src/test/resources/packaging/tests/module_and_plugin_test_cases.bash b/qa/vagrant/src/test/resources/packaging/tests/module_and_plugin_test_cases.bash index 64797a33f57..31b9ca4f3fd 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/module_and_plugin_test_cases.bash +++ b/qa/vagrant/src/test/resources/packaging/tests/module_and_plugin_test_cases.bash @@ -5,9 +5,14 @@ # rpm, and deb. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # The test case can be executed with the Bash Automated # Testing System tool available at https://github.com/sstephenson/bats diff --git a/qa/vagrant/src/test/resources/packaging/utils/modules.bash b/qa/vagrant/src/test/resources/packaging/utils/modules.bash index 2e80fd648f3..9691fd74701 100644 --- a/qa/vagrant/src/test/resources/packaging/utils/modules.bash +++ b/qa/vagrant/src/test/resources/packaging/utils/modules.bash @@ -4,9 +4,14 @@ # the .deb/.rpm packages and the SysV/Systemd scripts. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # Licensed to Elasticsearch under one or more contributor # license agreements. See the NOTICE file distributed with @@ -41,4 +46,4 @@ check_module() { check_secure_module() { check_module "$@" plugin-security.policy -} \ No newline at end of file +} diff --git a/qa/vagrant/src/test/resources/packaging/utils/packages.bash b/qa/vagrant/src/test/resources/packaging/utils/packages.bash index 700c1c66185..dc1842c76f7 100644 --- a/qa/vagrant/src/test/resources/packaging/utils/packages.bash +++ b/qa/vagrant/src/test/resources/packaging/utils/packages.bash @@ -4,9 +4,14 @@ # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # Licensed to Elasticsearch under one or more contributor # license agreements. See the NOTICE file distributed with diff --git a/qa/vagrant/src/test/resources/packaging/utils/plugins.bash b/qa/vagrant/src/test/resources/packaging/utils/plugins.bash index 55e7fdfc484..d6a4f389fd0 100644 --- a/qa/vagrant/src/test/resources/packaging/utils/plugins.bash +++ b/qa/vagrant/src/test/resources/packaging/utils/plugins.bash @@ -1,12 +1,17 @@ #!/bin/bash -# This file contains some utilities to test the elasticsearch scripts, -# the .deb/.rpm packages and the SysV/Systemd scripts. +# This file contains some utilities to test the elasticsearch +# plugin installation and uninstallation process. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # Licensed to Elasticsearch under one or more contributor # license agreements. See the NOTICE file distributed with diff --git a/qa/vagrant/src/test/resources/packaging/utils/tar.bash b/qa/vagrant/src/test/resources/packaging/utils/tar.bash index b5edebaf41c..5a34cb5b9fd 100644 --- a/qa/vagrant/src/test/resources/packaging/utils/tar.bash +++ b/qa/vagrant/src/test/resources/packaging/utils/tar.bash @@ -1,12 +1,17 @@ #!/bin/bash -# This file contains some utilities to test the elasticsearch scripts, -# the .deb/.rpm packages and the SysV/Systemd scripts. +# This file contains some utilities to test the elasticsearch +# tar distribution. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # Licensed to Elasticsearch under one or more contributor # license agreements. See the NOTICE file distributed with diff --git a/qa/vagrant/src/test/resources/packaging/utils/utils.bash b/qa/vagrant/src/test/resources/packaging/utils/utils.bash index 877f49b576d..bb0ebbf1814 100644 --- a/qa/vagrant/src/test/resources/packaging/utils/utils.bash +++ b/qa/vagrant/src/test/resources/packaging/utils/utils.bash @@ -4,9 +4,14 @@ # the .deb/.rpm packages and the SysV/Systemd scripts. # 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. +# dramatically change your system. It should only be executed +# in a throw-away VM like those made by the Vagrantfile at +# the root of the Elasticsearch source code. This should +# cause the script to fail if it is executed any other way: +[ -f /etc/is_vagrant_vm ] || { + >&2 echo "must be run on a vagrant VM" + exit 1 +} # Licensed to Elasticsearch under one or more contributor # license agreements. See the NOTICE file distributed with