[Title] Refactored the code for transfered job
authordonghee yang <donghee.yang@samsung.com>
Wed, 3 Apr 2013 13:42:51 +0000 (22:42 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Wed, 3 Apr 2013 13:42:51 +0000 (22:42 +0900)
src/build_server/BuildJob.rb
src/build_server/GitBuildJob.rb
src/build_server/ReverseBuildChecker.rb
src/build_server/SocketJobRequestListener.rb
test/build-server.multi-svr1/01.testcase
test/build-server.multi-svr1/02.testcase

index f1e9a011a7ad367aa965d07e60cb5422d313d02c..18c96545153c44e48fe49b513f8ae0e0690605ff 100644 (file)
@@ -45,8 +45,6 @@ class BuildJob < CommonJob
 
        attr_accessor :pkginfo, :source_path
        attr_accessor :pkgsvr_client
-#      attr_accessor :rev_fail_projects, :rev_success_jobs
-#      attr_accessor :pending_ancestor
        attr_accessor :no_reverse
        attr_accessor :remote_id, :remote_status, :remote_error_msg
 
@@ -57,7 +55,6 @@ class BuildJob < CommonJob
                @os = os
                @type = "BUILD"
 
-               #@resolve = false
                @host_os = Utils::HOST_OS
                if not @server.distmgr.nil? then
                        @pkgsvr_url = @server.distmgr.get_distribution(project.dist_name).pkgsvr_url
@@ -95,8 +92,10 @@ class BuildJob < CommonJob
                @is_rev_build_check_job = false
                @is_remote_job = false
 
-               # for internal(transferred) job
-               @is_internal_job = false
+               # "verified" means that server will not check any rule
+               @is_verified = false
+               # "send_result_back" mean that server will send package file by network
+               @send_result_back = false
                @dock_num = "0"
 
                @external_pkgs = []
@@ -154,18 +153,13 @@ class BuildJob < CommonJob
        end
 
 
-       def set_internal_job( dock_num )
-               @is_internal_job = true
+       def set_transfered_job( dock_num )
+               @is_verified = true
+               @send_result_back = true
                @dock_num = dock_num
        end
 
 
-       ## set option for waiting for resolve
-       #def set_resolve_flag()
-       #       @resolve = true
-       #end
-
-
        # set force rebuild
        # This make project to build
        # even though there is a package of same version on pkg-server
@@ -494,16 +488,15 @@ class BuildJob < CommonJob
                @log.info( "New Job #{@id} is started", Log::LV_USER)
 
                # checking build dependency
-               if not @is_remote_job and not @is_internal_job and
+               if not @is_remote_job and not @is_verified and
                        not check_build_dependency() then
-                       if @is_internal_job then copy_result_files_to_master() end
                        @status = "ERROR"
                        return false
                end
 
                # clean build
                if not build() then
-                       if @is_internal_job then copy_result_files_to_master() end
+                       if @is_verified then copy_result_files_to_master() end
 
                        @status = "ERROR"
                        return false
@@ -512,7 +505,7 @@ class BuildJob < CommonJob
                lock_event
 
                # upload
-               if not @is_rev_build_check_job and not @is_internal_job and
+               if not @is_rev_build_check_job and not @send_result_back and
                        @parent.nil? and
                        not upload() then
                        @status = "ERROR"
@@ -520,7 +513,7 @@ class BuildJob < CommonJob
                end
 
                # copy result files to transport path
-               if @is_internal_job then
+               if @send_result_back then
                        copy_result_files_to_master()
                elsif not @parent.nil? and not @is_rev_build_check_job then
                        copy_result_files(@parent.source_path)
@@ -639,50 +632,11 @@ class BuildJob < CommonJob
 
        # build clean
        def     build()
-
-               ## check there are pending packages which wait for me
-               ## it will return nil if not exist
-               ## this process must be skip if it is sub-job
-               #if not @is_rev_build_check_job and not @is_internal_job then
-               #       @server.cancel_lock.synchronize do
-               #               @pending_ancestor = get_pending_ancestor_job()
-               #       end
-               #end
-
-               #if not @pending_ancestor.nil? then
-               #       # resolve other pending job
-               #       resolve()
-               #elsif @resolve then
-               #       # wait for being resolved by other jobs
-               #       # this condition must be placed after checking pending status
-               #       wait_resolve()
-               #else
-               #       # build
-               #       build_normal()
-               #end
-
                # build
                build_normal()
        end
 
 
-       ## return pending job that wait for me
-       #def get_pending_ancestor_job()
-       #       @server.jobmgr.get_pending_jobs.each do |job|
-       #               # must have same distribution
-       #               if get_distribution_name() != job.get_distribution_name() then
-       #                       next
-       #               end
-
-       #               if job.is_rev_fail_project(@project,@os) then
-       #                       return job
-       #               end
-       #       end
-
-       #       return nil
-       #end
-
-
        # check whether build this job or not
        # if not build, then return its compat pkgs list
        def check_compatable_packages
@@ -815,7 +769,7 @@ class BuildJob < CommonJob
                # check reverse dependecy if not sub jobs
 
                if not @no_reverse then
-                       if not @is_rev_build_check_job and not @is_internal_job and
+                       if not @is_rev_build_check_job and not @is_verified and
                                not ReverseBuildChecker.check( self, true ).empty? then
                                @log.error( "Reverse-build-check failed!" )
                                return false
@@ -869,6 +823,9 @@ class BuildJob < CommonJob
        # copy binary package files and log file to transport dir
        def copy_result_files_to_master()
                outgoing_dir = "#{@server.transport_path}/#{@dock_num}"
+               if not File.exist? outgoing_dir then
+                       FileUtils.mkdir_p outgoing_dir
+               end
 
                @log.info( "Copying log to #{outgoing_dir}", Log::LV_USER)
                file = "#{@source_path}/../log"
index 87fb076b1c141242b80d30d278f24f0d42898c36..db1a18495e3dc18f0856892673d9174661677931 100644 (file)
@@ -127,7 +127,7 @@ class GitBuildJob < BuildJob
                @log.info( "Initializing job...", Log::LV_USER)
 
                # if internal job, copy external_pkgs
-               if @is_internal_job then
+               if not @external_pkgs.empty? then
                        @log.info( "Copying external dependent pkgs...", Log::LV_USER)
                        ext_pkgs_dir = "#{@job_root}/external_pkgs"
 
@@ -165,7 +165,7 @@ class GitBuildJob < BuildJob
                @pkgsvr_client =  Client.new(@pkgsvr_url, @job_working_dir, @log)
 
                # checking version if not reverse-build job or not internal-job
-               if not @is_rev_build_check_job and not @is_internal_job  then
+               if not @is_rev_build_check_job and not @is_verified then
 
                        #check change log
                        change_log = {}
index 9b61cbc90b779214afb482fd947a7ca6c77e6334..7f6e3207425920f747607b01fc50fdaa5c6c3523 100644 (file)
@@ -82,22 +82,6 @@ class ReverseBuildChecker
                        if rev_prj.type != "GIT" then next end
                        found = false
 
-                       ## if job on resolve process, its unresolved project
-                       ##of pending ancestor must be excluded.
-                       #if job.type == "BUILD" and not job.pending_ancestor.nil? then
-                       #       found = false
-                       #       job.pending_ancestor.rev_fail_projects.each do  |fp|
-                       #               f_prj = fp[0]
-                       #               f_os =  fp[1]
-
-                       #               if rev_prj == f_prj and rev_os == f_os then
-                       #                       found = true
-                       #                       break
-                       #               end
-                       #       end
-                       #       if found then next end
-                       #end
-
                        # if this is sub job, all other sibling job must be excluded
                        if job.is_sub_job? then
                                job.get_parent_job().get_sub_jobs().each do |sub_job|
index ec7a4f586893b8ed3e1c6f9b945093b652c5914d..80ce94010f1e75a1190ed17debd959627907d567 100644 (file)
@@ -125,8 +125,6 @@ class SocketJobRequestListener
                case  cmd
                when "BUILD"
                        handle_cmd_build( req_line, req )
-               #when "RESOLVE"
-               #       handle_cmd_resolve( req_line, req )
                when "QUERY"
                        handle_cmd_query( req_line, req )
                when "CANCEL"
@@ -280,7 +278,7 @@ class SocketJobRequestListener
                        git_repos = project_name_list[0]
                        os = os_list[0]
 
-                       new_job = create_new_internal_job(git_repos, os, git_commit, pkg_files, dock_num, dist_name )
+                       new_job = create_new_transfered_job(git_repos, os, git_commit, pkg_files, dock_num, dist_name )
                        if new_job.nil? then
                                raise BuildServerException.new("ERR006"),"Transfered-Build job"
                        else
@@ -1069,13 +1067,13 @@ class SocketJobRequestListener
 
 
        private
-       def create_new_internal_job( git_repos, os, git_commit, pkg_files, dock_num, dist_name )
+       def create_new_transfered_job( git_repos, os, git_commit, pkg_files, dock_num, dist_name )
                prj = @parent_server.prjmgr.get_git_project( git_repos, dist_name )
                if prj.nil? then
                        prj = @parent_server.prjmgr.create_unnamed_git_project( git_repos, dist_name )
                end
                new_job = prj.create_new_job(os)
-               new_job.set_internal_job( dock_num )
+               new_job.set_transfered_job( dock_num )
                new_job.git_commit = git_commit
                incoming_dir = "#{@parent_server.transport_path}/#{dock_num}"
                pkg_files.each do |file|
index 7e1da68cf0acd7df58c4c16204e5aaf519132b61..dde9eb89249405b01ec7ffe9a53caa0a90f5f898 100644 (file)
@@ -14,7 +14,6 @@ Info: Start to build on remote server...
 Info: Sending build request to remote server...
 Info: Added new job
 Info: Initializing job...
-Info: Copying external dependent pkgs...
 Info: Invoking a thread for building Job
 Info: New Job
 Info: Started to build this job...
index d8cf450b397d5f002b707c2d3a2c948835bc292a..505bde0caad9964254455680063cbe5f42e7a76b 100644 (file)
@@ -14,7 +14,6 @@ Info: Start to build on remote server...
 Info: Sending build request to remote server...
 Info: Added new job
 Info: Initializing job...
-Info: Copying external dependent pkgs...
 Info: Invoking a thread for building Job
 Info: New Job
 Info: Started to build this job...