Skip to content
Browse files

[api] use generic function for injecting build jobs (fixes breakage a…

…fter fix for scheduler of aggregation block check)

Conflicts:
	src/api/script/start_test_backend
	src/api/test/test_helper.rb
  • Loading branch information...
1 parent 18ef6ce commit 3f5b72f4cea59032981d1295e75a3b5fb2a7deef @adrianschroeter adrianschroeter committed Sep 3, 2012
Showing with 22 additions and 50 deletions.
  1. +6 −50 src/api/script/start_test_backend
  2. +16 −0 src/api/test/test_helper.rb
View
56 src/api/script/start_test_backend
@@ -2,6 +2,7 @@
ENV['RAILS_ENV'] = 'test'
require File.dirname(__FILE__) + '/../config/boot'
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
+require File.expand_path(File.dirname(__FILE__)) + "/../test/test_helper"
# check for still running daemons from former run
[ '3200', '3201', '3202' ].each do |port|
@@ -293,56 +294,11 @@ IO.popen("cd #{RAILS_ROOT}/tmp/backend_config; exec perl #{perlopts} ./bs_sched
io.each {|line| logger.debug line.strip unless line.blank? }
end
-# find out about the triggered build job and write back dispatching data
-
-# home:Iggy
-FindIggyJob=IO.popen("find #{RAILS_ROOT}/tmp/backend_data/jobs/i586/ -name home:Iggy::10.2::TestPack-*")
-IggyJob=FindIggyJob.readlines.first.chomp
-jobid=""
-IO.popen("md5sum #{IggyJob}|cut -d' ' -f 1") do |io|
- jobid = io.readlines.first.chomp
-end
-f = File.open("#{IggyJob}:status", 'w')
-f.write( "<jobstatus code=\"building\"> <jobid>#{jobid}</jobid> </jobstatus>" )
-f.close
-# upload build result as a worker would do
-system("cd #{RAILS_ROOT}/test/fixtures/backend/binary/; exec find . -name '*i586.rpm' -o -name '*src.rpm' -o -name meta -o -name logfile | cpio -H newc -o | curl -s -X POST -T - 'http://localhost:3201/putjob?arch=i586&code=success&job=#{IggyJob.gsub(/.*\//, '')}&jobid=#{jobid}'")
-
-# HiddenProject
-jobid=""
-IO.popen("md5sum #{RAILS_ROOT}/tmp/backend_data/jobs/i586/HiddenProject::nada::pack-47a5fb1c73c75bb252283e2ad1110182|cut -d' ' -f 1") do |io|
- jobid = io.readlines.first.chomp
-end
-f = File.open("#{RAILS_ROOT}/tmp/backend_data/jobs/i586/HiddenProject::nada::pack-47a5fb1c73c75bb252283e2ad1110182:status", 'w')
-f.write( "<jobstatus code=\"building\"> <jobid>#{jobid}</jobid> </jobstatus>" )
-f.close
-# upload build result as a worker would do
-system("cd #{RAILS_ROOT}/test/fixtures/backend/binary/; exec find . -name '*i586.rpm' -o -name '*src.rpm' -o -name meta -o -name logfile | cpio -H newc -o | curl -s -X POST -T - 'http://localhost:3201/putjob?arch=i586&code=success&job=HiddenProject::nada::pack-47a5fb1c73c75bb252283e2ad1110182&jobid=#{jobid}'")
-
-# BinaryAccess
-# BinaryprotectedProject::nada::bdpack-47a5fb1c73c75bb252283e2ad1110182
-jobid=""
-IO.popen("md5sum #{RAILS_ROOT}/tmp/backend_data/jobs/i586/BinaryprotectedProject::nada::bdpack-47a5fb1c73c75bb252283e2ad1110182|cut -d' ' -f 1") do |io|
- jobid = io.readlines.first.chomp
-end
-f = File.open("#{RAILS_ROOT}/tmp/backend_data/jobs/i586/BinaryprotectedProject::nada::bdpack-47a5fb1c73c75bb252283e2ad1110182:status", 'w')
-f.write( "<jobstatus code=\"building\"> <jobid>#{jobid}</jobid> </jobstatus>" )
-f.close
-# upload build result as a worker would do
-system("cd #{RAILS_ROOT}/test/fixtures/backend/binary/; exec find . -name '*i586.rpm' -o -name '*src.rpm' -o -name meta -o -name logfile | cpio -H newc -o | curl -s -X POST -T - 'http://localhost:3201/putjob?arch=i586&code=success&job=BinaryprotectedProject::nada::bdpack-47a5fb1c73c75bb252283e2ad1110182&jobid=#{jobid}'")
-
-# SourceAccess
-FindSourceprotectedJob=IO.popen("find #{RAILS_ROOT}/tmp/backend_data/jobs/i586/ -name SourceprotectedProject::repo::pack*")
-SourceprotectedJob=FindSourceprotectedJob.readlines.first.chomp
-jobid=""
-IO.popen("md5sum #{SourceprotectedJob}|cut -d' ' -f 1") do |io|
- jobid = io.readlines.first.chomp
-end
-f = File.open("#{SourceprotectedJob}:status", 'w')
-f.write( "<jobstatus code=\"building\"> <jobid>#{jobid}</jobid> </jobstatus>" )
-f.close
-# upload build result as a worker would do
-system("cd #{RAILS_ROOT}/test/fixtures/backend/binary/; exec find . -name '*i586.rpm' -o -name '*src.rpm' -o -name meta -o -name logfile | cpio -H newc -o | curl -s -X POST -T - 'http://localhost:3201/putjob?arch=i586&code=success&job=#{SourceprotectedJob.gsub(/.*\//, '')}&jobid=#{jobid}'")
+# Inject build job results
+inject_build_job( "home:Iggy", "TestPack", "10.2", "i586" )
+inject_build_job( "HiddenProject", "pack", "nada", "i586" )
+inject_build_job( "BinaryprotectedProject", "bdpack", "nada", "i586" )
+inject_build_job( "SourceprotectedProject", "pack", "repo", "i586" )
# upload a binary file to repository directly
Suse::Backend.put( '/build/home:Iggy/10.2/i586/_repository/delete_me.rpm?wipe=1', File.open("#{RAILS_ROOT}/test/fixtures/backend/binary/delete_me-1.0-1.i586.rpm").read() )
View
16 src/api/test/test_helper.rb
@@ -6,6 +6,22 @@
# or the code has to be fixed
#$ENABLE_BROKEN_TEST=true
+ def inject_build_job( project, package, repo, arch )
+ job=IO.popen("find #{Rails.root}/tmp/backend_data/jobs/#{arch}/ -name #{project}::#{repo}::#{package}-*")
+ jobfile=job.readlines.first.chomp
+ jobid=""
+ IO.popen("md5sum #{jobfile}|cut -d' ' -f 1") do |io|
+ jobid = io.readlines.first.chomp
+ end
+ data = REXML::Document.new(File.new(jobfile))
+ verifymd5 = data.elements["/buildinfo/verifymd5"].text
+ f = File.open("#{jobfile}:status", 'w')
+ f.write( "<jobstatus code=\"building\"> <jobid>#{jobid}</jobid> <workerid>simulated</workerid> <hostarch>#{arch}</hostarch> </jobstatus>" )
+ f.close
+ system("cd #{Rails.root}/test/fixtures/backend/binary/; exec find . -name '*#{arch}.rpm' -o -name '*src.rpm' -o -name logfile | cpio -H newc -o 2>/dev/null | curl -s -X POST -T - 'http://localhost:3201/putjob?arch=#{arch}&code=success&job=#{jobfile.gsub(/.*\//, '')}&jobid=#{jobid}' > /dev/null")
+ system("echo \"#{verifymd5} #{package}\" > #{jobfile}:dir/meta")
+ end
+
module ActionController
module Integration #:nodoc:
class Session

0 comments on commit 3f5b72f

Please sign in to comment.
Something went wrong with that request. Please try again.