@@ -423,38 +423,46 @@ function Test-DataLakeStoreFileSystem
423
423
$result = Get-AzureRMDataLakeStoreItem - Account $accountName - path $folderToCreate
424
424
Assert-NotNull $result " No value was returned on folder get"
425
425
Assert-AreEqual " Directory" $result.Type
426
+
426
427
# Create and get Empty File
427
428
$result = New-AzureRMDataLakeStoreItem - Account $accountName - path $emptyFilePath
428
429
Assert-NotNull $result " No value was returned on empty file creation"
429
430
$result = Get-AzureRMDataLakeStoreItem - Account $accountName - path $emptyFilePath
431
+ $emptyFileCreationDate = $result.LastWriteTime # To be used later
430
432
Assert-NotNull $result " No value was returned on empty file get"
431
433
Assert-AreEqual " File" $result.Type
432
434
Assert-AreEqual 0 $result.Length
435
+
433
436
# Create and get file with content
434
437
$result = New-AzureRMDataLakeStoreItem - Account $accountName - path $contentFilePath - Value $content
435
438
Assert-NotNull $result " No value was returned on content file creation"
436
439
$result = Get-AzureRMDataLakeStoreItem - Account $accountName - path $contentFilePath
437
440
Assert-NotNull $result " No value was returned on content file get"
438
441
Assert-AreEqual " File" $result.Type
439
442
Assert-AreEqual $content.length $result.Length
440
- # set and validate expiration for a file
443
+
444
+ # set absolute expiration for content file
441
445
Assert-True {253402300800000 -ge $result.ExpirationTime -or 0 -le $result.ExpirationTime } # validate that expiration is currently max value
442
446
[DateTimeOffset ]$timeToUse = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer ]::GetVariable(" absoluteTime" , [DateTimeOffset ]::UtcNow.AddSeconds(120 ))
443
- $result = Set-AzureRmDataLakeStoreItemExpiry - Account $accountName - path $contentFilePath - Expiration $timeToUse
444
- Assert-AreEqual $timeToUse.UtcTicks $result.Expiration.UtcTicks
447
+ $result = Set-AdlStoreItemExpiry - Account $accountName - path $contentFilePath - Expiration $timeToUse
448
+ Assert-NumAreInRange $timeToUse.UtcTicks $result.Expiration.UtcTicks 500000 # range of 50 milliseconds
449
+
445
450
# set it back to "never expire"
446
- $result = Set-AzureRmDataLakeStoreItemExpiry - Account $accountName - path $contentFilePath
451
+ $result = Set-AdlStoreItemExpiry - Account $accountName - path $contentFilePath
447
452
Assert-True {253402300800000 -ge $result.ExpirationTime -or 0 -le $result.ExpirationTime } # validate that expiration is currently max value
453
+
448
454
# list files
449
455
$result = Get-AzureRMDataLakeStoreChildItem - Account $accountName - path $folderToCreate
450
456
Assert-NotNull $result " No value was returned on folder list"
451
457
Assert-AreEqual 2 $result.length
458
+
452
459
# add content to empty file
453
460
Add-AzureRMDataLakeStoreItemContent - Account $accountName - Path $emptyFilePath - Value $content
454
461
$result = Get-AzureRMDataLakeStoreItem - Account $accountName - path $emptyFilePath
455
462
Assert-NotNull $result " No value was returned on empty file get with content added"
456
463
Assert-AreEqual " File" $result.Type
457
464
Assert-AreEqual $content.length $result.Length
465
+
458
466
# concat files
459
467
$result = Join-AzureRMDataLakeStoreItem - Account $accountName - Paths $emptyFilePath , $contentFilePath - Destination $concatFile
460
468
Assert-NotNull $result " No value was returned on concat file"
@@ -505,6 +513,7 @@ function Test-DataLakeStoreFileSystem
505
513
Assert-NotNull $result " No value was returned on import file get"
506
514
Assert-AreEqual " File" $result.Type
507
515
Assert-AreEqual $localFileInfo.length $result.Length
516
+
508
517
# download file
509
518
$currentDir = Split-Path $fileToCopy
510
519
$targetFile = Join-Path $currentDir " adlspstestdownload.txt"
@@ -517,7 +526,7 @@ function Test-DataLakeStoreFileSystem
517
526
$downloadedFileInfo = Get-ChildItem $targetFile
518
527
Assert-AreEqual $ ($content.length * 2 ) $downloadedFileInfo.length
519
528
Remove-Item - path $targetFile - force - confirm:$false
520
-
529
+
521
530
# move a file
522
531
$result = Move-AzureRMDataLakeStoreItem - Account $accountName - Path $concatFile - Destination $moveFile
523
532
Assert-NotNull $result " No value was returned on move file"
@@ -526,6 +535,7 @@ function Test-DataLakeStoreFileSystem
526
535
Assert-AreEqual " File" $result.Type
527
536
Assert-AreEqual $ ($content.length * 2 ) $result.Length
528
537
Assert-Throws {Get-AzureRMDataLakeStoreItem - Account $accountName - path $concatFile }
538
+
529
539
# move a folder
530
540
$result = Move-AzureRMDataLakeStoreItem - Account $accountName - Path $folderToCreate - Destination $moveFolder
531
541
Assert-NotNull $result " No value was returned on move folder"
@@ -534,9 +544,11 @@ function Test-DataLakeStoreFileSystem
534
544
Assert-AreEqual " Directory" $result.Type
535
545
Assert-AreEqual 0 $result.Length
536
546
Assert-Throws {Get-AzureRMDataLakeStoreItem - Account $accountName - path $folderToCreate }
547
+
537
548
# delete a file
538
549
Assert-True {Remove-AzureRMDataLakeStoreItem - Account $accountName - paths " $moveFolder /movefile.txt" - force - passthru } " Remove File Failed"
539
550
Assert-Throws {Get-AzureRMDataLakeStoreItem - Account $accountName - path $moveFile }
551
+
540
552
# delete a folder
541
553
Assert-True {Remove-AzureRMDataLakeStoreItem - Account $accountName - paths $moveFolder - force - recurse - passthru} " Remove folder failed"
542
554
Assert-Throws {Get-AzureRMDataLakeStoreItem - Account $accountName - path $moveFolder }
@@ -600,6 +612,17 @@ function Test-DataLakeStoreFileSystemPermissions
600
612
# define the permissions to add/remove
601
613
$aceUserId = " 027c28d5-c91d-49f0-98c5-d10134b169b3"
602
614
615
+ # set owner
616
+ New-AdlStoreItem - Account $accountName - Path " /temp"
617
+ $prevOwner = Get-AdlStoreItemOwner - Account $accountName - Path " /temp" - Type User
618
+ $prevGroup = Get-AdlStoreItemOwner - Account $accountName - Path " /temp" - Type Group
619
+ $currentOwner = Set-AdlStoreItemOwner - Account $accountName - Path " /temp" - Type User - Id $aceUserId - PassThru
620
+ $currentGroup = Get-AdlStoreItemOwner - Account $accountName - Path " /temp" - Type Group
621
+ Assert-AreEqual $aceUserId $currentOwner
622
+ Assert-AreNotEqual $prevOwner $currentOwner
623
+ Assert-AreEqual $prevGroup $currentGroup
624
+ Remove-AdlStoreItem - Account $accountName - paths " /temp" - force
625
+
603
626
# Set and get all the permissions
604
627
$result = Get-AzureRMDataLakeStoreItemAclEntry - Account $accountName - path " /"
605
628
Assert-NotNull $result " Did not get any result from ACL get"
@@ -636,14 +659,17 @@ function Test-DataLakeStoreFileSystemPermissions
636
659
Set-AzureRMDataLakeStoreItemAclEntry - Account $accountName - path " /" - AceType User - Id $aceUserId - Permissions All
637
660
$result = Get-AzureRMDataLakeStoreItemAclEntry - Account $accountName - path " /"
638
661
Assert-AreEqual $ ($currentCount + 1 ) $result.Count
662
+
639
663
# remove a specific permission with friendly remove
640
664
Remove-AzureRMDataLakeStoreItemAclEntry - Account $accountName - path " /" - AceType User - Id $aceUserId
641
665
$result = Get-AzureRMDataLakeStoreItemAclEntry - Account $accountName - path " /"
642
666
Assert-AreEqual $ ($currentCount ) $result.Count
667
+
643
668
# set and get a specific permission with the ACE string
644
669
Set-AzureRMDataLakeStoreItemAclEntry - Account $accountName - path " /" - Acl $ ([string ]::Format(" user:{0}:rwx" , $aceUserId ))
645
670
$result = Get-AzureRMDataLakeStoreItemAclEntry - Account $accountName - path " /"
646
671
Assert-AreEqual $ ($currentCount + 1 ) $result.Count
672
+
647
673
# remove a specific permission with the ACE string
648
674
Remove-AzureRMDataLakeStoreItemAclEntry - Account $accountName - path " /" - Acl $ ([string ]::Format(" user:{0}:---" , $aceUserId ))
649
675
$result = Get-AzureRMDataLakeStoreItemAclEntry - Account $accountName - path " /"
0 commit comments