Skip to content

Integrating the new custom dataplane sdk for ADLS to the powershell cmdlets #4986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Dec 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b2ea51e
Replaced the old filesystem sdk with the current adls dotnetsdk
rahuldutta90 Oct 13, 2017
4e6c491
Fixes to the warning messages, Documented changes and breaking changes
rahuldutta90 Oct 18, 2017
7581898
Updated the markdown files
rahuldutta90 Oct 18, 2017
38a2a72
Merge branch 'preview' into preview
rahuldutta90 Oct 18, 2017
26253c1
Fix the markdown file for NEw-AzureRmDataLakeStoreItem
rahuldutta90 Oct 19, 2017
c12f7dc
Merge branch 'preview' of https://github.com/rahuldutta90/azure-power…
rahuldutta90 Oct 19, 2017
655d3e5
1) Deprecated clean parameter in Remove-AzureRmDataLakeStoreItem 2) D…
rahuldutta90 Oct 19, 2017
b950e87
Updated breaking changes, examples for New-AzureRmDataLakeStoreItem a…
rahuldutta90 Oct 19, 2017
bdadfae
1) Restored parameters resume and forcebinary for Import and export 2…
rahuldutta90 Nov 14, 2017
201ab30
Merge from https://github.com/Azure/azure-powershell.git
rahuldutta90 Nov 15, 2017
4d717fe
1) Resolve the merge for parametersetname 2) Restore the help message…
rahuldutta90 Nov 15, 2017
0a6c68c
Add management reference
rahuldutta90 Nov 15, 2017
d3cfbf5
Make the parameter for setExpiry singular
rahuldutta90 Nov 21, 2017
b5245f0
Remove unecessary dependencies like NLog.config, remove space from pa…
rahuldutta90 Nov 22, 2017
efdd22f
Changed ADLS SDK version to be signed by Microsoft certificate
rahuldutta90 Nov 30, 2017
8ce1349
Merge branch 'preview' into preview
twitchax Nov 30, 2017
1918a61
Make FileType enum nullable, add exceptions for static code analysis
rahuldutta90 Dec 1, 2017
eecb58f
Merge branch 'preview' of https://github.com/rahuldutta90/azure-power…
rahuldutta90 Dec 1, 2017
1b72d24
Add build exceptions, Remove nullable type from parameter, MAke a par…
rahuldutta90 Dec 1, 2017
c3ca135
Added exception for Changing type of Expiration to non nullable in Se…
rahuldutta90 Dec 1, 2017
e2360f9
Merge branch 'adls-data-plane' into preview
cormacpayne Dec 14, 2017
ad92197
Merge branch 'adls-data-plane' into preview
cormacpayne Dec 14, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,28 @@ function Assert-AreEqual

return $true
}

###################
#
# Verify that if actual falls in an acceptable range of expected
#
# param [long] $expected : The expected number
# param [long] $actual : The actual number
# param [long] $interval : The acceptable offset either side of the expected
# param [string] $message : The message to return if the given objects are not equal
####################
function Assert-NumAreInRange
{
param([long] $expected, [long] $actual, [long] $interval, [string] $message)
if (!$message)
{
$message = "Assertion failed because expected '$expected' does not fall in accepted range of 'interval' of actual '$actual'"
}
if(!($actual -ge ($expected-$interval) -and $actual -le ($expected+$interval)))
{
throw $message
}
return $true
}
###################
#
# Verify that two given arrays are equal
Expand Down
36 changes: 36 additions & 0 deletions src/ResourceManager/DataLakeStore/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,42 @@
-->
## Current Release

