end
def upload_request(bs_ip, bs_port, dock, transporter, package )
- client = BuildCommClient.create( bs_ip, bs_port, nil, 0 )
- if client.nil? then
- raise RuntimeError, "Can't access server #{bs_ip}:#{bs_port}"
+ result = false
+ begin
+ client = BuildCommClient.create( bs_ip, bs_port, nil, 0 )
+ if client.nil? then
+ raise RuntimeError, "Can't access server #{bs_ip}:#{bs_port}"
+ end
+ msg = "UPLOAD|#{dock}"
+ client.send( msg )
+ result = client.send_file(package, transporter)
+ ensure
+ client.terminate if not client.nil?
end
- msg = "UPLOAD|#{dock}"
- client.send( msg )
- result = client.send_file(package, transporter)
- client.terminate
+
if not result then
- raise RuntimeError, "Uploading file failed!.. #{result}"
- else
- puts "Uploading file success!.. #{result}"
+ raise RuntimeError, "Uploading file failed!..."
end
end
puts job_error
result = false
end
- client.terminate
rescue => e
puts "ERROR: #{e}"
- client.terminate
exit 1
+ ensure
+ client.terminate if not client.nil?
end
# Query log in case sync
client.terminate
end
- # Query log in case sync
- if result then
- begin
- client = BuildCommClient.create( bs_ip, bs_port, nil, 0 )
- if client.nil? then
- puts "Can't access server #{bs_ip}:#{bs_port}"
- 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]
- else
- # print log
- puts line
- end
- end
+ if not result then exit(1) 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
+ # Query log in case sync
+ begin
+ result = JobLog.monitor(bs_ip, bs_port, job_id) do |line|
+ 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
- ensure
- client.terminate
end
- end
- if not result then
- exit 1
+ rescue BuildServerException => e
+ puts e.err_message()
+ result = false
end
+
+ if not result then exit(-1) end
+
else
raise RuntimeError, "input option incorrect : #{option[:cmd]}"
end
file_path = File.expand_path(file_path)
# send request
- success = false
- client = BuildCommClient.create( "127.0.0.1", server.port )
- if client.nil? then
- puts "Server is not running!"
- return false
- end
- if client.send "REGISTER|BINARY-LOCAL|#{file_path}|#{server.password}|#{dist_name}" then
- # recevie & print
- mismatched = false
- result = client.read_lines do |l|
- puts l
- if l.include? "Password mismatched!" then
- mismatched = true
- end
+ success = true
+ job_id = nil
+ job_status = nil
+ job_error = nil
+ result = false
+ begin
+ client = BuildCommClient.create( "127.0.0.1", server.port )
+ if client.nil? then
+ puts "Server is not running!"
+ return false
end
- if result and not mismatched then
- success = true
+ if client.send "REGISTER|BINARY-LOCAL|#{file_path}|#{server.password}|#{dist_name}" then
+ # recevie & print
+ result = client.read_lines do |l|
+ if l.strip.start_with?("=JOB_START") then
+ job_id = l.strip.split(",")[1]
+ elsif l.strip.start_with?("=JOB_STATUS") then
+ data = l.strip.split(",")
+ job_status = data[1]
+ job_error = data[2]
+ else
+ puts l
+ end
+ end
+ if not result then
+ puts "Error: Communication failed! #{client.get_error_msg()}"
+ elsif job_id.nil? then
+ puts job_error
+ result = false
+ end
end
+ rescue => e
+ puts "ERROR: #{e}"
+ result = false
+ ensure
+ client.terminate if not client.nil?
end
- # terminate
- client.terminate
-
- if not success then
+ if not result then
puts "Registering package failed!"
+ return false
end
- return true
+ begin
+ result = JobLog.monitor("127.0.0.1", server.port, job_id) do |line|
+ 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
+ rescue BuildServerException => e
+ puts e.err_message()
+ result = false
+ end
+
+ return result
end
# server
"ERR016" => "Can't received register file!",
"ERR017" => "Project locked!",
+ "ERR018" => "Connection failed!",
+ "ERR019" => "Receiving log data failed!",
+
"ERR900" => "Cancel event received!",
"ERR901" => "Job already upload status. Cancel failed!"
}
return category, level, contents
end
+
+
+ def JobLog.monitor(ip, port, job_id)
+
+ result = true
+ job_status = ""
+ begin
+ client = BuildCommClient.create( ip, port, nil, 0 )
+ if client.nil? then
+ raise BuildServerException.new("ERR018"), "#{ip}:#{port}"
+ 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]
+ else
+ if block_given? then
+ yield line.strip
+ else
+ puts line.strip
+ end
+ end
+ end
+
+ if not result then
+ raise BuildServerException.new("ERR019"), "#{client.get_error_msg()}"
+ end
+
+ # Check job status
+ if not job_status.eql? "FINISHED" then
+ result = false
+ end
+ ensure
+ client.terminate if not client.nil?
+ end
+
+ return result
+ end
end
handle_cmd_register_internal( line, req )
rescue BuildServerException => e
@log.error(e.message)
- BuildCommServer.send(req, e.err_message())
+ BuildCommServer.send(req, "=JOB_STATUS,ERROR,#{e.err_message()}")
BuildCommServer.send_end(req)
BuildCommServer.disconnect(req)
rescue => e
check_distribution(dist_name, req)
# check project
- prj = check_project_for_package_file_name(file_path, dist_name, req)
-
+ file_name = File.basename(file_path)
+ prj = check_project_for_package_file_name(file_name, 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()
- BuildCommServer.send_end(req)
- BuildCommServer.disconnect(req)
+ @parent_server.jobmgr.commit_job(new_job)
+ logger = new_job.create_logger()
+ # notify that job has been received
BuildCommServer.send(req, "=JOB_START,#{new_job.id}")
- BuildCommServer.send(req,"Info: Added new job \"#{new_job.id}\" for #{new_job.os}!")
+ logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
if not @parent_server.job_log_url.empty? then
- BuildCommServer.send(req,"Info: * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log")
+ logger.info( " * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
end
- BuildCommServer.send(req,"Info: Above job(s) will be processed asynchronously!")
+ BuildCommServer.send_end(req)
+ BuildCommServer.disconnect(req)
# add
@parent_server.jobmgr.add_job( new_job )
logger = new_job.create_logger()
# notify that job has been received
+ BuildCommServer.send(req, "=JOB_START,#{new_job.id}")
logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
if not @parent_server.job_log_url.empty? then
logger.info( " * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
# get package name
new_name = filename.sub(/(.*)_(.*)_(.*)\.zip/,'\1,\2,\3')
pkg_name = new_name.split(",")[0]
-
+puts "========> #{filename} , #{new_name}, #{pkg_name}"
prj = @parent_server.prjmgr.get_project_from_package_name(pkg_name, dist_name)
if prj.nil? then
raise BuildServerException.new("ERR013"), "#{pkg_name} #{dist_name}"
../../build-svr register -n testserver3 -D unstable -P bin/bin_0.0.0_ubuntu-32.zip
#POST-EXEC
#EXPECT
+Info: Added new job
Info: Initializing job...
Info: Checking package version ...
Info: Invoking a thread for REGISTER Job
Info: Upload succeeded. Sync local pkg-server again...
Info: Snapshot:
Info: Job is completed!
+Info: Job is FINISHED successfully!
Info: Upload succeeded. Sync local pkg-server again...
Info: Snapshot:
Info: Job is completed!
+Info: Job is FINISHED successfully!
+Info: Updating the source info for project "testbin"
#PRE-EXEC
#EXEC
-../../build-svr fullbuild -n testserver3 -D unstable2
+../../build-cli build -d 127.0.0.1:2223 -N testa,testb -o all -D unstable2 --rebuild
#POST-EXEC
#EXPECT
+Info: Added new job
Info: Initializing job...
Info: Invoking a thread for MULTI-BUILD Job
Info: New Job