@@ -93,7 +93,7 @@ describe('test versioning concurrency', () => {
9393 expect ( failed_operations ) . toHaveLength ( 0 ) ;
9494 } , test_timeout ) ;
9595
96- // same as s3tests_boto3/functional/test_s3.py::test_versioning_concurrent_multi_object_delete,
96+ // same as s3tests_boto3/functional/test_s3.py::test_versioning_concurrent_multi_object_delete,
9797 // this test has a bug, it tries to create the bucket twice and fails
9898 // https://github.com/ceph/s3-tests/blob/master/s3tests_boto3/functional/test_s3.py#L1642
9999 // see - https://github.com/ceph/s3-tests/issues/588
@@ -488,7 +488,73 @@ describe('test versioning concurrency', () => {
488488 expect ( successful_operations2 ) . toHaveLength ( num_of_concurrency2 ) ;
489489 expect ( failed_operations1 ) . toHaveLength ( 0 ) ;
490490 const versions = await nsfs . list_object_versions ( { bucket : bucket } , DUMMY_OBJECT_SDK ) ;
491- expect ( versions . objects . length ) . toBe ( num_of_concurrency1 + 1 ) ; // num_of_concurrency1 is the number of versions uploaded when versioning was enabled + 1 null version
491+ expect ( versions . objects . length ) . toBe ( num_of_concurrency1 + 1 ) ; // num_of_concurrency1 is the number of versions uploaded when versioning was enabled + 1 null version
492+ } , test_timeout ) ;
493+
494+ it ( 'multiple delete different keys' , async ( ) => {
495+ const bucket = 'bucket1' ;
496+ const key_prefix = 'key_deleted' ;
497+ const versions_arr = [ ] ;
498+ const num_deletes = 5 ;
499+ const num_objects = 7 ;
500+
501+ for ( let i = 0 ; i < num_objects ; i ++ ) {
502+ const random_data = Buffer . from ( String ( i ) ) ;
503+ const body = buffer_utils . buffer_to_read_stream ( random_data ) ;
504+ const res = await nsfs . upload_object ( { bucket, key : key_prefix + i , source_stream : body } , DUMMY_OBJECT_SDK ) . catch ( err => console . log ( 'put error - ' , err ) ) ;
505+ versions_arr . push ( res . version_id ) ;
506+ }
507+ const number_of_successful_operations = [ ] ;
508+ const failed_operations = [ ] ;
509+ for ( let i = 0 ; i < num_deletes ; i ++ ) {
510+ nsfs . delete_object ( { bucket, key : key_prefix + i , version_id : versions_arr [ i ] } , DUMMY_OBJECT_SDK )
511+ . then ( res => number_of_successful_operations . push ( res ) )
512+ . catch ( err => failed_operations . push ( err ) ) ;
513+ }
514+ await P . delay ( 2000 ) ;
515+ expect ( number_of_successful_operations ) . toHaveLength ( num_deletes ) ;
516+ expect ( failed_operations ) . toHaveLength ( 0 ) ;
517+ const list_objects = await nsfs . list_objects ( { bucket} , DUMMY_OBJECT_SDK ) ;
518+ let num_objs = 0 ;
519+ list_objects . objects . forEach ( obj => {
520+ if ( obj . key . startsWith ( key_prefix ) ) {
521+ num_objs += 1 ;
522+ }
523+ } ) ;
524+ expect ( num_objs ) . toBe ( num_objects - num_deletes ) ;
525+
526+ } , test_timeout ) ;
527+
528+ it ( 'copy-object to same target' , async ( ) => {
529+ const num_copies = 5 ;
530+ const bucket = 'bucket1' ;
531+ const copy_source = { bucket, key : 'key1' } ;
532+ const random_data = Buffer . from ( "test data, it is test data" ) ;
533+ const body = buffer_utils . buffer_to_read_stream ( random_data ) ;
534+ const source_res = await nsfs . upload_object ( { bucket : copy_source . bucket ,
535+ key : copy_source . key , source_stream : body } , DUMMY_OBJECT_SDK ) ;
536+ copy_source . version_id = source_res . version_id ;
537+
538+ const key = 'key3' ;
539+ const versions_arr = [ ] ;
540+ const failed_operations = [ ] ;
541+ // copy key1 5 times to key3
542+ for ( let i = 0 ; i < num_copies ; i ++ ) {
543+ nsfs . upload_object ( { bucket, key, source_stream : body , copy_source } , DUMMY_OBJECT_SDK )
544+ . then ( res => versions_arr . push ( res . etag ) )
545+ . catch ( err => failed_operations . push ( err ) ) ;
546+ }
547+ await P . delay ( 1000 ) ;
548+ expect ( versions_arr ) . toHaveLength ( num_copies ) ;
549+ expect ( failed_operations ) . toHaveLength ( 0 ) ;
550+ const list_objects = await nsfs . list_object_versions ( { bucket} , DUMMY_OBJECT_SDK ) ;
551+ let num_versions = 0 ;
552+ list_objects . objects . forEach ( obj => {
553+ if ( obj . key === key ) {
554+ num_versions += 1 ;
555+ }
556+ } ) ;
557+ expect ( num_versions ) . toBe ( num_copies ) ;
492558 } , test_timeout ) ;
493559} ) ;
494560
0 commit comments