vagrant-openshift 1.0.12 → 1.0.13

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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.asciidoc +5 -3
  4. data/lib/vagrant-openshift/action/build_openshift3.rb +30 -5
  5. data/lib/vagrant-openshift/action/{install_rhc.rb → build_openshift3_base_images.rb} +13 -11
  6. data/lib/vagrant-openshift/action/{run_openshift2_tests.rb → build_sti.rb} +28 -11
  7. data/lib/vagrant-openshift/action/clean.rb +1 -4
  8. data/lib/vagrant-openshift/action/clean_network_setup.rb +1 -1
  9. data/lib/vagrant-openshift/action/download_artifacts_openshift3.rb +4 -1
  10. data/lib/vagrant-openshift/action/{download_artifacts_openshift2.rb → download_artifacts_sti.rb} +3 -11
  11. data/lib/vagrant-openshift/action/generate_template.rb +38 -40
  12. data/lib/vagrant-openshift/action/install_openshift3.rb +5 -16
  13. data/lib/vagrant-openshift/action/{build_openshift2.rb → install_openshift3_asset_dependencies.rb} +17 -5
  14. data/lib/vagrant-openshift/action/install_openshift3_base_dependencies.rb +20 -5
  15. data/lib/vagrant-openshift/action/{local_openshift2_checkout.rb → push_openshift3_release.rb} +14 -14
  16. data/lib/vagrant-openshift/action/run_openshift3_tests.rb +38 -14
  17. data/lib/vagrant-openshift/action/run_sti_tests.rb +64 -0
  18. data/lib/vagrant-openshift/action.rb +44 -83
  19. data/lib/vagrant-openshift/command/build_openshift3.rb +9 -0
  20. data/lib/vagrant-openshift/command/{build_openshift2_base.rb → build_openshift3_base_images.rb} +5 -5
  21. data/lib/vagrant-openshift/command/{build_openshift3_infrastructure_images.rb → build_sti.rb} +10 -12
  22. data/lib/vagrant-openshift/command/checkout_repositories.rb +1 -1
  23. data/lib/vagrant-openshift/command/{install_rhc.rb → install_openshift3_assets_base.rb} +5 -5
  24. data/lib/vagrant-openshift/command/local_openshift3_setup.rb +1 -1
  25. data/lib/vagrant-openshift/command/openshift_init.rb +4 -4
  26. data/lib/vagrant-openshift/command/push_openshift3_release.rb +57 -0
  27. data/lib/vagrant-openshift/command/repo_sync_openshift3.rb +1 -13
  28. data/lib/vagrant-openshift/command/{repo_sync_openshift2.rb → repo_sync_sti.rb} +11 -19
  29. data/lib/vagrant-openshift/command/test_openshift3.rb +8 -0
  30. data/lib/vagrant-openshift/command/test_openshift3_image.rb +8 -17
  31. data/lib/vagrant-openshift/command/test_sti.rb +59 -0
  32. data/lib/vagrant-openshift/config.rb +2 -14
  33. data/lib/vagrant-openshift/constants.rb +3 -67
  34. data/lib/vagrant-openshift/helper/command_helper.rb +0 -3
  35. data/lib/vagrant-openshift/plugin.rb +24 -29
  36. data/lib/vagrant-openshift/provisioner.rb +5 -37
  37. data/lib/vagrant-openshift/templates/builder/Rakefile +0 -205
  38. data/lib/vagrant-openshift/templates/command/init-openshift/box_info.yaml +34 -49
  39. data/lib/vagrant-openshift/version.rb +1 -1
  40. metadata +33 -48
  41. data/lib/vagrant-openshift/action/build_openshift3_images.rb +0 -54
  42. data/lib/vagrant-openshift/action/build_openshift3_infrastructure_images.rb +0 -50
  43. data/lib/vagrant-openshift/action/checkout_openshift2_tests.rb +0 -57
  44. data/lib/vagrant-openshift/action/create_openshift2_puppet_file.rb +0 -84
  45. data/lib/vagrant-openshift/action/create_openshift2_test_users.rb +0 -36
  46. data/lib/vagrant-openshift/action/idle_all_gears_openshift2.rb +0 -36
  47. data/lib/vagrant-openshift/action/install_openshift2_base_dependencies.rb +0 -50
  48. data/lib/vagrant-openshift/action/install_openshift2_build_dependencies.rb +0 -48
  49. data/lib/vagrant-openshift/action/preserve_mcollective_logs.rb +0 -48
  50. data/lib/vagrant-openshift/action/setup_builder_files.rb +0 -57
  51. data/lib/vagrant-openshift/action/uninstall_openshift2_rpms.rb +0 -37
  52. data/lib/vagrant-openshift/command/build_openshift3_images.rb +0 -68
  53. data/lib/vagrant-openshift/command/local_openshift2_setup.rb +0 -62
  54. data/lib/vagrant-openshift/command/test_openshift2.rb +0 -108
  55. data/lib/vagrant-openshift/templates/builder/lib/rpm.rb +0 -248
  56. data/lib/vagrant-openshift/templates/builder/lib/test.rb +0 -432
  57. data/lib/vagrant-openshift/templates/builder/yum-listbuilddep +0 -124
  58. data/lib/vagrant-openshift/templates/command/init-openshift/Vagrantfile.erb +0 -171
