bellows 1.0.10 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ * Mon May 7 2012 Dan Prince <dprince@redhat.com> - 1.0.11
2
+ - The comment task now uses Gerrit 'verified' to report results.
3
+ It votes with -1 and +1 based on SmokeStack results.
4
+ - Add 'projects' config option. Defaults to ['nova', 'keystone', 'glance']
5
+ - Add 'job_types' config option. The comment task now makes use of
6
+ configurable job_types when determining when results are present
7
+ and approved.
8
+
1
9
  * Mon Jan 9 2012 Dan Prince <dan.prince@rackspace.com> - 1.0.10
2
10
  - Fix 'undefined method `[]' for nil:NilClass' error that could occur in
3
11
  the approved? method of smoke_stack.rb. This error was keeping bellows
data/README.md CHANGED
@@ -25,6 +25,19 @@ Installation
25
25
 
26
26
  test_suite_ids:
27
27
  - 1
28
+
29
+ job_types:
30
+ - name: job_unit_tester
31
+ auto_approved: Yes
32
+ description: "Unit"
33
+
34
+ - name: job_puppet_vpc
35
+ auto_approved: No
36
+ description: "Libvirt (Fedora 16)"
37
+
38
+ - name: job_chef_vpc_xen
39
+ auto_approved: No
40
+ description: "XenServer (Ubuntu 11.10)"
28
41
  EOF_CAT
29
42
 
30
43
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.10
1
+ 1.0.11
@@ -23,8 +23,8 @@ module Bellows
23
23
  reviews
24
24
  end
25
25
 
