Skip to content

Commit

Permalink
[api] ensure that release requests can not get opened when stopped pa…
Browse files Browse the repository at this point in the history
…tchinfos exist

this worked when former successful builds happened.
  • Loading branch information
adrianschroeter committed Oct 28, 2013
1 parent f33b408 commit ed33df0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/api/app/models/bs_request_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -704,18 +704,19 @@ def create_expand_package(packages, opts = {})
end
end
pkg.project.repositories.each do |repo|
firstarch=repo.architectures.first if repo
if firstarch
# skip excluded patchinfos
status = state.get_elements("/resultlist/result[@repository='#{repo.name}' and @arch='#{firstarch.name}']").first
unless status and s=status.get_elements("status[@package='#{pkg.name}']").first and s.attributes['code'] == 'excluded'
binaries = REXML::Document.new(Suse::Backend.get("/build/#{URI.escape(pkg.project.name)}/#{URI.escape(repo.name)}/#{URI.escape(firstarch.name)}/#{URI.escape(pkg.name)}").body)
l = binaries.get_elements('binarylist/binary')
if l and l.count > 0
found_patchinfo = true
else
raise BuildNotFinished.new "patchinfo #{pkg.name} is not yet build for repository '#{repo.name}'"
end
next unless repo
firstarch=repo.architectures.first
next unless firstarch
# skip excluded patchinfos
status = state.get_elements("/resultlist/result[@repository='#{repo.name}' and @arch='#{firstarch.name}']").first
unless status and s=status.get_elements("status[@package='#{pkg.name}']").first and s.attributes['code'] == 'excluded'
raise BuildNotFinished.new "patchinfo #{pkg.name} is broken" if s.attributes['code'] == 'broken'
binaries = REXML::Document.new(Suse::Backend.get("/build/#{URI.escape(pkg.project.name)}/#{URI.escape(repo.name)}/#{URI.escape(firstarch.name)}/#{URI.escape(pkg.name)}").body)
l = binaries.get_elements('binarylist/binary')
if l and l.count > 0
found_patchinfo = true
else
raise BuildNotFinished.new "patchinfo #{pkg.name} is not yet build for repository '#{repo.name}'"
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions src/api/test/functional/maintenance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,16 @@ def test_create_maintenance_project_and_release_packages
assert_response :success
assert_xml_tag :parent => { :tag => 'result', :attributes => { :repository=> 'BaseDistro2.0_LinkedUpdateProject', :arch=> 'i586', :state=> 'unpublished'} },
:tag => 'status', :attributes => { :package=> 'patchinfo', :code=> 'broken'}
# try to create release request nevertheless
raw_post '/request?cmd=create&addrevision=1', '<request>
<action type="maintenance_release">
<source project="' + incidentProject + '" />
</action>
<state name="new" />
</request>'
assert_response 400
assert_xml_tag( :tag => 'status', :attributes => { :code => 'build_not_finished'} )
assert_match(/patchinfo patchinfo is broken/, @response.body)
# un-block patchinfo build, but filter for an empty result
pi.delete_element 'stopped'
pi.add_element 'binary'
Expand Down
2 changes: 1 addition & 1 deletion src/api/test/unit/code_quality_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def setup
'BsRequestAction#check_action_permission!' => 221.25,
'BsRequestAction#check_newstate!' => 372.38,
'BsRequestAction#check_sanity' => 78.06,
'BsRequestAction#create_expand_package' => 317.89,
'BsRequestAction#create_expand_package' => 324.93,
'BsRequestAction#default_reviewers' => 135.96,
'BsRequestAction#find_reviewers' => 61.68,
'BsRequestAction#notify_params' => 56.35,
Expand Down

0 comments on commit ed33df0

Please sign in to comment.