* Moved from AutoRest sdk to our version of Dataplane sdk for Azure data lake.
* Refactored following cmdlets to use the new version of SDK:
* Add-AzureRmDataLakeStoreItemContent
* Export-AzureRmDataLakeStoreItem
* Get-AzureRmDataLakeStoreChildItem
* Get-AzureRmDataLakeStoreItem
* Get-AzureRmDataLakeStoreItemAclEntry
* Get-AzureRmDataLakeStoreItemContent
* Get-AzureRmDataLakeStoreItemOwner
* Get-AzureRmDataLakeStoreItemPermission
* Import-AzureRmDataLakeStoreItem
* Join-AzureRmDataLakeStoreItem
* Move-AzureRmDataLakeStoreItem
* New-AzureRmDataLakeStoreItem
* Remove-AzureRmDataLakeStoreItem
* Remove-AzureRmDataLakeStoreItemAcl
* Remove-AzureRmDataLakeStoreItemAclEntry
* Set-AzureRmDataLakeStoreItemAcl
* Set-AzureRmDataLakeStoreItemAclEntry
* Set-AzureRmDataLakeStoreItemExpiry
* Set-AzureRmDataLakeStoreItemOwner
* Set-AzureRmDataLakeStoreItemPermission
* Test-AzureRmDataLakeStoreItem
* Refactored following models to use models from new SDK:
* DataLakeStoreEnums
* DataLakeStoreFileSystemClient
* DataLakeStoreItem
* DataLakeStoreItemAce
* DataLakeStorePathInstance
* Moved the commands and models related to the dataplane into separate folders
* Export-AzureRmDataLakeStoreItem (documented in the breaking changes) - Deprecated parameters PerFileThreadCount, ConcurrentFileCount and introduced parameter Concurrency
* Import-AzureRMDataLakeStoreItem (documented in the breaking changes) -Deprecated parametersPerFileThreadCount, ConcurrentFileCount and introduced parameter Concurrency
* Get-AzureRMDataLakeStoreItemContent - Fixed the tail behavior for contents greater than 4MB
* Set-AzureRMDataLakeStoreItemExpiry - Introduced new parameter set for setting relative expiration time
* Remove-AzureRmDataLakeStoreItem (documented in the breaking changes) - Deprecated parameter Clean.

