bellows 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/VERSION +1 -1
- data/lib/bellows/gerrit.rb +4 -0
- data/lib/bellows/smoke_stack.rb +25 -0
- data/lib/bellows/tasks.rb +52 -1
- data/test/test_task.rb +19 -0
- metadata +4 -4
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.7
|
data/lib/bellows/gerrit.rb
CHANGED
data/lib/bellows/smoke_stack.rb
CHANGED
@@ -9,6 +9,31 @@ module Bellows
|
|
9
9
|
JSON.parse(Bellows::HTTP.get("/jobs.json?limit=99999"))
|
10
10
|
end
|
11
11
|
|
12
|
+
def self.jobs_with_hash(git_hash, jobs=nil)
|
13
|
+
if jobs.nil?
|
14
|
+
jobs = JSON.parse(Bellows::HTTP.get("/jobs.json?limit=99999"))
|
15
|
+
end
|
16
|
+
jobs_found = []
|
17
|
+
jobs.each do |job|
|
18
|
+
data = job.values[0]
|
19
|
+
['nova','keystone','glance'].each do |project|
|
20
|
+
revision = data["#{project}_revision"]
|
21
|
+
if revision and revision == git_hash then
|
22
|
+
jobs_found << job
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
jobs_found
|
27
|
+
end
|
28
|
+
|
29
|
+
#Return a reference to the first job of the specified type.
|
30
|
+
def self.job_data_for_type(jobs, job_type)
|
31
|
+
jobs.each do |job|
|
32
|
+
return job.values[0] if job.keys[0] == job_type
|
33
|
+
end
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
|
12
37
|
def self.smoke_tests(project)
|
13
38
|
tests = {}
|
14
39
|
data = JSON.parse(Bellows::HTTP.get("/smoke_tests.json"))
|
data/lib/bellows/tasks.rb
CHANGED
@@ -72,7 +72,6 @@ module Bellows
|
|
72
72
|
Util.validate_project(project)
|
73
73
|
test = options[:test]
|
74
74
|
limit = options[:limit] || 5
|
75
|
-
# jobs indexed by revision
|
76
75
|
jobs = Set.new
|
77
76
|
Bellows::SmokeStack.jobs.each do |job|
|
78
77
|
data = job.values[0]
|
@@ -107,5 +106,57 @@ module Bellows
|
|
107
106
|
end
|
108
107
|
end
|
109
108
|
|
109
|
+
desc "comment PROJECT", "Add gerrit comments for reviews w/ results."
|
110
|
+
method_options :test => :boolean
|
111
|
+
method_options :quiet => :boolean
|
112
|
+
method_options :cache_file => :string, :required => true
|
113
|
+
def comment(project, options=(options or {}))
|
114
|
+
Util.validate_project(project)
|
115
|
+
test = options[:test]
|
116
|
+
cache_file = options[:cache_file]
|
117
|
+
jobs = Bellows::SmokeStack.jobs
|
118
|
+
|
119
|
+
if cache_file.nil? or cache_file.empty?
|
120
|
+
puts "ERROR: cache_file is required."
|
121
|
+
exit 1
|
122
|
+
end
|
123
|
+
|
124
|
+
cached_hashes = Set.new
|
125
|
+
if File.exists?(cache_file) then
|
126
|
+
IO.read(cache_file).each_line do |line|
|
127
|
+
cached_hashes << line.chomp
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
File.open(cache_file, 'a') do |file|
|
132
|
+
Bellows::Gerrit.reviews(project) do |review|
|
133
|
+
revision = review['currentPatchSet']['revision'][0,7]
|
134
|
+
desc = review['owner']['name'] + ": " +review['subject']
|
135
|
+
if not cached_hashes.include? revision
|
136
|
+
refspec = review['currentPatchSet']['ref']
|
137
|
+
patchset_num = review['currentPatchSet']['number']
|
138
|
+
jobs_for_rev = Bellows::SmokeStack.jobs_with_hash(revision, jobs)
|
139
|
+
if jobs_for_rev.count > 0 then
|
140
|
+
unit=Bellows::SmokeStack.job_data_for_type(jobs_for_rev, 'job_unit_tester')
|
141
|
+
libvirt=Bellows::SmokeStack.job_data_for_type(jobs_for_rev, 'job_vpc')
|
142
|
+
xenserver=Bellows::SmokeStack.job_data_for_type(jobs_for_rev, 'job_xen_hybrid')
|
143
|
+
if unit and libvirt and xenserver then
|
144
|
+
puts "Commenting ... " + desc if not options[:quiet]
|
145
|
+
message = "SmokeStack Results (patch set #{patchset_num}):\n"
|
146
|
+
message += "\tUnit #{unit['status']}: http://smokestack.openstack.org/?go=/jobs/#{unit['id']}\n"
|
147
|
+
message += "\tLibvirt #{libvirt['status']}: http://smokestack.openstack.org/?go=/jobs/#{libvirt['id']}\n"
|
148
|
+
message += "\tXenServer #{xenserver['status']}: http://smokestack.openstack.org/?go=/jobs/#{xenserver['id']}"
|
149
|
+
out = Bellows::Gerrit.comment(review['currentPatchSet']['revision'], message) if not test
|
150
|
+
puts out if not options[:quiet]
|
151
|
+
file.write revision + "\n" if not test
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
110
161
|
end
|
111
162
|
end
|
data/test/test_task.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
$:.unshift File.dirname(__FILE__)
|
2
2
|
require 'helper'
|
3
|
+
require 'tempfile'
|
3
4
|
|
4
5
|
class TaskTest < Test::Unit::TestCase
|
5
6
|
|
@@ -21,4 +22,22 @@ class TaskTest < Test::Unit::TestCase
|
|
21
22
|
|
22
23
|
end
|
23
24
|
|
25
|
+
def test_comment
|
26
|
+
|
27
|
+
jobs_data = fixture('jobs.json')
|
28
|
+
Bellows::SmokeStack.stubs(:jobs).returns(JSON.parse(jobs_data))
|
29
|
+
|
30
|
+
gerrit_data = fixture('gerrit.json')
|
31
|
+
Bellows::Gerrit.stubs(:run_cmd).returns(gerrit_data)
|
32
|
+
|
33
|
+
cache_file=Tempfile.new('smokestack')
|
34
|
+
|
35
|
+
response = mock()
|
36
|
+
Bellows::HTTP.stubs(:post).returns(response)
|
37
|
+
tasks = Bellows::Tasks.new
|
38
|
+
|
39
|
+
tasks.comment('nova', options={:quiet => true, :cache_file => cache_file.path})
|
40
|
+
|
41
|
+
end
|
42
|
+
|
24
43
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bellows
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 7
|
10
|
+
version: 1.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dan Prince
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-12-
|
18
|
+
date: 2011-12-12 00:00:00 -05:00
|
19
19
|
default_executable: bellows
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|