@@ -615,9 +615,8 @@ def test_storage_azcopy_blob_url(self, resource_group, first_account, second_acc
615
615
local_file = self .create_temp_file (20480.5 )
616
616
self .cmd ('disk create -n {} -g {} --for-upload --upload-size-bytes 20972032'
617
617
.format (diskname , resource_group ))
618
- sasURL = self .cmd (
619
- 'disk grant-access --access-level Write --duration-in-seconds 3600 -n {} -g {} --query accessSas -o tsv'
620
- .format (diskname , resource_group )).output .strip ('\n ' )
618
+ sasURL = self .cmd ('disk grant-access --access-level Write --duration-in-seconds 3600 -n {} -g {} -o tsv'
619
+ .format (diskname , resource_group )).output .strip ('\n ' )
621
620
self .cmd ('storage copy -s "{}" -d "{}" --blob-type PageBlob'
622
621
.format (local_file , sasURL ))
623
622
@@ -632,6 +631,7 @@ def test_storage_azcopy_blob_account(self, resource_group, first_account, second
632
631
633
632
first_container = self .create_container (first_account_info )
634
633
second_container = self .create_container (second_account_info )
634
+ third_container = self .create_container (second_account_info )
635
635
636
636
first_account_url = 'https://{}.blob.core.windows.net' .format (first_account )
637
637
@@ -708,13 +708,20 @@ def test_storage_azcopy_blob_account(self, resource_group, first_account, second
708
708
.format (second_container , second_account ), checks = JMESPathCheck ('length(@)' , 11 ))
709
709
710
710
# Copy an entire storage account data to another blob account
711
- self .cmd ('storage copy --source-account-name {} --destination-account-name {} --recursive --preserve-s2s-access-tier false '
712
- .format (first_account , second_account ))
711
+ self .cmd ('storage copy --source-account-name {} --destination-account-name {} --recursive '
712
+ '--preserve-s2s-access-tier false' .format (first_account , second_account ))
713
713
self .cmd ('storage container list --account-name {}'
714
- .format (second_account ), checks = JMESPathCheck ('length(@)' , 2 ))
714
+ .format (second_account ), checks = JMESPathCheck ('length(@)' , 3 ))
715
715
self .cmd ('storage blob list -c {} --account-name {}'
716
716
.format (first_container , second_account ), checks = JMESPathCheck ('length(@)' , 22 ))
717
717
718
+ # Copy an entire directory from blob virtual directory to another blob virtual directory with wildcard
719
+ self .cmd ('storage copy --source-account-name {} --source-container {} --source-blob {} '
720
+ '--destination-account-name {} --destination-container {} --recursive --preserve-s2s-access-tier false'
721
+ .format (second_account , second_container , 'apple/*' , second_account , third_container ))
722
+ self .cmd ('storage blob list -c {} --account-name {}'
723
+ .format (third_container , second_account ), checks = JMESPathCheck ('length(@)' , 10 ))
724
+
718
725
@ResourceGroupPreparer ()
719
726
@StorageAccountPreparer (parameter_name = 'first_account' )
720
727
@StorageAccountPreparer (parameter_name = 'second_account' , sku = 'Premium_LRS' , kind = 'BlockBlobStorage' )
@@ -881,6 +888,26 @@ def test_storage_azcopy_file_account(self, resource_group, storage_account_info,
881
888
self .assertEqual (3 , sum (len (d ) for r , d , f in os .walk (local_folder )))
882
889
self .assertEqual (21 , sum (len (f ) for r , d , f in os .walk (local_folder )))
883
890
891
+ # Copy with wildcard *
892
+ self .cmd ('storage directory create -s {} -n {} --account-name {}' .format (share , 'parent' , storage_account ))
893
+ self .cmd ('storage directory create -s {} -n {} --account-name {}'
894
+ .format (share , 'parent/source' , storage_account ))
895
+ self .cmd ('storage copy --source-local-path "{}" --destination-account-name {} --destination-share {} '
896
+ '--destination-file-path {} --recursive'
897
+ .format (os .path .join (test_dir , 'butter/file_*' ), storage_account , share , 'parent/source' ))
898
+ self .cmd ('storage copy --source-account-name {} --source-share {} --source-file-path {} --account-name {} '
899
+ '--destination-share {} --destination-file-path {} --recursive -- --as-subdir=false'
900
+ .format (storage_account , share , 'parent/source/*' , storage_account , share , 'parent/target' ))
901
+ self .cmd ('storage file list -s {} --path {} --account-name {}' .format (
902
+ share , 'parent/target' , storage_account ), checks = JMESPathCheck ('length(@)' , 10 ))
903
+ self .cmd ('storage copy --source-account-name {} --source-share {} --source-file-path {} --account-name {} '
904
+ '--destination-share {} --destination-file-path {} --recursive -- --as-subdir=false'
905
+ .format (storage_account , share , 'parent/*' , storage_account , share , 'parentdst' ))
906
+ self .cmd ('storage file list -s {} --path {} --account-name {}'
907
+ .format (share , 'parentdst/source' , storage_account ), checks = JMESPathCheck ('length(@)' , 10 ))
908
+ self .cmd ('storage file list -s {} --path {} --account-name {}'
909
+ .format (share , 'parentdst/target' , storage_account ), checks = JMESPathCheck ('length(@)' , 10 ))
910
+
884
911
@ResourceGroupPreparer ()
885
912
@StorageAccountPreparer (parameter_name = 'first_account' , allow_shared_key_access = False )
886
913
@StorageAccountPreparer (parameter_name = 'second_account' , sku = 'Premium_LRS' , kind = 'BlockBlobStorage' ,
@@ -972,9 +999,8 @@ def test_storage_azcopy_blob_url_oauth(self, resource_group, first_account, seco
972
999
local_file = self .create_temp_file (20480.5 )
973
1000
self .cmd ('disk create -n {} -g {} --for-upload --upload-size-bytes 20972032'
974
1001
.format (diskname , resource_group ))
975
- sasURL = self .cmd (
976
- 'disk grant-access --access-level Write --duration-in-seconds 3600 -n {} -g {} --query accessSas -o tsv'
977
- .format (diskname , resource_group )).output .strip ('\n ' )
1002
+ sasURL = self .cmd ('disk grant-access --access-level Write --duration-in-seconds 3600 -n {} -g {} -o tsv'
1003
+ .format (diskname , resource_group )).output .strip ('\n ' )
978
1004
self .oauth_cmd ('storage copy -s "{}" -d "{}" --blob-type PageBlob' .format (
979
1005
local_file , sasURL ))
980
1006
@@ -986,8 +1012,10 @@ def test_storage_azcopy_blob_url_oauth(self, resource_group, first_account, seco
986
1012
def test_storage_azcopy_blob_account_oauth (self , resource_group , first_account , second_account , test_dir ):
987
1013
first_container = self .create_random_name (prefix = 'container' , length = 24 )
988
1014
second_container = self .create_random_name (prefix = 'container' , length = 24 )
1015
+ third_container = self .create_random_name (prefix = 'container' , length = 24 )
989
1016
self .oauth_cmd ('storage container create -n {} --account-name {}' , first_container , first_account )
990
1017
self .oauth_cmd ('storage container create -n {} --account-name {}' , second_container , second_account )
1018
+ self .oauth_cmd ('storage container create -n {} --account-name {}' , third_container , second_account )
991
1019
992
1020
first_account_url = 'https://{}.blob.core.windows.net' .format (first_account )
993
1021
@@ -1072,10 +1100,18 @@ def test_storage_azcopy_blob_account_oauth(self, resource_group, first_account,
1072
1100
'--preserve-s2s-access-tier false' .format (
1073
1101
first_account , second_account ))
1074
1102
self .oauth_cmd ('storage container list --account-name {}' .format (
1075
- second_account ), checks = JMESPathCheck ('length(@)' , 2 ))
1103
+ second_account ), checks = JMESPathCheck ('length(@)' , 3 ))
1076
1104
self .oauth_cmd ('storage blob list -c {} --account-name {}' .format (
1077
1105
first_container , second_account ), checks = JMESPathCheck ('length(@)' , 22 ))
1078
1106
1107
+ # Copy an entire directory from blob virtual directory to another blob virtual directory with wildcard
1108
+ self .oauth_cmd ('storage copy --source-account-name {} --source-container {} --source-blob {} '
1109
+ '--destination-account-name {} --destination-container {} --recursive '
1110
+ '--preserve-s2s-access-tier false'
1111
+ .format (second_account , second_container , 'apple/*' , second_account , third_container ))
1112
+ self .oauth_cmd ('storage blob list -c {} --account-name {}'
1113
+ .format (third_container , second_account ), checks = JMESPathCheck ('length(@)' , 10 ))
1114
+
1079
1115
@ResourceGroupPreparer ()
1080
1116
@StorageAccountPreparer (parameter_name = 'first_account' , allow_shared_key_access = False )
1081
1117
@StorageAccountPreparer (parameter_name = 'second_account' , sku = 'Premium_LRS' , kind = 'BlockBlobStorage' ,
@@ -1236,3 +1272,24 @@ def test_storage_azcopy_file_account_oauth(self, resource_group, storage_account
1236
1272
storage_account , share , local_folder ))
1237
1273
self .assertEqual (3 , sum (len (d ) for r , d , f in os .walk (local_folder )))
1238
1274
self .assertEqual (21 , sum (len (f ) for r , d , f in os .walk (local_folder )))
1275
+
1276
+ # Copy with wildcard *
1277
+ self .file_oauth_cmd ('storage directory create -s {} -n {} --account-name {}'
1278
+ .format (share , 'parent' , storage_account ))
1279
+ self .file_oauth_cmd ('storage directory create -s {} -n {} --account-name {}'
1280
+ .format (share , 'parent/source' , storage_account ))
1281
+ self .oauth_cmd ('storage copy --source-local-path "{}" --destination-account-name {} --destination-share {} '
1282
+ '--destination-file-path {} --recursive'
1283
+ .format (os .path .join (test_dir , 'butter/file_*' ), storage_account , share , 'parent/source' ))
1284
+ self .cmd ('storage copy --source-account-name {} --source-share {} --source-file-path {} --account-name {} '
1285
+ '--destination-share {} --destination-file-path {} --recursive --auth-mode login -- --as-subdir=false'
1286
+ .format (storage_account , share , 'parent/source/*' , storage_account , share , 'parent/target' ))
1287
+ self .file_oauth_cmd ('storage file list -s {} --path {} --account-name {}'
1288
+ .format (share , 'parent/target' , storage_account ), checks = JMESPathCheck ('length(@)' , 10 ))
1289
+ self .cmd ('storage copy --source-account-name {} --source-share {} --source-file-path {} --account-name {} '
1290
+ '--destination-share {} --destination-file-path {} --recursive --auth-mode login -- --as-subdir=false'
1291
+ .format (storage_account , share , 'parent/*' , storage_account , share , 'parentdst' ))
1292
+ self .file_oauth_cmd ('storage file list -s {} --path {} --account-name {}'
1293
+ .format (share , 'parentdst/source' , storage_account ), checks = JMESPathCheck ('length(@)' , 10 ))
1294
+ self .file_oauth_cmd ('storage file list -s {} --path {} --account-name {}'
1295
+ .format (share , 'parentdst/target' , storage_account ), checks = JMESPathCheck ('length(@)' , 10 ))
0 commit comments