Fixed a bug that "sync" register invokes "dup-register" 18/15718/1
authordonghee yang <donghee.yang@samsung.com>
Mon, 27 Jan 2014 13:40:24 +0000 (22:40 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Mon, 27 Jan 2014 13:40:24 +0000 (22:40 +0900)
[Description]

Change-Id: I570146c34a1e8f2263c2825353dad038d0d66a5f
Signed-off-by: donghee yang <donghee.yang@samsung.com>
src/build_server/PackageSync.rb
src/pkg_server/client.rb
test/bin/bin_0.0.2_ubuntu-32.zip [new file with mode: 0644]
test/bin/bin_0.0.2_windows-32.zip [new file with mode: 0644]
test/build-server.multi-svr2/02.testcase [new file with mode: 0644]
test/build-server.multi-svr2/buildsvr.init
test/build-server.multi-svr2/testsuite2 [new file with mode: 0644]

index fe666b8280364f63d9ef965e99c96479bc321acf..d17036450edf1145d2e1f45d22d772a2757cfd03 100644 (file)
@@ -112,7 +112,6 @@ class PackageSyncAction < Action
 
                        file_paths.each do |file_path|
                                @server.log.info "Creating new job for registering \"#{file_path}\""
-                prj = @server.prjmgr.get_project_from_package_name( pkg_name, @dist_name )
                                new_job = prj.create_new_job_from_local_file( file_path )
                                if new_job.nil? then
                                        @server.log.error "Creating job failed: #{prj.name} #{pkg_name} #{@dist_name}"
@@ -165,14 +164,19 @@ class PackageSyncAction < Action
                }
                bin_prjs.each do  |p|
                        pkg_name = p.pkg_name
+            compat_pkgs = []
                        p.os_list.each do  |os|
                                # get pkg version in server
                                main_ver = @main_client.get_attr_from_pkg(pkg_name, os, "version")
-                               remote_ver = @pkgsvr_client.get_attr_from_pkg(pkg_name, os, "version")
+                               remote_pkg = @pkgsvr_client.get_pkg_from_list(pkg_name, os)
+                               remote_ver = remote_pkg.version
                                if remote_ver.nil? then next end
 
                                if main_ver.nil? or Version.new(main_ver) < Version.new(remote_ver) then
-                                       pkgs.push [pkg_name, os, p]
+                    if (compat_pkgs.index { |pkg| remote_pkg.size == pkg[0] and remote_pkg.checksum == pkg[1] } ) == nil  then
+                                           pkgs.push [pkg_name, os, p]
+                        compat_pkgs.push [remote_pkg.size, remote_pkg.checksum]
+                    end
                                end
                        end
                end
index b587e4a0b4c8602c55dc7c1878849939e5d0c9dc..79d4658fd9667c5ccd0270f54c3cb4309c1b84c3 100644 (file)
@@ -1525,6 +1525,7 @@ class Client
         when "version" then return pkg.version
         when "src_path" then return pkg.src_path
         when "os" then return pkg.os
+        when "os_list" then return pkg.os_list
         when "build_dep_list" then return pkg.build_dep_list
         when "install_dep_list" then return pkg.install_dep_list
         when "attribute" then return pkg.attribute
diff --git a/test/bin/bin_0.0.2_ubuntu-32.zip b/test/bin/bin_0.0.2_ubuntu-32.zip
new file mode 100644 (file)
index 0000000..642e31a
Binary files /dev/null and b/test/bin/bin_0.0.2_ubuntu-32.zip differ
diff --git a/test/bin/bin_0.0.2_windows-32.zip b/test/bin/bin_0.0.2_windows-32.zip
new file mode 100644 (file)
index 0000000..642e31a
Binary files /dev/null and b/test/bin/bin_0.0.2_windows-32.zip differ
diff --git a/test/build-server.multi-svr2/02.testcase b/test/build-server.multi-svr2/02.testcase
new file mode 100644 (file)
index 0000000..f612716
--- /dev/null
@@ -0,0 +1,67 @@
+#PRE-EXEC
+#EXEC
+../../pkg-svr register -n pkgsvr02 -d unstable -P bin/bin_0.0.2_ubuntu-32.zip
+../../pkg-svr register -n pkgsvr02 -d unstable -P bin/bin_0.0.2_windows-32.zip
+sleep 50
+../../pkg-cli list-rpkg -P bin -u `pwd`/pkgsvr01/unstable -o ubuntu-32
+../../pkg-cli list-rpkg -P bin -u `pwd`/pkgsvr01/unstable -o windows-32
+../../build-cli build -N testa -d 127.0.0.1:2223 -o ubuntu-32  -U admin@user -w 1234
+#POST-EXEC
+#EXPECT
+Archive:  bin/bin_0.0.2_ubuntu-32.zip
+inflating:
+snapshot is generated :
+package registed successfully
+Archive:  bin/bin_0.0.2_windows-32.zip
+inflating:
+snapshot is generated :
+package registed successfully
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+bin  (0.0.2)
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+I, [
+bin  (0.0.2)
+Info: Added new job "2" for ubuntu-32!
+Info: Initializing job...
+Info: Checking package version ...
+Info: Invoking a thread for building Job 2
+Info: New Job 2 is started
+Info: Checking build dependency ...
+Info: Checking install dependency ...
+Info: Started to build this job...
+Info: JobBuilder#2 is created
+Info: Downloding client is initializing...
+Info: Installing dependent packages...
+Info: Downloading dependent source packages...
+Info: Make clean...
+Info: Make build...
+Info: Make install...
+Info: Generatiing pkginfo.manifest...
+Info: Zipping...
+Info: Creating package file ... a_0.0.1_ubuntu-32.zip
+Info: Checking reverse build dependency ...
+Info: Uploading ...
+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 "testa"
index fd6a79c9e1d77e383960930fe00da3418b8dcb1e..dc61c8711bbd1bd1cbe92cf8878ff1202a4e7f65 100755 (executable)
@@ -28,9 +28,24 @@ cd ..
 ${RUBY} ../../build-svr add-dist -n testserver3 -D unstable -u `pwd`/pkgsvr01/unstable -d 127.0.0.1:3333
 ${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 teste -P bin -D unstable -o ubuntu-32
+${RUBY} ../../build-svr add-prj -n testserver3 -N testa -g `pwd`/git01/a -b master
+${RUBY} ../../build-svr add-prj -n testserver3 -N teste -P bin -D unstable -o ubuntu-32,windows-32
 ${RUBY} ../../build-svr add-sync -n testserver3 -u `pwd`/pkgsvr02/unstable -D unstable
 
+mkdir -p git01
+cp ../git01/*.tar.gz git01/
+cd git01
+rm -rf a
+rm -rf a1
+rm -rf b
+rm -rf c
+rm -rf d
+tar xvf a_v1.tar.gz
+tar xvf b_v1.tar.gz
+tar xvf c_v1.tar.gz
+tar xvf d_v0.tar.gz
+tar xvf a1_v1.tar.gz
+cd ..
 mkdir -p bin
 cp ../bin/*.zip ./bin/
 
diff --git a/test/build-server.multi-svr2/testsuite2 b/test/build-server.multi-svr2/testsuite2
new file mode 100644 (file)
index 0000000..a170772
--- /dev/null
@@ -0,0 +1 @@
+02.testcase