forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
83 lines (68 loc) · 2.92 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require "rspec"
require "rspec/core/runner"
require "rspec/core/rake_task"
require "stud/try"
require_relative "vagrant/helpers"
require_relative "platform_config"
platforms = PlatformConfig.new
task :spec => 'spec:all'
task :default => :spec
namespace :qa do
namespace :vm do
def user_feedback_string_for(action, platform, machines, options={})
experimental_string = options["experimental"] ? "experimental" : "non experimental"
message = "#{action} all #{experimental_string} VM's defined in acceptance/Vagrantfile"
"#{message} for #{platform}: #{machines}" if !platform.nil?
end
desc "Generate a valid ssh-config"
task :ssh_config do
require "json"
# Loop until the Vagrant box finishes SSH bootstrap
raw_ssh_config = Stud.try(50.times, LogStash::CommandExecutor::CommandError) do
LogStash::VagrantHelpers.fetch_config.stdout.split("\n");
end
parsed_ssh_config = LogStash::VagrantHelpers.parse(raw_ssh_config)
File.write(".vm_ssh_config", parsed_ssh_config.to_json)
end
desc "Bootstrap all the VM's used for this tests"
task :setup, :platform do |t, args|
config = PlatformConfig.new
experimental = (ENV['LS_QA_EXPERIMENTAL_OS'].to_s.downcase || "false") == "true"
machines = config.select_names_for(args[:platform], {"experimental" => experimental})
puts user_feedback_string_for("bootstrapping", args[:platform], machines, {"experimental" => experimental})
options = {:debug => ENV['LS_QA_DEBUG']}
puts "Destroying #{machines}"
LogStash::VagrantHelpers.destroy(machines, options)
puts "Bootstrapping #{machines}"
LogStash::VagrantHelpers.bootstrap(machines, options)
end
desc "Halt all VM's involved in the acceptance test round"
task :halt, :platform do |t, args|
config = PlatformConfig.new
experimental = (ENV['LS_QA_EXPERIMENTAL_OS'].to_s.downcase || "false") == "true"
machines = config.select_names_for(args[:platform], {"experimental" => experimental})
puts user_feedback_string_for("halting", args[:platform], machines, {"experimental" => experimental})
options = {:debug => ENV['LS_QA_DEBUG']}
puts "Halting #{machines}"
LogStash::VagrantHelpers.halt(machines, options)
end
end
namespace :acceptance do
desc "Run all acceptance"
task :all do
exit(RSpec::Core::Runner.run([Rake::FileList["acceptance/spec/lib/**/*_spec.rb"]]))
end
platforms.types.each do |type|
desc "Run acceptance test in #{type} machines"
task type do
ENV['LS_TEST_PLATFORM']=type
exit(RSpec::Core::Runner.run([Rake::FileList["acceptance/spec/lib/*_spec.rb"]]))
end
end
desc "Run one single machine acceptance test"
task :single, :machine do |t, args|
ENV['LS_VAGRANT_HOST'] = args[:machine]
exit(RSpec::Core::Runner.run([Rake::FileList["acceptance/spec/lib/**/**/*_spec.rb"]]))
end
end
end