bellows 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ * Mon Aug 19 2013 Dan Prince <dprince@redhat.com> - 2.0.2
2
+ - Add support for new SS status types ('BuildFail', 'TestFail', etc.)
3
+ - Add support for automatic test failure approval.
4
+ - Add support for automatic build failure approval.
5
+
1
6
  * Mon Aug 12 2013 Dan Prince <dprince@redhat.com> - 2.0.1
2
7
  - Rename quantum to neutron.
3
8
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
@@ -191,15 +191,35 @@ module Bellows
191
191
 
192
192
  #returns true if jobs all passed (green) or all failed results are approved
193
193
  def self.complete?(job_datas)
194
- approved = true
194
+ complete = true
195
195
  job_datas.each do |arr|
196
196
  job_type = arr[0]
197
197
  job_data = arr[1]
198
- if job_data.nil? or (job_data['status'] == 'Failed' and (job_data['approved_by'].nil? and not job_type['auto_approved']))
199
- approved = false
198
+ return false if job_data.nil? or (job_data['status'] and ['Pending', 'Running'].include?(job_data['status'])) # waiting on pending jobs or data
199
+
200
+ # if bellows doesn't understand the status then we fail
201
+ if not ['Pending', 'Running', 'Success', 'Failed', 'BuildFail', 'TestFail'].include?(job_data['status']) then
202
+ return false
200
203
  end
204
+
205
+ next if job_type['auto_approved'] # global auto_approved
206
+
207
+ # special case for build failures
208
+ if job_data['status'] == 'BuildFail' and not job_type['buildfail_auto_approved'] and not job_data['approved_by'] then
209
+ complete = false
210
+ end
211
+
212
+ # special case for test failures
213
+ if job_data['status'] == 'TestFail' and not job_type['testfail_auto_approved'] and not job_data['approved_by'] then
214
+ complete = false
215
+ end
216
+
217
+ if job_data['status'] == 'Failed' and not job_data['approved_by'] then
218
+ complete = false
219
+ end
220
+
201
221
  end
202
- approved
222
+ complete
203
223
  end
204
224
 
205
225
  end
@@ -57,4 +57,138 @@ class SmokeStackTest < Test::Unit::TestCase
57
57
 
58
58
  end
59
59
 
