Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 192 lines (172 sloc) 7.103 kB
b194ce9 @pxie Add harness and two test scripts
pxie authored
1 $:.unshift(File.join(File.dirname(__FILE__), "lib"))
8ed2b25 @mmb Specs for core set of Cloud Foundry functionality.
mmb authored
2 require 'rspec/core/rake_task'
b194ce9 @pxie Add harness and two test scripts
pxie authored
3 require "harness"
438dfa7 add longevity support to every rake task
michael zhang authored
4 #require "harness/color_helper"
5 include BVT::Harness::ColorHelpers
b194ce9 @pxie Add harness and two test scripts
pxie authored
6
7 task :default => [:help]
8
9 desc "List help commands"
10 task :help do
11 puts "Usage: rake [command]"
61a47e8 several bug fixes
michael zhang authored
12 puts " admin\t\trun admin test cases"
438dfa7 add longevity support to every rake task
michael zhang authored
13 puts " tests\t\trun core tests in parallel, e.g. rake test[5] (default to 10, max = 16)\n"
ab189cb support config file parameter
michael zhang authored
14 puts " \t\tOptions: VCAP_BVT_LONGEVITY=N can loop this task.\n"
15 puts " \t\te.g. rake tests[8] VCAP_BVT_LONGEVITY=10"
16 puts " \t\tVCAP_BVT_CONFIG_FILE=[path_to_config_file] to specify config file.\n"
17 puts " \t\te.g. rake tests VCAP_BVT_CONFIG_FILE=/home/czhang/my_test.yml\n"
18 puts " \t\tAbove options are also usable in other tasks."
f79bcf0 update README and Rakefile
michael zhang authored
19 puts " full\t\trun full tests in parallel, e.g. rake full[5] (default to 10, max = 16)"
20 puts " random\trun all bvts randomly, e.g. rake random[1023] to re-run seed 1023"
21 puts " java\t\trun java tests (spring, java_web) in parallel\n" +
22 "\t\te.g. rake java[5] (default to 10, max = 16)"
23 puts " jvm\t\trun jvm tests (spring, java_web, grails, lift) in parallel\n" +
24 "\t\te.g. rake jvm[5] (default to 10, max = 16)"
25 puts " ruby\t\trun ruby tests (rails3, sinatra, rack) in parallel\n" +
26 "\t\te.g. rake ruby[5] (default to 10, max = 16)"
27 puts " services\trun service tests (mongodb/redis/mysql/postgres/rabbitmq/neo4j/vblob) in parallel\n" +
28 "\t\te.g. rake services[5] (default to 10, max = 16)"
29 puts " clean\t\tclean up test environment(only run this task after interruption).\n" +
61a47e8 several bug fixes
michael zhang authored
30 "\t\t 1, Remove all apps and services under test user\n" +
02abed3 enhancement for rake clean
michael zhang authored
31 "\t\t 2, Remove all apps and services under parallel users"
8ed2b25 @mmb Specs for core set of Cloud Foundry functionality.
mmb authored
32
33 puts " core\t\trun core tests for verifying that an installation meets\n" +
34 "\t\tminimal Cloud Foundry compatibility requirements"
35
36 puts " mcf\t\trun Micro Cloud Foundry tests\n"
37
61a47e8 several bug fixes
michael zhang authored
38 puts " help\t\tlist help commands"
b194ce9 @pxie Add harness and two test scripts
pxie authored
39 end
40
8f767f1 add p1 tags for tests subset
michael zhang authored
41 desc "run full tests (not include admin cases)"
42 task :full, :thread_number do |t, args|
43 threads = 10
44 threads = args[:thread_number].to_i if args[:thread_number]
644f2c5 @pxie remove password, support multi-target config
pxie authored
45 BVT::Harness::RakeHelper.generate_config_file
46 BVT::Harness::RakeHelper.check_environment
8f767f1 add p1 tags for tests subset
michael zhang authored
47 if threads == 1
8ed2b25 @mmb Specs for core set of Cloud Foundry functionality.
mmb authored
48 longevity('sh("rspec --format Fuubar --color spec/ --tag ~admin --tag ~slow")')
8f767f1 add p1 tags for tests subset
michael zhang authored
49 else
8ed2b25 @mmb Specs for core set of Cloud Foundry functionality.
mmb authored
50 longevity("BVT::Harness::ParallelHelper.run_tests(#{threads}, {'tags' => '~admin,~slow'})")
8f767f1 add p1 tags for tests subset
michael zhang authored
51 end
10c769f new parallel implimentation
michael zhang authored
52 end
53
8f767f1 add p1 tags for tests subset
michael zhang authored
54 desc "run tests subset"
10c769f new parallel implimentation
michael zhang authored
55 task :tests, :thread_number do |t, args|
56 threads = 10
57 threads = args[:thread_number].to_i if args[:thread_number]
644f2c5 @pxie remove password, support multi-target config
pxie authored
58 BVT::Harness::RakeHelper.generate_config_file
59 BVT::Harness::RakeHelper.check_environment
8f767f1 add p1 tags for tests subset
michael zhang authored
60 if threads == 1
8ed2b25 @mmb Specs for core set of Cloud Foundry functionality.
mmb authored
61 longevity('sh("rspec --format Fuubar --color spec/ --tag ~admin --tag p1 --tag ~slow")')
8f767f1 add p1 tags for tests subset
michael zhang authored
62 else
8ed2b25 @mmb Specs for core set of Cloud Foundry functionality.
mmb authored
63 longevity("BVT::Harness::ParallelHelper.run_tests(#{threads}, {'tags' => 'p1,~admin,~slow'})")
8f767f1 add p1 tags for tests subset
michael zhang authored
64 end
4130c66 Add random order & seed support
michael zhang authored
65 end
66
67 desc "Run all bvts randomly, add [N] to specify a seed"
68 task :random, :seed do |t, args|
69 BVT::Harness::RakeHelper.generate_config_file
70 BVT::Harness::RakeHelper.check_environment
71 if args[:seed] != nil
8ed2b25 @mmb Specs for core set of Cloud Foundry functionality.
mmb authored
72 longevity("sh 'bundle exec rspec spec/ --tag ~admin --tag p1 --tag ~slow' +
438dfa7 add longevity support to every rake task
michael zhang authored
73 ' --seed #{args[:seed]} --format d -c'")
4130c66 Add random order & seed support
michael zhang authored
74 else
8ed2b25 @mmb Specs for core set of Cloud Foundry functionality.
mmb authored
75 longevity('sh "bundle exec rspec spec/ --tag ~admin --tag p1 --tag ~slow" +
438dfa7 add longevity support to every rake task
michael zhang authored
76 " --order rand --format d -c"')
4130c66 Add random order & seed support
michael zhang authored
77 end
3e62211 @pxie add rake admin task for administrative cases
pxie authored
78 end
79
80 desc "Run admin test cases"
81 task :admin do
61a47e8 several bug fixes
michael zhang authored
82 BVT::Harness::RakeHelper.generate_config_file(true)
3e62211 @pxie add rake admin task for administrative cases
pxie authored
83 BVT::Harness::RakeHelper.check_environment
f79bcf0 update README and Rakefile
michael zhang authored
84 sh "bundle exec rspec --format Fuubar --color spec/users/ --tag admin"
b194ce9 @pxie Add harness and two test scripts
pxie authored
85 end
eabea58 Simplified rake menu & add task messages
michael zhang authored
86
87 desc "Run java tests (spring, java_web)"
438dfa7 add longevity support to every rake task
michael zhang authored
88 task :java, :thread_number, :longevity, :fail_fast do |t, args|
f79bcf0 update README and Rakefile
michael zhang authored
89 threads = 10
90 threads = args[:thread_number].to_i if args[:thread_number]
644f2c5 @pxie remove password, support multi-target config
pxie authored
91 BVT::Harness::RakeHelper.generate_config_file
92 BVT::Harness::RakeHelper.check_environment
f79bcf0 update README and Rakefile
michael zhang authored
93 if threads == 1
438dfa7 add longevity support to every rake task
michael zhang authored
94 longevity('sh "bundle exec rspec --format Fuubar --color -P spec/**/*_spring_spec.rb," +
95 "spec/**/*_java_web_spec.rb"')
f79bcf0 update README and Rakefile
michael zhang authored
96 else
438dfa7 add longevity support to every rake task
michael zhang authored
97 longevity("BVT::Harness::ParallelHelper.run_tests(#{threads}, {'pattern' => /_(spring|java_web)_spec\.rb/})")
f79bcf0 update README and Rakefile
michael zhang authored
98 end
eabea58 Simplified rake menu & add task messages
michael zhang authored
99 end
100
101 desc "Run jvm tests (spring, java_web, grails, lift)"
f79bcf0 update README and Rakefile
michael zhang authored
102 task :jvm, :thread_number do |t, args|
103 threads = 10
104 threads = args[:thread_number].to_i if args[:thread_number]
644f2c5 @pxie remove password, support multi-target config
pxie authored
105 BVT::Harness::RakeHelper.generate_config_file
106 BVT::Harness::RakeHelper.check_environment
f79bcf0 update README and Rakefile
michael zhang authored
107 if threads == 1
438dfa7 add longevity support to every rake task
michael zhang authored
108 longevity('sh "bundle exec rspec --format Fuubar --color -P spec/**/*_spring_spec.rb,spec" +
109 "/**/*_java_web_spec.rb,spec/**/*_grails_spec.rb,spec/**/*_lift_spec.rb"')
f79bcf0 update README and Rakefile
michael zhang authored
110 else
438dfa7 add longevity support to every rake task
michael zhang authored
111 longevity("BVT::Harness::ParallelHelper.run_tests(#{threads},
112 {'pattern' => /_(spring|java_web|grails|lift)_spec\.rb/})")
f79bcf0 update README and Rakefile
michael zhang authored
113 end
eabea58 Simplified rake menu & add task messages
michael zhang authored
114 end
115
116 desc "Run ruby tests (rails3, sinatra, rack)"
f79bcf0 update README and Rakefile
michael zhang authored
117 task :ruby, :thread_number do |t, args|
118 threads = 10
119 threads = args[:thread_number].to_i if args[:thread_number]
644f2c5 @pxie remove password, support multi-target config
pxie authored
120 BVT::Harness::RakeHelper.generate_config_file
121 BVT::Harness::RakeHelper.check_environment
f79bcf0 update README and Rakefile
michael zhang authored
122 if threads == 1
438dfa7 add longevity support to every rake task
michael zhang authored
123 longevity('sh "bundle exec rspec --format Fuubar --color -P spec/**/ruby18_*_spec.rb," +
124 "spec/**/ruby19_*_spec.rb"')
f79bcf0 update README and Rakefile
michael zhang authored
125 else
438dfa7 add longevity support to every rake task
michael zhang authored
126 longevity("BVT::Harness::ParallelHelper.run_tests(#{threads}, {'pattern' => /ruby1[89]_.+_spec\.rb/})")
f79bcf0 update README and Rakefile
michael zhang authored
127 end
eabea58 Simplified rake menu & add task messages
michael zhang authored
128 end
129
bcfc75a add tags support
michael zhang authored
130 desc "Run service tests (mongodb, redis, mysql, postgres, rabbitmq, neo4j, vblob)"
f79bcf0 update README and Rakefile
michael zhang authored
131 task :services, :thread_number do |t, args|
132 threads = 10
133 threads = args[:thread_number].to_i if args[:thread_number]
644f2c5 @pxie remove password, support multi-target config
pxie authored
134 BVT::Harness::RakeHelper.generate_config_file
135 BVT::Harness::RakeHelper.check_environment
f79bcf0 update README and Rakefile
michael zhang authored
136 if threads == 1
438dfa7 add longevity support to every rake task
michael zhang authored
137 longevity('sh "bundle exec rspec --format Fuubar --color spec/ --tag mongodb --tag rabbitmq " +
138 "--tag mysql --tag redis --tag postgresql --tag neo4j --tag vblob"')
f79bcf0 update README and Rakefile
michael zhang authored
139 else
438dfa7 add longevity support to every rake task
michael zhang authored
140 longevity("BVT::Harness::ParallelHelper.run_tests(#{threads}, {'tags' =>
141 '~admin,mongodb,rabbitmq,mysql,redis,postgresql,neo4j,vblob'})")
f79bcf0 update README and Rakefile
michael zhang authored
142 end
eabea58 Simplified rake menu & add task messages
michael zhang authored
143 end
144
c21b824 @pxie Add rake clean task to do cleanup work manually
pxie authored
145 desc "Clean up test environment"
146 task :clean do
147 BVT::Harness::RakeHelper.cleanup!
148 end
d2a4721 rake tasks update, sync blobs related
michael zhang authored
149
150 desc "sync yeti assets binaries"
151 task :sync_assets do
152 BVT::Harness::RakeHelper.sync_assets
153 end
59de8d4 Add longevity rake task
michael zhang authored
154
8ed2b25 @mmb Specs for core set of Cloud Foundry functionality.
mmb authored
155 desc 'run core tests for verifying that an installation meets minimal Cloud Foundry compatibility requirements'
156 RSpec::Core::RakeTask.new(:core) do |t|
157 t.rspec_opts = '--tag cfcore'
158 end
159
160 desc 'run Micro Cloud Foundry tests'
161 RSpec::Core::RakeTask.new(:mcf) do |t|
162 t.rspec_opts = '--tag mcf'
163 end
164
438dfa7 add longevity support to every rake task
michael zhang authored
165 def get_longevity_time
166 return ENV['VCAP_BVT_LONGEVITY'].to_i if ENV['VCAP_BVT_LONGEVITY']
167 return 1
168 end
169
170 def longevity(cmd)
171 loop_times = get_longevity_time
172 if loop_times == 1
173 eval(cmd)
174 return
175 elsif loop_times < 1
176 puts red("longevity input error")
177 return
59de8d4 Add longevity rake task
michael zhang authored
178 end
438dfa7 add longevity support to every rake task
michael zhang authored
179 time_start = Time.now
180 puts yellow("loop times: #{loop_times}")
59de8d4 Add longevity rake task
michael zhang authored
181 $stdout.flush
182 loop_times.times {|i|
438dfa7 add longevity support to every rake task
michael zhang authored
183 puts yellow("This is #{i} run.")
184 eval(cmd)
59de8d4 Add longevity rake task
michael zhang authored
185 }
438dfa7 add longevity support to every rake task
michael zhang authored
186 puts yellow("longevity finished!")
187 puts yellow("loop times: #{loop_times}")
188 t1 = Time.now
189 running_time = (t1 - time_start).to_i
190 puts yellow("total running time: #{running_time} seconds")
59de8d4 Add longevity rake task
michael zhang authored
191 end
Something went wrong with that request. Please try again.