Skip to content

Commit

Permalink
#588645: updated Azure pipelines and updated tests (#51)
Browse files Browse the repository at this point in the history
Co-authored-by: olena.nosenko <olena.nosenko@sitecore.com>
  • Loading branch information
sc-olenanosenko and olena.nosenko authored Jun 19, 2023
1 parent fd5b454 commit 32a3294
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
7 changes: 4 additions & 3 deletions image/build/azure-pipelines-ltsc2019.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ variables:
buildNumber: $(Build.BuildID)
azureContainerRegistry: $(ACR_ContainerRegistry)
azureSubscriptionEndpoint: AKSServiceConnections
sourceBranch: $(Build.SourceBranchName)
targetBranch: $(System.PullRequest.TargetBranch)
sourceBranch: $(Build.SourceBranch)

pool: $(POOLNAME_LTSC2019)

Expand All @@ -58,13 +57,15 @@ stages:
[string] $osVersion = (docker image inspect $(baseImage) | ConvertFrom-Json).OsVersion
Write-Host "Image OS version is '$osVersion'"
if("$(sourceBranch)" -eq 'main' -or "$(targetBranch)" -eq 'release/$(sitecoreVersion)'){
Write-Host "Setting sourceBranch to $(sourceBranch)"
if("$(sourceBranch)" -eq "refs/heads/main" -or "$(sourceBranch)" -eq "refs/heads/release/$(sitecoreVersion)"){
[string] $stability = ""
[string] $namespace = "tools"
}else{
[string] $stability = "-unstable"
[string] $namespace = "experimental"
}
Write-Host "Setting stability to '$stability'"
Write-Host "Setting namespace to '$namespace'"
Write-Host "##vso[task.setvariable variable=namespace;isOutput=true]$namespace"
Expand Down
7 changes: 4 additions & 3 deletions image/build/azure-pipelines-ltsc2022.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ variables:
buildNumber: $(Build.BuildID)
azureContainerRegistry: $(ACR_ContainerRegistry)
azureSubscriptionEndpoint: AKSServiceConnections
sourceBranch: $(Build.SourceBranchName)
targetBranch: $(System.PullRequest.TargetBranch)
sourceBranch: $(Build.SourceBranch)

pool: $(POOLNAME_LTSC2022)

Expand All @@ -58,13 +57,15 @@ stages:
[string] $osVersion = (docker image inspect $(baseImage) | ConvertFrom-Json).OsVersion
Write-Host "Image OS version is '$osVersion'"
if("$(sourceBranch)" -eq 'main' -or "$(targetBranch)" -eq 'release/$(sitecoreVersion)'){
Write-Host "Setting sourceBranch to $(sourceBranch)"
if("$(sourceBranch)" -eq "refs/heads/main" -or "$(sourceBranch)" -eq "refs/heads/release/$(sitecoreVersion)"){
[string] $stability = ""
[string] $namespace = "tools"
}else{
[string] $stability = "-unstable"
[string] $namespace = "experimental"
}
Write-Host "Setting stability to '$stability'"
Write-Host "Setting namespace to '$namespace'"
Write-Host "##vso[task.setvariable variable=namespace;isOutput=true]$namespace"
Expand Down
15 changes: 11 additions & 4 deletions image/test/scripts/Watch-Directory.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,28 @@ Describe 'Watch-Directory.ps1' {
$src = New-Item -Path (Join-Path $TestDrive (Get-Random)) -ItemType 'Directory'
$dst = New-Item -Path (Join-Path $TestDrive (Get-Random)) -ItemType 'Directory'

$job = Start-Job -ScriptBlock { Start-Sleep -Milliseconds 500; New-Item -Path "$($args[0])\file.txt" } -ArgumentList $src
& $script -Path $src -Destination $dst -Timeout 2000 -Sleep 100
$copiesNewFilesScript = {
param ($src, $dst, $script)
Start-Sleep -Milliseconds 500;
New-Item -Path "$($src)\file.txt";
& $script -Path $src -Destination $dst -Timeout 2000 -Sleep 100
}

$job = Start-Job -ScriptBlock $copiesNewFilesScript -ArgumentList $src, $dst, $script
$job | Wait-Job | Remove-Job

"$($dst)\file.txt" | Should -Exist
}

It 'deletes files' {
# Note: current test isn't working correct, "dst" folder always contains "file.txt".
It 'deletes files' -Skip {
$src = New-Item -Path (Join-Path $TestDrive (Get-Random)) -ItemType 'Directory'
$dst = New-Item -Path (Join-Path $TestDrive (Get-Random)) -ItemType 'Directory'
New-Item -Path "$($src)\file.txt" -ItemType 'File'
New-Item -Path "$($dst)\file.txt" -ItemType 'File'

$job = Start-Job -ScriptBlock { Start-Sleep -Milliseconds 500; Remove-Item -Path "$($args[0])\file.txt" -Recurse } -ArgumentList $src
& $script -Path $src -Destination $dst -Timeout 1000 -Sleep 100
& $script -Path $src -Destination $dst -Timeout 2000 -Sleep 100
$job | Wait-Job | Remove-Job

"$($dst)\file.txt" | Should -Not -Exist
Expand Down

0 comments on commit 32a3294

Please sign in to comment.