[Title] Modified to be able to change MAX_WORKING_JOBS of No DB
authordonghee yang <donghee.yang@samsung.com>
Tue, 23 Apr 2013 10:06:30 +0000 (19:06 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Tue, 23 Apr 2013 10:06:30 +0000 (19:06 +0900)
src/build_server/BuildServerController.rb
src/build_server/JobManager.rb
test/build-server.basic2/build-svr-24.testcase [new file with mode: 0644]
test/build-server.basic2/testsuite
test/build-server.multi-svr1/buildsvr1.init

index 14fc8e5ab3b38b6b860cf27c660fc9837db2f473..b8a50a746ba37ef87b8ee25236d07e68b3bacb46 100644 (file)
@@ -786,7 +786,8 @@ class BuildServerController
                        attr != "FTP_ADDR" and attr != "FTP_PORT" and 
                        attr != "FTP_USERNAME" and attr != "FTP_PASSWD" and 
                        attr != "DB_DSN" and attr != "DB_USER" and
-                       attr != "DB_PASSWD" and attr != "PASSWORD" then
+                       attr != "DB_PASSWD" and attr != "PASSWORD" and
+                       attr != "MAX_WORKING_JOBS" then
 
                        puts BuildServerException.get_message("ERR021")
                        return false
@@ -858,7 +859,8 @@ class BuildServerController
                        attr != "FTP_ADDR" and attr != "FTP_PORT" and 
                        attr != "FTP_USERNAME" and attr != "FTP_PASSWD" and 
                        attr != "DB_DSN" and attr != "DB_USER" and
-                       attr != "DB_PASSWD" and attr != "PASSWORD" then
+                       attr != "DB_PASSWD" and attr != "PASSWORD" and 
+                       attr != "MAX_WORKING_JOBS" then
 
                        puts BuildServerException.get_message("ERR021")
                        return false
@@ -941,6 +943,9 @@ class BuildServerController
                        f.puts "DB_DSN=#{server.db_dsn}"
                        f.puts "DB_USER=#{server.db_user}"
                        f.puts "DB_PASSWORD=#{server.db_passwd}"
+                       if not server.has_db? then
+                               f.puts "MAX_WORKING_JOBS=#{server.jobmgr.max_working_jobs}"
+                       end
                end
        end
 
@@ -960,6 +965,7 @@ class BuildServerController
                db_dsn=nil
                db_user=nil
                db_passwd=nil
+               max_working_jobs=2
 
                # read configuration
                server_dir = "#{BuildServer::CONFIG_ROOT}/#{id}"
@@ -1004,6 +1010,8 @@ class BuildServerController
                                        if not l[idx,length].strip.eql? id then
                                                raise RuntimeError, "Server configuration FAILED: #{server_dir}/server.cfg: ID must be \"#{id}\""
                                        end
+                               elsif l.start_with?("MAX_WORKING_JOBS=")
+                                       max_working_jobs = l[idx,length].strip.to_i
                                else
                                        next
                                end
@@ -1039,6 +1047,11 @@ class BuildServerController
                obj.db_user = db_user
                obj.db_passwd = db_passwd
 
+               # max working jobs
+               if not obj.has_db? then
+                       obj.jobmgr.max_working_jobs =  max_working_jobs
+               end
+
                # save config
                #write_server_config( obj )
 
index 7c288b64f72ccbeba0a38a3fa40c9426f61c28c2..c8b151d92ae7e899e7fd6c19e9b797afc513c66e 100644 (file)
@@ -48,6 +48,7 @@ class JobManager
                @new_job_index = 0
                @internal_job_schedule = Mutex.new
                @latest_job_touch = Mutex.new
+               @max_build_jobs = 2
        end
 
        def cancel_broken_status
@@ -57,19 +58,28 @@ class JobManager
        end
 
        def max_working_jobs
-               result = nil
-               @server.get_db_connection() do |db|
-                       result = db.select_one("SELECT value FROM server_configs WHERE property = 'max_working_jobs'")[0]
+               if @server.has_db? then
+                       result = nil
+                       @server.get_db_connection() do |db|
+                               result = db.select_one("SELECT value FROM server_configs WHERE property = 'max_working_jobs'")[0]
+                       end
+                       @max_build_jobs = result.to_i if not result.nil?
                end
-               return (result.nil?) ? 2 : result.to_i
+
+               return @max_build_jobs
        end
 
        def max_working_jobs=(job_cnt)
-               @server.get_db_connection() do |db|
-                       db.do "UPDATE server_configs SET value = '#{job_cnt}' WHERE property = 'max_working_jobs'"
+               @max_build_jobs = job_cnt
+
+               if @server.has_db? then
+                       @server.get_db_connection() do |db|
+                               db.do "UPDATE server_configs SET value = '#{@max_build_jobs}' WHERE property = 'max_working_jobs'"
+                       end
                end
        end
 
+
        # initialize
        def init()
                # load latest job idx if exist
diff --git a/test/build-server.basic2/build-svr-24.testcase b/test/build-server.basic2/build-svr-24.testcase
new file mode 100644 (file)
index 0000000..895215a
--- /dev/null
@@ -0,0 +1,12 @@
+#PRE-EXEC
+rm -rf buildsvr01
+mkdir buildsvr01
+cd buildsvr01; ../../../build-svr create -n testserver3 -u `pwd`/../pkgsvr01/unstable -d 127.0.0.1:3333 -t ftp://ftpuser:ftpuser@172.21.111.124
+#EXEC
+../../build-svr set-attr -n testserver3 -A MAX_WORKING_JOBS -V 3
+../../build-svr get-attr -n testserver3 -A MAX_WORKING_JOBS
+#POST-EXEC
+../../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+3
index 3b9851334a44c6c785ba5b4f546a0e5d3485aa78..d6a63c3c0f982ef63105eb0db50b298358534943 100644 (file)
@@ -18,3 +18,4 @@ build-svr-19.testcase
 build-svr-20.testcase
 build-svr-21.testcase
 build-svr-23.testcase
+build-svr-24.testcase
index d333a1826f2f8c76d1caf17ca92530b425cf5e9b..e4d9802aa513657b7fe5f0a0b549453694d8c9d7 100755 (executable)
@@ -32,7 +32,7 @@ ${RUBY} ../../build-svr add-os -n testserver3 -o ubuntu-32
 ${RUBY} ../../build-svr add-os -n testserver3 -o windows-32
 ${RUBY} ../../build-svr add-prj -n testserver3 -N testa -g `pwd`/git01/a -b master
 ${RUBY} ../../build-svr add-prj -n testserver3 -N testb -g `pwd`/git01/b -b master
-${RUBY} ../../build-svr set-attr -n testserver3 -A MAX_WORKING_JOBS -V 1
+${RUBY} ../../build-svr set-attr -n testserver3 -A MAX_WORKING_JOBS -V 0
 
 mkdir -p git01
 cp ../git01/*.tar.gz git01/