Browse Source

Added Vagrant test runner, initially running some Ubuntus and CentOSes.

pull/13/merge
Martin Pärtel 5 years ago
parent
commit
aef3aa07b8
  1. 5
      .gitignore
  2. 2
      ChangeLog
  3. 6
      Makefile.am
  4. 8
      README.md
  5. 23
      vagrant/centos6/Vagrantfile
  6. 23
      vagrant/centos7/Vagrantfile
  7. 25
      vagrant/precise64/Vagrantfile
  8. 99
      vagrant/test.rb
  9. 25
      vagrant/trusty64/Vagrantfile
  10. 25
      vagrant/xenial64/Vagrantfile

5
.gitignore vendored

@ -45,3 +45,8 @@ tests/internals/test_rate_limiter
tests/internals/*.log
tests/internals/*.trs
# Vagrant
vagrant/*/*.log
vagrant/*/.vagrant

2
ChangeLog

@ -1,6 +1,8 @@
2017-03-12 Martin Pärtel <martin dot partel at gmail dot com>
* Made tests work with Ruby 1.8.7 and FUSE 2.8 again (issue #49).
* Added Vagrant test runner, initially running some Ubuntus and
CentOSes.
2017-02-04 Martin Pärtel <martin dot partel at gmail dot com>

6
Makefile.am

@ -1,2 +1,8 @@
SUBDIRS = src tests
vagrant-clean:
-for i in vagrant/*/Vagrantfile; do cd `dirname $$i` && (vagrant destroy -f || true) ; cd $$OLDPWD; done
-rm -Rf vagrant/*/.vagrant vagrant/*/*.log
vagrant-test:
-vagrant/test.rb

8
README.md

@ -60,6 +60,14 @@ The test suite requires Ruby 1.8.7+. If you're using [RVM](https://rvm.io/)
then you may need to use `rvmsudo` instead of plain `sudo` to run the root
tests.
### Vagrant test runner ###
There is also a set of Vagrant configs for running the test suite on a variety
of systems. Run them with `vagrant/test.rb` (add `--help` for extra options).
You can destroy all bindfs Vagrant machines (but not the downloaded images)
with `make vagrant-clean`.
## License ##

23
vagrant/centos6/Vagrantfile vendored

@ -0,0 +1,23 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/6"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "../../", "/bindfs",
type: "rsync",
rsync__auto: false,
rsync__exclude: ["vagrant"],
rsync__args: ["-av", "--delete-after"]
config.vm.provider "virtualbox" do |v|
v.name = "bindfs-centos6"
end
config.vm.provision "shell", inline: <<-SHELL
yum install -y fuse fuse-devel gcc make pkg-config ruby valgrind
usermod -G fuse -a vagrant
echo user_allow_other > /etc/fuse.conf
SHELL
end

23
vagrant/centos7/Vagrantfile vendored

@ -0,0 +1,23 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "../../", "/bindfs",
type: "rsync",
rsync__auto: false,
rsync__exclude: ["vagrant"],
rsync__args: ["-av", "--delete-after"]
config.vm.provider "virtualbox" do |v|
v.name = "bindfs-centos7"
end
config.vm.provision "shell", inline: <<-SHELL
yum install -y fuse fuse-devel gcc make pkg-config ruby valgrind
usermod -G fuse -a vagrant
echo user_allow_other > /etc/fuse.conf
SHELL
end

25
vagrant/precise64/Vagrantfile vendored

@ -0,0 +1,25 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/precise64"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "../../", "/bindfs",
type: "rsync",
rsync__auto: false,
rsync__exclude: ["vagrant"],
rsync__args: ["-av", "--delete-after"]
config.vm.provider "virtualbox" do |v|
v.name = "bindfs-precise64"
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y fuse libfuse-dev build-essential pkg-config ruby1.9.3 valgrind
apt-get clean
adduser vagrant fuse
echo user_allow_other > /etc/fuse.conf
SHELL
end

