vagrant-openshift 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitattributes +1 -0
- data/.gitignore +24 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +13 -0
- data/README.asciidoc +379 -0
- data/Rakefile +53 -0
- data/lib/vagrant-openshift/action/build_geard.rb +41 -0
- data/lib/vagrant-openshift/action/build_geard_broker.rb +59 -0
- data/lib/vagrant-openshift/action/build_geard_console.rb +55 -0
- data/lib/vagrant-openshift/action/build_geard_images.rb +54 -0
- data/lib/vagrant-openshift/action/build_sources.rb +39 -0
- data/lib/vagrant-openshift/action/checkout_repositories.rb +72 -0
- data/lib/vagrant-openshift/action/checkout_tests.rb +57 -0
- data/lib/vagrant-openshift/action/clean.rb +51 -0
- data/lib/vagrant-openshift/action/clean_network_setup.rb +52 -0
- data/lib/vagrant-openshift/action/clone_upstream_repositories.rb +65 -0
- data/lib/vagrant-openshift/action/create_ami.rb +54 -0
- data/lib/vagrant-openshift/action/create_bare_repo_placeholders.rb +53 -0
- data/lib/vagrant-openshift/action/create_puppet_file.rb +84 -0
- data/lib/vagrant-openshift/action/create_test_users.rb +36 -0
- data/lib/vagrant-openshift/action/create_yum_repositories.rb +121 -0
- data/lib/vagrant-openshift/action/download_artifacts.rb +70 -0
- data/lib/vagrant-openshift/action/generate_template.rb +89 -0
- data/lib/vagrant-openshift/action/idle_all_gears.rb +36 -0
- data/lib/vagrant-openshift/action/install_build_dependencies.rb +48 -0
- data/lib/vagrant-openshift/action/install_geard.rb +76 -0
- data/lib/vagrant-openshift/action/install_geard_base_dependencies.rb +72 -0
- data/lib/vagrant-openshift/action/install_geard_broker.rb +39 -0
- data/lib/vagrant-openshift/action/install_geard_images.rb +51 -0
- data/lib/vagrant-openshift/action/install_open_shift_dependencies.rb +50 -0
- data/lib/vagrant-openshift/action/install_rhc.rb +42 -0
- data/lib/vagrant-openshift/action/local_geard_checkout.rb +58 -0
- data/lib/vagrant-openshift/action/local_repo_checkout.rb +47 -0
- data/lib/vagrant-openshift/action/modify_ami.rb +54 -0
- data/lib/vagrant-openshift/action/modify_instance.rb +71 -0
- data/lib/vagrant-openshift/action/prepare_ssh_config.rb +89 -0
- data/lib/vagrant-openshift/action/preserve_mcollective_logs.rb +48 -0
- data/lib/vagrant-openshift/action/restart_geard.rb +39 -0
- data/lib/vagrant-openshift/action/restart_geard_broker.rb +43 -0
- data/lib/vagrant-openshift/action/restart_geard_console.rb +43 -0
- data/lib/vagrant-openshift/action/run_geard_tests.rb +57 -0
- data/lib/vagrant-openshift/action/run_tests.rb +47 -0
- data/lib/vagrant-openshift/action/set_host_name.rb +43 -0
- data/lib/vagrant-openshift/action/setup_bind_dns_key.rb +38 -0
- data/lib/vagrant-openshift/action/setup_bind_host.rb +141 -0
- data/lib/vagrant-openshift/action/setup_builder_files.rb +57 -0
- data/lib/vagrant-openshift/action/setup_geard_broker.rb +71 -0
- data/lib/vagrant-openshift/action/sync_local_repository.rb +115 -0
- data/lib/vagrant-openshift/action/sync_upstream_repository.rb +71 -0
- data/lib/vagrant-openshift/action/test_exit_code.rb +36 -0
- data/lib/vagrant-openshift/action/uninstall_openshift_rpms.rb +37 -0
- data/lib/vagrant-openshift/action/yum_update.rb +67 -0
- data/lib/vagrant-openshift/action.rb +308 -0
- data/lib/vagrant-openshift/command/build_geard.rb +51 -0
- data/lib/vagrant-openshift/command/build_geard_base.rb +51 -0
- data/lib/vagrant-openshift/command/build_geard_broker.rb +59 -0
- data/lib/vagrant-openshift/command/build_geard_console.rb +59 -0
- data/lib/vagrant-openshift/command/build_geard_images.rb +68 -0
- data/lib/vagrant-openshift/command/build_origin_base.rb +51 -0
- data/lib/vagrant-openshift/command/checkout_repositories.rb +55 -0
- data/lib/vagrant-openshift/command/clone_upstream_repositories.rb +54 -0
- data/lib/vagrant-openshift/command/create_ami.rb +49 -0
- data/lib/vagrant-openshift/command/install_geard.rb +51 -0
- data/lib/vagrant-openshift/command/install_geard_broker.rb +51 -0
- data/lib/vagrant-openshift/command/install_rhc.rb +49 -0
- data/lib/vagrant-openshift/command/local_geard_setup.rb +62 -0
- data/lib/vagrant-openshift/command/local_repo_setup.rb +62 -0
- data/lib/vagrant-openshift/command/modify_ami.rb +54 -0
- data/lib/vagrant-openshift/command/modify_instance.rb +63 -0
- data/lib/vagrant-openshift/command/openshift_init.rb +83 -0
- data/lib/vagrant-openshift/command/repo_sync.rb +73 -0
- data/lib/vagrant-openshift/command/repo_sync_geard.rb +78 -0
- data/lib/vagrant-openshift/command/restart_geard.rb +51 -0
- data/lib/vagrant-openshift/command/restart_geard_broker.rb +51 -0
- data/lib/vagrant-openshift/command/restart_geard_console.rb +51 -0
- data/lib/vagrant-openshift/command/setup_geard_broker.rb +49 -0
- data/lib/vagrant-openshift/command/test.rb +108 -0
- data/lib/vagrant-openshift/command/test_geard.rb +59 -0
- data/lib/vagrant-openshift/command/test_geard_image.rb +147 -0
- data/lib/vagrant-openshift/config.rb +56 -0
- data/lib/vagrant-openshift/constants.rb +111 -0
- data/lib/vagrant-openshift/helper/command_helper.rb +213 -0
- data/lib/vagrant-openshift/plugin.rb +171 -0
- data/lib/vagrant-openshift/provisioner.rb +82 -0
- data/lib/vagrant-openshift/templates/builder/Rakefile +231 -0
- data/lib/vagrant-openshift/templates/builder/lib/.gitkeep +0 -0
- data/lib/vagrant-openshift/templates/builder/lib/rpm.rb +248 -0
- data/lib/vagrant-openshift/templates/builder/lib/test.rb +432 -0
- data/lib/vagrant-openshift/templates/builder/yum-listbuilddep +124 -0
- data/lib/vagrant-openshift/templates/command/init-openshift/Vagrantfile.erb +175 -0
- data/lib/vagrant-openshift/templates/command/init-openshift/box_info.yaml +152 -0
- data/lib/vagrant-openshift/version.rb +21 -0
- data/lib/vagrant-openshift.rb +34 -0
- data/vagrant-openshift.gemspec +43 -0
- metadata +234 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyright 2013 Red Hat, Inc.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#++
|
|
16
|
+
require 'open3'
|
|
17
|
+
require 'securerandom'
|
|
18
|
+
|
|
19
|
+
class Test
|
|
20
|
+
@@SSH_TIMEOUT = 4800
|
|
21
|
+
|
|
22
|
+
def test(options)
|
|
23
|
+
@is_fedora = system("test -e /etc/fedora-release")
|
|
24
|
+
reset_test_dir(false)
|
|
25
|
+
|
|
26
|
+
test_queues = [[], [], [], []]
|
|
27
|
+
|
|
28
|
+
if options[:broker_extended]
|
|
29
|
+
(1..4).each do |i|
|
|
30
|
+
test_queues[i-1] << build_cucumber_command("REST API Group #{i}", ["@broker_api#{i}"])
|
|
31
|
+
end
|
|
32
|
+
(1..4).each do |i|
|
|
33
|
+
test_queues[i-1] << build_rake_command("OpenShift Broker Functionals Ext #{i}", "cd /data/src/github.com/openshift/openshift-test/broker; rake test:functionals_ext#{i}")
|
|
34
|
+
end
|
|
35
|
+
test_queues[1] << build_rake_command("OpenShift Broker Integration Ext", "cd /data/src/github.com/openshift/openshift-test/broker; rake test:integration_ext")
|
|
36
|
+
test_queues[2] << build_rake_command("OpenShift Broker OO Admin Scripts", "cd /data/src/github.com/openshift/openshift-test/broker; rake test:oo_admin_scripts")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if options[:node_extended]
|
|
40
|
+
(1..3).each do |i|
|
|
41
|
+
test_queues[i-1] << build_cucumber_command("Extended Node Group #{i}", ["@node_extended#{i}"])
|
|
42
|
+
end
|
|
43
|
+
test_queues[3] << build_rake_command("OpenShift Node Functionals Ext", "cd /data/src/github.com/openshift/openshift-test/node; rake ext_node_func_test")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
if options[:cart_extended]
|
|
47
|
+
(1..4).each do |i|
|
|
48
|
+
test_queues[i-1] << build_cucumber_command("Extended Cartridge Group #{i}", ["@cartridge_extended#{i}"])
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
if options[:gear_extended]
|
|
53
|
+
(1..4).each do |i|
|
|
54
|
+
test_queues[i-1] << build_cucumber_command("Extended Gear Group #{i}", ["@gear_extended#{i}"])
|
|
55
|
+
end
|
|
56
|
+
(1..4).each do |i|
|
|
57
|
+
test_queues[i-1] << build_rake_command("OpenShift Gear Functionals Ext #{i}", "cd /data/src/github.com/openshift/openshift-test/node; rake ext_gear_func_test#{i}")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
if options[:rhc_extended]
|
|
62
|
+
test_queues[0] << build_cucumber_command("RHC Integration",[],
|
|
63
|
+
{"RHC_SERVER" => "broker.example.com", "RHC_DOMAIN" => "example.com"},
|
|
64
|
+
nil,"/data/src/github.com/openshift/openshift-test/rhc/cucumber")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
if options[:broker]
|
|
68
|
+
test_queues[3] << build_rake_command("OpenShift Broker Units", "cd /data/src/github.com/openshift/openshift-test/broker; rake test:units", {}, false)
|
|
69
|
+
test_queues[1] << build_rake_command("OpenShift Broker Integration", "cd /data/src/github.com/openshift/openshift-test/broker; rake test:integration", {}, false)
|
|
70
|
+
(1..3).each do |i|
|
|
71
|
+
test_queues[i-1] << build_rake_command("OpenShift Broker Functional #{i}", "cd /data/src/github.com/openshift/openshift-test/broker; rake test:functionals#{i}", {}, false)
|
|
72
|
+
end
|
|
73
|
+
test_queues[1] << build_rake_command("OpenShift Admin Console Functional", "cd /data/src/github.com/openshift/openshift-test/broker; rake test:admin_console_functionals", {}, false)
|
|
74
|
+
test_queues[3] << build_cucumber_command("Broker cucumber", ["@broker"])
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
if options[:node]
|
|
78
|
+
test_queues[1] << build_rake_command("Node Essentials", "cd /data/src/github.com/openshift/openshift-test/node; rake essentials_test | tail -100; exit ${PIPESTATUS[0]}", {}, false)
|
|
79
|
+
test_queues[3] << build_rake_command("Node Frontend Plugin ApacheDB", "cd /data/src/github.com/openshift/openshift-test/plugins/frontend/apachedb; rake test", {}, false)
|
|
80
|
+
test_queues[3] << build_rake_command("Node Frontend Plugin Mod Rewrite", "cd /data/src/github.com/openshift/openshift-test/plugins/frontend/apache-mod-rewrite; rake test", {}, false)
|
|
81
|
+
test_queues[3] << build_rake_command("Node Frontend Plugin NodeJS Websocket", "cd /data/src/github.com/openshift/openshift-test/plugins/frontend/nodejs-websocket; rake test", {}, false)
|
|
82
|
+
test_queues[3] << build_rake_command("Node Frontend Plugin Haproxy SNI Proxy", "cd /data/src/github.com/openshift/openshift-test/plugins/frontend/haproxy-sni-proxy; rake test", {}, false)
|
|
83
|
+
(1..3).each do |i|
|
|
84
|
+
test_queues[i] << build_cucumber_command("Node Group #{i.to_s}", ["@node#{i.to_s}"])
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if options[:cart]
|
|
89
|
+
(1..3).each do |i|
|
|
90
|
+
test_queues[i] << build_cucumber_command("Cartridge Group #{i.to_s}", ["@cartridge#{i.to_s}"])
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
if options[:rhc]
|
|
95
|
+
if @is_fedora
|
|
96
|
+
test_queues[0] << build_rake_command("RHC Spec", 'cd /data/src/github.com/openshift/openshift-test/rhc; bundle install --local && bundle exec rake spec', {"SKIP_RUNCON" => 1}, false)
|
|
97
|
+
else
|
|
98
|
+
test_queues[0] << build_rake_command("RHC Spec", 'cd /data/src/github.com/openshift/openshift-test/rhc; bundle install --path=/tmp/rhc_bundle && bundle exec rake spec', {}, false)
|
|
99
|
+
test_queues[0] << build_rake_command("RHC Features", 'cd /data/src/github.com/openshift/openshift-test/rhc; export TEST_INSECURE=1; export TEST_RANDOM_USER=1; export RHC_SERVER=localhost; bundle install --path=/tmp/rhc_bundle && bundle exec rspec features/*_feature.rb', {}, false)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
run_tests_with_retry(test_queues)
|
|
104
|
+
|
|
105
|
+
#These are special tests that cannot be written to work concurrently
|
|
106
|
+
singleton_queue = []
|
|
107
|
+
|
|
108
|
+
if options[:node_extended]
|
|
109
|
+
idle_all_gears
|
|
110
|
+
singleton_queue << build_cucumber_command("Node singletons", ["@node_singleton"])
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if options[:gear_extended]
|
|
114
|
+
idle_all_gears
|
|
115
|
+
singleton_queue << build_cucumber_command("Gear singletons", ["@gear_singleton"])
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
run_tests_with_retry([singleton_queue])
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def run_tests_with_retry(test_queues)
|
|
122
|
+
test_run_success = false
|
|
123
|
+
(1..3).each do |retry_cnt|
|
|
124
|
+
print "Test run ##{retry_cnt}\n\n\n"
|
|
125
|
+
failure_queue = run_tests(test_queues)
|
|
126
|
+
if failure_queue.empty?
|
|
127
|
+
test_run_success = true
|
|
128
|
+
break
|
|
129
|
+
else
|
|
130
|
+
reset_test_dir(true)
|
|
131
|
+
end
|
|
132
|
+
test_queues = [failure_queue]
|
|
133
|
+
end
|
|
134
|
+
exit 1 unless test_run_success
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def run_tests(test_queues)
|
|
138
|
+
threads = []
|
|
139
|
+
failures = []
|
|
140
|
+
|
|
141
|
+
test_queues.each do |tqueue|
|
|
142
|
+
threads << Thread.new do
|
|
143
|
+
test_queue = tqueue
|
|
144
|
+
start_time = Time.new
|
|
145
|
+
test_queue.each do |test|
|
|
146
|
+
stdout_data = ""
|
|
147
|
+
stderr_data = ""
|
|
148
|
+
rc = -1
|
|
149
|
+
|
|
150
|
+
Open3.popen3(test[:command]) do |stdin, stdout, stderr, wait_thr|
|
|
151
|
+
pid = wait_thr.pid # pid of the started process.
|
|
152
|
+
stdin.close
|
|
153
|
+
|
|
154
|
+
stdout_data = stdout.read.chomp
|
|
155
|
+
stderr_data = stderr.read.chomp
|
|
156
|
+
|
|
157
|
+
stdout.close
|
|
158
|
+
stderr.close
|
|
159
|
+
rc = wait_thr.value # Process::Status object returned.
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
print %{
|
|
163
|
+
#######################################################################################################################
|
|
164
|
+
Test: #{test[:title]}
|
|
165
|
+
#######################################################################################################################
|
|
166
|
+
|
|
167
|
+
#{test[:command]}
|
|
168
|
+
|
|
169
|
+
#{stdout_data}
|
|
170
|
+
#{stderr_data}
|
|
171
|
+
|
|
172
|
+
#######################################################################################################################\n}
|
|
173
|
+
|
|
174
|
+
test[:output] = stdout_data + "\n" + stdout_data
|
|
175
|
+
test[:exit_code] = rc
|
|
176
|
+
test[:success] = rc == 0
|
|
177
|
+
test[:completed] = true
|
|
178
|
+
|
|
179
|
+
still_running_tests = test_queues.map do |q|
|
|
180
|
+
q.select{ |t| t[:completed] != true }
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
if still_running_tests.length > 0
|
|
184
|
+
mins, secs = (Time.new - start_time).abs.divmod(60)
|
|
185
|
+
print "\nStill Running Tests (#{mins}m #{secs.to_i}s):\n"
|
|
186
|
+
still_running_tests.each_index do |q_idx|
|
|
187
|
+
print "\t Queue #{q_idx}:\n"
|
|
188
|
+
print still_running_tests[q_idx].map{ |t| "\t\t#{t[:title]}" }.join("\n"), "\n"
|
|
189
|
+
end
|
|
190
|
+
print "\n\n\n"
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
all_tests=[]
|
|
194
|
+
test_queues.each do |q|
|
|
195
|
+
all_tests += q
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
failed_tests = all_tests.select{ |t| t[:success] == false && t[:completed] == true }
|
|
199
|
+
unless failed_tests.empty?
|
|
200
|
+
puts "Failed Tests:"
|
|
201
|
+
failed_tests.each do |t|
|
|
202
|
+
print "\t#{t[:title]}\n"
|
|
203
|
+
end
|
|
204
|
+
puts "\n\n\n"
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
passed_tests = all_tests.select{ |t| t[:success] == true && t[:completed] == true }
|
|
208
|
+
unless passed_tests.empty?
|
|
209
|
+
puts "Passed Tests:"
|
|
210
|
+
passed_tests.each do |t|
|
|
211
|
+
print "\t#{t[:title]}\n"
|
|
212
|
+
end
|
|
213
|
+
puts "\n\n\n"
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
threads.each { |t| t.join }
|
|
221
|
+
|
|
222
|
+
failures = test_queues.map{ |q| q.select{ |t| t[:success] == false }}
|
|
223
|
+
failures.flatten!
|
|
224
|
+
retry_queue = []
|
|
225
|
+
if failures.length > 0
|
|
226
|
+
idle_all_gears
|
|
227
|
+
print "Failures\n"
|
|
228
|
+
print failures.map{ |f| f[:title] }.join("\n")
|
|
229
|
+
print "\n\n\n"
|
|
230
|
+
|
|
231
|
+
#process failures
|
|
232
|
+
failures.each do |failed_test|
|
|
233
|
+
if failed_test[:options].has_key?(:cucumber_rerun_file)
|
|
234
|
+
retry_queue << build_cucumber_command(failed_test[:title], [], failed_test[:options][:env],
|
|
235
|
+
failed_test[:options][:cucumber_rerun_file],
|
|
236
|
+
failed_test[:options][:test_dir],
|
|
237
|
+
"*.feature",
|
|
238
|
+
failed_test[:options][:require_gemfile_dir],
|
|
239
|
+
failed_test[:options][:other_outputs])
|
|
240
|
+
elsif failed_test[:output] =~ /cucumber openshift-test\/tests\/.*\.feature:\d+/
|
|
241
|
+
output.lines.each do |line|
|
|
242
|
+
if line =~ /cucumber openshift-test\/tests\/(.*\.feature):(\d+)/
|
|
243
|
+
test = $1
|
|
244
|
+
scenario = $2
|
|
245
|
+
if failed_test[:options][:retry_indivigually]
|
|
246
|
+
retry_queue << build_cucumber_command(failed_test[:title], [], failed_test[:options][:env],
|
|
247
|
+
failed_test[:options][:cucumber_rerun_file],
|
|
248
|
+
failed_test[:options][:test_dir],
|
|
249
|
+
"#{test}:#{scenario}")
|
|
250
|
+
else
|
|
251
|
+
retry_queue << build_cucumber_command(failed_test[:title], [], failed_test[:options][:env],
|
|
252
|
+
failed_test[:options][:cucumber_rerun_file],
|
|
253
|
+
failed_test[:options][:test_dir],
|
|
254
|
+
"#{test}")
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
elsif failed_test[:options][:retry_indivigually] && failed_test[:output].include?("Failure:") && failed_test[:output].include?("rake_test_loader")
|
|
259
|
+
found_test = false
|
|
260
|
+
failed_test[:output].lines.each do |line|
|
|
261
|
+
if line =~ /\A(test_\w+)\((\w+Test)\) \[\/.*\/(test\/.*_test\.rb):(\d+)\]:/
|
|
262
|
+
found_test = true
|
|
263
|
+
test_name = $1
|
|
264
|
+
class_name = $2
|
|
265
|
+
file_name = $3
|
|
266
|
+
|
|
267
|
+
# determine if the first part of the command is a directory change
|
|
268
|
+
# if so, include that in the retry command
|
|
269
|
+
chdir_command = ""
|
|
270
|
+
if cmd =~ /\A(cd .+?; )/
|
|
271
|
+
chdir_command = $1
|
|
272
|
+
end
|
|
273
|
+
retry_queue << build_rake_command("#{class_name} (#{test_name})", "#{chdir_command} ruby -Ilib:test #{file_name} -n #{test_name}", true)
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
retry_queue << {
|
|
277
|
+
:command => failed_test[:command],
|
|
278
|
+
:options => failed_test[:options],
|
|
279
|
+
:title => failed_test[:title]
|
|
280
|
+
}
|
|
281
|
+
else
|
|
282
|
+
retry_queue << {
|
|
283
|
+
:command => failed_test[:command],
|
|
284
|
+
:options => failed_test[:options],
|
|
285
|
+
:title => failed_test[:title]
|
|
286
|
+
}
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
retry_queue
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def build_cucumber_command(title="", tags=[], test_env = {}, old_rerun_file=nil, test_dir="/data/src/github.com/openshift/openshift-test/tests",
|
|
294
|
+
feature_file="*.feature", require_gemfile_dir=nil, other_outputs = nil)
|
|
295
|
+
|
|
296
|
+
other_outputs ||= {:junit => '/tmp/rhc/cucumber_results'}
|
|
297
|
+
rerun_file = "/tmp/rerun_#{SecureRandom.hex}.txt"
|
|
298
|
+
opts = []
|
|
299
|
+
opts << "--strict"
|
|
300
|
+
opts << "-f progress"
|
|
301
|
+
opts << "-f rerun --out #{rerun_file} "
|
|
302
|
+
other_outputs.each do |formatter, file|
|
|
303
|
+
opts << "-f #{formatter} --out #{file}"
|
|
304
|
+
end
|
|
305
|
+
if @is_fedora
|
|
306
|
+
tags += ["~@fedora-18-only", "~@rhel-only", "~@not-fedora-19", "~@jboss", "~@not-origin"]
|
|
307
|
+
else
|
|
308
|
+
tags += ["~@fedora-18-only", "~@fedora-19-only", "~@not-rhel", "~@jboss", "~@not-origin"]
|
|
309
|
+
end
|
|
310
|
+
opts += tags.map{ |t| "-t #{t}"}
|
|
311
|
+
opts << "-r #{test_dir}"
|
|
312
|
+
if old_rerun_file.nil?
|
|
313
|
+
opts << "#{test_dir}/#{feature_file}"
|
|
314
|
+
else
|
|
315
|
+
opts << "@#{old_rerun_file}"
|
|
316
|
+
end
|
|
317
|
+
if not require_gemfile_dir.nil?
|
|
318
|
+
{:command => wrap_test_command("cd #{require_gemfile_dir}; bundle install --path=gems; bundle exec \"cucumber #{opts.join(' ')}\"", test_env),
|
|
319
|
+
:options =>
|
|
320
|
+
{:cucumber_rerun_file => rerun_file,
|
|
321
|
+
:timeout => @@SSH_TIMEOUT,
|
|
322
|
+
:test_dir => test_dir,
|
|
323
|
+
:env => test_env,
|
|
324
|
+
:require_gemfile_dir => require_gemfile_dir,
|
|
325
|
+
:other_outputs => other_outputs
|
|
326
|
+
},
|
|
327
|
+
:title => title
|
|
328
|
+
}
|
|
329
|
+
else
|
|
330
|
+
{:command => wrap_test_command("cucumber #{opts.join(' ')}", test_env),
|
|
331
|
+
:options => {
|
|
332
|
+
:cucumber_rerun_file => rerun_file,
|
|
333
|
+
:timeout => @@SSH_TIMEOUT,
|
|
334
|
+
:test_dir => test_dir,
|
|
335
|
+
:env => test_env,
|
|
336
|
+
:other_outputs => other_outputs
|
|
337
|
+
},
|
|
338
|
+
:title => title}
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def build_rake_command(title="", cmd="", test_env = {}, retry_indivigually=true)
|
|
343
|
+
{:command => wrap_test_command(cmd, test_env), :options => {:retry_indivigually => retry_indivigually, :timeout => @@SSH_TIMEOUT, :env => test_env}, :title => title}
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def wrap_test_command(command, test_env={})
|
|
347
|
+
env_str = ""
|
|
348
|
+
unless test_env.nil?
|
|
349
|
+
test_env.each do |k,v|
|
|
350
|
+
env_str += "export #{k}=#{v}; "
|
|
351
|
+
end
|
|
352
|
+
end
|
|
353
|
+
if @is_fedora
|
|
354
|
+
if test_env["SKIP_RUNCON"]
|
|
355
|
+
"export REGISTER_USER=1 ; #{env_str} #{command}"
|
|
356
|
+
else
|
|
357
|
+
%{runcon system_u:system_r:openshift_initrc_t:s0-s0:c0.c1023 bash -c \"export REGISTER_USER=1 ; #{env_str} #{command}"}
|
|
358
|
+
end
|
|
359
|
+
else
|
|
360
|
+
%{/usr/bin/scl enable ruby193 "export LANG=en_US.UTF-8 ; export REGISTER_USER=1; #{env_str} #{command}"}
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
def reset_test_dir(backup=false)
|
|
365
|
+
File.open('/tmp/reset_test_dir.sh', "w") do |file|
|
|
366
|
+
file.write(%{
|
|
367
|
+
if [ -d /tmp/rhc ]
|
|
368
|
+
then
|
|
369
|
+
if #{backup}
|
|
370
|
+
then
|
|
371
|
+
if \$(ls /tmp/rhc/run_* > /dev/null 2>&1)
|
|
372
|
+
then
|
|
373
|
+
rm -rf /tmp/rhc_previous_runs
|
|
374
|
+
mkdir -p /tmp/rhc_previous_runs
|
|
375
|
+
mv /tmp/rhc/run_* /tmp/rhc_previous_runs
|
|
376
|
+
fi
|
|
377
|
+
if \$(ls /tmp/rhc/* > /dev/null 2>&1)
|
|
378
|
+
then
|
|
379
|
+
for i in {1..100}
|
|
380
|
+
do
|
|
381
|
+
if ! [ -d /tmp/rhc_previous_runs/run_$i ]
|
|
382
|
+
then
|
|
383
|
+
mkdir -p /tmp/rhc_previous_runs/run_$i
|
|
384
|
+
mv /tmp/rhc/* /tmp/rhc_previous_runs/run_$i
|
|
385
|
+
break
|
|
386
|
+
fi
|
|
387
|
+
done
|
|
388
|
+
fi
|
|
389
|
+
if \$(ls /tmp/rhc_previous_runs/run_* > /dev/null 2>&1)
|
|
390
|
+
then
|
|
391
|
+
mv /tmp/rhc_previous_runs/run_* /tmp/rhc/
|
|
392
|
+
rm -rf /tmp/rhc_previous_runs
|
|
393
|
+
fi
|
|
394
|
+
else
|
|
395
|
+
rm -rf /tmp/rhc
|
|
396
|
+
fi
|
|
397
|
+
fi
|
|
398
|
+
mkdir -p /tmp/rhc/junit
|
|
399
|
+
})
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
system 'chmod +x /tmp/reset_test_dir.sh'
|
|
403
|
+
system '/tmp/reset_test_dir.sh'
|
|
404
|
+
system 'rm -rf /var/www/openshift/broker/tmp/cache/*'
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
def idle_all_gears
|
|
408
|
+
is_fedora = system("test -e /etc/fedora-release")
|
|
409
|
+
|
|
410
|
+
print "Idling all gears on remote instance\n"
|
|
411
|
+
|
|
412
|
+
if is_fedora
|
|
413
|
+
system('/sbin/service mcollective stop; /sbin/service mcollective start')
|
|
414
|
+
else
|
|
415
|
+
system('/sbin/service ruby193-mcollective stop; /sbin/service ruby193-mcollective start')
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
system(%{
|
|
419
|
+
for gear in `oo-admin-ctl-gears list`; do
|
|
420
|
+
oo-admin-ctl-gears idlegear $gear;
|
|
421
|
+
done;
|
|
422
|
+
})
|
|
423
|
+
|
|
424
|
+
if is_fedora
|
|
425
|
+
system('/sbin/service httpd reload')
|
|
426
|
+
else
|
|
427
|
+
system('/sbin/service httpd graceful')
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
print "Done\n"
|
|
431
|
+
end
|
|
432
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/python -tt
|
|
2
|
+
|
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program; if not, write to the Free Software Foundation,
|
|
15
|
+
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
16
|
+
|
|
17
|
+
import sys
|
|
18
|
+
sys.path.insert(0,'/usr/share/yum-cli')
|
|
19
|
+
|
|
20
|
+
import yum
|
|
21
|
+
from yum.misc import setup_locale
|
|
22
|
+
from yum.i18n import exception2msg
|
|
23
|
+
import yum.Errors
|
|
24
|
+
from utils import YumUtilBase
|
|
25
|
+
|
|
26
|
+
import logging
|
|
27
|
+
import rpmUtils
|
|
28
|
+
import rpm
|
|
29
|
+
|
|
30
|
+
rhn_source_repos = False
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class YumBuildDep(YumUtilBase):
|
|
35
|
+
NAME = 'yum-listbuilddep'
|
|
36
|
+
VERSION = '1.0'
|
|
37
|
+
USAGE = 'yum-listbuilddep package1.spec [package2.spec] [...]'
|
|
38
|
+
|
|
39
|
+
def __init__(self):
|
|
40
|
+
YumUtilBase.__init__(self,
|
|
41
|
+
YumBuildDep.NAME,
|
|
42
|
+
YumBuildDep.VERSION,
|
|
43
|
+
YumBuildDep.USAGE)
|
|
44
|
+
self.logger = logging.getLogger("yum.verbose.cli.yumbuildep")
|
|
45
|
+
# Add util commandline options to the yum-cli ones
|
|
46
|
+
self.optparser = self.getOptionParser()
|
|
47
|
+
if hasattr(rpm, 'reloadConfig'):
|
|
48
|
+
self.optparser.add_option("--target",
|
|
49
|
+
help="set target architecture for spec parsing")
|
|
50
|
+
self.main()
|
|
51
|
+
|
|
52
|
+
def main(self):
|
|
53
|
+
# Parse the commandline option and setup the basics.
|
|
54
|
+
try:
|
|
55
|
+
opts = self.doUtilConfigSetup()
|
|
56
|
+
except yum.Errors.RepoError, e:
|
|
57
|
+
self.logger.error("Cannot handle specific enablerepo/disablerepo options.")
|
|
58
|
+
sys.exit(50)
|
|
59
|
+
|
|
60
|
+
# turn of our local gpg checking for opening the srpm if it is turned
|
|
61
|
+
# off for repos :)
|
|
62
|
+
if (opts.nogpgcheck or
|
|
63
|
+
not self.conf.localpkg_gpgcheck or not self.conf.gpgcheck):
|
|
64
|
+
self.ts.pushVSFlags((rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS))
|
|
65
|
+
|
|
66
|
+
# Check if there is anything to do.
|
|
67
|
+
if len(self.cmds) < 1:
|
|
68
|
+
print self.optparser.format_help()
|
|
69
|
+
sys.exit(0)
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
self.get_build_deps(opts)
|
|
73
|
+
except yum.Errors.MiscError, e:
|
|
74
|
+
msg = "There was a problem getting the build deps, exiting:\n %s" % e
|
|
75
|
+
self.logger.error(msg)
|
|
76
|
+
sys.exit(1)
|
|
77
|
+
sys.exit()
|
|
78
|
+
|
|
79
|
+
def get_build_deps(self,opts):
|
|
80
|
+
srcnames = []
|
|
81
|
+
specnames = []
|
|
82
|
+
srpms = []
|
|
83
|
+
specworks = False
|
|
84
|
+
reloadworks = False
|
|
85
|
+
|
|
86
|
+
# See if we can use spec files for buildrequires
|
|
87
|
+
if hasattr(rpm, 'spec') and hasattr(rpm.spec, 'sourceHeader'):
|
|
88
|
+
specworks = True
|
|
89
|
+
# See if we can reload rpm configuration
|
|
90
|
+
if hasattr(rpm, 'reloadConfig'):
|
|
91
|
+
reloadworks = True
|
|
92
|
+
|
|
93
|
+
for arg in self.cmds:
|
|
94
|
+
if specworks and arg.endswith('.spec'):
|
|
95
|
+
specnames.append(arg)
|
|
96
|
+
|
|
97
|
+
toActOn = []
|
|
98
|
+
for name in specnames:
|
|
99
|
+
# (re)load rpm config for target if set
|
|
100
|
+
if reloadworks and opts.target:
|
|
101
|
+
rpm.reloadConfig(opts.target)
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
spec = rpm.spec(name)
|
|
105
|
+
except ValueError:
|
|
106
|
+
self.logger.error("Bad spec: %s" % name)
|
|
107
|
+
continue
|
|
108
|
+
|
|
109
|
+
# reset default rpm config after each parse to avoid side-effects
|
|
110
|
+
if reloadworks:
|
|
111
|
+
rpm.reloadConfig()
|
|
112
|
+
|
|
113
|
+
buildreqs = []
|
|
114
|
+
for d in rpm.ds(spec.sourceHeader, 'requires'):
|
|
115
|
+
buildreqs.append(d.DNEVR()[2:])
|
|
116
|
+
|
|
117
|
+
if len(buildreqs) > 0:
|
|
118
|
+
self.logger.info('["%s"]' % '","'.join(buildreqs))
|
|
119
|
+
else:
|
|
120
|
+
self.logger.info('[]')
|
|
121
|
+
|
|
122
|
+
if __name__ == '__main__':
|
|
123
|
+
setup_locale()
|
|
124
|
+
util = YumBuildDep()
|