Skip to content

Commit b5ca316

Browse files
committed
fix timing issues
1 parent fe639f6 commit b5ca316

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

tests/Get-DbaExternalProcess.Tests.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,17 @@ Describe $CommandName -Tag IntegrationTests {
6969
GO"
7070

7171
# remove sql file
72-
Remove-Item -Path $sqlFile
72+
foreach ($run in 1..20) {
73+
try {
74+
Remove-Item -Path $sqlFile -ErrorAction Stop
75+
break
76+
} catch {
77+
Start-Sleep -Seconds 1
78+
}
79+
}
80+
if (Test-Path -Path $sqlFile) {
81+
Write-Warning -Message "File $sqlFile could not be removed."
82+
}
7383

7484
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
7585
}
@@ -78,7 +88,6 @@ Describe $CommandName -Tag IntegrationTests {
7888
It "returns a process" {
7989
Start-Sleep -Seconds 1
8090
$results = Get-DbaExternalProcess -ComputerName $computerName | Where-Object Name -eq "cmd.exe"
81-
Start-Sleep -Seconds 5
8291
$results.ComputerName | Should -Be $computerName
8392
$results.Name | Should -Be "cmd.exe"
8493
$results.ProcessId | Should -Not -Be $null

tests/Stop-DbaExternalProcess.Tests.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,17 @@ Describe $CommandName -Tag IntegrationTests {
7070
GO"
7171

7272
# remove sql file
73-
Remove-Item -Path $sqlFile
73+
foreach ($run in 1..20) {
74+
try {
75+
Remove-Item -Path $sqlFile -ErrorAction Stop
76+
break
77+
} catch {
78+
Start-Sleep -Seconds 1
79+
}
80+
}
81+
if (Test-Path -Path $sqlFile) {
82+
Write-Warning -Message "File $sqlFile could not be removed."
83+
}
7484

7585
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
7686
}
@@ -79,7 +89,6 @@ Describe $CommandName -Tag IntegrationTests {
7989
It "returns results" {
8090
Start-Sleep -Seconds 1
8191
$results = Get-DbaExternalProcess -ComputerName $computerName | Select-Object -First 1 | Stop-DbaExternalProcess
82-
Start-Sleep -Seconds 5
8392
$results.ComputerName | Should -Be $computerName
8493
$results.Name | Should -Be "cmd.exe"
8594
$results.ProcessId | Should -Not -BeNullOrEmpty

0 commit comments

Comments
 (0)