bellows 1.0.4 → 1.0.5
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.
- data/CHANGELOG +4 -0
- data/Gemfile +1 -0
- data/README.md +5 -0
- data/VERSION +1 -1
- data/lib/bellows/gerrit.rb +5 -1
- data/lib/bellows/smoke_stack.rb +9 -5
- data/lib/bellows/tasks.rb +56 -16
- data/lib/bellows/util.rb +8 -0
- data/test/fixtures/gerrit.json +2 -0
- data/test/fixtures/jobs.json +44 -0
- data/test/fixtures/nova_smoke_tests.json +3 -0
- data/test/helper.rb +8 -1
- data/test/test_task.rb +24 -0
- metadata +28 -8
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
* Thu Dec 3 2011 Dan Prince <dan.prince@rackspace.com> - 1.0.5
|
2
|
+
- Add 'fire' task to run jobs for reviews without results.
|
3
|
+
- Add --quiet option to all tasks.
|
4
|
+
|
1
5
|
* Thu Nov 17 2011 Dan Prince <dan.prince@rackspace.com> - 1.0.4
|
2
6
|
- Explicitly set config templates and tests on sync.
|
3
7
|
- All --all option to sync command. Remove 'reconfig' task.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -34,6 +34,7 @@ Examples
|
|
34
34
|
Available bellows tasks:
|
35
35
|
|
36
36
|
Tasks:
|
37
|
+
bellows fire PROJECT # Run jobs for reviews without results.
|
37
38
|
bellows help [TASK] # Describe available tasks or one specific task
|
38
39
|
bellows purge PROJECT # Purge merged reviews from SmokeStack
|
39
40
|
bellows sync PROJECT # Create tests & update refspecs for active reviews.
|
@@ -50,6 +51,10 @@ Sync test suite choices for active reviews in SmokeStack (based on the selection
|
|
50
51
|
|
51
52
|
bellows sync nova --all
|
52
53
|
|
54
|
+
Fire tests for reviews without results (3 at a time):
|
55
|
+
|
56
|
+
bellows fire nova --limit=3
|
57
|
+
|
53
58
|
All commands support creating and maintaining test configs for nova, glance, and keystone.
|
54
59
|
|
55
60
|
License
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.5
|
data/lib/bellows/gerrit.rb
CHANGED
@@ -3,9 +3,13 @@ require 'json'
|
|
3
3
|
module Bellows
|
4
4
|
class Gerrit
|
5
5
|
|
6
|
+
def self.run_cmd(command)
|
7
|
+
return %x{ssh review gerrit #{command}}
|
8
|
+
end
|
9
|
+
|
6
10
|
def self.reviews(project, status="open", branch="master")
|
7
11
|
reviews = []
|
8
|
-
out
|
12
|
+
out=Gerrit.run_cmd(%{query "status: #{status}" --current-patch-set --format JSON})
|
9
13
|
out.each_line do |line|
|
10
14
|
data = JSON.parse(line)
|
11
15
|
if data['project'] and data['project'] == "openstack/#{project}" and data['branch'] and data['branch'] == branch
|
data/lib/bellows/smoke_stack.rb
CHANGED
@@ -5,16 +5,20 @@ require 'bellows/util'
|
|
5
5
|
module Bellows
|
6
6
|
class SmokeStack
|
7
7
|
|
8
|
-
def self.
|
9
|
-
|
8
|
+
def self.jobs()
|
9
|
+
JSON.parse(Bellows::HTTP.get("/jobs.json?limit=10000"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.smoke_tests(project)
|
13
|
+
tests = {}
|
10
14
|
data = JSON.parse(Bellows::HTTP.get("/smoke_tests.json"))
|
11
15
|
data.each do |item|
|
12
16
|
branch = item['smoke_test']["#{project}_package_builder"]['branch']
|
13
17
|
if branch and not branch.empty? then
|
14
|
-
|
18
|
+
tests.store(Bellows::Util.short_spec(branch), item['smoke_test'])
|
15
19
|
end
|
16
20
|
end
|
17
|
-
|
21
|
+
tests
|
18
22
|
end
|
19
23
|
|
20
24
|
def self.format_request(smoke_test)
|
@@ -36,7 +40,7 @@ module Bellows
|
|
36
40
|
end
|
37
41
|
|
38
42
|
def self.update_smoke_test(id, updates={})
|
39
|
-
|
43
|
+
|
40
44
|
data = JSON.parse(Bellows::HTTP.get("/smoke_tests/#{id}.json"))
|
41
45
|
['nova', 'glance', 'keystone'].each do |proj|
|
42
46
|
if updates["#{proj}_package_builder"]
|
data/lib/bellows/tasks.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'set'
|
2
3
|
require 'bellows/http'
|
3
4
|
require 'bellows/util'
|
4
5
|
require 'bellows/gerrit'
|
@@ -10,14 +11,12 @@ module Bellows
|
|
10
11
|
desc "sync PROJECT", "Create tests & update refspecs for active reviews."
|
11
12
|
method_options :test => :boolean
|
12
13
|
method_options :all => :boolean
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
exit 1
|
17
|
-
end
|
14
|
+
method_options :quiet => :boolean
|
15
|
+
def sync(project, options=(options or {}))
|
16
|
+
Util.validate_project(project)
|
18
17
|
test = options[:test]
|
19
18
|
all = options[:all]
|
20
|
-
smoke_tests = Bellows::SmokeStack.
|
19
|
+
smoke_tests = Bellows::SmokeStack.smoke_tests(project)
|
21
20
|
configs=Util.load_configs
|
22
21
|
test_suite_ids = configs['test_suite_ids'].collect {|x| x.to_s }
|
23
22
|
config_template_ids = configs['config_template_ids'].collect {|x| x.to_s }
|
@@ -33,11 +32,11 @@ module Bellows
|
|
33
32
|
Bellows::SmokeStack.create_smoke_test(project, desc, refspec, config_template_ids, test_suite_ids) if not test
|
34
33
|
else
|
35
34
|
if smoke_test["#{project}_package_builder"]['branch'] != refspec then
|
36
|
-
puts "Updating... " + desc
|
37
|
-
puts "refspec: " + refspec
|
35
|
+
puts "Updating... " + desc if not options[:quiet]
|
36
|
+
puts "refspec: " + refspec if not options[:quiet]
|
38
37
|
Bellows::SmokeStack.update_smoke_test(smoke_test['id'], {"#{project}_package_builder" => { "branch" => refspec}, "description" => desc, "status" => "Updated", "test_suite_ids" => test_suite_ids, "config_template_ids" => config_template_ids}) if not test
|
39
38
|
elsif all then
|
40
|
-
puts "Updating (all)... " + desc
|
39
|
+
puts "Updating (all)... " + desc if not options[:quiet]
|
41
40
|
Bellows::SmokeStack.update_smoke_test(smoke_test['id'], {"#{project}_package_builder" => { "branch" => refspec}, "description" => desc, "test_suite_ids" => test_suite_ids, "config_template_ids" => config_template_ids}) if not test
|
42
41
|
end
|
43
42
|
end
|
@@ -46,13 +45,11 @@ module Bellows
|
|
46
45
|
|
47
46
|
desc "purge PROJECT", "Purge merged reviews from SmokeStack"
|
48
47
|
method_options :test => :boolean
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
exit 1
|
53
|
-
end
|
48
|
+
method_options :quiet => :boolean
|
49
|
+
def purge(project, options=(options or {}))
|
50
|
+
Util.validate_project(project)
|
54
51
|
test = options[:test]
|
55
|
-
smoke_tests = Bellows::SmokeStack.
|
52
|
+
smoke_tests = Bellows::SmokeStack.smoke_tests(project)
|
56
53
|
reviews = Bellows::Gerrit.reviews(project, "merged")
|
57
54
|
reviews += Bellows::Gerrit.reviews(project, "abandoned")
|
58
55
|
reviews.each do |review|
|
@@ -61,11 +58,54 @@ module Bellows
|
|
61
58
|
smoke_test = smoke_tests[review_id]
|
62
59
|
desc = review['owner']['name'] + ": " +review['subject']
|
63
60
|
if smoke_test
|
64
|
-
puts "Deleting... " + desc
|
61
|
+
puts "Deleting... " + desc if not options[:quiet]
|
65
62
|
Bellows::HTTP.delete("/smoke_tests/#{smoke_test['id']}") if not test
|
66
63
|
end
|
67
64
|
end
|
68
65
|
end
|
69
66
|
|
67
|
+
desc "fire PROJECT", "Run jobs for reviews without results."
|
68
|
+
method_options :test => :boolean
|
69
|
+
method_options :quiet => :boolean
|
70
|
+
method_options :limit => :integer
|
71
|
+
def fire(project, options=(options or {}))
|
72
|
+
Util.validate_project(project)
|
73
|
+
test = options[:test]
|
74
|
+
limit = options[:limit] || 5
|
75
|
+
# jobs indexed by revision
|
76
|
+
jobs = Set.new
|
77
|
+
Bellows::SmokeStack.jobs.each do |job|
|
78
|
+
data = job.values[0]
|
79
|
+
if data
|
80
|
+
revision = data["#{project}_revision"]
|
81
|
+
if revision and not revision.empty?
|
82
|
+
jobs.add(revision)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
smoke_tests = Bellows::SmokeStack.smoke_tests(project)
|
87
|
+
|
88
|
+
count=0
|
89
|
+
Bellows::Gerrit.reviews(project) do |review|
|
90
|
+
revision = review['currentPatchSet']['revision'][0,7]
|
91
|
+
desc = review['owner']['name'] + ": " +review['subject']
|
92
|
+
if not jobs.include? revision
|
93
|
+
puts "Running ... " + desc if not options[:quiet]
|
94
|
+
refspec = review['currentPatchSet']['ref']
|
95
|
+
review_id = Bellows::Util.short_spec(refspec)
|
96
|
+
smoke_test = smoke_tests[review_id]
|
97
|
+
if smoke_test then
|
98
|
+
count += 1
|
99
|
+
Bellows::HTTP.post("/smoke_tests/#{smoke_test['id']}/run_jobs", {}) if not test
|
100
|
+
else
|
101
|
+
puts "WARNING: no smoke test exists for: #{refspec}" if not options[:quiet]
|
102
|
+
end
|
103
|
+
if count >= limit.to_i then
|
104
|
+
break
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
70
110
|
end
|
71
111
|
end
|
data/lib/bellows/util.rb
CHANGED
@@ -43,5 +43,13 @@ module Bellows
|
|
43
43
|
refspec.sub(/\/[^\/]*$/, "")
|
44
44
|
end
|
45
45
|
|
46
|
+
VALID_PROJECTS = ['nova', 'glance', 'keystone']
|
47
|
+
def self.validate_project(project)
|
48
|
+
if not VALID_PROJECTS.include?(project) then
|
49
|
+
puts "ERROR: Please specify a valid project name."
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
46
54
|
end
|
47
55
|
end
|
@@ -0,0 +1,2 @@
|
|
1
|
+
{"project":"openstack/nova","branch":"master","id":"I111111185925d2bab882a34c237819b51838dfae","number":"1234","subject":"Test branch 1","owner":{"name":"Dan Prince","email":"dan.prince@rackspace.com","username":"dprince"},"url":"https://review.openstack.org/1234","lastUpdated":1321970185,"sortKey":"001937240000072e","open":true,"status":"NEW","currentPatchSet":{"number":"1","revision":"1234567b2f935a0626b8de75360ce5d15f01758c","ref":"refs/changes/38/1234/1","uploader":{"name":"Dan Prince","email":"dan.prince@rackspace.com","username":"dprince"},"approvals":[{"type":"CRVW","description":"Code Review","value":"2","grantedOn":1321970185,"by":{"name":"Jimmy Barnes","email":"jimmy.barnes@openstack.com","username":"jbarnes"}},{"type":"CRVW","description":"Code Review","value":"1","grantedOn":1321942411,"by":{"name":"John Smith","email":"john.smith@openstack.org","username":"jsmity"}}]}}
|
2
|
+
{"project":"openstack/nova","branch":"master","id":"I222222285925d2bab882a34c237819b51838dfae","number":"5678","subject":"Test branch 2","owner":{"name":"Dan Prince","email":"dan.prince@rackspace.com","username":"dprince"},"url":"https://review.openstack.org/5678","lastUpdated":1321970185,"sortKey":"001937240000072e","open":true,"status":"NEW","currentPatchSet":{"number":"1","revision":"zzzzzzzb2f935a0626b8de75360ce5d15f01758c","ref":"refs/changes/38/5678/1","uploader":{"name":"Dan Prince","email":"dan.prince@rackspace.com","username":"dprince"},"approvals":[{"type":"CRVW","description":"Code Review","value":"2","grantedOn":1321970185,"by":{"name":"Jimmy Barnes","email":"jimmy.barnes@openstack.com","username":"jbarnes"}},{"type":"CRVW","description":"Code Review","value":"1","grantedOn":1321942411,"by":{"name":"John Smith","email":"john.smith@openstack.org","username":"jsmity"}}]}}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"job_unit_tester": {
|
4
|
+
"config_template_id": null,
|
5
|
+
"created_at": "2011-11-28T16:40:43-05:00",
|
6
|
+
"id": 4182,
|
7
|
+
"job_group_id": 2601,
|
8
|
+
"msg": null,
|
9
|
+
"nova_revision": "1234567",
|
10
|
+
"glance_revision": "1a2b3c4",
|
11
|
+
"keystone_revision": "4a5b7c7",
|
12
|
+
"status": "Success",
|
13
|
+
"updated_at": "2011-11-28T16:40:15-05:00"
|
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
|
+
}
|
44
|
+
]
|
@@ -0,0 +1,3 @@
|
|
1
|
+
[{"smoke_test":{"cookbook_url":"","created_at":"2011-09-27T14:51:35-04:00","description":"Nova trunk","id":331,"status":"Success","unit_tests":false,"updated_at":"2011-12-03T15:09:01-05:00","nova_package_builder":{"branch":"master","created_at":"2011-09-27T14:51:35-04:00","id":681,"merge_trunk":false,"packager_url":"","revision_hash":"","smoke_test_id":331,"updated_at":"2011-09-27T14:51:35-04:00","url":"git://github.com/openstack/nova.git"},"glance_package_builder":{"branch":"master","created_at":"2011-09-27T14:51:35-04:00","id":682,"merge_trunk":false,"packager_url":"","revision_hash":"","smoke_test_id":331,"updated_at":"2011-10-26T13:07:10-04:00","url":"git://github.com/openstack/glance.git"},"keystone_package_builder":{"branch":"master","created_at":"2011-09-27T14:51:35-04:00","id":683,"merge_trunk":false,"packager_url":"","revision_hash":"","smoke_test_id":331,"updated_at":"2011-09-27T14:51:35-04:00","url":"git://github.com/openstack/keystone.git"}}},
|
2
|
+
{"smoke_test":{"cookbook_url":"","created_at":"2011-09-27T14:51:35-04:00","description":"Test 1","id":331,"status":"Pending","unit_tests":false,"updated_at":"2011-12-03T15:09:01-05:00","nova_package_builder":{"branch":"refs/changes/38/5678/1","created_at":"2011-09-27T14:51:35-04:00","id":681,"merge_trunk":false,"packager_url":"","revision_hash":"","smoke_test_id":331,"updated_at":"2011-09-27T14:51:35-04:00","url":"git://github.com/openstack/nova.git"},"glance_package_builder":{"branch":"master","created_at":"2011-09-27T14:51:35-04:00","id":682,"merge_trunk":false,"packager_url":"","revision_hash":"","smoke_test_id":331,"updated_at":"2011-10-26T13:07:10-04:00","url":"git://github.com/openstack/glance.git"},"keystone_package_builder":{"branch":"master","created_at":"2011-09-27T14:51:35-04:00","id":683,"merge_trunk":false,"packager_url":"","revision_hash":"","smoke_test_id":331,"updated_at":"2011-09-27T14:51:35-04:00","url":"git://github.com/openstack/keystone.git"}}}
|
3
|
+
]
|
data/test/helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
3
|
require 'thor'
|
4
|
+
|
4
5
|
begin
|
5
6
|
Bundler.setup(:default, :development)
|
6
7
|
rescue Bundler::BundlerError => e
|
@@ -13,6 +14,12 @@ require 'test/unit'
|
|
13
14
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
15
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
16
|
require 'bellows'
|
17
|
+
require 'mocha'
|
18
|
+
|
19
|
+
def fixture_path
|
20
|
+
File.expand_path("../fixtures", __FILE__)
|
21
|
+
end
|
16
22
|
|
17
|
-
|
23
|
+
def fixture(file)
|
24
|
+
File.read(fixture_path + '/' + file)
|
18
25
|
end
|
data/test/test_task.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TaskTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_fire
|
7
|
+
|
8
|
+
jobs_data = fixture('jobs.json')
|
9
|
+
Bellows::SmokeStack.stubs(:jobs).returns(JSON.parse(jobs_data))
|
10
|
+
|
11
|
+
smoke_tests_data = fixture('nova_smoke_tests.json')
|
12
|
+
Bellows::HTTP.stubs(:get).returns(smoke_tests_data)
|
13
|
+
|
14
|
+
gerrit_data = fixture('gerrit.json')
|
15
|
+
Bellows::Gerrit.stubs(:run_cmd).returns(gerrit_data)
|
16
|
+
|
17
|
+
response = mock()
|
18
|
+
Bellows::HTTP.stubs(:post).returns(response)
|
19
|
+
tasks = Bellows::Tasks.new
|
20
|
+
tasks.fire('nova', options={:quiet => true})
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
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: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
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-
|
18
|
+
date: 2011-12-03 00:00:00 -05:00
|
19
19
|
default_executable: bellows
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -84,8 +84,24 @@ dependencies:
|
|
84
84
|
type: :development
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
prerelease: false
|
87
|
-
name:
|
87
|
+
name: mocha
|
88
88
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 41
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
- 9
|
97
|
+
- 9
|
98
|
+
version: 0.9.9
|
99
|
+
requirement: *id005
|
100
|
+
type: :development
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
prerelease: false
|
103
|
+
name: json
|
104
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
89
105
|
none: false
|
90
106
|
requirements:
|
91
107
|
- - ">="
|
@@ -94,12 +110,12 @@ dependencies:
|
|
94
110
|
segments:
|
95
111
|
- 0
|
96
112
|
version: "0"
|
97
|
-
requirement: *
|
113
|
+
requirement: *id006
|
98
114
|
type: :runtime
|
99
115
|
- !ruby/object:Gem::Dependency
|
100
116
|
prerelease: false
|
101
117
|
name: thor
|
102
|
-
version_requirements: &
|
118
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
103
119
|
none: false
|
104
120
|
requirements:
|
105
121
|
- - ">="
|
@@ -108,7 +124,7 @@ dependencies:
|
|
108
124
|
segments:
|
109
125
|
- 0
|
110
126
|
version: "0"
|
111
|
-
requirement: *
|
127
|
+
requirement: *id007
|
112
128
|
type: :runtime
|
113
129
|
description: CLI to drive SmokeStack test creation and maintenance based on Gerrit reviews.
|
114
130
|
email: dan.prince@rackspace.com
|
@@ -135,7 +151,11 @@ files:
|
|
135
151
|
- lib/bellows/smoke_stack.rb
|
136
152
|
- lib/bellows/tasks.rb
|
137
153
|
- lib/bellows/util.rb
|
154
|
+
- test/fixtures/gerrit.json
|
155
|
+
- test/fixtures/jobs.json
|
156
|
+
- test/fixtures/nova_smoke_tests.json
|
138
157
|
- test/helper.rb
|
158
|
+
- test/test_task.rb
|
139
159
|
- test/test_util.rb
|
140
160
|
has_rdoc: true
|
141
161
|
homepage: http://github.com/dprince/bellows
|