Skip to content

Support pagination for enumerating deleted items #26974

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

Open
wants to merge 17 commits into
base: release-2025-06-03
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -25,6 +25,7 @@ namespace Microsoft.Azure.Commands.DataLakeStore.Test.ScenarioTests

public class AdlsAliasTests : DataLakeStoreTestRunner
{
private readonly string AccountName = "sss-datalakestore-test-c17";
private readonly string ResourceGroupLocation = "westus";
private readonly string TestFileSystemPermissionResourceGroupLocation = "ukwest";
private readonly string TestFileSystemResourceGroupLocation = "ukwest";
Expand Down Expand Up @@ -75,14 +76,14 @@ public void TestAdlsFileSystem()
{
var workingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
var testLocation = Path.Combine(workingPath, "ScenarioTests", (this.GetType().Name + ".ps1"));
TestRunner.RunTestScript($"Test-DataLakeStoreFileSystem -fileToCopy '{testLocation}' -location '{TestFileSystemResourceGroupLocation}'");
TestRunner.RunTestScript($"Test-DataLakeStoreFileSystem -fileToCopy '{testLocation}' -location '{ResourceGroupLocation}' -accountName '{AccountName}'");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAdlsFileSystemPermissions()
{
TestRunner.RunTestScript($"Test-DataLakeStoreFileSystemPermissions -location '{TestFileSystemPermissionResourceGroupLocation}'");
TestRunner.RunTestScript($"Test-DataLakeStoreFileSystemPermissions -location '{ResourceGroupLocation}' -accountName '{AccountName}'");
}

[Fact]
Expand All @@ -96,7 +97,7 @@ public void TestNegativeAdlsAccount()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAdlsEnumerateAndRestoreDeletedItem()
{
TestRunner.RunTestScript($"Test-AdlsEnumerateAndRestoreDeletedItem -location '{ResourceGroupLocation}'");
TestRunner.RunTestScript($"Test-AdlsEnumerateAndRestoreDeletedItem -location '{ResourceGroupLocation}' -accountName '{AccountName}'");
}
}
}
138 changes: 24 additions & 114 deletions src/DataLakeStore/DataLakeStore.Test/ScenarioTests/AdlsAliasTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ function Test-DataLakeStoreFileSystem
param
(
$fileToCopy,
$location
$location,
$accountName
)

if ([string]::IsNullOrEmpty($location))
Expand All @@ -498,34 +499,6 @@ function Test-DataLakeStoreFileSystem

try
{
# Creating Account
$resourceGroupName = Get-ResourceGroupName
$accountName = Get-DataLakeStoreAccountName
New-AzResourceGroup -Name $resourceGroupName -Location $location
$accountCreated = New-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName -Location $location -DisableEncryption

Assert-AreEqual $accountName $accountCreated.Name
Assert-AreEqual $location $accountCreated.Location
Assert-AreEqual "Microsoft.DataLakeStore/accounts" $accountCreated.Type
Assert-True {$accountCreated.Id -like "*$resourceGroupName*"}

# In loop to check if account exists
for ($i = 0; $i -le 60; $i++)
{
[array]$accountGet = Get-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName
if ($accountGet[0].ProvisioningState -like "Succeeded")
{
Assert-AreEqual $accountName $accountGet[0].Name
Assert-AreEqual $location $accountGet[0].Location
Assert-AreEqual "Microsoft.DataLakeStore/accounts" $accountGet[0].Type
Assert-True {$accountGet[0].Id -like "*$resourceGroupName*"}
break
}

Write-Host "account not yet provisioned. current state: $($accountGet[0].ProvisioningState)"
[Microsoft.WindowsAzure.Commands.Utilities.Common.TestMockSupport]::Delay(30000)
Assert-False {$i -eq 60} " Data Lake Store account is not in succeeded state even after 30 min."
}

# define all the files and folders to create
$encodingFolder="/encodingFolder"
Expand Down Expand Up @@ -724,18 +697,12 @@ function Test-DataLakeStoreFileSystem
Assert-True {Remove-AdlStoreItem -Account $accountName -paths $summaryFolder -force -recurse -passthru} "Remove folder failed"
Assert-Throws {Get-AdlStoreItem -Account $accountName -path $summaryFolder}
Assert-True {Remove-AdlStoreItem -Account $accountName -paths $encodingFolder -force -recurse -passthru} "Remove folder failed"

# Delete Data Lake account
Assert-True {Remove-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName -Force -PassThru} "Remove Account failed."

# Verify that it is gone by trying to get it again
Assert-Throws {Get-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName}
}
finally
{
# cleanup the resource group that was used in case it still exists. This is a best effort task, we ignore failures here.
Invoke-HandledCmdlet -Command {Remove-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName -Force -ErrorAction SilentlyContinue} -IgnoreFailures
Invoke-HandledCmdlet -Command {Remove-AzResourceGroup -Name $resourceGroupName -Force -ErrorAction SilentlyContinue} -IgnoreFailures
# Skip cleanup for existing account and resource group
Write-Host "Skipping cleanup for existing account and resource group."
}
}

