forked from xing/beetle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
110 lines (94 loc) · 2.69 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
require 'rake'
require 'rake/testtask'
require 'bundler/gem_tasks'
# rake 0.9.2 hack to supress deprecation warnings caused by cucumber
include Rake::DSL if RAKEVERSION >= "0.9"
require 'cucumber/rake/task'
# 1.8/1.9 compatible way of loading lib/beetle.rb
$:.unshift 'lib'
require 'beetle'
namespace :test do
task :coverage => :test do
system 'open coverage/index.html'
end
end
namespace :beetle do
task :test do
Beetle::Client.new.test
end
task :trace do
trap('INT'){ EM.stop_event_loop }
Beetle::Client.new.trace
end
end
namespace :rabbit do
def start(node_name, port, web_port)
script = File.expand_path(File.dirname(__FILE__)+"/script/start_rabbit")
# on my machine, the rabbitmq user is not be allowed to access my files.
# so we need to put the config file under /tmp
config_file = "/tmp/beetle-testing-rabbitmq-#{node_name}"
create_config_file config_file, web_port
puts "starting rabbit #{node_name} on port #{port}, web management port #{web_port}"
puts "type ^C a RETURN to abort"
sleep 1
exec "sudo #{script} #{node_name} #{port} #{config_file}"
end
def create_config_file(config_file, web_port)
File.open("#{config_file}.config",'w') do |f|
f.puts "["
f.puts " {rabbitmq_management, [{listener, [{port, #{web_port}}]}]}"
f.puts "]."
end
end
desc "start rabbit instance 1"
task :start1 do
start "rabbit1", 5672, 15672
end
desc "start rabbit instance 2"
task :start2 do
start "rabbit2", 5673, 15673
end
desc "reset rabbit instances (deletes all data!)"
task :reset do
["rabbit1", "rabbit2"].each do |node|
`sudo rabbitmqctl -n #{node} stop_app`
`sudo rabbitmqctl -n #{node} reset`
`sudo rabbitmqctl -n #{node} start_app`
end
end
end
namespace :redis do
def config_file(suffix)
File.expand_path(File.dirname(__FILE__)+"/etc/redis-#{suffix}.conf")
end
desc "start main redis"
task :start1 do
exec "redis-server #{config_file(:master)}"
end
desc "start slave redis"
task :start2 do
exec "redis-server #{config_file(:slave)}"
end
end
Cucumber::Rake::Task.new(:cucumber) do |t|
t.cucumber_opts = "features --format progress"
end
task :default do
Rake::Task[:test].invoke
Rake::Task[:cucumber].invoke
end
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/**/*_test.rb']
t.verbose = true
end
require 'rdoc/task'
RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = 'site/rdoc'
rdoc.title = 'Beetle'
rdoc.main = 'README.rdoc'
rdoc.options << '--line-numbers' << '--inline-source' << '--quiet'
rdoc.rdoc_files.include('**/*.rdoc')
rdoc.rdoc_files.include('MIT-LICENSE')
rdoc.rdoc_files.include('lib/**/*.rb')
end