26
- def self.comment(revision, message)
27
- Gerrit.run_cmd(%{review --code-review 0 -m \"'#{message}'\" #{revision}})
26
+ def self.comment(revision, message, verify_vote=0)
27
+ Gerrit.run_cmd(%{review --verified #{verify_vote} -m \"'#{message}'\" #{revision}})
28
28
  end
29
29
 
30
30
  end
@@ -16,7 +16,7 @@ module Bellows
16
16
  jobs_found = []
17
17
  jobs.each do |job|
18
18
  data = job.values[0]
19
- ['nova','keystone','glance'].each do |project|
19
+ Util.projects.each do |project|
20
20
  revision = data["#{project}_revision"]
21
21
  if revision and revision == git_hash then
22
22
  jobs_found << job
@@ -34,6 +34,16 @@ module Bellows
34
34
  nil
35
35
  end
36
36
 
37
+ DEFAULT_JOB_TYPES=[{'name' => 'job_unit_tester', 'auto_approved' => false, 'description' => 'Unit'}]
38
+ def self.job_types()
39
+ configs=Util.load_configs
40
+ job_type_list = configs['job_types']
41
+ if job_type_list.nil? or job_type_list.empty? then
42
+ job_type_list = DEFAULT_JOB_TYPES
43
+ end
44
+ job_type_list
45
+ end
46
+
37
47
  def self.smoke_tests(project)
38
48
  tests = {}
39
49
  data = JSON.parse(Bellows::HTTP.get("/smoke_tests.json"))
@@ -67,7 +77,7 @@ module Bellows
67
77
  def self.update_smoke_test(id, updates={})
68
78
 
69
79
  data = JSON.parse(Bellows::HTTP.get("/smoke_tests/#{id}.json"))
70
- ['nova', 'glance', 'keystone'].each do |proj|
80
+ Util.projects.each do |proj|
71
81
  if updates["#{proj}_package_builder"]
72
82
  data["smoke_test"]["#{proj}_package_builder"].merge!(updates["#{proj}_package_builder"])
73
83
  updates.delete("#{proj}_package_builder")
@@ -83,7 +93,7 @@ module Bellows
83
93
 
84
94
  post_data = { "smoke_test[description]" => description }
85
95
 
86
- ['nova', 'glance', 'keystone'].each do |proj|
96
+ Util.projects.each do |proj|
87
97
  base_name="smoke_test[#{proj}_package_builder_attributes]"
88
98
  if project == proj then
89
99
  post_data.store("#{base_name}[url]", "https://review.openstack.org/p/openstack/#{project}")
@@ -109,10 +119,10 @@ module Bellows
109
119
  end
110
120
 
111
121
  #returns true if jobs all passed (green) or all failed results are approved
112
- def self.approved?(job_datas)
122
+ def self.complete?(job_datas)
113
123
  approved = true
114
- job_datas.each do |data|
115
- if data.nil? or (data['status'] == 'Failed' and data['approved_by'].nil?)
124
+ job_datas.each_pair do |job_type, job_data|
125
+ if job_data.nil? or (job_data['status'] == 'Failed' and (job_data['approved_by'].nil? and not job_type['auto_approved']))
116
126
  approved = false
117
127
  end
118
128
  end
data/lib/bellows/tasks.rb CHANGED
@@ -137,17 +137,24 @@ module Bellows
137
137
  patchset_num = review['currentPatchSet']['number']
138
138
  jobs_for_rev = Bellows::SmokeStack.jobs_with_hash(revision, jobs)
139
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 Bellows::SmokeStack.approved?([unit, libvirt, xenserver]) then
140
+
141
+ job_types = Bellows::SmokeStack.job_types
142
+ job_datas = {}
143
+ job_types.each do |job_type|
144
+ job_data=Bellows::SmokeStack.job_data_for_type(jobs_for_rev, job_type['name'])
145
+ job_datas.store(job_type, job_data)
146
+ end
147
+
148
+ if Bellows::SmokeStack.complete?(job_datas) then
144
149
  puts "Commenting ... " + desc if not options[:quiet]
145
150
  message = "SmokeStack Results (patch set #{patchset_num}):\n"
146
- message += "\tUnit #{unit['status']}:#{unit['msg']} http://smokestack.openstack.org/?go=/jobs/#{unit['id']}\n"
147
- message += "\tLibvirt #{libvirt['status']}:#{libvirt['msg']} http://smokestack.openstack.org/?go=/jobs/#{libvirt['id']}\n"
148
- message += "\tXenServer #{xenserver['status']}:#{xenserver['msg']} http://smokestack.openstack.org/?go=/jobs/#{xenserver['id']}"
149
- puts message
150
- out = Bellows::Gerrit.comment(review['currentPatchSet']['revision'], message) if not test
151
+ verify_vote = 1
152
+ job_datas.each_pair do |job_type, job_data|
153
+ message += "\t#{job_type['description']} #{job_data['status']}:#{job_data['msg']} http://smokestack.openstack.org/?go=/jobs/#{job_data['id']}\n"
154
+ verify_vote = -1 if job_data['status'] == 'Failed'
155
+ end
156
+ puts message if not options[:quiet]
157
+ out = Bellows::Gerrit.comment(review['currentPatchSet']['revision'], message, verify_vote) if not test
151
158
  puts out if not options[:quiet] and not test
152
159
  file.write revision + "\n" if not test
153
160
  end
data/lib/bellows/util.rb CHANGED
@@ -3,33 +3,34 @@ require 'yaml'
3
3
  module Bellows
4
4
  module Util
5
5
 
6
+ DEFAULT_PROJECTS = ['nova', 'glance', 'keystone']
6
7
  @@configs=nil
7
8
 
8
9
  def self.load_configs
9
10
 
10
- return @@configs if not @@configs.nil?
11
+ return @@configs if not @@configs.nil?
11
12
 
12
- config_file=ENV['BELLOWS_CONFIG_FILE']
13
- if config_file.nil? then
13
+ config_file=ENV['BELLOWS_CONFIG_FILE']
14
+ if config_file.nil? then
14
15
 
15
- config_file=ENV['HOME']+File::SEPARATOR+".bellows.conf"
16
- if not File.exists?(config_file) then
17
- config_file="/etc/bellows.conf"
18
- end
16
+ config_file=ENV['HOME']+File::SEPARATOR+".bellows.conf"
17
+ if not File.exists?(config_file) then
18
+ config_file="/etc/bellows.conf"
19
+ end
19
20
 
20
- end
21
+ end
21
22
 
22
- if File.exists?(config_file) then
23
- configs = YAML.load_file(config_file) || {}
24
- raise_if_nil_or_empty(configs, "smokestack_url")
25
- raise_if_nil_or_empty(configs, "smokestack_username")
26
- raise_if_nil_or_empty(configs, "smokestack_password")
27
- @@configs=configs
28
- else
29
- raise "Failed to load bellows config file. Please configure /etc/bellows.conf or create a .bellows.conf config file in your HOME directory."
30
- end
23
+ if File.exists?(config_file) then
24
+ configs = YAML.load_file(config_file) || {}
25
+ raise_if_nil_or_empty(configs, "smokestack_url")
26
+ raise_if_nil_or_empty(configs, "smokestack_username")
27
+ raise_if_nil_or_empty(configs, "smokestack_password")
28
+ @@configs=configs
29
+ else
30
+ raise "Failed to load bellows config file. Please configure /etc/bellows.conf or create a .bellows.conf config file in your HOME directory."
31
+ end
31
32
 
32
- @@configs
33
+ @@configs
33
34
 
34
35
  end
35
36
 
@@ -43,13 +44,26 @@ module Bellows
43
44
  refspec.sub(/\/[^\/]*$/, "")
44
45
  end
45
46
 
46
- VALID_PROJECTS = ['nova', 'glance', 'keystone']
47
47
  def self.validate_project(project)
48
- if not VALID_PROJECTS.include?(project) then
48
+ configs=self.load_configs
49
+ projects = configs['projects']
50
+ if projects.nil? or projects.empty? then
51
+ projects = DEFAULT_PROJECTS
52
+ end
53
+ if not projects.include?(project) then
49
54
  puts "ERROR: Please specify a valid project name."
50
55
  exit 1
51
56
  end
52
57
  end
53
58
 
59
+ def self.projects
60
+ configs=self.load_configs
61
+ proj_list = configs['projects']
62
+ if proj_list.nil? or proj_list.empty? then
63
+ proj_list = DEFAULT_PROJECTS
64
+ end
65
+ return proj_list
66
+ end
67
+
54
68
  end
55
69
  end
@@ -0,0 +1,23 @@
1
+ smokestack_url: http://localhost:3000
2
+ smokestack_username: admin
3
+ smokestack_password: cloud
4
+
5
+ config_template_ids:
6
+ - 1
7
+ - 2
8
+
9
+ test_suite_ids:
10
+ - 1
11
+
12
+ job_types:
13
+ - name: job_unit_tester
14
+ auto_approved: true
15
+ description: "Unit"
16
+
17
+ - name: job_puppet_vpc
18
+ auto_approved: false
19
+ description: "Libvirt (Fedora 16)"
20
+
21
+ - name: job_chef_vpc_xen
22
+ auto_approved: false
23
+ description: "XenServer 5.6 SP2"
@@ -5,40 +5,12 @@
5
5
  "created_at": "2011-11-28T16:40:43-05:00",
6
6
  "id": 4182,
7
7
  "job_group_id": 2601,
8
- "msg": null,
8
+ "msg": "Unit Tests Failed.",
9
9
  "nova_revision": "1234567",
10
10
  "glance_revision": "1a2b3c4",
11
11
  "keystone_revision": "4a5b7c7",
12
- "status": "Success",
12
+ "status": "Failed",
13
13
  "updated_at": "2011-11-28T16:40:15-05:00"
14
14
  }
15
- },
16
- {
17
- "job_xen_hybrid": {
18
- "config_template_id": 4,
19
- "created_at": "2011-11-28T16:40:43-05:00",
20
- "id": 4181,
21
- "job_group_id": 2601,
22
- "msg": null,
23
- "nova_revision": "1234567",
24
- "glance_revision": "1a2b3c4",
25
- "keystone_revision": "4a5b7c7",
26
- "status": "Success",
27
- "updated_at": "2011-11-28T16:40:43-05:00"
28
- }
29
- },
30
- {
31
- "job_vpc": {
32
- "config_template_id": 1,
33
- "created_at": "2011-11-28T16:40:42-05:00",
34
- "id": 4180,
35
- "job_group_id": 2601,
36
- "msg": null,
37
- "nova_revision": "1234567",
38
- "glance_revision": "1a2b3c4",
39
- "keystone_revision": "4a5b7c7",
40
- "status": "Success",
41
- "updated_at": "2011-11-28T16:40:46-05:00"
42
- }
43
15
  }
44
16
  ]
@@ -0,0 +1,32 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+ require 'helper'
3
+ require 'yaml'
4
+
5
+ class SmokeStackTest < Test::Unit::TestCase
6
+
7
+ def test_job_types_default
8
+
9
+ Bellows::Util.stubs(:load_configs).returns({})
10
+ assert_equal 1, Bellows::SmokeStack.job_types.size
11
+
12
+ end
13
+
14
+ def test_job_types_config
15
+
16
+ sample_config = fixture('config.yaml')
17
+ Bellows::Util.stubs(:load_configs).returns(YAML::load(sample_config))
18
+ assert_equal 3, Bellows::SmokeStack.job_types.size
19
+
20
+ unit_tester_type = Bellows::SmokeStack.job_types[0]
21
+ assert_equal 'job_unit_tester', unit_tester_type['name']
22
+ assert_equal 'Unit', unit_tester_type['description']
23
+ assert_equal true, unit_tester_type['auto_approved']
24
+
25
+ unit_tester_type = Bellows::SmokeStack.job_types[1]
26
+ assert_equal 'job_puppet_vpc', unit_tester_type['name']
27
+ assert_equal 'Libvirt (Fedora 16)', unit_tester_type['description']
28
+ assert_equal false, unit_tester_type['auto_approved']
29
+
30
+ end
31
+
32
+ end
metadata CHANGED
@@ -1,141 +1,103 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bellows
3
- version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 0
9
- - 10
10
- version: 1.0.10
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.11
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Dan Prince
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-01-09 00:00:00 -05:00
19
- default_executable: bellows
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- prerelease: false
12
+ date: 2012-05-08 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
23
15
  name: bundler
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &17251620 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
18
+ requirements:
27
19
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 0
33
- - 0
20
+ - !ruby/object:Gem::Version
34
21
  version: 1.0.0
35
- requirement: *id001
36
22
  type: :development
37
- - !ruby/object:Gem::Dependency
38
23
  prerelease: false
24
+ version_requirements: *17251620
25
+ - !ruby/object:Gem::Dependency
39
26
  name: jeweler
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &17191940 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
29
+ requirements:
43
30
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 7
46
- segments:
47
- - 1
48
- - 6
49
- - 4
31
+ - !ruby/object:Gem::Version
50
32
  version: 1.6.4
51
- requirement: *id002
52
33
  type: :development
53
- - !ruby/object:Gem::Dependency
54
34
  prerelease: false
35
+ version_requirements: *17191940
36
+ - !ruby/object:Gem::Dependency
55
37
  name: thor
56
- version_requirements: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &17190120 !ruby/object:Gem::Requirement
57
39
  none: false
58
- requirements:
40
+ requirements:
59
41
  - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 43
62
- segments:
63
- - 0
64
- - 14
65
- - 6
42
+ - !ruby/object:Gem::Version
66
43
  version: 0.14.6
67
- requirement: *id003
68
44
  type: :development
69
- - !ruby/object:Gem::Dependency
70
45
  prerelease: false
46
+ version_requirements: *17190120
47
+ - !ruby/object:Gem::Dependency
71
48
  name: json
72
- version_requirements: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &17188240 !ruby/object:Gem::Requirement
73
50
  none: false
74
- requirements:
51
+ requirements:
75
52
  - - ~>
76
- - !ruby/object:Gem::Version
77
- hash: 11
78
- segments:
79
- - 1
80
- - 4
81
- - 6
53
+ - !ruby/object:Gem::Version
82
54
  version: 1.4.6
83
- requirement: *id004
84
55
  type: :development
85
- - !ruby/object:Gem::Dependency
86
56
  prerelease: false
57
+ version_requirements: *17188240
58
+ - !ruby/object:Gem::Dependency
87
59
  name: mocha
88
- version_requirements: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &17186340 !ruby/object:Gem::Requirement
89
61
  none: false
90
- requirements:
62
+ requirements:
91
63
  - - ~>
92
- - !ruby/object:Gem::Version
93
- hash: 41
94
- segments:
95
- - 0
96
- - 9
97
- - 9
64
+ - !ruby/object:Gem::Version
98
65
  version: 0.9.9
99
- requirement: *id005
100
66
  type: :development
101
- - !ruby/object:Gem::Dependency
102
67
  prerelease: false
68
+ version_requirements: *17186340
69
+ - !ruby/object:Gem::Dependency
103
70
  name: json
104
- version_requirements: &id006 !ruby/object:Gem::Requirement
71
+ requirement: &17167400 !ruby/object:Gem::Requirement
105
72
  none: false
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- hash: 3
110
- segments:
111
- - 0
112
- version: "0"
113
- requirement: *id006
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
114
77
  type: :runtime
115
- - !ruby/object:Gem::Dependency
116
78
  prerelease: false
79
+ version_requirements: *17167400
80
+ - !ruby/object:Gem::Dependency
117
81
  name: thor
118
- version_requirements: &id007 !ruby/object:Gem::Requirement
82
+ requirement: &17164440 !ruby/object:Gem::Requirement
119
83
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 3
124
- segments:
125
- - 0
126
- version: "0"
127
- requirement: *id007
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
128
88
  type: :runtime
129
- description: CLI to drive SmokeStack test creation and maintenance based on Gerrit reviews.
89
+ prerelease: false
90
+ version_requirements: *17164440
91
+ description: CLI to drive SmokeStack test creation and maintenance based on Gerrit
92
+ reviews.
130
93
  email: dan.prince@rackspace.com
131
- executables:
94
+ executables:
132
95
  - bellows
133
96
  extensions: []
134
-
135
- extra_rdoc_files:
97
+ extra_rdoc_files:
136
98
  - LICENSE.txt
137
99
  - README.md
138
- files:
100
+ files:
139
101
  - .document
140
102
  - CHANGELOG
141
103
  - Gemfile
@@ -151,45 +113,40 @@ files:
151
113
  - lib/bellows/smoke_stack.rb
152
114
  - lib/bellows/tasks.rb
153
115
  - lib/bellows/util.rb
116
+ - test/fixtures/config.yaml
154
117
  - test/fixtures/gerrit.json
155
118
  - test/fixtures/jobs.json
156
119
  - test/fixtures/nova_smoke_tests.json
157
120
  - test/helper.rb
121
+ - test/test_smoke_stack.rb
158
122
  - test/test_task.rb
159
123
  - test/test_util.rb
160
- has_rdoc: true
161
124
  homepage: http://github.com/dprince/bellows
162
- licenses:
125
+ licenses:
163
126
  - MIT
164
127
  post_install_message:
165
128
  rdoc_options: []
166
-
167
- require_paths:
129
+ require_paths:
168
130
  - lib
169
- required_ruby_version: !ruby/object:Gem::Requirement
131
+ required_ruby_version: !ruby/object:Gem::Requirement
170
132
  none: false
171
- requirements:
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- hash: 3
175
- segments:
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ segments:
176
138
  - 0
177
- version: "0"
178
- required_rubygems_version: !ruby/object:Gem::Requirement
139
+ hash: 3288239817883980822
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
141
  none: false
180
- requirements:
181
- - - ">="
182
- - !ruby/object:Gem::Version
183
- hash: 3
184
- segments:
185
- - 0
186
- version: "0"
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
187
146
  requirements: []
188
-
189
147
  rubyforge_project:
190
- rubygems_version: 1.3.7
148
+ rubygems_version: 1.8.15
191
149
  signing_key:
192
150
  specification_version: 3
193
151
  summary: Fire it up! SmokeStack automation w/ Gerrit.
194
152
  test_files: []
195
-