Expand All @@ -747,7 +714,8 @@ function Test-DataLakeStoreFileSystemPermissions
{
param
(
$location
$location,
$accountName
)

if ([string]::IsNullOrEmpty($location))
Expand All @@ -757,34 +725,6 @@ function Test-DataLakeStoreFileSystemPermissions

try
{
# Creating Account
$resourceGroupName = Get-ResourceGroupName
$accountName = Get-DataLakeStoreAccountName
New-AzResourceGroup -Name $resourceGroupName -Location $location
$accountCreated = New-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName -Location $location -DisableEncryption

Assert-AreEqual $accountName $accountCreated.Name
Assert-AreEqual $location $accountCreated.Location
Assert-AreEqual "Microsoft.DataLakeStore/accounts" $accountCreated.Type
Assert-True {$accountCreated.Id -like "*$resourceGroupName*"}

# In loop to check if account exists
for ($i = 0; $i -le 60; $i++)
{
[array]$accountGet = Get-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName
if ($accountGet[0].ProvisioningState -like "Succeeded")
{
Assert-AreEqual $accountName $accountGet[0].Name
Assert-AreEqual $location $accountGet[0].Location
Assert-AreEqual "Microsoft.DataLakeStore/accounts" $accountGet[0].Type
Assert-True {$accountGet[0].Id -like "*$resourceGroupName*"}
break
}

Write-Host "account not yet provisioned. current state: $($accountGet[0].ProvisioningState)"
[Microsoft.WindowsAzure.Commands.Utilities.Common.TestMockSupport]::Delay(30000)
Assert-False {$i -eq 60} " Data Lake Store account is not in succeeded state even after 30 min."
}

#define folder name to create for recursive Acl
$folderToCreate = "/aclRecurseFolder"
Expand Down Expand Up @@ -888,18 +828,11 @@ function Test-DataLakeStoreFileSystemPermissions
Set-AdlStoreItemPermission -Account $accountName -path "/" -Permission 777 | Out-Null
$permission = Get-AdlStoreItemPermission -Account $accountName -path "/"
Assert-AreEqual 777 $permission

# Delete Data Lake account
Assert-True {Remove-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName -Force -PassThru} "Remove Account failed."

# Verify that it is gone by trying to get it again
Assert-Throws {Get-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName}
}
finally
{
# cleanup the resource group that was used in case it still exists. This is a best effort task, we ignore failures here.
Invoke-HandledCmdlet -Command {Remove-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName -Force -ErrorAction SilentlyContinue} -IgnoreFailures
Invoke-HandledCmdlet -Command {Remove-AzResourceGroup -Name $resourceGroupName -Force -ErrorAction SilentlyContinue} -IgnoreFailures
# Skip cleanup for existing account and resource group
Write-Host "Skipping cleanup for existing account and resource group."
}
}

Expand Down Expand Up @@ -1007,7 +940,8 @@ function Test-AdlsEnumerateAndRestoreDeletedItem
param
(
$fileToCopy,
$location
$location,
$accountName
)

if ([string]::IsNullOrEmpty($location))
Expand All @@ -1017,39 +951,11 @@ function Test-AdlsEnumerateAndRestoreDeletedItem

