-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into adreed/folder-naming
- Loading branch information
Showing
18 changed files
with
465 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
parameters: | ||
- name: storage_account_name | ||
type: string | ||
- name: container_name | ||
type: string | ||
- name: orp_source_account_name | ||
type: string | ||
- name: orp_destination_account_name | ||
type: string | ||
- name: orp_source_container_name | ||
type: string | ||
- name: destination_container_name | ||
type: string | ||
- name: goos | ||
type: string | ||
- name: goarch | ||
type: string | ||
- name: cgo_enabled | ||
type: string | ||
- name: build_name | ||
type: string | ||
- name: azcopy_msi_app_id | ||
type: string | ||
|
||
steps: | ||
- task: PowerShell@2 | ||
displayName: "Run Scenarios" | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
# Print "Building executable" | ||
echo "Building executable" | ||
# Set environment variables | ||
$build_name = '${{ parameters.build_name }}' | ||
$env:GOOS = '${{ parameters.goos }}' | ||
$env:GOARCH = '${{ parameters.goarch }}' | ||
$env:AZCOPY_AUTO_LOGIN_TYPE = "MSI" | ||
$env:AZCOPY_MSI_CLIENT_ID = '${{ parameters.azcopy_msi_app_id }}' | ||
$env:CGO_ENABLED = '${{ parameters.cgo_enabled }}' | ||
go build -cover -o $build_name | ||
# Check if the executable was created | ||
if (-Not (Test-Path "./$build_name")) { | ||
Write-Error "Executable not found: $build_name" | ||
exit 1 | ||
} | ||
Write-Output "Executable built successfully: $build_name" | ||
######################################################## Scenario 1 ######################################################## | ||
# Right now we dont have this fix available in the older version of AzCopy. So, we are using the latest version of AzCopy to run the scenarios. | ||
# We will update this workaround once the fix is available in the older version of AzCopy. | ||
echo "Scenario 1: Test successful copying from BlobToPipe" | ||
echo "Creating container '${{ parameters.container_name }}' in storage account '${{ parameters.storage_account_name }}'" | ||
& "./$build_name" "make" "https://${{ parameters.storage_account_name }}.blob.core.windows.net/${{ parameters.container_name }}" | ||
echo "Copy a test file from local to the created container" | ||
echo "Hello, Azure!" > myfile.txt | ||
& "./$build_name" "cp" "myfile.txt" "https://${{ parameters.storage_account_name }}.blob.core.windows.net/${{ parameters.container_name }}" | ||
& "./$build_name" "cp" "https://${{ parameters.storage_account_name }}.blob.core.windows.net/${{ parameters.container_name }}/myfile.txt" "--from-to=BlobPipe" "--check-md5" "FailIfDifferentOrMissing" > filename | ||
if ($LASTEXITCODE -eq 0) { | ||
Write-Output "Successfully executed the scenario." | ||
} else { | ||
Write-Error "AzCopy command failed with exit code $LASTEXITCODE." | ||
} | ||
# Perform cleanup | ||
echo "Perform cleanup" | ||
echo "Remove the test file from the container" | ||
& "./$build_name" "rm" "https://${{ parameters.storage_account_name }}.blob.core.windows.net/${{ parameters.container_name }}/myfile.txt" | ||
echo "Remove the container from the storage account" | ||
& az storage container delete --name ${{ parameters.container_name }} --account-name ${{ parameters.storage_account_name }} | ||
######################################################## Scenario 2 ######################################################## | ||
# Test copying from Object Replication Policy source container to destination container | ||
# Assign an object replication policy to a storage account. | ||
# Perform azcopy copy operation to copy the blob to another container. | ||
echo "Scenario 2: Test copying from Object Replication Policy source container to destination container" | ||
echo "Creating a test file named 'myfile.txt' and copying it to the source container '${{ parameters.orp_source_container_name }}' within the storage account '${{ parameters.orp_source_account_name }}', which has the ORP policy applied." | ||
echo "Hello, Azure!" > myfile.txt | ||
& "./$build_name" "cp" "myfile.txt" "https://${{ parameters.orp_source_account_name }}.blob.core.windows.net/${{ parameters.orp_source_container_name }}" | ||
echo "Copy the test file from the source container to the destination container '${{ parameters.destination_container_name }}' in storage account '${{ parameters.orp_destination_account_name }}'." | ||
& "./$build_name" "cp" "https://${{ parameters.orp_source_account_name }}.blob.core.windows.net/${{parameters.orp_source_container_name}}" "https://${{ parameters.orp_destination_account_name }}.blob.core.windows.net/${{parameters.destination_container_name}}" --recursive | ||
if ($LASTEXITCODE -eq 0) { | ||
Write-Output "Successfully executed the scenario." | ||
} else { | ||
Write-Error "AzCopy command failed with exit code $LASTEXITCODE." | ||
} | ||
# Perform cleanup | ||
echo "Perform cleanup" | ||
echo "Remove the test file from the source and destination container" | ||
& "./$build_name" "rm" "https://${{ parameters.orp_destination_account_name }}.blob.core.windows.net/${{parameters.destination_container_name}}/myfile.txt" | ||
& "./$build_name" "rm" "https://${{ parameters.orp_source_account_name }}.blob.core.windows.net/${{ parameters.orp_source_container_name }}/myfile.txt" | ||
displayName: "Run Scenarios" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Set-PSDebug -Trace 1 | ||
|
||
$rgs = Get-AzResourceGroup -Name azcopy-newe2e-* | ||
|
||
$rmTarget = @() | ||
|
||
foreach($rg in $rgs) { | ||
if ($rg.Tags) | ||
{ | ||
$unixTime = $rg.Tags["creation"] | ||
|
||
if ($unixTime) { | ||
$date = (Get-Date 01.01.1970)+[System.TimeSpan]::FromSeconds($unixTime) | ||
if ($date.AddDays(1).CompareTo((Get-Date)) -eq -1) { | ||
$rmTarget = $rmTarget + @($rg) | ||
} | ||
} else { | ||
# If it isn't present, it's considered too old and needs to be deleted. | ||
$rmTarget = $rmTarget + @($rg) | ||
} | ||
} else { | ||
$rmTarget = $rmTarget + @($rg) | ||
} | ||
} | ||
|
||
foreach ($rg in $rmTarget) { | ||
$rgn = $rg.ResourceGroupName | ||
Write-Output "Removing $rgn" | ||
Remove-AzResourceGroup -Name $rgn -Force | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
trigger: none | ||
pr: none | ||
|
||
schedules: | ||
- cron: "0 0 * * *" | ||
displayName: "E2E cleanup (Nightly)" | ||
branches: | ||
include: [ "main" ] | ||
always: true | ||
|
||
steps: | ||
- task: AzurePowerShell@5 | ||
displayName: Clean up E2E runs | ||
inputs: | ||
azureSubscription: 'e2ecleanup' | ||
ScriptType: 'FilePath' | ||
ScriptPath: 'e2e-cleanup.ps1' | ||
FailOnStandardError: true | ||
pwsh: true | ||
azurePowershellVersion: 'LatestVersion' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.