From: donghee yang Date: Thu, 28 Mar 2013 02:23:13 +0000 (+0900) Subject: Merge branch 'develop' into new_log X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0950a94eff029a41701c81cd617cd230bc1ee7b4;p=sdk%2Ftools%2Fsdk-build.git Merge branch 'develop' into new_log Conflicts: build-cli src/build_server/BuildClientOptionParser.rb src/build_server/MultiBuildJob.rb src/build_server/RemoteBuilder.rb src/build_server/SocketJobRequestListener.rb test/build-server.basic1/build-cli-01.testcase --- 0950a94eff029a41701c81cd617cd230bc1ee7b4 diff --cc build-cli index 6b11d1e,b047c0d..c34682f --- a/build-cli +++ b/build-cli @@@ -182,115 -175,18 +182,98 @@@ begi puts " :" exit 1 end - client = BuildCommClient.create( result[0], result[1], nil, 0 ) - if not client.nil? then - client.send "BUILD|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:noreverse]}|#{option[:dist]}|#{option[:user]}|#{option[:rebuild]}" - if not client.print_stream then - puts "ERROR: #{client.get_error_msg()}" + + # Request build + begin + client = BuildCommClient.create( addr[0], addr[1], nil, 0 ) + if client.nil? then + puts "Connection to server failed!" + exit 1 end + cmd = "BUILD|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:noreverse]}|#{option[:dist]}|#{option[:user]}|#{option[:rebuild]}" + + client.send(cmd) + + result = client.read_lines do |line| + if line.strip.start_with?("=JOB_START") then + job_id = line.strip.split(",")[1] + next + elsif line.strip.start_with?("=JOB_STATUS") then + data = line.strip.split(",") + job_status = data[1] + job_error = data[2] + next + end + # print log + puts line + end + + if not result then + puts "Error: Communication failed! #{client.get_error_msg()}" + elsif job_id.nil? then + puts job_error + result = false + end + client.terminate + rescue => e + puts "ERROR: #{e}" client.terminate - else - puts "Connection to server failed!" + exit 1 + end + + # Query log in case sync + if result and option[:async].eql? "NO" then + begin + client = BuildCommClient.create( addr[0], addr[1], nil, 0 ) + if client.nil? then + puts "ERROR: Can't query log, Connection to server failed!" + exit 1 + end + + client.send "LOG|#{job_id}" + result = client.read_lines do |line| + if line.strip.start_with?("=JOB_STATUS") then + data = line.strip.split(",") + job_status = data[1] + job_error = data[2] + next + end + + # print log + category, level, contents = JobLog.parse_log(line) + if level < Log::LV_USER then next end + + if category == "INFO" then + puts "Info: #{contents}" + elsif category == "WARN" then + puts "Warn: #{contents}" + elsif category == "ERROR" then + puts "Error: #{contents}" + else + next + end + end + + if not result then + puts "ERROR: Can't query log, Communication failed! #{client.get_error_msg()}" + end + + # Check job status + if not job_status.eql? "FINISHED" then + result = false + end + client.terminate + rescue => e + puts "ERROR: #{e}" + result = false + client.terminate + end + end + + if not result then exit 1 end - - # when "resolve" - # result = Utils.parse_server_addr(option[:domain]) - # if result.nil? then - # puts "Server address is incorrect. (#{option[:domain]})" - # puts "Tune as following format." - # puts " :" - # exit 1 - # end - # client = BuildCommClient.create( result[0], result[1], nil, 0 ) - # if not client.nil? then - # client.send "RESOLVE|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:dist]}|#{option[:user]}|#{option[:verbose]}" - # if not client.print_stream then - # puts "ERROR: #{client.get_error_msg()}" - # end - # client.terminate - # end when "query" result = Utils.parse_server_addr(option[:domain]) if result.nil? then diff --cc src/build_server/RemoteBuilder.rb index 38b45a1,3e79ad8..61f23a2 --- a/src/build_server/RemoteBuilder.rb +++ b/src/build_server/RemoteBuilder.rb @@@ -99,16 -99,14 +99,16 @@@ class RemoteBuilde # send build request @log.info( "Sending build request to remote server...", Log::LV_USER ) - result, result_files = send_build_request(git_repos, os, is_rev_build, - srcinfo, no_reverse, local_pkgs, dock, dist_name, user_email) - @log.info( "Receiving log file from remote server...", Log::LV_USER ) - if not receive_file_from_remote( "#{source_path}/../remote_log", dock ) then - @log.warn( "File transfering failed! : remote_log", Log::LV_USER ) + result = send_build_request(git_repos, os, is_rev_build, - srcinfo, no_reverse, local_pkgs, dock, dist_name, user_email) ++ srcinfo, no_reverse, local_pkgs, dock, dist_name, user_email) + if not result then + @log.error( "Building job request on remote server failed!", Log::LV_USER ) + return false end + result, result_files = send_monitor_request(is_rev_build) + if not result then @log.error( "Building job on remote server failed!", Log::LV_USER ) return false diff --cc src/build_server/SocketJobRequestListener.rb index 4719f38,767d819..a996c37 --- a/src/build_server/SocketJobRequestListener.rb +++ b/src/build_server/SocketJobRequestListener.rb @@@ -720,11 -725,16 +724,19 @@@ class SocketJobRequestListene # check distribution check_distribution(dist_name, req) + # check project + prj = check_project_for_package_file_name(filename, dist_name, req) + + # check project status + if prj.status != "OPEN" then + raise BuildServerException.new("ERR017"), "#{prj.name} on #{dist_name}. project is [[#{prj.status}]]" + end + new_job = @parent_server.jobmgr.create_new_register_job( file_path, dist_name ) - new_job.create_logger( req ) + new_job.create_logger() + + BuildCommServer.send_end(req) + BuildCommServer.disconnect(req) # add @parent_server.jobmgr.add_job( new_job ) diff --cc test/build-server.basic1/build-cli-01.testcase index e839c73,d1133e3..4cb527e --- a/test/build-server.basic1/build-cli-01.testcase +++ b/test/build-server.basic1/build-cli-01.testcase @@@ -8,37 -8,35 +8,37 @@@ Requiest service to build-server comman Usage: build-cli [OPTS] or build-cli (-h|-v) Subcommands: - build Build and create package. - query Query information about build-server. - query-system Query system information about build-server. - query-project Query project information about build-server. - query-job Query job information about build-server. - query-log Query log contents about job in build-server. - cancel Cancel a building project. - register Register the package to the build-server. + build Build and create package. + query Query information about build-server. + query-system Query system information about build-server. + query-project Query project information about build-server. + query-job Query job information about build-server. + query-log Query log contents about job in build-server. + cancel Cancel a building project. + register Register the package to the build-server. Subcommand usage: - build-cli build -N -d [-o ] [-w ] [--async] [-D ] [-U user-email] - build-cli query -d - build-cli query-system -d - build-cli query-project -d - build-cli query-job -d - build-cli query-log -d -j - build-cli cancel -j -d [-w ] [-U user-email] - build-cli register -P -d [-t ] [-w ] [-D ] [-U user-email] +build-cli build -N -d [-o ] [-w ] [--async] [-D ] [-U user-email] +build-cli query -d +build-cli query-system -d +build-cli query-project -d +build-cli query-job -d +build-cli query-log -d -j [--output ] +build-cli cancel -j -d [-w ] [-U user-email] +build-cli register -P -d [-t ] [-w ] [-D ] [-U user-email] Options: - -N, --project project name - -d, --address build server address: 127.0.0.1:2224 - -o, --os target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64 - --async asynchronous job - -j, --job job number - -w, --passwd password for managing project - -P, --pkg package file path - -D, --dist distribution name - -t, --ftp ftp server url: ftp://dibsftp:dibsftp@127.0.0.1 - -U, --user user email infomation - -h, --help display help - -v, --version display version +-N, --project project name +-d, --address build server address: 127.0.0.1:2224 +-o, --os target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64 +--async asynchronous job +-j, --job job number +-w, --passwd password for managing project +-P, --pkg package file path +-D, --dist distribution name +-t, --ftp ftp server url: ftp://dibsftp:dibsftp@127.0.0.1 +-U, --user user email infomation +--output output file path +-V, --verbose verbose mode +-h, --help display help +-v, --version display version