try
{
# Creating Account
$resourceGroupName = Get-ResourceGroupName
$accountName = Get-DataLakeStoreAccountName + "-c12" # testing accountname validation
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location
$accountCreated = New-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName -Location $location
Assert-AreEqual $accountName $accountCreated.Name
Assert-AreEqual $location $accountCreated.Location
Assert-AreEqual "Microsoft.DataLakeStore/accounts" $accountCreated.Type
Assert-True {$accountCreated.Id -like "*$resourceGroupName*"}

# In loop to check if account exists
for ($i = 0; $i -le 60; $i++)
{
[array]$accountGet = Get-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName
if ($accountGet[0].ProvisioningState -like "Succeeded")
{
Assert-AreEqual $accountName $accountGet[0].Name
Assert-AreEqual $location $accountGet[0].Location
Assert-AreEqual "Microsoft.DataLakeStore/accounts" $accountGet[0].Type
Assert-True {$accountGet[0].Id -like "*$resourceGroupName*"}
break
}

Write-Host "account not yet provisioned. current state: $($accountGet[0].ProvisioningState)"
[Microsoft.WindowsAzure.Commands.Utilities.Common.TestMockSupport]::Delay(30000)
Assert-False {$i -eq 60} " Data Lake Store account is not in succeeded state even after 30 min."
}

# define all the files and folders
# define all the files and folders
$folderToCreate1 = "/adlfolderTest1"
$folderToCreate2 = "/adlfolderTest2"
$fileToCreate1 = "/adlfolderTest1/adlfile1"
$fileToCreate1 = "/adlfolderTest1/testadlfile1"
$fileToCreate2 = "/adlfolderTest2/adlfile2"

# Create and get Empty folder
Expand All @@ -1075,25 +981,29 @@ function Test-AdlsEnumerateAndRestoreDeletedItem
$out = Get-AdlStoreDeletedItem -Account $accountName -filter "adlfolderTest1" -Count 1000
foreach($item in $out)
{
Assert-True { Restore-AdlStoreDeletedItem -Account $accountName -Path $item.TrashDirPath -Destination $item.OriginalPath -Type "file" -Force -Passthru}
# Check if the destination already exists
$relativeOriginalPath = $item.OriginalPath -replace "^adl://[^/]+", ""
if (Test-AzDataLakeStoreItem -Account $accountName -Path $relativeOriginalPath) {
continue
}
Assert-True { Restore-AdlStoreDeletedItem -Account $accountName -Path $item.TrashDirPath -Destination $item.OriginalPath -Type $item.Type -Force -Passthru}
}

$out = Get-AdlStoreDeletedItem -Account $accountName -filter "adlfolderTest2" -Count 1000
foreach($item in $out)
{
# Check if the destination already exists
$relativeOriginalPath = $item.OriginalPath -replace "^adl://[^/]+", ""
if (Test-AzDataLakeStoreItem -Account $accountName -Path $relativeOriginalPath) {
continue
}
Assert-True { Restore-AdlStoreDeletedItem -Account $accountName $item -Force -Passthru}
}

# Delete Data Lake account
Assert-True {Remove-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName -Force -PassThru} "Remove Account failed."

# Verify that it is gone by trying to get it again
Assert-Throws {Get-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName}
}
finally
{
# cleanup the resource group that was used in case it still exists. This is a best effort task, we ignore failures here.
Invoke-HandledCmdlet -Command {Remove-AdlStore -ResourceGroupName $resourceGroupName -Name $accountName -Force -ErrorAction SilentlyContinue} -IgnoreFailures
Invoke-HandledCmdlet -Command {Remove-AzResourceGroup -Name $resourceGroupName -Force -ErrorAction SilentlyContinue} -IgnoreFailures
# Skip cleanup for existing account and resource group
Write-Host "Skipping cleanup for existing account and resource group."
}
}
14 changes: 11 additions & 3 deletions src/DataLakeStore/DataLakeStore.Test/ScenarioTests/AdlsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace Microsoft.Azure.Commands.DataLakeStore.Test.ScenarioTests

public class AdlsTests : DataLakeStoreTestRunner
{
private readonly string AccountName = "sss-datalakestore-test-c17";
private readonly string ResourceGroupLocation = "westus";
private readonly string TestFileSystemPermissionResourceGroupLocation = "ukwest";
private readonly string TestFileSystemResourceGroupLocation = "ukwest";
Expand Down Expand Up @@ -74,14 +75,14 @@ public void TestAdlsFileSystem()
{
var workingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
var testLocation = Path.Combine(workingPath, "ScenarioTests", (this.GetType().Name + ".ps1"));
TestRunner.RunTestScript($"Test-DataLakeStoreFileSystem -fileToCopy '{testLocation}' -location '{TestFileSystemResourceGroupLocation}'");
TestRunner.RunTestScript($"Test-DataLakeStoreFileSystem -fileToCopy '{testLocation}' -location '{ResourceGroupLocation}' -accountName '{AccountName}'");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAdlsFileSystemPermissions()
{
TestRunner.RunTestScript($"Test-DataLakeStoreFileSystemPermissions -location '{TestFileSystemPermissionResourceGroupLocation}'");
TestRunner.RunTestScript($"Test-DataLakeStoreFileSystemPermissions -location '{ResourceGroupLocation}' -accountName '{AccountName}'");
}

[Fact]
Expand All @@ -91,11 +92,18 @@ public void TestNegativeAdlsAccount()
TestRunner.RunTestScript($"Test-NegativeDataLakeStoreAccount -location '{ResourceGroupLocation}'");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAdlsEnumerateDeletedItem()
{
TestRunner.RunTestScript($"Test-EnumerateDataLakeStoreDeletedItem -location '{ResourceGroupLocation}' -accountName '{AccountName}'");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAdlsEnumerateAndRestoreDeletedItem()
{
TestRunner.RunTestScript($"Test-EnumerateAndRestoreDataLakeStoreDeletedItem -location '{ResourceGroupLocation}'");
TestRunner.RunTestScript($"Test-EnumerateAndRestoreDataLakeStoreDeletedItem -location '{ResourceGroupLocation} '-accountName '{AccountName}'");
}
}
}
Loading
Loading