2015-08-04 09:36:22 -04:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
|
|
|
# This Vagrantfile exists to test packaging. Read more about its use in the
|
|
|
|
# vagrant section in TESTING.asciidoc.
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
Vagrant.configure(2) do |config|
|
2015-11-02 12:40:47 -05:00
|
|
|
config.vm.define "ubuntu-1204" do |config|
|
2016-03-18 13:33:58 -04:00
|
|
|
config.vm.box = "elastic/ubuntu-12.04-x86_64"
|
2015-08-04 09:36:22 -04:00
|
|
|
ubuntu_common config
|
|
|
|
end
|
2015-11-02 12:40:47 -05:00
|
|
|
config.vm.define "ubuntu-1404" do |config|
|
2016-03-18 13:33:58 -04:00
|
|
|
config.vm.box = "elastic/ubuntu-14.04-x86_64"
|
2015-08-04 09:36:22 -04:00
|
|
|
ubuntu_common config
|
|
|
|
end
|
2016-09-12 11:58:32 -04:00
|
|
|
config.vm.define "ubuntu-1604" do |config|
|
|
|
|
config.vm.box = "elastic/ubuntu-16.04-x86_64"
|
|
|
|
ubuntu_common config, extra: <<-SHELL
|
|
|
|
# Install Jayatana so we can work around it being present.
|
|
|
|
[ -f /usr/share/java/jayatanaag.jar ] || install jayatana
|
2015-09-27 21:33:05 -04:00
|
|
|
SHELL
|
2015-08-04 09:36:22 -04:00
|
|
|
end
|
2015-09-08 13:43:18 -04:00
|
|
|
# Wheezy's backports don't contain Openjdk 8 and the backflips required to
|
|
|
|
# get the sun jdk on there just aren't worth it. We have jessie for testing
|
|
|
|
# debian and it works fine.
|
2015-11-02 12:40:47 -05:00
|
|
|
config.vm.define "debian-8" do |config|
|
2016-03-18 13:33:58 -04:00
|
|
|
config.vm.box = "elastic/debian-8-x86_64"
|
2017-02-16 22:32:12 -05:00
|
|
|
deb_common config
|
2015-08-04 09:36:22 -04:00
|
|
|
end
|
2015-08-10 15:49:57 -04:00
|
|
|
config.vm.define "centos-6" do |config|
|
2016-03-18 13:33:58 -04:00
|
|
|
config.vm.box = "elastic/centos-6-x86_64"
|
2015-09-08 13:43:18 -04:00
|
|
|
rpm_common config
|
2015-08-04 09:36:22 -04:00
|
|
|
end
|
2015-08-10 15:49:57 -04:00
|
|
|
config.vm.define "centos-7" do |config|
|
2016-03-18 13:33:58 -04:00
|
|
|
config.vm.box = "elastic/centos-7-x86_64"
|
|
|
|
rpm_common config
|
|
|
|
end
|
|
|
|
config.vm.define "oel-6" do |config|
|
|
|
|
config.vm.box = "elastic/oraclelinux-6-x86_64"
|
2015-09-08 13:43:18 -04:00
|
|
|
rpm_common config
|
2015-08-04 09:36:22 -04:00
|
|
|
end
|
2015-08-10 15:49:57 -04:00
|
|
|
config.vm.define "oel-7" do |config|
|
2016-03-18 13:33:58 -04:00
|
|
|
config.vm.box = "elastic/oraclelinux-7-x86_64"
|
2015-09-08 13:43:18 -04:00
|
|
|
rpm_common config
|
2015-08-04 09:36:22 -04:00
|
|
|
end
|
2016-07-07 13:31:30 -04:00
|
|
|
config.vm.define "fedora-24" do |config|
|
|
|
|
config.vm.box = "elastic/fedora-24-x86_64"
|
2015-09-08 13:43:18 -04:00
|
|
|
dnf_common config
|
2015-08-04 09:36:22 -04:00
|
|
|
end
|
2015-09-15 17:20:53 -04:00
|
|
|
config.vm.define "opensuse-13" do |config|
|
2016-03-18 13:33:58 -04:00
|
|
|
config.vm.box = "elastic/opensuse-13-x86_64"
|
2015-09-22 08:59:39 -04:00
|
|
|
opensuse_common config
|
|
|
|
end
|
|
|
|
config.vm.define "sles-12" do |config|
|
2016-03-18 13:33:58 -04:00
|
|
|
config.vm.box = "elastic/sles-12-x86_64"
|
2015-09-22 08:59:39 -04:00
|
|
|
sles_common config
|
2015-09-15 17:20:53 -04:00
|
|
|
end
|
2015-08-04 09:36:22 -04:00
|
|
|
# Switch the default share for the project root from /vagrant to
|
|
|
|
# /elasticsearch because /vagrant is confusing when there is a project inside
|
|
|
|
# the elasticsearch project called vagrant....
|
|
|
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
2015-09-15 17:20:53 -04:00
|
|
|
config.vm.synced_folder ".", "/elasticsearch"
|
2016-10-19 04:01:13 -04:00
|
|
|
# Expose project directory
|
|
|
|
PROJECT_DIR = ENV['VAGRANT_PROJECT_DIR'] || Dir.pwd
|
|
|
|
config.vm.synced_folder PROJECT_DIR, "/project"
|
2015-09-24 10:04:59 -04:00
|
|
|
config.vm.provider "virtualbox" do |v|
|
2016-08-23 14:53:42 -04:00
|
|
|
# Give the boxes 3GB because Elasticsearch defaults to using 2GB
|
2016-08-23 23:12:24 -04:00
|
|
|
v.memory = 3072
|
2015-09-24 10:04:59 -04:00
|
|
|
end
|
2015-08-10 15:49:57 -04:00
|
|
|
if Vagrant.has_plugin?("vagrant-cachier")
|
|
|
|
config.cache.scope = :box
|
|
|
|
end
|
|
|
|
config.vm.defined_vms.each do |name, config|
|
|
|
|
config.options[:autostart] = false
|
|
|
|
set_prompt = lambda do |config|
|
|
|
|
# Sets up a consistent prompt for all users. Or tries to. The VM might
|
|
|
|
# contain overrides for root and vagrant but this attempts to work around
|
|
|
|
# them by re-source-ing the standard prompt file.
|
|
|
|
config.vm.provision "prompt", type: "shell", inline: <<-SHELL
|
|
|
|
cat \<\<PROMPT > /etc/profile.d/elasticsearch_prompt.sh
|
|
|
|
export PS1='#{name}:\\w$ '
|
|
|
|
PROMPT
|
|
|
|
grep 'source /etc/profile.d/elasticsearch_prompt.sh' ~/.bashrc |
|
|
|
|
cat \<\<SOURCE_PROMPT >> ~/.bashrc
|
|
|
|
# Replace the standard prompt with a consistent one
|
|
|
|
source /etc/profile.d/elasticsearch_prompt.sh
|
|
|
|
SOURCE_PROMPT
|
|
|
|
grep 'source /etc/profile.d/elasticsearch_prompt.sh' ~vagrant/.bashrc |
|
|
|
|
cat \<\<SOURCE_PROMPT >> ~vagrant/.bashrc
|
|
|
|
# Replace the standard prompt with a consistent one
|
|
|
|
source /etc/profile.d/elasticsearch_prompt.sh
|
|
|
|
SOURCE_PROMPT
|
|
|
|
SHELL
|
|
|
|
end
|
|
|
|
config.config_procs.push ['2', set_prompt]
|
|
|
|
end
|
2015-08-04 09:36:22 -04:00
|
|
|
end
|
|
|
|
|
2015-09-27 21:33:05 -04:00
|
|
|
def ubuntu_common(config, extra: '')
|
2017-02-16 22:32:12 -05:00
|
|
|
deb_common config, extra: extra
|
2015-09-08 13:43:18 -04:00
|
|
|
end
|
|
|
|
|
2017-02-16 22:32:12 -05:00
|
|
|
def deb_common(config, extra: '')
|
2015-08-04 09:36:22 -04:00
|
|
|
# http://foo-o-rama.com/vagrant--stdin-is-not-a-tty--fix.html
|
|
|
|
config.vm.provision "fix-no-tty", type: "shell" do |s|
|
|
|
|
s.privileged = false
|
|
|
|
s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
|
|
|
|
end
|
2015-09-08 13:43:18 -04:00
|
|
|
provision(config,
|
|
|
|
update_command: "apt-get update",
|
|
|
|
update_tracking_file: "/var/cache/apt/archives/last_update",
|
|
|
|
install_command: "apt-get install -y",
|
2017-02-16 22:32:12 -05:00
|
|
|
extra: extra)
|
2015-08-04 09:36:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def rpm_common(config)
|
2015-09-08 13:43:18 -04:00
|
|
|
provision(config,
|
|
|
|
update_command: "yum check-update",
|
|
|
|
update_tracking_file: "/var/cache/yum/last_update",
|
2017-02-16 22:32:12 -05:00
|
|
|
install_command: "yum install -y")
|
2015-08-04 09:36:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def dnf_common(config)
|
2015-09-08 13:43:18 -04:00
|
|
|
provision(config,
|
|
|
|
update_command: "dnf check-update",
|
|
|
|
update_tracking_file: "/var/cache/dnf/last_update",
|
|
|
|
install_command: "dnf install -y",
|
2017-02-16 22:32:12 -05:00
|
|
|
install_command_retries: 5)
|
2015-08-04 09:36:22 -04:00
|
|
|
if Vagrant.has_plugin?("vagrant-cachier")
|
|
|
|
# Autodetect doesn't work....
|
|
|
|
config.cache.auto_detect = false
|
|
|
|
config.cache.enable :generic, { :cache_dir => "/var/cache/dnf" }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-22 08:59:39 -04:00
|
|
|
def opensuse_common(config)
|
|
|
|
suse_common config, ''
|
|
|
|
end
|
|
|
|
|
|
|
|
def suse_common(config, extra)
|
2015-09-15 17:20:53 -04:00
|
|
|
provision(config,
|
|
|
|
update_command: "zypper --non-interactive list-updates",
|
|
|
|
update_tracking_file: "/var/cache/zypp/packages/last_update",
|
|
|
|
install_command: "zypper --non-interactive --quiet install --no-recommends",
|
2015-09-22 08:59:39 -04:00
|
|
|
extra: extra)
|
|
|
|
end
|
|
|
|
|
|
|
|
def sles_common(config)
|
|
|
|
extra = <<-SHELL
|
2017-02-03 11:52:48 -05:00
|
|
|
zypper rr systemsmanagement_puppet puppetlabs-pc1
|
2015-09-22 08:59:39 -04:00
|
|
|
zypper addrepo -t yast2 http://demeter.uni-regensburg.de/SLES12-x64/DVD1/ dvd1 || true
|
|
|
|
zypper --no-gpg-checks --non-interactive refresh
|
|
|
|
zypper --non-interactive install git-core
|
|
|
|
SHELL
|
|
|
|
suse_common config, extra
|
2015-09-15 17:20:53 -04:00
|
|
|
end
|
|
|
|
|
2015-09-08 13:43:18 -04:00
|
|
|
# Register the main box provisioning script.
|
|
|
|
# @param config Vagrant's config object. Required.
|
|
|
|
# @param update_command [String] The command used to update the package
|
|
|
|
# manager. Required. Think `apt-get update`.
|
|
|
|
# @param update_tracking_file [String] The location of the file tracking the
|
|
|
|
# last time the update command was run. Required. Should be in a place that
|
|
|
|
# is cached by vagrant-cachier.
|
|
|
|
# @param install_command [String] The command used to install a package.
|
|
|
|
# Required. Think `apt-get install #{package}`.
|
|
|
|
# @param extra [String] Extra provisioning commands run before anything else.
|
|
|
|
# Optional. Used for things like setting up the ppa for Java 8.
|
|
|
|
def provision(config,
|
|
|
|
update_command: 'required',
|
|
|
|
update_tracking_file: 'required',
|
|
|
|
install_command: 'required',
|
2016-10-05 11:42:25 -04:00
|
|
|
install_command_retries: 0,
|
2015-09-08 13:43:18 -04:00
|
|
|
extra: '')
|
|
|
|
# Vagrant run ruby 2.0.0 which doesn't have required named parameters....
|
|
|
|
raise ArgumentError.new('update_command is required') if update_command == 'required'
|
|
|
|
raise ArgumentError.new('update_tracking_file is required') if update_tracking_file == 'required'
|
|
|
|
raise ArgumentError.new('install_command is required') if install_command == 'required'
|
Tests: Add platformTest to vagrant (#23339)
This change adds a new test task, platformTest, which runs `gradle test
integTest` within a vagrant host. This will allow us to still test on
all the supported platforms, but be able to standardize on the tools
provided in the host system, for example, with a modern version of git
that can allow #22946.
In order to have sufficient memory and cpu to run the tests, the
vagrantfile has been updated to use 8GB and 4 cpus by default. This can
be customized with the `VAGRANT_MEMORY` and `VAGRANT_CPUS` environment
variables. Also, to save time to show this can work, it currently uses
the same Vagrantfile the packaging tests do. There are a lot of cleanups
we can do to how the gradle-vagrant tasks work, including generating
Vagrantfile altogether, but I think this is fine for now as the same
machines that would run platformTest run packagingTest, and they are
relatively beefy machines, so the higher memory and cpu for them, with
either task, should not be an issue.
2017-02-27 12:21:28 -05:00
|
|
|
config.vm.provider "virtualbox" do |v|
|
|
|
|
# Give the box more memory and cpu because our tests are beasts!
|
|
|
|
v.memory = Integer(ENV['VAGRANT_MEMORY'] || 8192)
|
|
|
|
v.cpus = Integer(ENV['VAGRANT_CPUS'] || 4)
|
|
|
|
end
|
|
|
|
config.vm.synced_folder "#{Dir.home}/.gradle/caches", "/home/vagrant/.gradle/caches",
|
|
|
|
create: true,
|
|
|
|
owner: "vagrant"
|
|
|
|
config.vm.provision "dependencies", type: "shell", inline: <<-SHELL
|
2015-08-04 09:36:22 -04:00
|
|
|
set -e
|
2015-09-08 13:43:18 -04:00
|
|
|
set -o pipefail
|
2016-10-05 11:42:25 -04:00
|
|
|
|
|
|
|
# Retry install command up to $2 times, if failed
|
|
|
|
retry_installcommand() {
|
|
|
|
n=0
|
|
|
|
while true; do
|
|
|
|
#{install_command} $1 && break
|
|
|
|
let n=n+1
|
|
|
|
if [ $n -ge $2 ]; then
|
|
|
|
echo "==> Exhausted retries to install $1"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
echo "==> Retrying installing $1, attempt $((n+1))"
|
|
|
|
# Add a small delay to increase chance of metalink providing updated list of mirrors
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
installed() {
|
|
|
|
command -v $1 2>&1 >/dev/null
|
|
|
|
}
|
2016-10-05 11:42:25 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
install() {
|
|
|
|
# Only apt-get update if we haven't in the last day
|
2015-09-08 13:43:18 -04:00
|
|
|
if [ ! -f #{update_tracking_file} ] || [ "x$(find #{update_tracking_file} -mtime +0)" == "x#{update_tracking_file}" ]; then
|
2015-11-02 12:40:47 -05:00
|
|
|
echo "==> Updating repository"
|
|
|
|
#{update_command} || true
|
|
|
|
touch #{update_tracking_file}
|
2015-08-04 09:36:22 -04:00
|
|
|
fi
|
2015-11-02 12:40:47 -05:00
|
|
|
echo "==> Installing $1"
|
2016-10-05 11:42:25 -04:00
|
|
|
if [ #{install_command_retries} -eq 0 ]
|
|
|
|
then
|
|
|
|
#{install_command} $1
|
|
|
|
else
|
|
|
|
retry_installcommand $1 #{install_command_retries}
|
|
|
|
fi
|
2015-08-04 09:36:22 -04:00
|
|
|
}
|
2016-10-05 11:42:25 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
ensure() {
|
|
|
|
installed $1 || install $1
|
|
|
|
}
|
2015-09-08 13:43:18 -04:00
|
|
|
|
|
|
|
#{extra}
|
|
|
|
|
2017-02-16 22:32:12 -05:00
|
|
|
installed java || {
|
|
|
|
echo "==> Java is not installed on vagrant box ${config.vm.box}"
|
|
|
|
return 1
|
|
|
|
}
|
2015-09-15 17:20:53 -04:00
|
|
|
ensure tar
|
2015-08-04 09:36:22 -04:00
|
|
|
ensure curl
|
|
|
|
ensure unzip
|
|
|
|
|
|
|
|
installed bats || {
|
|
|
|
# Bats lives in a git repository....
|
|
|
|
ensure git
|
2015-11-02 12:40:47 -05:00
|
|
|
echo "==> Installing bats"
|
2015-08-04 09:36:22 -04:00
|
|
|
git clone https://github.com/sstephenson/bats /tmp/bats
|
|
|
|
# Centos doesn't add /usr/local/bin to the path....
|
2015-09-08 13:43:18 -04:00
|
|
|
/tmp/bats/install.sh /usr
|
|
|
|
rm -rf /tmp/bats
|
2015-08-04 09:36:22 -04:00
|
|
|
}
|
Tests: Add platformTest to vagrant (#23339)
This change adds a new test task, platformTest, which runs `gradle test
integTest` within a vagrant host. This will allow us to still test on
all the supported platforms, but be able to standardize on the tools
provided in the host system, for example, with a modern version of git
that can allow #22946.
In order to have sufficient memory and cpu to run the tests, the
vagrantfile has been updated to use 8GB and 4 cpus by default. This can
be customized with the `VAGRANT_MEMORY` and `VAGRANT_CPUS` environment
variables. Also, to save time to show this can work, it currently uses
the same Vagrantfile the packaging tests do. There are a lot of cleanups
we can do to how the gradle-vagrant tasks work, including generating
Vagrantfile altogether, but I think this is fine for now as the same
machines that would run platformTest run packagingTest, and they are
relatively beefy machines, so the higher memory and cpu for them, with
either task, should not be an issue.
2017-02-27 12:21:28 -05:00
|
|
|
|
|
|
|
installed gradle || {
|
|
|
|
echo "==> Installing gradle"
|
|
|
|
curl -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
|
|
|
|
ln -s /opt/gradle-3.3/bin/gradle /usr/bin/gradle
|
|
|
|
# make nfs mounted gradle home dir writeable
|
2017-02-27 19:11:57 -05:00
|
|
|
# TODO: also chgrp to vagrant once sles and opensuse have vagrant group...
|
|
|
|
chown vagrant /home/vagrant/.gradle
|
Tests: Add platformTest to vagrant (#23339)
This change adds a new test task, platformTest, which runs `gradle test
integTest` within a vagrant host. This will allow us to still test on
all the supported platforms, but be able to standardize on the tools
provided in the host system, for example, with a modern version of git
that can allow #22946.
In order to have sufficient memory and cpu to run the tests, the
vagrantfile has been updated to use 8GB and 4 cpus by default. This can
be customized with the `VAGRANT_MEMORY` and `VAGRANT_CPUS` environment
variables. Also, to save time to show this can work, it currently uses
the same Vagrantfile the packaging tests do. There are a lot of cleanups
we can do to how the gradle-vagrant tasks work, including generating
Vagrantfile altogether, but I think this is fine for now as the same
machines that would run platformTest run packagingTest, and they are
relatively beefy machines, so the higher memory and cpu for them, with
either task, should not be an issue.
2017-02-27 12:21:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
cat \<\<VARS > /etc/profile.d/elasticsearch_vars.sh
|
2015-11-05 15:47:54 -05:00
|
|
|
export ZIP=/elasticsearch/distribution/zip/build/distributions
|
|
|
|
export TAR=/elasticsearch/distribution/tar/build/distributions
|
|
|
|
export RPM=/elasticsearch/distribution/rpm/build/distributions
|
|
|
|
export DEB=/elasticsearch/distribution/deb/build/distributions
|
2016-10-19 04:01:13 -04:00
|
|
|
export BATS=/project/build/bats
|
|
|
|
export BATS_UTILS=/project/build/bats/utils
|
|
|
|
export BATS_TESTS=/project/build/bats/tests
|
|
|
|
export BATS_ARCHIVES=/project/build/bats/archives
|
Tests: Add platformTest to vagrant (#23339)
This change adds a new test task, platformTest, which runs `gradle test
integTest` within a vagrant host. This will allow us to still test on
all the supported platforms, but be able to standardize on the tools
provided in the host system, for example, with a modern version of git
that can allow #22946.
In order to have sufficient memory and cpu to run the tests, the
vagrantfile has been updated to use 8GB and 4 cpus by default. This can
be customized with the `VAGRANT_MEMORY` and `VAGRANT_CPUS` environment
variables. Also, to save time to show this can work, it currently uses
the same Vagrantfile the packaging tests do. There are a lot of cleanups
we can do to how the gradle-vagrant tasks work, including generating
Vagrantfile altogether, but I think this is fine for now as the same
machines that would run platformTest run packagingTest, and they are
relatively beefy machines, so the higher memory and cpu for them, with
either task, should not be an issue.
2017-02-27 12:21:28 -05:00
|
|
|
export GRADLE_HOME=/opt/gradle-3.3
|
2015-08-04 09:36:22 -04:00
|
|
|
VARS
|
2016-11-15 09:19:34 -05:00
|
|
|
cat \<\<SUDOERS_VARS > /etc/sudoers.d/elasticsearch_vars
|
|
|
|
Defaults env_keep += "ZIP"
|
|
|
|
Defaults env_keep += "TAR"
|
|
|
|
Defaults env_keep += "RPM"
|
|
|
|
Defaults env_keep += "DEB"
|
|
|
|
Defaults env_keep += "BATS"
|
|
|
|
Defaults env_keep += "BATS_UTILS"
|
|
|
|
Defaults env_keep += "BATS_TESTS"
|
|
|
|
Defaults env_keep += "BATS_ARCHIVES"
|
|
|
|
SUDOERS_VARS
|
2016-11-15 11:42:57 -05:00
|
|
|
chmod 0440 /etc/sudoers.d/elasticsearch_vars
|
2015-08-04 09:36:22 -04:00
|
|
|
SHELL
|
|
|
|
end
|