Skip to content

Commit 0604eb8

Browse files
authored
Modify Network Sdk directive and Add scenario test for LoadBalancerProbes_NoHealthyBackendsBehaviorParameter (#25429)
* Modify Network Sdk directive and Add scenario test for LoadBalancerProbes_NoHealthyBackendsBehaviorParameter * Add generated sdk
1 parent edb1005 commit 0604eb8

File tree

6 files changed

+3261
-2
lines changed

6 files changed

+3261
-2
lines changed

src/Network/Network.Management.Sdk/Generated/Models/Probe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public Probe()
170170
/// Gets or sets determines how new connections are handled by the load
171171
/// balancer when all backend instances are probed down. Possible values include: 'AllProbedDown', 'AllProbedUp'
172172
/// </summary>
173-
[Newtonsoft.Json.JsonProperty(PropertyName = "properties.NoHealthyBackendsBehavior")]
173+
[Newtonsoft.Json.JsonProperty(PropertyName = "properties.noHealthyBackendsBehavior")]
174174
public string NoHealthyBackendsBehavior {get; set; }
175175

176176
/// <summary>

src/Network/Network.Management.Sdk/Generated/Models/ProbePropertiesFormat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public ProbePropertiesFormat()
125125
/// Gets or sets determines how new connections are handled by the load
126126
/// balancer when all backend instances are probed down. Possible values include: &#39;AllProbedDown&#39;, &#39;AllProbedUp&#39;
127127
/// </summary>
128-
[Newtonsoft.Json.JsonProperty(PropertyName = "NoHealthyBackendsBehavior")]
128+
[Newtonsoft.Json.JsonProperty(PropertyName = "noHealthyBackendsBehavior")]
129129
public string NoHealthyBackendsBehavior {get; set; }
130130

131131
/// <summary>

src/Network/Network.Management.Sdk/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,7 @@ directive:
103103
model-name: Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties
104104
set:
105105
model-name: ManagedServiceIdentityUserAssignedIdentitiesValue
106+
- from: swagger-document
107+
where: $
108+
transform: return $.replace(/"NoHealthyBackendsBehavior"/g, "noHealthyBackendsBehavior")
106109
```

src/Network/Network.Test/ScenarioTests/LoadBalancerTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ public void TestLoadBalancerProbes_ProbeThresholdParameter()
9797
TestRunner.RunTestScript("Test-LoadBalancerProbes_ProbeThresholdParameter");
9898
}
9999

100+
[Fact]
101+
[Trait(Category.AcceptanceType, Category.CheckIn)]
102+
[Trait(Category.Owner, NrpTeamAlias.slbdev)]
103+
public void TestLoadBalancerProbes_NoHealthyBackendsBehaviorParameter()
104+
{
105+
TestRunner.RunTestScript("Test-LoadBalancerProbes_NoHealthyBackendsBehaviorParameter");
106+
}
107+
100108
[Fact]
101109
[Trait(Category.AcceptanceType, Category.CheckIn)]
102110
[Trait(Category.Owner, NrpTeamAlias.slbdev)]

src/Network/Network.Test/ScenarioTests/LoadBalancerTests.ps1

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,96 @@ function Test-LoadBalancerProbes_ProbeThresholdParameter
11891189
}
11901190

11911191

1192+
<#
1193+
.SYNOPSIS
1194+
Tests for load balancer probes
1195+
#>
1196+
function Test-LoadBalancerProbes_NoHealthyBackendsBehaviorParameter
1197+
{
1198+
# Setup
1199+
$rgname = Get-ResourceGroupName
1200+
$vnetName = Get-ResourceName
1201+
$subnetName = Get-ResourceName
1202+
$publicIpName = Get-ResourceName
1203+
$domainNameLabel = Get-ResourceName
1204+
$lbName = Get-ResourceName
1205+
$frontendName = Get-ResourceName
1206+
$backendAddressPoolName = Get-ResourceName
1207+
$probeName = Get-ResourceName
1208+
$inboundNatRuleName = Get-ResourceName
1209+
$lbruleName = Get-ResourceName
1210+
$rglocation = Get-ProviderLocation ResourceManagement
1211+
$resourceTypeParent = "Microsoft.Network/loadBalancers"
1212+
$location = Get-ProviderLocation $resourceTypeParent
1213+
1214+
try
1215+
{
1216+
# Create the resource group
1217+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval"}
1218+
1219+
# Create the publicip
1220+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static -DomainNameLabel $domainNameLabel
1221+
1222+
$frontend = New-AzLoadBalancerFrontendIpConfig -Name $frontendName -PublicIpAddress $publicip
1223+
$backendAddressPool = New-AzLoadBalancerBackendAddressPoolConfig -Name $backendAddressPoolName
1224+
$probe = New-AzLoadBalancerProbeConfig -Name $probeName -Protocol Tcp -Port 80 -IntervalInSeconds 15 -ProbeCount 2 -NoHealthyBackendsBehavior "AllProbedUp"
1225+
$inboundNatRule = New-AzLoadBalancerInboundNatRuleConfig -Name $inboundNatRuleName -FrontendIPConfigurationId $frontend.Id -Protocol Tcp -FrontendPort 3389 -BackendPort 3389 -IdleTimeoutInMinutes 15 -EnableFloatingIP
1226+
$lbrule = New-AzLoadBalancerRuleConfig -Name $lbruleName -FrontendIPConfigurationId $frontend.Id -BackendAddressPoolId $backendAddressPool.Id -ProbeId $probe.Id -Protocol Tcp -FrontendPort 80 -BackendPort 80 -IdleTimeoutInMinutes 15 -EnableFloatingIP
1227+
New-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname -Location $location -FrontendIpConfiguration $frontend -BackendAddressPool $backendAddressPool -Probe $probe -InboundNatRule $inboundNatRule -LoadBalancingRule $lbrule -Tier Regional
1228+
1229+
$lb = Get-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname
1230+
1231+
# Test LbProbe Cmdlet
1232+
Assert-AreEqual '1' $lb.Probes[0].ProbeThreshold
1233+
Assert-AreEqual "AllProbedUp" $lb.Probes[0].NoHealthyBackendsBehavior
1234+
1235+
# Test Probe cmdlets
1236+
$probeName2 = Get-ResourceName
1237+
$lb = Get-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname | Add-AzLoadBalancerProbeConfig -Name $probeName2 -RequestPath healthcheck2.aspx -Protocol http -Port 81 -IntervalInSeconds 16 -ProbeCount 3 -ProbeThreshold $null -NoHealthyBackendsBehavior "AllProbedDown" | Set-AzLoadBalancer
1238+
1239+
Assert-AreEqual 2 @($lb.Probes).Count
1240+
Assert-AreEqual $probeName2 $lb.Probes[1].Name
1241+
Assert-AreEqual 1 $lb.Probes[1].ProbeThreshold
1242+
Assert-AreEqual "healthcheck2.aspx" $lb.Probes[1].RequestPath
1243+
Assert-AreEqual 81 $lb.Probes[1].Port
1244+
Assert-AreEqual "AllProbedDown" $lb.Probes[1].NoHealthyBackendsBehavior
1245+
1246+
$lb = Get-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname | Set-AzLoadBalancerProbeConfig -Name $probeName2 -RequestPath healthcheck2.aspx -Protocol http -Port 85 -IntervalInSeconds 16 -ProbeCount 3 -NoHealthyBackendsBehavior "AllProbedUp" | Set-AzLoadBalancer
1247+
Assert-AreEqual 2 @($lb.Probes).Count
1248+
Assert-AreEqual $probeName2 $lb.Probes[1].Name
1249+
Assert-AreEqual "healthcheck2.aspx" $lb.Probes[1].RequestPath
1250+
Assert-AreEqual 85 $lb.Probes[1].Port
1251+
Assert-AreEqual 1 $lb.Probes[1].ProbeThreshold
1252+
Assert-AreEqual "AllProbedUp" $lb.Probes[1].NoHealthyBackendsBehavior
1253+
1254+
$probeConfig = Get-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname | Get-AzLoadBalancerProbeConfig -Name $probeName2
1255+
$probeConfigList = Get-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname | Get-AzLoadBalancerProbeConfig
1256+
Assert-AreEqual 2 @($probeConfigList).Count
1257+
Assert-AreEqual $probeName $probeConfigList[0].Name
1258+
Assert-AreEqual $probeName2 $probeConfigList[1].Name
1259+
Assert-AreEqual $probeConfig.Name $probeConfigList[1].Name
1260+
Assert-AreEqual "AllProbedUp" $lb.Probes[1].NoHealthyBackendsBehavior
1261+
1262+
$lb = Get-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname | Remove-AzLoadBalancerProbeConfig -Name $probeName2 | Set-AzLoadBalancer
1263+
Assert-AreEqual 1 @($lb.Probes).Count
1264+
Assert-AreEqual $probeName $lb.Probes[0].Name
1265+
Assert-AreEqual "AllProbedUp" $lb.Probes[0].NoHealthyBackendsBehavior
1266+
1267+
# Delete
1268+
$deleteLb = $lb | Remove-AzLoadBalancer -PassThru -Force
1269+
Assert-AreEqual true $deleteLb
1270+
1271+
$list = Get-AzLoadBalancer -ResourceGroupName $rgname
1272+
Assert-AreEqual 0 @($list).Count
1273+
}
1274+
finally
1275+
{
1276+
# Cleanup
1277+
Clean-ResourceGroup $rgname
1278+
}
1279+
}
1280+
1281+
11921282
<#
11931283
.SYNOPSIS
11941284
Tests creating new simple Load balancer and edit InboundNatRuleV2 using config cmdlets

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.LoadBalancerTests/TestLoadBalancerProbes_NoHealthyBackendsBehaviorParameter.json

Lines changed: 3158 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)