## Version 5.0.0
* NOTE: This is a breaking change release. Please see the migration guide (https://aka.ms/azps-migration-guide) for a full list of breaking changes introduced.
* Removed the Obsolete Properties fields in PSDataLakeStoreAccount.cs and its assoicated files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
<Name>Commands.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.DataLakeStore\Commands.DataLakeStore.csproj">
<Project>{8aab43e6-e8f6-4f91-af8a-6a63cd78ef1e}</Project>
<Name>Commands.DataLakeStore</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="MSSharedLibKey.snk" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;

namespace Microsoft.Azure.Commands.DataLakeStore.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,38 +424,46 @@ function Test-DataLakeStoreFileSystem
$result = Get-AdlStoreItem -Account $accountName -path $folderToCreate
Assert-NotNull $result "No value was returned on folder get"
Assert-AreEqual "Directory" $result.Type

# Create and get Empty File
$result = New-AdlStoreItem -Account $accountName -path $emptyFilePath
Assert-NotNull $result "No value was returned on empty file creation"
$result = Get-AdlStoreItem -Account $accountName -path $emptyFilePath
$emptyFileCreationDate=$result.LastWriteTime # To be used later
Assert-NotNull $result "No value was returned on empty file get"
Assert-AreEqual "File" $result.Type
Assert-AreEqual 0 $result.Length

# Create and get file with content
$result = New-AdlStoreItem -Account $accountName -path $contentFilePath -Value $content
Assert-NotNull $result "No value was returned on content file creation"
$result = Get-AdlStoreItem -Account $accountName -path $contentFilePath
Assert-NotNull $result "No value was returned on content file get"
Assert-AreEqual "File" $result.Type
Assert-AreEqual $content.length $result.Length
# set and validate expiration for a file

# set absolute expiration for content file
Assert-True {253402300800000 -ge $result.ExpirationTime -or 0 -le $result.ExpirationTime} # validate that expiration is currently max value
[DateTimeOffset]$timeToUse = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("absoluteTime", [DateTimeOffset]::UtcNow.AddSeconds(120))
$result = Set-AdlStoreItemExpiry -Account $accountName -path $contentFilePath -Expiration $timeToUse
Assert-AreEqual $timeToUse.UtcTicks $result.Expiration.UtcTicks
Assert-NumAreInRange $timeToUse.UtcTicks $result.Expiration.UtcTicks 500000 # range of 50 milliseconds

# set it back to "never expire"
$result = Set-AdlStoreItemExpiry -Account $accountName -path $contentFilePath
Assert-True {253402300800000 -ge $result.ExpirationTime -or 0 -le $result.ExpirationTime} # validate that expiration is currently max value

# list files
$result = Get-AdlStoreChildItem -Account $accountName -path $folderToCreate
Assert-NotNull $result "No value was returned on folder list"
Assert-AreEqual 2 $result.length

# add content to empty file
Add-AdlStoreItemContent -Account $accountName -Path $emptyFilePath -Value $content
$result = Get-AdlStoreItem -Account $accountName -path $emptyFilePath
Assert-NotNull $result "No value was returned on empty file get with content added"
Assert-AreEqual "File" $result.Type
Assert-AreEqual $content.length $result.Length

# concat files
$result = Join-AdlStoreItem -Account $accountName -Paths $emptyFilePath,$contentFilePath -Destination $concatFile
Assert-NotNull $result "No value was returned on concat file"
Expand Down Expand Up @@ -506,6 +514,7 @@ function Test-DataLakeStoreFileSystem
Assert-NotNull $result "No value was returned on import file get"
Assert-AreEqual "File" $result.Type
Assert-AreEqual $localFileInfo.length $result.Length

# download file
$currentDir = Split-Path $fileToCopy
$targetFile = Join-Path $currentDir "adlspstestdownload.txt"
Expand All @@ -527,6 +536,7 @@ function Test-DataLakeStoreFileSystem
Assert-AreEqual "File" $result.Type
Assert-AreEqual $($content.length*2) $result.Length
Assert-Throws {Get-AdlStoreItem -Account $accountName -path $concatFile}

# move a folder
$result = Move-AdlStoreItem -Account $accountName -Path $folderToCreate -Destination $moveFolder
Assert-NotNull $result "No value was returned on move folder"
Expand All @@ -535,9 +545,11 @@ function Test-DataLakeStoreFileSystem
Assert-AreEqual "Directory" $result.Type
Assert-AreEqual 0 $result.Length
Assert-Throws {Get-AdlStoreItem -Account $accountName -path $folderToCreate}

# delete a file
Assert-True {Remove-AdlStoreItem -Account $accountName -paths "$moveFolder/movefile.txt" -force -passthru } "Remove File Failed"
Assert-Throws {Get-AdlStoreItem -Account $accountName -path $moveFile}

# delete a folder
Assert-True {Remove-AdlStoreItem -Account $accountName -paths $moveFolder -force -recurse -passthru} "Remove folder failed"
Assert-Throws {Get-AdlStoreItem -Account $accountName -path $moveFolder}
Expand Down Expand Up @@ -601,6 +613,17 @@ function Test-DataLakeStoreFileSystemPermissions
# define the permissions to add/remove
$aceUserId = "027c28d5-c91d-49f0-98c5-d10134b169b3"

#set owner
New-AdlStoreItem -Account $accountName -Path "/temp"
$prevOwner=Get-AdlStoreItemOwner -Account $accountName -Path "/temp" -Type User
$prevGroup=Get-AdlStoreItemOwner -Account $accountName -Path "/temp" -Type Group
$currentOwner=Set-AdlStoreItemOwner -Account $accountName -Path "/temp" -Type User -Id $aceUserId -PassThru
$currentGroup=Get-AdlStoreItemOwner -Account $accountName -Path "/temp" -Type Group
Assert-AreEqual $aceUserId $currentOwner
Assert-AreNotEqual $prevOwner $currentOwner
Assert-AreEqual $prevGroup $currentGroup
Remove-AdlStoreItem -Account $accountName -paths "/temp" -force

# Set and get all the permissions
$result = Get-AdlStoreItemAclEntry -Account $accountName -path "/"
Assert-NotNull $result "Did not get any result from ACL get"
Expand Down Expand Up @@ -635,14 +658,17 @@ function Test-DataLakeStoreFileSystemPermissions
Set-AdlStoreItemAclEntry -Account $accountName -path "/" -AceType User -Id $aceUserId -Permissions All
$result = Get-AdlStoreItemAclEntry -Account $accountName -path "/"
Assert-AreEqual $($currentCount+1) $result.Count

# remove a specific permission with friendly remove
Remove-AdlStoreItemAclEntry -Account $accountName -path "/" -AceType User -Id $aceUserId
$result = Get-AdlStoreItemAclEntry -Account $accountName -path "/"
Assert-AreEqual $($currentCount) $result.Count

# set and get a specific permission with the ACE string
Set-AdlStoreItemAclEntry -Account $accountName -path "/" -Acl $([string]::Format("user:{0}:rwx", $aceUserId))
$result = Get-AdlStoreItemAclEntry -Account $accountName -path "/"
Assert-AreEqual $($currentCount+1) $result.Count

# remove a specific permission with the ACE string
Remove-AdlStoreItemAclEntry -Account $accountName -path "/" -Acl $([string]::Format("user:{0}:---", $aceUserId))
$result = Get-AdlStoreItemAclEntry -Account $accountName -path "/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,38 +423,46 @@ function Test-DataLakeStoreFileSystem
$result = Get-AzureRMDataLakeStoreItem -Account $accountName -path $folderToCreate
Assert-NotNull $result "No value was returned on folder get"
Assert-AreEqual "Directory" $result.Type

# Create and get Empty File
$result = New-AzureRMDataLakeStoreItem -Account $accountName -path $emptyFilePath
Assert-NotNull $result "No value was returned on empty file creation"
$result = Get-AzureRMDataLakeStoreItem -Account $accountName -path $emptyFilePath
$emptyFileCreationDate=$result.LastWriteTime # To be used later
Assert-NotNull $result "No value was returned on empty file get"
Assert-AreEqual "File" $result.Type
Assert-AreEqual 0 $result.Length

# Create and get file with content
$result = New-AzureRMDataLakeStoreItem -Account $accountName -path $contentFilePath -Value $content
Assert-NotNull $result "No value was returned on content file creation"
$result = Get-AzureRMDataLakeStoreItem -Account $accountName -path $contentFilePath
Assert-NotNull $result "No value was returned on content file get"
Assert-AreEqual "File" $result.Type
Assert-AreEqual $content.length $result.Length
# set and validate expiration for a file

# set absolute expiration for content file
Assert-True {253402300800000 -ge $result.ExpirationTime -or 0 -le $result.ExpirationTime} # validate that expiration is currently max value
[DateTimeOffset]$timeToUse = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("absoluteTime", [DateTimeOffset]::UtcNow.AddSeconds(120))
$result = Set-AzureRmDataLakeStoreItemExpiry -Account $accountName -path $contentFilePath -Expiration $timeToUse
Assert-AreEqual $timeToUse.UtcTicks $result.Expiration.UtcTicks
$result = Set-AdlStoreItemExpiry -Account $accountName -path $contentFilePath -Expiration $timeToUse
Assert-NumAreInRange $timeToUse.UtcTicks $result.Expiration.UtcTicks 500000 # range of 50 milliseconds

# set it back to "never expire"
$result = Set-AzureRmDataLakeStoreItemExpiry -Account $accountName -path $contentFilePath
$result = Set-AdlStoreItemExpiry -Account $accountName -path $contentFilePath
Assert-True {253402300800000 -ge $result.ExpirationTime -or 0 -le $result.ExpirationTime} # validate that expiration is currently max value

# list files
$result = Get-AzureRMDataLakeStoreChildItem -Account $accountName -path $folderToCreate
Assert-NotNull $result "No value was returned on folder list"
Assert-AreEqual 2 $result.length

# add content to empty file
Add-AzureRMDataLakeStoreItemContent -Account $accountName -Path $emptyFilePath -Value $content
$result = Get-AzureRMDataLakeStoreItem -Account $accountName -path $emptyFilePath
Assert-NotNull $result "No value was returned on empty file get with content added"
Assert-AreEqual "File" $result.Type
Assert-AreEqual $content.length $result.Length

# concat files
$result = Join-AzureRMDataLakeStoreItem -Account $accountName -Paths $emptyFilePath,$contentFilePath -Destination $concatFile
Assert-NotNull $result "No value was returned on concat file"
Expand Down Expand Up @@ -505,6 +513,7 @@ function Test-DataLakeStoreFileSystem
Assert-NotNull $result "No value was returned on import file get"
Assert-AreEqual "File" $result.Type
Assert-AreEqual $localFileInfo.length $result.Length

# download file
$currentDir = Split-Path $fileToCopy
$targetFile = Join-Path $currentDir "adlspstestdownload.txt"
Expand All @@ -517,7 +526,7 @@ function Test-DataLakeStoreFileSystem
$downloadedFileInfo = Get-ChildItem $targetFile
Assert-AreEqual $($content.length*2) $downloadedFileInfo.length
Remove-Item -path $targetFile -force -confirm:$false

# move a file
$result = Move-AzureRMDataLakeStoreItem -Account $accountName -Path $concatFile -Destination $moveFile
Assert-NotNull $result "No value was returned on move file"
Expand All @@ -526,6 +535,7 @@ function Test-DataLakeStoreFileSystem
Assert-AreEqual "File" $result.Type
Assert-AreEqual $($content.length*2) $result.Length
Assert-Throws {Get-AzureRMDataLakeStoreItem -Account $accountName -path $concatFile}

# move a folder
$result = Move-AzureRMDataLakeStoreItem -Account $accountName -Path $folderToCreate -Destination $moveFolder
Assert-NotNull $result "No value was returned on move folder"
Expand All @@ -534,9 +544,11 @@ function Test-DataLakeStoreFileSystem
Assert-AreEqual "Directory" $result.Type
Assert-AreEqual 0 $result.Length
Assert-Throws {Get-AzureRMDataLakeStoreItem -Account $accountName -path $folderToCreate}

# delete a file
Assert-True {Remove-AzureRMDataLakeStoreItem -Account $accountName -paths "$moveFolder/movefile.txt" -force -passthru } "Remove File Failed"
Assert-Throws {Get-AzureRMDataLakeStoreItem -Account $accountName -path $moveFile}

# delete a folder
Assert-True {Remove-AzureRMDataLakeStoreItem -Account $accountName -paths $moveFolder -force -recurse -passthru} "Remove folder failed"
Assert-Throws {Get-AzureRMDataLakeStoreItem -Account $accountName -path $moveFolder}
Expand Down Expand Up @@ -600,6 +612,17 @@ function Test-DataLakeStoreFileSystemPermissions
# define the permissions to add/remove
$aceUserId = "027c28d5-c91d-49f0-98c5-d10134b169b3"

#set owner
New-AdlStoreItem -Account $accountName -Path "/temp"
$prevOwner=Get-AdlStoreItemOwner -Account $accountName -Path "/temp" -Type User
$prevGroup=Get-AdlStoreItemOwner -Account $accountName -Path "/temp" -Type Group
$currentOwner=Set-AdlStoreItemOwner -Account $accountName -Path "/temp" -Type User -Id $aceUserId -PassThru
$currentGroup=Get-AdlStoreItemOwner -Account $accountName -Path "/temp" -Type Group
Assert-AreEqual $aceUserId $currentOwner
Assert-AreNotEqual $prevOwner $currentOwner
Assert-AreEqual $prevGroup $currentGroup
Remove-AdlStoreItem -Account $accountName -paths "/temp" -force

# Set and get all the permissions
$result = Get-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/"
Assert-NotNull $result "Did not get any result from ACL get"
Expand Down Expand Up @@ -636,14 +659,17 @@ function Test-DataLakeStoreFileSystemPermissions
Set-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/" -AceType User -Id $aceUserId -Permissions All
$result = Get-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/"
Assert-AreEqual $($currentCount+1) $result.Count

# remove a specific permission with friendly remove
Remove-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/" -AceType User -Id $aceUserId
$result = Get-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/"
Assert-AreEqual $($currentCount) $result.Count

# set and get a specific permission with the ACE string
Set-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/" -Acl $([string]::Format("user:{0}:rwx", $aceUserId))
$result = Get-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/"
Assert-AreEqual $($currentCount+1) $result.Count

# remove a specific permission with the ACE string
Remove-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/" -Acl $([string]::Format("user:{0}:---", $aceUserId))
$result = Get-AzureRMDataLakeStoreItemAclEntry -Account $accountName -path "/"
Expand Down
Loading