[Title] Fixed not to process redundent jobs
authordonghee yang <donghee.yang@samsung.com>
Thu, 11 Apr 2013 06:58:36 +0000 (15:58 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Thu, 11 Apr 2013 06:58:36 +0000 (15:58 +0900)
src/build_server/BuildJob.rb
src/build_server/GitBuildJob.rb
src/build_server/JobManager.rb
src/build_server/MultiBuildJob.rb
src/build_server/RegisterPackageJob.rb
test/build-server.basic1/build-cli-36.testcase [new file with mode: 0644]
test/build-server.basic1/testsuite
test/build-server.multi_dist2/build-svr3-06.testcase [new file with mode: 0644]
test/build-server.multi_dist2/testsuite

index b30c75f887afdcccd2f0ed909fc84c517e4ac168..7985461302f5e3e072407dc241b84a333a147304 100644 (file)
@@ -260,6 +260,31 @@ class BuildJob < CommonJob
        end
 
 
+       def is_same_with?(wjob)
+               # must have same distribution
+               if get_distribution_name() != wjob.get_distribution_name() then
+                       return false
+               end
+
+               if @type != wjob.type then return false end
+
+               prj1 = get_project()
+               prj2 = wjob.get_project()
+
+               # check project name
+               if prj1.nil? or prj2.nil? or
+                       prj1.name != prj2.name then
+                       return false
+               end
+
+               # check version
+               if @pkginfo.nil? or wjob.pkginfo.nil? or
+                       not(Version.new(@pkginfo.get_version()) == Version.new(wjob.pkginfo.get_version())) then
+                       return false
+               end
+       end
+
+
        def is_compatible_with?(o)
                # must have same distribution
                if get_distribution_name() != o.get_distribution_name() then
index b68d60bc62873d343fb534d8526258b4f8bf4a4f..715f3a8823c1fac93ae9327234cbdb9361bda634 100644 (file)
@@ -204,6 +204,40 @@ class GitBuildJob < BuildJob
        end
 
 
+       def is_same_with?(wjob)
+               # must have same distribution
+               if get_distribution_name() != wjob.get_distribution_name() then
+                       return false
+               end
+               if @type != wjob.type then return false end
+
+               prj1 = @project
+               prj2 = wjob.get_project()
+
+               # check project name
+               if prj1.nil? or prj2.nil? or
+                       prj1.name != prj2.name then
+                       return false
+               end
+
+               # check version
+               if @pkginfo.nil? or wjob.pkginfo.nil? or
+                       not(Version.new(@pkginfo.get_version()) == Version.new(wjob.pkginfo.get_version())) then
+                       return false
+               end
+
+               if @git_commit != wjob.git_commit then return false end
+
+               # check compat os
+               wjob.pkginfo.get_target_packages(wjob.os).each do |p|
+                       if not p.os_list.include?(@os) then return false end
+               end
+
+
+               return true
+       end
+
+
        #
        # PROTECTED/PRIVATE METHODS
        #
index 5bfbf409bd7664a5c4bf275eeda02fbc4d5d65e9..8fe82bfbceaaabdf74a1df2b753becbc1ae68a85 100644 (file)
@@ -312,6 +312,9 @@ class JobManager
                        end
                end
 
+               # remove duplicated jobs
+               remove_duplicated_jobs()
+
                # reverse build job ->  internal job -> normal job
                job = get_available_job
 
@@ -344,6 +347,29 @@ class JobManager
                @reverse_build_jobs.delete_if {|j| j.id == job.id}
        end
 
+
+       # will remove redundent jobs
+       def remove_duplicated_jobs()
+               @jobs.reverse.each do |j1|
+                       if j1.status != "WAITING" then next end
+
+                       @jobs.each do |j2|
+                               if j1.id == j2.id then next end
+                               if j2.status != "WAITING" and j2.status != "WORKING" and
+                                       j2.status != "REMOTE_WORKING" then 
+                                       next    
+                               end
+
+                               if j1.is_same_with?(j2) then
+                                       j1.log.error("There already exists same job. (#{j2.id})", Log::LV_USER)
+                                       j1.status = "ERROR"
+                                       break
+                               end
+                       end     
+               end
+       end
+
+
        # select the job whith no build-dependency problem
        def get_available_job
                # select reverse build job with round-robin method
index 7076642e7b3e5b103cbe74f8ffd1ef7a5ad0ac30..89e2020e7430e2555f91db0bc47c4052880dc015 100644 (file)
@@ -252,6 +252,11 @@ class MultiBuildJob < CommonJob
        end
 
 
+       def is_same_with?(o)
+               return false
+       end
+
+
        def is_compatible_with?(o)
                return false
        end
index 394890186adb6d82d979bf527d5f4e12b0845327..745aba7dc8b1e205bd2bc8db1f768512dde224d1 100644 (file)
@@ -44,7 +44,7 @@ class RegisterPackageJob < CommonJob
 
        attr_accessor :source_path
        attr_accessor :pkgsvr_client, :pkg_type
-       attr_accessor :pkg_name, :pkginfo
+       attr_accessor :pkg_name, :pkginfo, :pkg_version
        attr_accessor :no_reverse
 
 
@@ -80,6 +80,7 @@ class RegisterPackageJob < CommonJob
                else
                        @pkg_type = "ARCHIVE"
                        @pkg_name = @filename
+                       @pkg_version = "0"
                end
                @pkginfo = nil #This info is valid only for BINARY package
                @project = project
@@ -118,6 +119,17 @@ class RegisterPackageJob < CommonJob
                @no_reverse = true
        end
 
+
+       def set_send_result_back( dock_num )
+               # do nothing
+       end
+
+
+       def is_send_result_back?
+               return false
+       end
+
+
        def execute_shell(cmd)
                # if canceled, must prevent invoking more process
                check_event
@@ -261,6 +273,30 @@ class RegisterPackageJob < CommonJob
        end
 
 
+       def is_same_with?(wjob)
+               # must have same distribution
+               if get_distribution_name() != wjob.get_distribution_name() then
+                       return false
+               end
+
+               if @type != wjob.type then return false end
+
+               case @pkg_type
+               when "BINARY"
+                       if @pkg_name == wjob.pkg_name and
+                               @pkg_version == wjob.pkg_version and
+                               wjob.pkginfo.packages.count == 1 and
+                               wjob.pkginfo.packages[0].os_list.include?(@os) then
+                               return true
+                       end
+               when "ARCHIVE"
+                       if @pkg_name == wjob.pkg_name then return true end
+               end
+
+               return false
+       end
+
+
        def is_compatible_with?(o)
                return false
        end
diff --git a/test/build-server.basic1/build-cli-36.testcase b/test/build-server.basic1/build-cli-36.testcase
new file mode 100644 (file)
index 0000000..7b13cdb
--- /dev/null
@@ -0,0 +1,13 @@
+#PRE-EXEC
+echo "This case will check redundent job"
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 --rebuild &
+#EXEC
+sleep 2
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32 --rebuild
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Info: Checking package version ...
+Error: There already exists same job.
+Error: Building job on remote server failed!
index 282784b0245e8bd8c1f2e828109d6c56952b471b..cfbf416d7c2a8b61011267744e0ed4c0ce8c3621 100644 (file)
@@ -33,3 +33,4 @@ build-cli-32.testcase
 build-cli-33.testcase
 build-cli-34.testcase
 build-cli-35.testcase
+build-cli-36.testcase
diff --git a/test/build-server.multi_dist2/build-svr3-06.testcase b/test/build-server.multi_dist2/build-svr3-06.testcase
new file mode 100644 (file)
index 0000000..d939dda
--- /dev/null
@@ -0,0 +1,12 @@
+#PRE-EXEC
+echo "Will check duplicated registration" 
+../../build-svr register -n testserver3 -D unstable -P bin/bin_0.0.1_ubuntu-32.zip &
+#EXEC
+sleep 1
+../../build-svr register -n testserver3 -D unstable -P bin/bin_0.0.1_ubuntu-32.zip
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Info: Checking package version ...
+Error: There already exists same job.
index 9f25506b3235086d40f162d15ad532e9441d731f..e306053ad9c98f8a70e6e0a7fb9a5fb568c12e1f 100644 (file)
@@ -3,3 +3,4 @@ build-svr3-02.testcase
 build-svr3-03.testcase
 build-svr3-04.testcase
 build-svr3-05.testcase
+build-svr3-06.testcase