[Title] fix multi server build
authorjiil.hyoun <jiil.hyoun@samsung.com>
Mon, 26 Nov 2012 12:15:38 +0000 (21:15 +0900)
committerjiil.hyoun <jiil.hyoun@samsung.com>
Mon, 26 Nov 2012 12:15:38 +0000 (21:15 +0900)
[Type] Bugfix
[Module] Toolchain /
[Priority] Major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: Ibbcf0da6e016207ae499426d78ab39d4080d9000

src/build_server/BuildJob.rb
src/build_server/BuildServerController.rb
src/build_server/CommonJob.rb
src/build_server/ProjectManager.rb
src/build_server/SocketJobRequestListener.rb

index c94f4ff4913e06868a98352062e1902f85a6bb33..c5d6843caf8601ed2d2473a92911698011673897 100644 (file)
@@ -138,6 +138,9 @@ class BuildJob < CommonJob
        def set_remote_job(server)
                @is_remote_job = true
                @remote_server=server
+               @server.get_db_connection() do |db|
+                       db.do "UPDATE jobs SET remote_build_server_id = '#{server.id}' WHERE id = '#{@id}'"
+               end
        end
 
 
index c5c274f379e12e98bc22e2062b8a853a4fae0843..efdd61553815ac53759ab6ac0e7795d9ec4fc836 100644 (file)
@@ -713,10 +713,18 @@ class BuildServerController
                case attr
                when "GIT_BIN_PATH"
                        server.git_bin_path = value
+               when "MAX_WORKING_JOBS"
+                       server.jobmgr.max_working_jobs = value.to_i
+               when "JOB_LOG_URL"
+                       server.job_log_url = value
+               when "SEND_MAIL"
+                       server.send_mail = value
                when "TEST_TIME"
                        server.test_time = value.to_i
                when "PASSWORD"
                        server.password = value
+               when "JOB_KEEP_TIME"
+                       server.keep_time = value.to_i
                when "FTP_ADDR"
                        server.ftp_addr = value
                when "FTP_PORT"
@@ -725,16 +733,18 @@ class BuildServerController
                        server.ftp_username = value
                when "FTP_PASSWD"
                        server.ftp_passwd = value
+               when "CHANGELOG_CHECK"
+                       server.changelog_check = value
                when "DB_DSN"
                        case value
                        when /^SQLite3:(.*)/i then
-                               if $1.strip.empty? then db_dsn = "SQLite3:#{BuildServer::CONFIG_ROOT}/#{@id}/server.db"
+                               if $1.strip.empty? then db_dsn = "SQLite3:#{BuildServer::CONFIG_ROOT}/#{id}/server.db"
                                else db_dsn = "SQLite3:#{$1.strip}"
                                end
                        when /^Mysql:(.*)/i then
                                db_dsn = "Mysql:#{$1}"
                        else
-                               db_dsn = "SQLite3:#{BuildServer::CONFIG_ROOT}/#{@id}/server.db"
+                               db_dsn = "SQLite3:#{BuildServer::CONFIG_ROOT}/#{id}/server.db"
                        end
                        server.db_dsn = db_dsn
                when "DB_USER"
index 52fdbbc3ef1609038702920daa15b20f8ae3de5e..dc84f9503357f53ac04a29d312ef27920b16f10d 100644 (file)
@@ -68,6 +68,12 @@ class CommonJob
        public
        def set_parent_job( parent )
                @parent = parent
+
+               if not parent.nil? then
+                       @server.get_db_connection() do |db|
+                               db.do "UPDATE jobs SET parent_job_id = #{parent.id} WHERE id = #{@id}"
+                       end
+               end
        end
 
 
@@ -235,8 +241,7 @@ class CommonJob
                                source_id = @project.get_source_id_from_ver(pkginfo.get_version(),db)
                                db.do "UPDATE jobs SET source_id=#{source_id} WHERE id=#{@id}"
                        end
-                       db.do "UPDATE jobs SET status='#{@status}',remote_build_server_id=#{remote_bs_id} 
-                               WHERE id=#{@id}"
+                       db.do "UPDATE jobs SET status='#{@status}',remote_build_server_id=#{remote_bs_id} WHERE id=#{@id}"
                        if @status == "FINISHED" or @status == "ERROR" or @status == "CANCELED" then
                                @end_time = Time.now.strftime("%F %T")
                                db.do "UPDATE jobs SET end_time=#{now} WHERE id=#{@id}"
index 6b13a1b2c7558c5fbbca4c6689f91bb3e9da3164..25a498e1142f788cfb0e74be72cf145f2f1e3f30 100644 (file)
@@ -283,6 +283,9 @@ class ProjectManager
                branch = "master"
                passwd = nil
                os_list = Utils.get_all_OSs()
+               os_list.each do |os|
+                       @server.add_supported_os(os)
+               end
                # add
                add_git_project(name , repos, branch, passwd, os_list, dist_name)
                # get
index a8975b571663c31032782c8a9c5305ab50bae94c..3030f7d322113c29533ac0822135006f0372f533 100644 (file)
@@ -221,6 +221,16 @@ class SocketJobRequestListener
                                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!"
+               end
+
                # multi build job
                if project_name_list.count > 1 or os_list.count > 1 then
                        new_job_list = []
@@ -234,6 +244,8 @@ class SocketJobRequestListener
                                        if new_job.nil? then
                                                @log.warn "\"#{pname}\" does not support #{os}"
                                                next
+                                       else
+                                               new_job.user_id = user_id
                                        end
                                        new_job_list.push new_job
                                        @log.info "Received a request for building this project : #{pname}, #{os}"
@@ -243,6 +255,11 @@ 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!"
+                               else
+                                       new_job.user_id = user_id
+                               end
                        elsif new_job_list.count == 1 then
                                new_job = new_job_list[0]
                        else
@@ -255,6 +272,11 @@ class SocketJobRequestListener
                        os = os_list[0]
 
                        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!"
+                       else
+                               new_job.user_id = user_id
+                       end
                        if rev_job then new_job.set_rev_build_check_job(nil) end
 
                        # single job
@@ -264,6 +286,11 @@ class SocketJobRequestListener
 
                        check_build_project(pname,passwd,dist_name,req)
                        new_job = create_new_job( pname, os, dist_name )
+                       if new_job.nil? then
+                               raise "\"#{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!"
@@ -271,17 +298,6 @@ class SocketJobRequestListener
                        raise "No valid jobs!"
                end
 
-               # check user email
-               user_id = @parent_server.check_user_id_from_email( user_email )
-               if user_id != -1 then
-                       new_job.user_id = user_id
-               else
-                       BuildCommServer.send_begin(req)
-                       req.puts "Error: Cannot find the user with \"#{user_email}\"!"
-                       BuildCommServer.send_end(req)
-                       raise "No user information!"
-               end
-
                # check reverse build
                if no_reverse then new_job.set_no_reverse end