60
+ def test_complete_with_single_success
61
+
62
+ comment_config = {'auto_approved' => false}
63
+ job_data = {'status' => 'Success', 'approved_by' => nil}
64
+ job_datas = [[comment_config, job_data]]
65
+
66
+ assert_equal true, Bellows::SmokeStack.complete?(job_datas)
67
+
68
+ end
69
+
70
+ def test_complete_with_single_failed
71
+
72
+ comment_config = {'auto_approved' => false}
73
+ job_data = {'status' => 'Failed', 'approved_by' => nil}
74
+ job_datas = [[comment_config, job_data]]
75
+
76
+ assert_equal false, Bellows::SmokeStack.complete?(job_datas)
77
+
78
+ end
79
+
80
+ def test_complete_with_single_failed_manually_approved
81
+
82
+ comment_config = {'auto_approved' => false}
83
+ job_data = {'status' => 'Failed', 'approved_by' => 'dprince'}
84
+ job_datas = [[comment_config, job_data]]
85
+
86
+ assert_equal true, Bellows::SmokeStack.complete?(job_datas)
87
+
88
+ end
89
+
90
+ def test_complete_with_single_failed_auto_approved
91
+
92
+ comment_config = {'auto_approved' => true}
93
+ job_data = {'status' => 'Failed', 'approved_by' => nil}
94
+ job_datas = [[comment_config, job_data]]
95
+
96
+ assert_equal true, Bellows::SmokeStack.complete?(job_datas)
97
+
98
+ end
99
+
100
+ def test_complete_with_invalid_job_status
101
+
102
+ comment_config = {'auto_approved' => true}
103
+ job_data = {'status' => 'Foo', 'approved_by' => 'dprince'}
104
+ job_datas = [[comment_config, job_data]]
105
+
106
+ assert_equal false, Bellows::SmokeStack.complete?(job_datas)
107
+
108
+ end
109
+
110
+ def test_complete_with_job_pending
111
+
112
+ job_datas = []
113
+ comment_config = {'auto_approved' => true}
114
+ job_data = {'status' => 'Success', 'approved_by' => nil}
115
+ job_datas << [comment_config, job_data]
116
+ comment_config = {'auto_approved' => true}
117
+ job_data = {'status' => 'Pending', 'approved_by' => 'dprince'}
118
+ job_datas << [comment_config, job_data]
119
+
120
+ assert_equal false, Bellows::SmokeStack.complete?(job_datas)
121
+
122
+ end
123
+
124
+ def test_complete_with_job_running
125
+
126
+ job_datas = []
127
+ comment_config = {'auto_approved' => true}
128
+ job_data = {'status' => 'Success', 'approved_by' => nil}
129
+ job_datas << [comment_config, job_data]
130
+ comment_config = {'auto_approved' => true}
131
+ job_data = {'status' => 'Pending', 'approved_by' => 'dprince'}
132
+ job_datas << [comment_config, job_data]
133
+
134
+ assert_equal false, Bellows::SmokeStack.complete?(job_datas)
135
+
136
+ end
137
+
138
+ def test_complete_with_build_fail_auto_approved
139
+
140
+ job_datas = []
141
+ comment_config = {'buildfail_auto_approved' => true}
142
+ job_data = {'status' => 'BuildFail', 'approved_by' => nil}
143
+ job_datas << [comment_config, job_data]
144
+ comment_config = {}
145
+ job_data = {'status' => 'Success', 'approved_by' => nil}
146
+ job_datas << [comment_config, job_data]
147
+
148
+ assert_equal true, Bellows::SmokeStack.complete?(job_datas)
149
+
150
+ end
151
+
152
+ def test_complete_with_build_fail_manually_approved
153
+
154
+ job_datas = []
155
+ comment_config = {'buildfail_auto_approved' => false}
156
+ job_data = {'status' => 'BuildFail', 'approved_by' => 'dprince'}
157
+ job_datas << [comment_config, job_data]
158
+ comment_config = {}
159
+ job_data = {'status' => 'Success', 'approved_by' => nil}
160
+ job_datas << [comment_config, job_data]
161
+
162
+ assert_equal true, Bellows::SmokeStack.complete?(job_datas)
163
+
164
+ end
165
+
166
+ def test_complete_with_build_fail_auto_approved
167
+
168
+ job_datas = []
169
+ comment_config = {'testfail_auto_approved' => true}
170
+ job_data = {'status' => 'TestFail', 'approved_by' => nil}
171
+ job_datas << [comment_config, job_data]
172
+ comment_config = {}
173
+ job_data = {'status' => 'Success', 'approved_by' => nil}
174
+ job_datas << [comment_config, job_data]
175
+
176
+ assert_equal true, Bellows::SmokeStack.complete?(job_datas)
177
+
178
+ end
179
+
180
+ def test_complete_with_build_fail_manually_approved
181
+
182
+ job_datas = []
183
+ comment_config = {'testfail_auto_approved' => false}
184
+ job_data = {'status' => 'TestFail', 'approved_by' => 'dprince'}
185
+ job_datas << [comment_config, job_data]
186
+ comment_config = {}
187
+ job_data = {'status' => 'Success', 'approved_by' => nil}
188
+ job_datas << [comment_config, job_data]
189
+
190
+ assert_equal true, Bellows::SmokeStack.complete?(job_datas)
191
+
192
+ end
193
+
60
194
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bellows
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-12 00:00:00.000000000 Z
12
+ date: 2013-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -173,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  segments:
175
175
  - 0
176
- hash: -3862304819193504318
176
+ hash: -3928135736151112540
177
177
  required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  none: false
179
179
  requirements: