@@ -207,6 +207,26 @@ function Test-Blob
207
207
Assert-AreEqual $blob.Count 2
208
208
Get-AzStorageBlob - Container $containerName - Blob $objectName2 - Context $storageContext | Remove-AzStorageBlob - Force
209
209
210
+ # check XSCL Track2 Items works for container
211
+ $container = Get-AzStorageContainer $containerName - Context $storageContext
212
+ $containerProperties = $container.BlobContainerClient.GetProperties ().Value
213
+ Assert-AreEqual $container.BlobContainerProperties.ETag $containerProperties.ETag
214
+ Set-AzStorageContainerAcl $containerName - Context $storageContext - Permission Blob
215
+ $containerProperties = $container.BlobContainerClient.GetProperties ().Value
216
+ Assert-AreNotEqual $container.BlobContainerProperties.ETag $containerProperties.ETag
217
+ $container.FetchAttributes ()
218
+ Assert-AreEqual $container.BlobContainerProperties.ETag $containerProperties.ETag
219
+
220
+ # check XSCL Track2 Items works for Blob
221
+ $blob = Get-AzStorageBlob - Container $containerName - Blob $objectName1 - Context $storageContext
222
+ $blobProperties = $blob.BlobClient.GetProperties ().Value
223
+ Assert-AreEqual $blob.BlobProperties.ETag $blobProperties.ETag
224
+ Set-AzStorageBlobContent - File $localSrcFile - Container $containerName - Blob $objectName1 - Force - Context $storageContext
225
+ $blobProperties = $blob.BlobClient.GetProperties ().Value
226
+ Assert-AreNotEqual $blob.BlobProperties.ETag $blobProperties.ETag
227
+ $blob.FetchAttributes ()
228
+ Assert-AreEqual $blob.BlobProperties.ETag $blobProperties.ETag
229
+
210
230
# Copy blob to the same container, but with a different name.
211
231
Start-AzStorageBlobCopy - srcContainer $containerName - SrcBlob $objectName1 - DestContainer $containerName - DestBlob $objectName2 - StandardBlobTier $StandardBlobTier - RehydratePriority High - Context $storageContext - DestContext $storageContext
212
232
Get-AzStorageBlobCopyState - Container $containerName - Blob $objectName2 - Context $storageContext
@@ -684,6 +704,153 @@ function Test-Common
684
704
}
685
705
}
686
706
707
+ <#
708
+ . SYNOPSIS
709
+ Tests DatalakeGen-only related commands.
710
+ #>
711
+ function Test-DatalakeGen2
712
+ {
713
+ Param (
714
+ [Parameter (Mandatory = $True )]
715
+ [string ]
716
+ $StorageAccountName ,
717
+ [Parameter (Mandatory = $True )]
718
+ [string ]
719
+ $ResourceGroupName
720
+ )
721
+
722
+ New-TestResourceGroupAndStorageAccount - ResourceGroupName $ResourceGroupName - StorageAccountName $StorageAccountName - EnableHNFS $true
723
+
724
+ try {
725
+
726
+ $storageAccountKeyValue = $ (Get-AzStorageAccountKey - ResourceGroupName $ResourceGroupName - Name $StorageAccountName )[0 ].Value
727
+ $storageContext = New-AzStorageContext - StorageAccountName $StorageAccountName - StorageAccountKey $storageAccountKeyValue
728
+
729
+ $localSrcFile = " localsrcDatalakeGen2testfile.psd1" # The file need exist before test, and should be 512 bytes aligned
730
+ New-Item $localSrcFile - ItemType File - Force
731
+ $localDestFile = " localdestDatalakeGen2testfile.txt"
732
+
733
+ $filesystemName = " adlsgen2testfilesystem"
734
+ $directoryPath1 = " dir1"
735
+ $directoryPath2 = " dir2"
736
+ $directoryPath3 = " dir3"
737
+ $filePath1 = " dir1/Item1.txt"
738
+ $filePath2 = " dir2/Item2.txt"
739
+ $filePath3 = " dir2/Item3.txt"
740
+ $ContentType = " image/jpeg"
741
+ $ContentMD5 = " i727sP7HigloQDsqadNLHw=="
742
+
743
+ # Create FileSystem (actually a container)
744
+ New-AzDatalakeGen2FileSystem $filesystemName - Context $storageContext
745
+
746
+ # Create folders
747
+ $dir1 = New-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $directoryPath1 - Directory - Permission rwxrwxrwx - Umask --- rwx--- - Property @ {" ContentEncoding" = " UDF8" ; " CacheControl" = " READ" } - Metadata @ {" tag1" = " value1" ; " tag2" = " value2" }
748
+ Assert-AreEqual $dir1.Path $directoryPath1
749
+ Assert-AreEqual $dir1.Permissions.ToSymbolicPermissions () " rwx---rwx"
750
+ $dir2 = New-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $directoryPath2 - Directory
751
+
752
+ # Create (upload) File
753
+ $t = New-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $filePath1 - Source $localSrcFile - Force - AsJob
754
+ $t | wait-job
755
+ Assert-AreEqual $t.State " Completed"
756
+ Assert-AreEqual $t.Error $null
757
+ $file2 = New-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $filePath2 - Source $localSrcFile - Permission rwxrwxrwx - Umask --- rwx--- - Property @ {" ContentType" = $ContentType ; " ContentMD5" = $ContentMD5 } - Metadata @ {" tag1" = " value1" ; " tag2" = " value2" }
758
+ Assert-AreEqual $file2.Path $filePath2
759
+ Assert-AreEqual $file2.Properties.ContentType $ContentType
760
+ Assert-AreEqual $file2.Properties.Metadata.Count 2
761
+ Assert-AreEqual $file2.Permissions.ToSymbolicPermissions () " rwx---rwx"
762
+
763
+ # update Blob and Directory
764
+ $ContentType = " application/octet-stream"
765
+ $ContentMD5 = " NW/H9Zxr2md6L1/yhNKdew=="
766
+ $ContentEncoding = " UDF8"
767
+ # # create ACL with 3 ACEs
768
+ $acl = New-AzDataLakeGen2ItemAclObject - AccessControlType user - Permission rw-
769
+ $acl = New-AzDataLakeGen2ItemAclObject - AccessControlType group - Permission rw- - InputObject $acl
770
+ $acl = New-AzDataLakeGen2ItemAclObject - AccessControlType other - Permission " -wx" - InputObject $acl
771
+ # #Update File with pipeline
772
+ $file1 = Get-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $filePath1 | Update-AzDataLakeGen2Item `
773
+ - Acl $acl `
774
+ - Property @ {" ContentType" = $ContentType ; " ContentMD5" = $ContentMD5 } `
775
+ - Metadata @ {" tag1" = " value1" ; " tag2" = " value2" } `
776
+ - Permission rw- rw-- wx `
777
+ - Owner ' $superuser' `
778
+ - Group ' $superuser'
779
+ $file1 = Get-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $filePath1
780
+ Assert-AreEqual $file1.Path $filePath1
781
+ Assert-AreEqual $file1.Permissions.ToSymbolicPermissions () " rw-rw--wx"
782
+ Assert-AreEqual $file1.Properties.ContentType $ContentType
783
+ Assert-AreEqual $file1.Properties.Metadata.Count 2
784
+ Assert-AreEqual $file1.Owner ' $superuser'
785
+ Assert-AreEqual $file1.Group ' $superuser'
786
+ # # Update Directory
787
+ $dir1 = Update-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $directoryPath1 `
788
+ - Acl $acl `
789
+ - Property @ {" ContentEncoding" = $ContentEncoding } `
790
+ - Metadata @ {" tag1" = " value1" ; " tag2" = " value2" } `
791
+ - Permission rw- rw-- wx `
792
+ - Owner ' $superuser' `
793
+ - Group ' $superuser'
794
+ $dir1 = Get-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $directoryPath1
795
+ Assert-AreEqual $dir1.Path $directoryPath1
796
+ Assert-AreEqual $dir1.Permissions.ToSymbolicPermissions () " rw-rw--wx"
797
+ Assert-AreEqual $dir1.Properties.ContentEncoding $ContentEncoding
798
+ Assert-AreEqual $dir1.Properties.Metadata.Count 3 # inlucde "hdi_isfolder" which is handle by server
799
+ Assert-AreEqual $dir1.Owner ' $superuser'
800
+ Assert-AreEqual $dir1.Group ' $superuser'
801
+
802
+ # list Items
803
+ # # List direct Items from FileSystem
804
+ $items = Get-AzDataLakeGen2ChildItem - Context $storageContext - FileSystem $filesystemName - FetchPermission
805
+ Assert-AreEqual $items.Count 2
806
+ Assert-NotNull $items [0 ].Permissions
807
+ $items = Get-AzDataLakeGen2ChildItem - Context $storageContext - FileSystem $filesystemName - Recurse
808
+ Assert-AreEqual $items.Count 4
809
+ Assert-Null $items [0 ].Permissions
810
+
811
+ # download File
812
+ $t = Get-AzDataLakeGen2ItemContent - Context $storageContext - FileSystem $filesystemName - Path $filePath1 - Destination $localDestFile - AsJob - Force
813
+ $t | Wait-Job
814
+ Assert-AreEqual $t.State " Completed"
815
+ Assert-AreEqual $t.Error $null
816
+ Assert-AreEqual (Get-FileHash - Path $localDestFile - Algorithm MD5).Hash (Get-FileHash - Path $localSrcFile - Algorithm MD5).Hash
817
+
818
+ # Move Items
819
+ # # Move File
820
+ $file3 = Move-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $filePath2 - DestFileSystem $filesystemName - DestPath $filePath3 - Force
821
+ $file3 = Get-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $filePath3
822
+ Assert-AreEqual $file3.Path $filePath3
823
+ Assert-AreEqual $file3.Permissions $file2.Permissions
824
+ $file2 = $file3 | Move-AzDataLakeGen2Item - DestFileSystem $filesystemName - DestPath $filePath2
825
+ $file2 = Get-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $filePath2
826
+ Assert-AreEqual $file2.Path $filePath2
827
+ Assert-AreEqual $file2.Permissions $file3.Permissions
828
+ # # Move Folder
829
+ $dir3 = Move-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $directoryPath1 - DestFileSystem $filesystemName - DestPath $directoryPath3
830
+ $dir3 = Get-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $directoryPath3
831
+ Assert-AreEqual $dir3.Path $directoryPath3
832
+ Assert-AreEqual $dir3.Permissions $dir1.Permissions
833
+ $dir1 = $dir3 | Move-AzDataLakeGen2Item - DestFileSystem $filesystemName - DestPath $directoryPath1
834
+ $dir1 = Get-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $directoryPath1
835
+ Assert-AreEqual $dir1.Path $directoryPath1
836
+
837
+ # Remove Items
838
+ Remove-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $filePath1 - Force
839
+ Remove-AzDataLakeGen2Item - Context $storageContext - FileSystem $filesystemName - Path $directoryPath1 - Force
840
+
841
+ # Clean Storage Account
842
+ Get-AzDataLakeGen2ChildItem - Context $storageContext - FileSystem $filesystemName | Remove-AzDataLakeGen2Item - Force
843
+
844
+ # remove File system (actually a container)
845
+ Remove-AzDatalakeGen2FileSystem $filesystemName - Context $storageContext
846
+
847
+ }
848
+ finally
849
+ {
850
+ Clean - ResourceGroup $ResourceGroupName
851
+ }
852
+ }
853
+
687
854
function New-TestResourceGroupAndStorageAccount
688
855
{
689
856
Param (
0 commit comments