Skip to content

Commit 05283f6

Browse files
authored
Fix Sql scenario test random failure issue (#23207)
* Fix Sql scenario test random failure issue * Add instruction for re-recording ElasticJobPrivateEndpoint test cases
1 parent 6e01438 commit 05283f6

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Sql/Sql.Test/ScenarioTests/DistributedAvailabilityGroupTests.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function Test-ManagedInstanceLink
5858
Assert-Null $listLinksZero
5959

6060
$upsertJ = New-AzSqlInstanceLink -ResourceGroupName $rgName -InstanceName $miName -LinkName $linkName -PrimaryAvailabilityGroupName $primaryAGName -SecondaryAvailabilityGroupName $secondaryAGName -TargetDatabase $targetDatabase -SourceEndpoint $sourceEndpoint -AsJob
61+
$upsertJ | Wait-Job
6162

6263
# wait a little bit for the link resource to be created
6364
Wait-Seconds 60
@@ -218,6 +219,7 @@ function Test-ManagedInstanceLinkErrHandling
218219

219220
# upsert via CreateByParentObjectParameterSet
220221
$upsertJ = New-AzSqlInstanceLink -InstanceObject $instance -LinkName $linkName -PrimaryAvailabilityGroupName $primaryAGName -SecondaryAvailabilityGroupName $secondaryAGName -TargetDatabase $targetDatabase -SourceEndpoint $sourceEndpoint -AsJob
222+
$upsertJ | Wait-Job
221223

222224
# wait a little bit for the link resource to be created
223225
Wait-Seconds 60
@@ -300,7 +302,8 @@ function Test-ManagedInstanceLinkPiping
300302

301303
# Upsert and get with parent instance Piping
302304
$upsertJ = $instance | New-AzSqlInstanceLink -LinkName $linkNamePipe -PrimaryAvailabilityGroupName $primaryAGNamePipe -SecondaryAvailabilityGroupName $secondaryAGNamePipe -TargetDatabase $targetDatabasePipe -SourceEndpoint $sourceEndpointPipe -AsJob
303-
305+
$upsertJ | Wait-Job
306+
304307
# wait a little bit for the link resource to be created
305308
Wait-Seconds 60
306309
$listResp = $instance | Get-AzSqlInstanceLink

src/Sql/Sql.Test/ScenarioTests/ElasticJobPrivateEndpointCrudTests.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ function Test-CreateJobPrivateEndpoint
2424
{
2525
$peName = Get-JobPrivateEndpointName
2626
$s1 = Get-AzSqlServer -ResourceGroupName $a1.ResourceGroupName -ServerName $a1.ServerName
27+
# Be aware, to successfully re-record this test you will have to go approve the private endpoint in the server's Networking blade. Otherwise, it will not complete or will timeout.
2728
$pe1AsJob = New-AzSqlElasticJobPrivateEndpoint -ElasticJobAgentObject $a1 -Name $peName -TargetServerAzureResourceId $s1.ResourceId -AsJob
29+
$pe1AsJob | Wait-Job
2830

2931
# Give the backend a chance to persist the private endpoint before running Get
30-
Start-Sleep 10
32+
Start-TestSleep 10
3133

3234
$pe1 = Get-AzSqlElasticJobPrivateEndpoint -ElasticJobAgentObject $a1 -Name $peName
3335

@@ -62,10 +64,12 @@ function Test-GetJobPrivateEndpoint
6264
{
6365
$peName = Get-JobPrivateEndpointName
6466
$s1 = Get-AzSqlServer -ResourceGroupName $a1.ResourceGroupName -ServerName $a1.ServerName
67+
# Be aware, to successfully re-record this test you will have to go approve the private endpoint in the server's Networking blade. Otherwise, it will not complete or will timeout.
6568
$pe1AsJob = New-AzSqlElasticJobPrivateEndpoint -ElasticJobAgentObject $a1 -Name $peName -TargetServerAzureResourceId $s1.ResourceId -AsJob
69+
$pe1AsJob | Wait-Job
6670

6771
# Give the backend a chance to persist the private endpoint before running Get
68-
Start-Sleep 10
72+
Start-TestSleep 10
6973

7074
# Validate with Default set
7175
$pe1 = Get-AzSqlElasticJobPrivateEndpoint -ResourceGroupName $a1.ResourceGroupName -ServerName $a1.ServerName -AgentName $a1.AgentName -Name $peName
@@ -134,10 +138,12 @@ function Test-RemoveJobPrivateEndpoint
134138
{
135139
$peName = Get-JobPrivateEndpointName
136140
$s1 = Get-AzSqlServer -ResourceGroupName $a1.ResourceGroupName -ServerName $a1.ServerName
141+
# Be aware, to successfully re-record this test you will have to go approve the private endpoint in the server's Networking blade. Otherwise, it will not complete or will timeout.
137142
$pe1AsJob = New-AzSqlElasticJobPrivateEndpoint -ElasticJobAgentObject $a1 -Name $peName -TargetServerAzureResourceId $s1.ResourceId -AsJob
143+
$pe1AsJob | Wait-Job
138144

139145
# Give the backend a chance to persist the private endpoint before running Get
140-
Start-Sleep 10
146+
Start-TestSleep 10
141147

142148
$pe1 = Get-AzSqlElasticJobPrivateEndpoint -ElasticJobAgentObject $a1 -Name $peName
143149

0 commit comments

Comments
 (0)