@@ -417,6 +417,54 @@ func (s *OssUploadSuite) TestUploadRoutineWithRecovery(c *C) {
417417 c .Assert (err , IsNil )
418418}
419419
420+ // TestUploadRoutineWithEmptyCheckPoint is multi-routine upload with empty check point
421+ func (s * OssUploadSuite ) TestUploadRoutineWithEmptyCheckPoint (c * C ) {
422+ objectName := objectNamePrefix + RandStr (8 )
423+ fileName := "../sample/BingWallpaper-2015-11-07.jpg"
424+ newFile := "upload-new-file-2.jpg"
425+
426+ // Use default routines and default CP file path
427+ // First upload for 4 parts
428+ uploadPartHooker = ErrorHooker
429+ err := s .bucket .UploadFile (objectName , fileName , 100 * 1024 , Checkpoint (true , "" ))
430+ c .Assert (err , NotNil )
431+ c .Assert (err .Error (), Equals , "ErrorHooker" )
432+ uploadPartHooker = defaultUploadPart
433+ // Check CP
434+ ucp := uploadCheckpoint {}
435+ cpConf := cpConfig {IsEnable : true , FilePath : "" }
436+ cpFilePath := getUploadCpFilePath (& cpConf , fileName , s .bucket .BucketName , objectName )
437+ err = ucp .load (cpFilePath )
438+ c .Assert (err , IsNil )
439+ c .Assert (ucp .Magic , Equals , uploadCpMagic )
440+ c .Assert (len (ucp .MD5 ), Equals , len ("LC34jZU5xK4hlxi3Qn3XGQ==" ))
441+ c .Assert (ucp .FilePath , Equals , fileName )
442+ c .Assert (ucp .FileStat .Size , Equals , int64 (482048 ))
443+ c .Assert (len (ucp .FileStat .LastModified .String ()) > 0 , Equals , true )
444+ c .Assert (ucp .FileStat .MD5 , Equals , "" )
445+ c .Assert (ucp .ObjectKey , Equals , objectName )
446+ c .Assert (len (ucp .UploadID ), Equals , len ("3F79722737D1469980DACEDCA325BB52" ))
447+ c .Assert (len (ucp .Parts ), Equals , 5 )
448+ c .Assert (len (ucp .todoParts ()), Equals , 1 )
449+ c .Assert (len (ucp .allParts ()), Equals , 5 )
450+
451+ // Second upload, finish the remaining part
452+ err = s .bucket .UploadFile (objectName , fileName , 100 * 1024 , Checkpoint (true , "" ))
453+ c .Assert (err , IsNil )
454+
455+ os .Remove (newFile )
456+ os .Remove (cpFilePath )
457+ err = s .bucket .GetObjectToFile (objectName , newFile )
458+ c .Assert (err , IsNil )
459+
460+ eq , err := compareFiles (fileName , newFile )
461+ c .Assert (err , IsNil )
462+ c .Assert (eq , Equals , true )
463+
464+ err = s .bucket .DeleteObject (objectName )
465+ c .Assert (err , IsNil )
466+ }
467+
420468// TestUploadRoutineWithRecoveryNegative is multiroutineed upload without checkpoint
421469func (s * OssUploadSuite ) TestUploadRoutineWithRecoveryNegative (c * C ) {
422470 objectName := objectNamePrefix + RandStr (8 )
0 commit comments