From: donghee yang Date: Wed, 26 Dec 2012 05:51:26 +0000 (+0900) Subject: [Title] Refactored Build Server's Exception Handling X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27f7f2311893079144cb5046950a7dd1ebc1c783;p=sdk%2Ftools%2Fsdk-build.git [Title] Refactored Build Server's Exception Handling --- diff --git a/src/build_server/BuildServerException.rb b/src/build_server/BuildServerException.rb new file mode 100644 index 0000000..8faed9a --- /dev/null +++ b/src/build_server/BuildServerException.rb @@ -0,0 +1,31 @@ +class BuildServerException < Exception + @@err_msgs = { + "ERR001" => "Invalid request format is used!", + "ERR002" => "Distribution not found!", + "ERR003" => "Unsupported OS name used!", + "ERR004" => "User account not found!", + "ERR005" => "Project access denied!", + "ERR006" => "Job creation failed!", + "ERR007" => "No supported OS defined in build server!", + "ERR008" => "Distribution locked!", + "ERR009" => "Project not found!", + "ERR010" => "Build operation not allowed on this project type!", + "ERR011" => "Project password required!", + "ERR012" => "Project password not matched!", + "ERR013" => "Project from file-name/distribution not found!", + "ERR014" => "Job cancel failed!", + "ERR015" => "Server password not matched!" + } + + def initialize(code) + @err_code = code + end + + def err_message() + if not message().nil? and not message().empty? then + return "Error: #{@@err_msgs[@err_code]}: #{message()}" + else + return "Error: #{@@err_msgs[@err_code]}" + end + end +end diff --git a/src/build_server/SocketJobRequestListener.rb b/src/build_server/SocketJobRequestListener.rb index d06f0d6..8db3568 100644 --- a/src/build_server/SocketJobRequestListener.rb +++ b/src/build_server/SocketJobRequestListener.rb @@ -29,6 +29,7 @@ Contributors: $LOAD_PATH.unshift File.dirname(__FILE__) require "JobLog.rb" require "BuildComm.rb" +require "BuildServerException.rb" class SocketJobRequestListener @@ -121,13 +122,9 @@ class SocketJobRequestListener case cmd when "BUILD" - @log.info "Received REQ: #{req_line}" handle_cmd_build( req_line, req ) - @log.info "Handled REQ: #{req_line}" when "RESOLVE" - @log.info "Received REQ: #{req_line}" handle_cmd_resolve( req_line, req ) - @log.info "Handled REQ: #{req_line}" when "QUERY" handle_cmd_query( req_line, req ) when "CANCEL" @@ -171,18 +168,33 @@ class SocketJobRequestListener end + # "BUILD" def handle_cmd_build( line, req ) + @log.info "Received REQ: #{line}" + + begin + handle_cmd_build_internal( line, req ) + rescue BuildServerException => e + BuildCommServer.send_begin(req) + @log.error(e.message) + BuildCommServer.send(req, e.err_message()) + BuildCommServer.send_end(req) + end + + @log.info "Handled REQ: #{line}" + end + + + def handle_cmd_build_internal( line, req ) tok = line.split("|").map { |x| x.strip } if tok.count < 3 then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end # check type if tok[1] != "GIT" then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end # 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 @@ -209,25 +221,17 @@ class SocketJobRequestListener end # check distribution - if not check_distribution(dist_name, req) then - raise "The distribution error!!" - end + check_distribution(dist_name, req) # check supported os if not internal job if not is_internal then os_list = check_supported_os( os_list , req ) - if os_list.nil? or os_list.empty? then - raise "Unsupported OS name is used!" - end end # check user email user_id = @parent_server.check_user_id_from_email( user_email ) if user_id == -1 then - BuildCommServer.send_begin(req) - req.puts "Error: Cannot find the user with \"#{user_email}\"!" - BuildCommServer.send_end(req) - raise "No user information!" + raise BuildServerException.new("ERR004"), user_email end @@ -240,11 +244,7 @@ class SocketJobRequestListener else passwd = passwd_list[0] end check_build_project(pname,passwd,dist_name,req) if not check_project_user_id(pname,dist_name,user_id) then - BuildCommServer.send_begin(req) - req.puts "Error: \"#{user_email}\" can't access \"#{pname}\" project!" - req.puts "You are not in project control group" - BuildCommServer.send_end(req) - raise "#{user_email} can't accesse #{pname} project!" + raise BuildServerException.new("ERR005"), "#{user_email} -> #{pname}" end os_list.each do |os| new_job = create_new_job( pname, os, dist_name ) @@ -263,14 +263,14 @@ class SocketJobRequestListener if new_job_list.count > 1 then new_job = @parent_server.prjmgr.create_new_multi_build_job( new_job_list ) if new_job.nil? then - raise "Multi-Build Job creation failed!" + raise BuildServerException.new("ERR006"),"Multi-Build job" else new_job.user_id = user_id end elsif new_job_list.count == 1 then new_job = new_job_list[0] else - raise "Multi-Build Job creation failed!" + raise BuildServerException.new("ERR006"),"No valid sub jobs in Multi-Build job" end # transfered job @@ -280,7 +280,7 @@ class SocketJobRequestListener new_job = create_new_internal_job(git_repos, os, git_commit, pkg_files, dock_num, dist_name ) if new_job.nil? then - raise "Internal-Build Job creation failed!" + raise BuildServerException.new("ERR006"),"Transfered-Build job" else new_job.user_id = user_id end @@ -293,30 +293,16 @@ class SocketJobRequestListener check_build_project(pname,passwd,dist_name,req) if not check_project_user_id(pname,dist_name,user_id) then - BuildCommServer.send_begin(req) - req.puts "Error: \"#{user_email}\" can't access \"#{pname}\" project!" - req.puts "You are not in project control group" - BuildCommServer.send_end(req) - raise "#{user_email} can't accesse #{pname} project!" + raise BuildServerException.new("ERR005"), "#{user_email} -> #{pname}" end new_job = create_new_job( pname, os, dist_name ) if new_job.nil? then - raise "\"#{pname}\" does not support #{os} in #{dist_name}" + raise BuildServerException.new("ERR006"), "\"#{pname}\" does not support #{os} in #{dist_name}" else new_job.user_id = user_id end else - BuildCommServer.send_begin(req) - req.puts "Error: There is no valid job to build!" - BuildCommServer.send_end(req) - raise "No valid jobs!" - end - - if new_job.nil? then - BuildCommServer.send_begin(req) - req.puts "Error: Creating job failed! (project may not exist)" - BuildCommServer.send_end(req) - raise "Internal Error!" + raise BuildServerException.new("ERR006"), "Cannot find your project to build!" end # check reverse build @@ -351,31 +337,38 @@ class SocketJobRequestListener def check_build_project(prj_name, passwd, dist_name, req) # check project prj = check_project_exist(prj_name, dist_name, req) - if prj.nil? then - raise "Requested project \"#{prj_name}\" does not exist!" - end # check passwd - if not check_project_password(prj, passwd, req) then - raise "Project's password is not matched!!" - end + check_project_password(prj, passwd, req) # check project type if prj.type == "BINARY" then + raise BuildServerException.new("ERR010"), prj.type + end + end + + + # "RESOLVE" + def handle_cmd_resolve( line, req ) + @log.info "Received REQ: #{line}" + + begin + handle_cmd_resolve_internal( line, req ) + rescue BuildServerException => e BuildCommServer.send_begin(req) - req.puts "Can't build about Binary type package." + @log.error(e.message) + BuildCommServer.send(req, e.err_message()) BuildCommServer.send_end(req) - raise "Can't build about Binary type package." end + + @log.info "Handled REQ: #{line}" end - # "RESOLVE" - def handle_cmd_resolve( line ,req) + def handle_cmd_resolve_internal( line ,req) tok = line.split("|").map { |x| x.strip } if tok.count < 3 then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end case tok[1] @@ -395,50 +388,33 @@ class SocketJobRequestListener end # check distribution - if not check_distribution(dist_name, req) then - raise "The distribution error!!" - end + check_distribution(dist_name, req) # check project prj = check_project_exist(project_name, dist_name, req) - if prj.nil? then - raise "Requested project does not exist!" - end # check passwd - if not check_project_password(prj, passwd, req) then - raise "Project's password is not matched!!" - end + check_project_password(prj, passwd, req) # check os os_list = check_supported_os( [os] , req ) - if os_list.nil? or os_list.empty? then - raise "Unsupported OS name is used!" - end os = os_list[0] # check user email user_id = @parent_server.check_user_id_from_email( user_email ) if user_id == -1 then - BuildCommServer.send_begin(req) - req.puts "Error: Cannot find the user with \"#{user_email}\"!" - BuildCommServer.send_end(req) - raise "No user information!" + raise BuildServerException.new("ERR004"), user_email end # check user accessable if not check_project_user_id(project_name,dist_name,user_id) then - BuildCommServer.send_begin(req) - req.puts "Error: \"#{user_email}\" can't access \"#{project_name}\" project!" - req.puts "You are not in project control group" - BuildCommServer.send_end(req) - raise "#{user_email} can't accesse #{project_name} project!" + raise BuildServerException.new("ERR005"), "#{user_email} -> #{project_name}" end # create new job new_job = create_new_job( project_name, os, dist_name ) if new_job.nil? then - raise "Creating build job failed : #{project_name}, #{os}" + raise BuildServerException.new("ERR006"), "Resolve job #{project_name} #{os}" end @log.info "Received a request for resolving this project : #{project_name}, #{os}" @@ -466,18 +442,28 @@ class SocketJobRequestListener @parent_server.jobmgr.add_job( new_job ) else - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end end # "QUERY" def handle_cmd_query( line, req ) + begin + handle_cmd_query_internal( line, req ) + rescue BuildServerException => e + BuildCommServer.send_begin(req) + @log.error(e.message) + BuildCommServer.send(req, e.err_message()) + BuildCommServer.send_end(req) + end + end + + + def handle_cmd_query_internal( line, req ) tok = line.split("|").map { |x| x.strip } if tok.count < 2 then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end case tok[1] @@ -581,28 +567,39 @@ class SocketJobRequestListener BuildCommServer.disconnect(req) else - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end end # "CANCEL" def handle_cmd_cancel( line, req ) + @log.info "Received REQ: #{line}" + + begin + handle_cmd_cancel_internal( line, req ) + rescue BuildServerException => e + BuildCommServer.send_begin(req) + @log.error(e.message) + BuildCommServer.send(req, e.err_message()) + BuildCommServer.send_end(req) + end + + @log.info "Handled REQ: #{line}" + end + + + def handle_cmd_cancel_internal( line, req ) tok = line.split("|").map { |x| x.strip } if tok.count < 2 then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end cancel_job = nil # check user email user_id = @parent_server.check_user_id_from_email( tok[3] ) if user_id == -1 then - BuildCommServer.send_begin(req) - req.puts "Error: Cannot find the user with \"#{tok[3]}\"!" - BuildCommServer.send_end(req) - raise "No user information!" + raise BuildServerException.new("ERR004"), tok[3] end #CANCEL, JOB @@ -613,69 +610,76 @@ class SocketJobRequestListener end end - BuildCommServer.send_begin(req) if cancel_job.nil? then - BuildCommServer.send(req, "There is no job \"#{tok[1]}\"") - raise "There is no job \"#{tok[1]}\"" + raise BuildServerException.new("ERR014"), "Job #{tok[1]} not found." else if cancel_job.cancel_state == "NONE" then # check passwd if not @parent_server.jobmgr.is_user_accessable(cancel_job,user_id) then - BuildCommServer.send_begin(req) - req.puts "Error: \"#{tok[3]}\" can't access \"#{cancel_job.get_project.name}\" project!" - req.puts "You are not in project control group" - BuildCommServer.send_end(req) - raise "#{tok[3]} can't accesse #{cancel_job.get_project.name} project!" + raise BuildServerException.new("ERR014"), "Access denied #{tok[3]}" end if cancel_job.type == "MULTIBUILD" then cancel_job.get_sub_jobs().select{|x| x.cancel_state == "NONE" }.each do |sub| - if not check_project_password( sub.get_project, tok[2], req) then - BuildCommServer.send(req, "Project's password is not matched!!") - raise "Project's password is not matched!!" - end + check_project_password( sub.get_project, tok[2], req) end + BuildCommServer.send_begin(req) BuildCommServer.send(req, "\"#{cancel_job.id}, #{cancel_job.get_sub_jobs().map{|x| x.id}.join(", ")}\" will be canceled") cancel_job.cancel_state = "INIT" + BuildCommServer.send_end(req) + BuildCommServer.disconnect(req) else prj = cancel_job.get_project() if not prj.nil? then - if not check_project_password( prj, tok[2], req) then - BuildCommServer.send(req, "Project's password is not matched!!") - raise "Project's password is not matched!!" - else - BuildCommServer.send(req, "\"#{cancel_job.id}\" will be canceled") - cancel_job.cancel_state = "INIT" - end + check_project_password( prj, tok[2], req) + + BuildCommServer.send_begin(req) + BuildCommServer.send(req, "\"#{cancel_job.id}\" will be canceled") + cancel_job.cancel_state = "INIT" + BuildCommServer.send_end(req) + BuildCommServer.disconnect(req) else - BuildCommServer.send(req, "Cannot cancel the job \"#{cancel_job.id}\"") + raise BuildServerException.new("ERR014"), "No project infomation" end end else - BuildCommServer.send(req, "\"#{cancel_job.id}\" is already canceled") + raise BuildServerException.new("ERR014"), "Job already canceled." end end - BuildCommServer.send_end(req) - BuildCommServer.disconnect(req) end # "STOP" def handle_cmd_stop( line, req ) + @log.info "Received REQ: #{line}" + + begin + handle_cmd_stop_internal( line, req ) + rescue BuildServerException => e + BuildCommServer.send_begin(req) + @log.error(e.message) + BuildCommServer.send(req, e.err_message()) + BuildCommServer.send_end(req) + end + + @log.info "Handled REQ: #{line}" + end + + + def handle_cmd_stop_internal( line, req ) tok = line.split("|").map { |x| x.strip } if tok.count < 2 then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end - BuildCommServer.send_begin(req) if tok[1] != @parent_server.password then - BuildCommServer.send(req,"Password mismatched!") + raise BuildServerException.new("ERR015"), "" else + BuildCommServer.send_begin(req) BuildCommServer.send(req,"Server will be down!") + BuildCommServer.send_end(req) + BuildCommServer.disconnect(req) end - BuildCommServer.send_end(req) - BuildCommServer.disconnect(req) if tok[1] == @parent_server.password then @parent_server.finish = true end @@ -684,20 +688,35 @@ class SocketJobRequestListener # "UPGRADE" def handle_cmd_upgrade( line, req ) + @log.info "Received REQ: #{line}" + + begin + handle_cmd_upgrade_internal( line, req ) + rescue BuildServerException => e + BuildCommServer.send_begin(req) + @log.error(e.message) + BuildCommServer.send(req, e.err_message()) + BuildCommServer.send_end(req) + end + + @log.info "Handled REQ: #{line}" + end + + + def handle_cmd_upgrade_internal( line, req ) tok = line.split("|").map { |x| x.strip } if tok.count < 2 then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end - BuildCommServer.send_begin(req) if tok[1] != @parent_server.password then - BuildCommServer.send(req,"Password mismatched!") + raise BuildServerException.new("ERR015"), "" else - BuildCommServer.send(req,"Server will be down!") + BuildCommServer.send_begin(req) + BuildCommServer.send(req,"Server will be upgraded!") + BuildCommServer.send_end(req) + BuildCommServer.disconnect(req) end - BuildCommServer.send_end(req) - BuildCommServer.disconnect(req) if tok[1] == @parent_server.password then @parent_server.finish = true @parent_server.upgrade = true @@ -707,10 +726,25 @@ class SocketJobRequestListener # "FULLBUILD" def handle_cmd_fullbuild( line, req ) + @log.info "Received REQ: #{line}" + + begin + handle_cmd_fullbuild_internal( line, req ) + rescue BuildServerException => e + BuildCommServer.send_begin(req) + @log.error(e.message) + BuildCommServer.send(req, e.err_message()) + BuildCommServer.send_end(req) + end + + @log.info "Handled REQ: #{line}" + end + + + def handle_cmd_fullbuild_internal( line, req ) tok = line.split("|").map { |x| x.strip } if tok.count < 2 then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end server_passwd = tok[1] @@ -720,17 +754,11 @@ class SocketJobRequestListener end # check distribution - if not check_distribution(dist_name, req, true) then - raise "The distribution error!!" - end + check_distribution(dist_name, req, true) # check server password if server_passwd != @parent_server.password then - BuildCommServer.send_begin(req) - BuildCommServer.send(req,"Password mismatched!") - BuildCommServer.send_end(req) - BuildCommServer.disconnect(req) - return + raise BuildServerException.new("ERR015"), "" end # create full build job @@ -748,10 +776,25 @@ class SocketJobRequestListener # "REGISTER" def handle_cmd_register( line, req ) + @log.info "Received REQ: #{line}" + + begin + handle_cmd_register_internal( line, req ) + rescue BuildServerException => e + BuildCommServer.send_begin(req) + @log.error(e.message) + BuildCommServer.send(req, e.err_message()) + BuildCommServer.send_end(req) + end + + @log.info "Handled REQ: #{line}" + end + + + def handle_cmd_register_internal( line, req ) tok = line.split("|").map { |x| x.strip } if tok.count < 4 then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end type = tok[1] @@ -767,9 +810,7 @@ class SocketJobRequestListener end # check distribution - if not check_distribution(dist_name, req) then - raise "The distribution error!!" - end + check_distribution(dist_name, req) new_job = @parent_server.jobmgr.create_new_register_job( file_path, dist_name ) logger = JobLog.new( new_job, req ) @@ -794,43 +835,29 @@ class SocketJobRequestListener end # check distribution - if not check_distribution(dist_name, req) then - raise "The distribution error!!" - end + check_distribution(dist_name, req) # check project prj = check_project_for_package_file_name(filename, dist_name, req) - if prj.nil? then - raise "No project is defined for this binary : #{filename}!" - end # check user email user_id = @parent_server.check_user_id_from_email( user_email ) if user_id == -1 then - BuildCommServer.send_begin(req) - req.puts "Error: Cannot find the user with \"#{user_email}\"!" - BuildCommServer.send_end(req) - raise "No user information!" + raise BuildServerException.new("ERR004"), user_email end if not check_project_pkg_name_user_id(filename, dist_name, user_id) then - BuildCommServer.send_begin(req) - req.puts "Error: \"#{user_email}\" can't regist \"#{filename}\"!" - req.puts "You are not in project control group" - BuildCommServer.send_end(req) - raise "#{user_email} can't regist #{filename}!" + raise BuildServerException.new("ERR005"), "#{user_email} -> #{prj.name}" end # check passwd - if not check_project_password(prj, passwd, req) then - raise "Project's password is not matched!!" - end + check_project_password(prj, passwd, req) # create new job @log.info "Received a request for uploading binaries : #{filename}" new_job = create_new_upload_job( prj.name, filename, dock, dist_name, req ) if new_job.nil? then - raise "Creating build job failed : #{prj.name}, #{filename}" + raise BuildServerException.new("ERR006"), "Register-job #{filename}, #{prj.name}, #{dist_name}" end new_job.user_id = user_id @@ -852,8 +879,7 @@ class SocketJobRequestListener # add @parent_server.jobmgr.add_job( new_job ) else - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" + raise BuildServerException.new("ERR001"), line end end @@ -864,11 +890,6 @@ class SocketJobRequestListener @log.info "Received File transfer REQ : #{line}" tok = line.split("|").map { |x| x.strip } - if tok.count < 2 then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" - end - dock_num = (tok[1].nil? or tok[1].empty?) ? "0" : tok[1].strip BuildCommServer.send_begin(req) @@ -884,11 +905,6 @@ class SocketJobRequestListener def handle_cmd_download( line, req ) @log.info "Received File transfer REQ : #{line}" tok = line.split("|").map { |x| x.strip } - if tok.count < 3 then - @log.info "Received Wrong REQ: #{line}" - raise "Invalid request format is used: #{line}" - end - dock_num = (tok[1].nil? or tok[1].empty?) ? "0" : tok[1].strip file_name = tok[2] @@ -919,11 +935,7 @@ class SocketJobRequestListener def check_project_exist(project_name, dist_name, req) prj = @parent_server.prjmgr.get_project(project_name, dist_name) if prj.nil? then - BuildCommServer.send_begin(req) - req.puts "Error: Requested project \"#{project_name}\" does not exist!" - req.puts "Info: Check project name using \"query\" command option !" - BuildCommServer.send_end(req) - return nil + raise BuildServerException.new("ERR009"), "#{project_name} on #{dist_name}" end return prj @@ -945,28 +957,25 @@ class SocketJobRequestListener prj = @parent_server.prjmgr.get_project_from_package_name(pkg_name, dist_name) if prj.nil? then - BuildCommServer.send_begin(req) - req.puts "Error: Requested project does not exist!" - req.puts "Info: Check project name using \"query\" command option !" - BuildCommServer.send_end(req) - return nil + raise BuildServerException.new("ERR013"), "#{pkg_name} #{dist_name}" end return prj end + private def check_project_password(prj, passwd, req) - if prj.is_passwd_set? and not prj.passwd_match?(passwd) then - BuildCommServer.send_begin(req) - req.puts "Error: Project's password is not matched!" - req.puts "Error: Use -w option to input your project password" - BuildCommServer.send_end(req) - return false - end + if prj.is_passwd_set? then + if passwd.nil? or passwd.empty? then + raise BuildServerException.new("ERR011"), "Use -w option to input your project password" + end - return true + if not prj.passwd_match?(passwd) then + raise BuildServerException.new("ERR012"), "" + end + end end @@ -974,17 +983,10 @@ class SocketJobRequestListener def check_distribution(dist_name, req, only_exist = false) dist = @parent_server.distmgr.get_distribution(dist_name) if dist.nil? then - BuildCommServer.send_begin(req) - req.puts "Error: The distribution \"#{dist_name}\" does not exist!" - BuildCommServer.send_end(req) + raise BuildServerException.new("ERR002"), dist_name elsif dist.status != "OPEN" and not only_exist then - BuildCommServer.send_begin(req) - req.puts "Error: The distribution \"#{dist_name}\" is locked!" - BuildCommServer.send_end(req) - return false + raise BuildServerException.new("ERR008"), dist_name end - - return true end @@ -993,10 +995,7 @@ class SocketJobRequestListener # check if supported os list contain at least one OS if @parent_server.supported_os_list.empty? then - BuildCommServer.send_begin(req) - req.puts "Error: There is no OS supported by the build server." - BuildCommServer.send_end(req) - return nil + raise BuildServerException.new("ERR007"), "" end result = [] @@ -1021,26 +1020,19 @@ class SocketJobRequestListener elsif @parent_server.supported_os_list.include?(os) then result.push os else - BuildCommServer.send_begin(req) - req.puts "Error: Unsupported OS name \"#{os}\" is used!" - req.puts "Error: Check the following supported OS list. " + msgs = "#{os}\n\tSupported OS list.\n" @parent_server.supported_os_list.each do |os_name| - req.puts " * #{os_name}" + msgs += "\t * #{os_name}\n" end - BuildCommServer.send_end(req) - return nil + raise BuildServerException.new("ERR003"),msgs end end + result.uniq! if result.empty? then - BuildCommServer.send_begin(req) - req.puts "Error: There is no OS supported by the build server." - BuildCommServer.send_end(req) - return nil + raise BuildServerException.new("ERR003"), "There is no OS name matched." end - result.uniq! - return result end @@ -1054,16 +1046,7 @@ class SocketJobRequestListener private def create_new_upload_job( project_name, filename, dock, dist_name, req) - new_job = @parent_server.prjmgr.get_project(project_name, dist_name).create_new_job(filename, dock) - - if new_job.nil? then - BuildCommServer.send_begin(req) - req.puts "Error: Creating job failed: #{project_name} #{filename} #{dist_name}" - BuildCommServer.send_end(req) - return nil - end - - return new_job + return @parent_server.prjmgr.get_project(project_name, dist_name).create_new_job(filename, dock) end diff --git a/test/build-server.basic1/build-cli-04.testcase b/test/build-server.basic1/build-cli-04.testcase index 0ab1208..977d486 100644 --- a/test/build-server.basic1/build-cli-04.testcase +++ b/test/build-server.basic1/build-cli-04.testcase @@ -3,5 +3,4 @@ ../../build-cli build -N non_exist_project -d 127.0.0.1:2223 -o ubuntu-32 #POST-EXEC #EXPECT -Error: Requested project "non_exist_project" does not exist! -Info: Check project name using "query" command option ! +Error: Project not found!: non_exist_project on BASE diff --git a/test/build-server.basic1/build-cli-12.testcase b/test/build-server.basic1/build-cli-12.testcase index d1a9353..a0b9e6f 100644 --- a/test/build-server.basic1/build-cli-12.testcase +++ b/test/build-server.basic1/build-cli-12.testcase @@ -5,7 +5,7 @@ echo "wrong os name in build command" ../../build-cli build -N testa -d 127.0.0.1:2223 -o wrong_os_name #POST-EXEC #EXPECT -Error: Unsupported OS name "wrong_os_name" is used! -Error: Check the following supported OS list. +Error: Unsupported OS name used!: wrong_os_name +Supported OS list. * ubuntu-32 * windows-32 diff --git a/test/build-server.basic1/build-cli-12_1.testcase b/test/build-server.basic1/build-cli-12_1.testcase index f53b6f5..cccfe9f 100644 --- a/test/build-server.basic1/build-cli-12_1.testcase +++ b/test/build-server.basic1/build-cli-12_1.testcase @@ -4,7 +4,7 @@ echo "wrong os name in resolve command" ../../build-cli resolve -N testa -d 127.0.0.1:2223 -o wrong_os_name #POST-EXEC #EXPECT -Error: Unsupported OS name "wrong_os_name" is used! -Error: Check the following supported OS list. +Error: Unsupported OS name used!: wrong_os_name +Supported OS list. * ubuntu-32 * windows-32 diff --git a/test/build-server.basic1/build-cli-14.testcase b/test/build-server.basic1/build-cli-14.testcase index 3a7107b..df9fff2 100644 --- a/test/build-server.basic1/build-cli-14.testcase +++ b/test/build-server.basic1/build-cli-14.testcase @@ -5,5 +5,4 @@ echo "Assume that testa,testb which are depended by testc are built and uploaded ../../build-cli build -N testc -d 127.0.0.1:2223 -o ubuntu-32 #POST-EXEC #EXPECT -Error: Project's password is not matched! -Error: Use -w option to input your project password +Error: Project password required!: Use -w option to input your project password diff --git a/test/build-server.basic1/build-cli-15.testcase b/test/build-server.basic1/build-cli-15.testcase index dd8305c..9b7cd98 100644 --- a/test/build-server.basic1/build-cli-15.testcase +++ b/test/build-server.basic1/build-cli-15.testcase @@ -5,5 +5,4 @@ echo "Assume that testa,testb which are depended by testc are built and uploaded ../../build-cli build -N testc -d 127.0.0.1:2223 -w 2222 -o ubuntu-32 #POST-EXEC #EXPECT -Error: Project's password is not matched! -Error: Use -w option to input your project password +Error: Project password not matched! diff --git a/test/build-server.basic1/build-cli-27.testcase b/test/build-server.basic1/build-cli-27.testcase index 60c8889..66eb1cf 100644 --- a/test/build-server.basic1/build-cli-27.testcase +++ b/test/build-server.basic1/build-cli-27.testcase @@ -4,4 +4,4 @@ cd git01;tar xf c_v5.tar.gz ../../build-cli build -N testc -d 127.0.0.1:2223 -o li_* -w 1111 #POST-EXEC #EXPECT -Error: There is no OS supported by the build server. +Error: Unsupported OS name used!: There is no OS name matched. diff --git a/test/build-server.basic1/build-cli-30.testcase b/test/build-server.basic1/build-cli-30.testcase index 33a5460..2fe774e 100644 --- a/test/build-server.basic1/build-cli-30.testcase +++ b/test/build-server.basic1/build-cli-30.testcase @@ -4,4 +4,4 @@ echo "user check" ../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 -U xxuser@user #POST-EXEC #EXPECT -Error: Cannot find the user with "xxuser@user"! +Error: User account not found!: xxuser@user diff --git a/test/build-server.multi-svr2/01.testcase b/test/build-server.multi-svr2/01.testcase index 05095f5..f71a53f 100644 --- a/test/build-server.multi-svr2/01.testcase +++ b/test/build-server.multi-svr2/01.testcase @@ -19,4 +19,5 @@ I, [ I, [ I, [ I, [ +I, [ bin (0.0.1) diff --git a/test/build-server.multi_dist2/build-svr3-05.testcase b/test/build-server.multi_dist2/build-svr3-05.testcase index a2b8660..6836515 100644 --- a/test/build-server.multi_dist2/build-svr3-05.testcase +++ b/test/build-server.multi_dist2/build-svr3-05.testcase @@ -14,7 +14,7 @@ echo "==" == Distribution is locked! == -Error: The distribution "unstable2" is locked! +Error: Distribution locked!: unstable2 == Distribution is unlocked! ==