@@ -1,248 +0,0 @@
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
-
17
- require_relative 'constants'
18
- require_relative 'options'
19
- require 'tempfile'
20
- require 'fileutils'
21
- require 'pathname'
22
- require 'yaml'
23
-
24
- class RPM
25
- def self.get_packages(options={})
26
- spec_cache = Pathname.new(Vagrant::Openshift::Constants.build_dir + ".spec_cache")
27
- if spec_cache.exist? && !options[:ignore_cache]
28
- return YAML.load(File.open(spec_cache.to_s))
29
- end
30
-
31
- parent_dir = Pathname.new(File.expand_path("__FILE__/../../"))
32
-
33
- #find all spec files
34
- spec_files = []
35
- Vagrant::Openshift::Constants.openshift2_repos.each do |name, url|
36
- repo_dir = parent_dir + name
37
- spec_files += Dir.glob((repo_dir + "**/*.spec").to_s).map{ |p| {path: p}}
38
- end
39
-
40
- #exclude ones that have not been tagged
41
- source_package_names = []
42
- spec_files.delete_if do |spec|
43
- spec[:name] = `rpm -q --specfile --queryformat '%{NAME}\n' #{spec[:path]}`.split("\n")[0]
44
- spec[:version] = `rpm -q --specfile --queryformat '%{VERSION}\n' #{spec[:path]}`.split("\n")[0]
45
- source_package_names << spec[:name]
46
- spec[:dir] = Pathname.new(spec[:path]).dirname
47
- is_tagged = Dir.chdir(spec[:dir]) { system "git tag | grep '#{spec[:name]}' 2>&1 1>/dev/null" }
48
- is_spec_bad = false
49
- if is_tagged
50
- begin
51
- spec[:build_deps] = YAML.load(`./yum-listbuilddep #{spec[:path]}`.split("\n").last)
52
- raise "Bad spec" if spec[:build_deps].class == Hash
53
- spec[:deps] = `rpm -q --specfile --requires #{spec[:path]}`.split("\n")
54
- rescue Exception => e
55
- next true
56
- end
57
- else
58
- puts "\n\nSkipping '#{spec[:name]}' in '#{spec[:dir]}' since it is not tagged.\n"
59
- next true
60
- end
61
-
62
- options.has_key?(:ignore_packages) && options[:ignore_packages].include?(spec[:name])
63
- end
64
-
65
- if(options.has_key?(:remove_os_build_deps) && options[:remove_os_build_deps])
66
- #remove deps provided by OS and keep only the ones that will be built from source
67
- spec_files.each do |spec|
68
- spec[:build_deps].delete_if{ |dep| not source_package_names.include? dep }
69
- end
70
- end
71
-
72
- File.open(spec_cache.to_s, "w") do |file|
73
- file.write(spec_files.to_yaml)
74
- end
75
-
76
- spec_files
77
- end
78
-
79
- def self.install_rpms(list)
80
- print "Installing #{list.size} in chunks of 20 packages"
81
- list.uniq.each_slice(20) do |sub_list|
82
- system %{yum install -y --skip-broken "#{sub_list.join('" "')}"}
83
- end
84
- end
85
-
86
- def self.uninstall_openshift
87
- #undo pam.d sshd modification
88
- if system("grep -n 'pam_openshift' /etc/pam.d/sshd")
89
- file = Tempfile.new('temp')
90
- begin
91
- file.write(%{
92
- set /files/etc/pam.d/sshd/#comment[.='pam_openshift.so close should be the first session rule'] 'pam_selinux.so close should be the first session rule'
93
- ins 01 before /files/etc/pam.d/sshd/*[argument='close']
94
- set /files/etc/pam.d/sshd/01/type session
95
- set /files/etc/pam.d/sshd/01/control required
96
- set /files/etc/pam.d/sshd/01/module pam_selinux.so
97
- set /files/etc/pam.d/sshd/01/argument close
98
-
99
- set /files/etc/pam.d/sshd/#comment[.='pam_openshift.so open should only be followed by sessions to be executed in the user context'] 'pam_selinux.so open should only be followed by sessions to be executed in the user context'
100
- ins 02 before /files/etc/pam.d/sshd/*[argument='open']
101
- set /files/etc/pam.d/sshd/02/type session
102
- set /files/etc/pam.d/sshd/02/control required
103
- set /files/etc/pam.d/sshd/02/module pam_selinux.so
104
- set /files/etc/pam.d/sshd/02/argument[1] open
105
- set /files/etc/pam.d/sshd/02/argument[2] env_params
106
-
107
- rm /files/etc/pam.d/sshd/*[module='pam_openshift.so']
108
- rm /files/etc/pam.d/sshd/*[module='pam_namespace.so']
109
- rm /files/etc/pam.d/sshd/*[module='pam_cgroup.so']
110
- rm /files/etc/pam.d/sshd/*[module='pam_succeed_if.so']
111
- save
112
- })
113
- file.close
114
- system("augtool --file #{file.path}")
115
- ensure
116
- file.unlink
117
- end
118
- end
119
- FileUtils.rm_rf("/etc/openshift")
120
-
121
- get_packages(ignore_cache: true).each_slice(10) do |spec_files_list|
122
- sub_list = spec_files_list.map {|s| s[:name] }
123
- system %{yum erase -y "#{sub_list.join('" "')}"}
124
- end
125
- end
126
-
127
- def self.build_packages(spec_files, opts={})
128
- built_specs = []
129
-
130
- FileUtils.mkdir_p "/tmp/tito/noarch/"
131
- FileUtils.mkdir_p (Vagrant::Openshift::Constants.build_dir + "origin-rpms").to_s
132
- FileUtils.mkdir_p (Vagrant::Openshift::Constants.build_dir + "origin-srpms").to_s
133
- (1..3).each do |phase|
134
- print "Build phase #{phase}\n"
135
- buildable = []
136
-
137
- #install pre reqs if they have already been built
138
- spec_files.each do |spec|
139
- spec[:build_deps].delete_if do |dep|
140
- if opts[:assume_deps_built] || built_specs.map{ |s| s[:name] }.include?(dep)
141
- puts "\n Installing...#{dep}"
142
- raise "Unable to install package #{package.name}" unless system("rpm -Uvh --force /tmp/tito/noarch/#{dep}*.rpm")
143
- true
144
- else
145
- false
146
- end
147
- end
148
- end
149
-
150
- buildable = spec_files.select{ |spec| spec[:build_deps].size == 0 }
151
-
152
- buildable.each do |spec|
153
- Dir.chdir(spec[:dir]) do
154
- puts "\n#{'-'*60}"
155
- system "rm -f /tmp/tito/noarch/#{spec[:name]}*.rpm"
156
- system "rm -f /tmp/tito/#{spec[:name]}*.src.rpm"
157
-
158
- raise "Unable to build #{spec[:name]}" unless system("tito build --rpm --test")
159
-
160
- Dir.glob('/tmp/tito/x86_64/*.rpm').each {|file|
161
- FileUtils.mv file, "/tmp/tito/noarch/"
162
- }
163
- Dir.glob("/tmp/tito/noarch/#{spec[:name]}*.rpm").each do |file|
164
- FileUtils.rm_f (Vagrant::Openshift::Constants.build_dir + "origin-rpms/" + "#{spec[:name]}*.rpm").to_s
165
- FileUtils.cp file, (Vagrant::Openshift::Constants.build_dir + "origin-rpms/").to_s
166
- end
167
- Dir.glob('/tmp/tito/*.src.rpm').each {|file|
168
- FileUtils.rm_f (Vagrant::Openshift::Constants.build_dir + "origin-srpms/" + "#{spec[:name]}*.src.rpm").to_s
169
- FileUtils.mv file, (Vagrant::Openshift::Constants.build_dir + "origin-srpms/").to_s
170
- }
171
-
172
- built_specs << spec
173
- spec_files.delete(spec)
174
- end
175
- end
176
- end
177
-
178
- File.open((Vagrant::Openshift::Constants.build_dir + ".built_packages").to_s, "w") do |file|
179
- file.write(tito_report.to_yaml)
180
- end
181
-
182
- print "Updating local repo for built sources"
183
- Dir.chdir((Vagrant::Openshift::Constants.build_dir + "origin-rpms/").to_s) do
184
- system("createrepo .")
185
- system("yum clean all")
186
- end
187
-
188
- built_specs
189
- end
190
-
191
- def self.updated_packages
192
- spec_files = get_updated_packages
193
- built_packages = build_packages(spec_files, {assume_deps_built: true})
194
- built_packages.each do |spec|
195
- unless system("rpm -Uvh --force #{Vagrant::Openshift::Constants.build_dir + "origin-rpms"}/#{spec[:name]}*.rpm")
196
- unless system("rpm -e --justdb --nodeps #{spec[:name]}; yum install -y #{Vagrant::Openshift::Constants.build_dir + "origin-rpms"}/#{spec[:name]}*.rpm")
197
- print "Unable to install updated package #{spec[:name]}"
198
- exit 1
199
- end
200
- end
201
- end
202
- end
203
-
204
- private
205
-
206
- def self.get_updated_packages
207
- raise "Please perform full build with 'rake openshift:build_all' before running sync" unless (Vagrant::Openshift::Constants.build_dir + ".built_packages").exist?
208
-
209
- spec_files = get_packages(remove_os_build_deps: true)
210
- cur_report = tito_report
211
- old_report = YAML.load(File.new((Vagrant::Openshift::Constants.build_dir + ".built_packages").to_s))
212
-
213
- updated_packages = []
214
- spec_files.each do |spec|
215
- cur_package_report = cur_report[spec[:name]]
216
- old_package_report = old_report[spec[:name]]
217
-
218
- if (old_package_report.nil? && !cur_package_report.nil?) ||
219
- (!cur_package_report.nil? && cur_package_report[:version] != old_package_report[:version]) ||
220
- (!cur_package_report.nil? && cur_package_report[:untagged_revisions] != old_package_report[:untagged_revisions])
221
- updated_packages << spec unless OPTIONS[:ignore_packages].include?(spec[:name])
222
- end
223
- end
224
-
225
- updated_packages
226
- end
227
-
228
- def self.tito_report
229
- packages = {}
230
- Vagrant::Openshift::Constants.openshift2_repos.each do |name, url|
231
- Dir.chdir((Vagrant::Openshift::Constants.build_dir + name).to_s) do
232
- tito_report = `tito report --untagged-commits`
233
- tito_report = tito_report.split(/[-]+{10,100}[\n]/)
234
- tito_report.shift
235
-
236
- tito_report.each do |package_report|
237
- package_report = package_report.split("\n")
238
- m = package_report.shift.match(/([a-z0-9\-]+)-([\d\.\-]+)..HEAD/)
239
- packages[m[1]] = {
240
- version: m[2],
241
- untagged_revisions: package_report.map{ |line| line.split(" ")[0] }
242
- }
243
- end
244
- end
245
- end
246
- packages
247
- end
248
- end
@@ -1,432 +0,0 @@
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..3).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" => "openshift.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