99
vagrant/test.rb

@ -0,0 +1,99 @@
#!/usr/bin/env ruby
HELP = <<EOS
Runs the bindfs test suite in all vagrant boxes in parallel.
Usage: test.rb [--nohalt] [vm1 [...]]
Options:
-h --help Print this and exit.
--nohalt Don't halt VMs when done.
If VM names are given, only those are tested.
Bugs:
- Spurious "Connection to 127.0.0.1 closed." messages can appear, and the
terminal may need a `reset` after this command finishes.
EOS
require 'fileutils'
Dir.chdir(File.dirname(__FILE__))
halt_vms = true
specifically_selected_vms = []
ARGV.each do |arg|
if arg == '-h' || arg == '--help'
puts HELP
exit
elsif arg == '--nohalt'
halt_vms = false
elsif !arg.start_with?('-')
specifically_selected_vms << arg
else
raise "Unknown option: #{arg}"
end
end
dirs = Dir.glob('*/Vagrantfile').map { |path| File.dirname(path) }
unless specifically_selected_vms.empty?
dirs = dirs.select { |dir| ARGV.include?(dir) }
end
puts "Running #{dirs.size} VMs in parallel: #{dirs.join(' ')}"
puts "Note: if your terminal goes wonky after this command, type 'reset'"
mutex = Thread::Mutex.new # protects `$stdout` and `errors`
errors = []
threads = dirs.map do |dir|
Thread.new do
begin
File.open(dir + "/test.log", "wb") do |logfile|
run_and_log = -> (command) do
logfile.puts ""
logfile.puts "##### #{command} #####"
logfile.flush
pid = Process.spawn(command, chdir: dir, out: logfile, err: :out)
Process.waitpid(pid)
$?.success?
end
unless run_and_log.call "vagrant up"
raise "vagrant up failed"
end
unless run_and_log.call "vagrant rsync"
raise "vagrant rsync failed"
end
unless run_and_log.call "vagrant ssh -c 'cd /bindfs && sudo rm -Rf tests/tmp_test_bindfs && ./configure && make clean && make && make check && sudo make check'"
mutex.synchronize do
errors << "VM #{dir} tests failed."
end
end
if halt_vms
unless run_and_log.call "vagrant halt"
raise "vagrant halt failed"
end
end
end
rescue
mutex.synchronize do
errors << "VM #{dir} error: #{$!}"
end
ensure
mutex.synchronize do
puts "Finished VM: #{dir}"
end
end
end
end
threads.each(&:join)
if errors.empty?
puts "OK"
else
unless errors.empty?
puts
puts "Errors:"
errors.each { |err| puts " #{err}" }
puts
puts "See test.log in a failed VM's directory for more information"
puts
end
end

25
vagrant/trusty64/Vagrantfile vendored

@ -0,0 +1,25 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "../../", "/bindfs",
type: "rsync",
rsync__auto: false,
rsync__exclude: ["vagrant"],
rsync__args: ["-av", "--delete-after"]
config.vm.provider "virtualbox" do |v|
v.name = "bindfs-trusty64"
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y fuse libfuse-dev build-essential pkg-config ruby1.9 valgrind
apt-get clean
adduser vagrant fuse
echo user_allow_other > /etc/fuse.conf
SHELL
end

25
vagrant/xenial64/Vagrantfile vendored

@ -0,0 +1,25 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "../../", "/bindfs",
type: "rsync",
rsync__auto: false,
rsync__exclude: ["vagrant"],
rsync__args: ["-av", "--delete-after"]
config.vm.provider "virtualbox" do |v|
v.name = "bindfs-xenial64"
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y fuse libfuse-dev build-essential pkg-config ruby valgrind
apt-get clean
adduser vagrant fuse
echo user_allow_other > /etc/fuse.conf
SHELL
end
Loading…
Cancel
Save