Skip to content

Commit c04f432

Browse files
- Added couple more test cases
- Fixed missing update configuration object! - Increased timeout as sometimes it take longer to provision
1 parent f0ae841 commit c04f432

File tree

6 files changed

+982
-2
lines changed

6 files changed

+982
-2
lines changed

src/ResourceManager/Automation/Commands.Automation.Test/Commands.Automation.Test.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@
254254
<None Include="ScenarioTests\UpdateManagement\UpdateManagementTests.ps1">
255255
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
256256
</None>
257+
<None Include="SessionRecords\Microsoft.Azure.Commands.ResourceManager.Automation.Test.ScenarioTests.UpdateManagement.UpdateManagementTests\CreateLinuxWeeklySUC.json" />
258+
<None Include="SessionRecords\Microsoft.Azure.Commands.ResourceManager.Automation.Test.ScenarioTests.UpdateManagement.UpdateManagementTests\CreateWindowsMonthlySUC.json" />
257259
</ItemGroup>
258260
<ItemGroup />
259261
<ItemGroup>

src/ResourceManager/Automation/Commands.Automation.Test/ScenarioTests/UpdateManagement/UpdateManagementTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,21 @@ public void GetAllMachineRunsWithFiltersNoResults()
144144
{
145145
RunPowerShellTest("Test-GetAllSoftwareUpdateMachineRunsWithFiltersNoResults");
146146
}
147+
148+
[Fact]
149+
[Trait(Category.AcceptanceType, Category.CheckIn)]
150+
[Trait(Category.Service, Category.Automation)]
151+
public void CreateLinuxWeeklySUC()
152+
{
153+
RunPowerShellTest("Test-CreateLinuxWeeklySoftwareUpdateConfiguration");
154+
}
155+
156+
[Fact]
157+
[Trait(Category.AcceptanceType, Category.CheckIn)]
158+
[Trait(Category.Service, Category.Automation)]
159+
public void CreateWindowsMonthlySUC()
160+
{
161+
RunPowerShellTest("Test-CreateWindowsMonthlySoftwareUpdateConfiguration");
162+
}
147163
}
148164
}

src/ResourceManager/Automation/Commands.Automation.Test/ScenarioTests/UpdateManagement/UpdateManagementTests.ps1

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ WaitForProvisioningState
1818
function WaitForProvisioningState() {
1919
param([string] $Name, [string] $ExpectedState)
2020
$state = ""
21-
$timeoutInSeconds = 60
21+
$timeoutInSeconds = 120
2222
$retries = $timeoutInSeconds / 5
2323
while($state -ne $ExpectedState -and $retries -gt 0) {
2424
$suc = Get-AzureRmAutomationSoftwareUpdateConfiguration -ResourceGroupName $rg `
@@ -331,4 +331,96 @@ function Test-GetAllSoftwareUpdateMachineRunsWithFiltersNoResults {
331331
-TargetComputer foo
332332

333333
Assert-AreEqual $runs.Count 0 "Get software update configurations machine runs with filters and no results didn't return expected number of items"
334-
}
334+
}
335+
336+
<#
337+
Test-CreateLinuxWeeklySoftwareUpdateConfigurationWithDefaults
338+
#>
339+
function Test-CreateLinuxWeeklySoftwareUpdateConfiguration() {
340+
$name = "mo-weekly-01"
341+
$startTime = ([DateTime]::Now).AddMinutes(10)
342+
$duration = New-TimeSpan -Hours 2
343+
$s = New-AzureRmAutomationSchedule -ResourceGroupName $rg `
344+
-AutomationAccountName $aa `
345+
-Name $name `
346+
-Description test-OneTime `
347+
-WeekInterval 1 `
348+
-DaysOfWeek Friday `
349+
-StartTime $startTime `
350+
-ForUpdate
351+
352+
$suc = New-AzureRmAutomationSoftwareUpdateConfiguration -ResourceGroupName $rg `
353+
-AutomationAccountName $aa `
354+
-Schedule $s `
355+
-Linux `
356+
-AzureVMResourceIds $azureVMIdsL `
357+
-Duration $duration `
358+
-IncludedPackageClassifications Other,Security `
359+
-ExcludedPackageNameMasks @("Mask-exc-01", "Mask-exc-02")
360+
361+
362+
Assert-NotNull $suc "New-AzureRmAutomationSoftwareUpdateConfiguration returned null"
363+
Assert-AreEqual $suc.Name $name "Name of created software update configuration didn't match given name"
364+
Assert-NotNull $suc.UpdateConfiguration "UpdateConfiguration of the software update configuration object is null"
365+
Assert-NotNull $suc.ScheduleConfiguration "ScheduleConfiguration of the software update configuration object is null"
366+
Assert-AreEqual $suc.ProvisioningState "Provisioning" "software update configuration provisioning state was not expected"
367+
Assert-AreEqual $suc.UpdateConfiguration.OperatingSystem "Linux" "UpdateConfiguration Operating system is not expected"
368+
Assert-AreEqual $suc.UpdateConfiguration.Duration $duration "UpdateConfiguration Duration is not expected"
369+
Assert-AreEqual $suc.UpdateConfiguration.AzureVirtualMachines.Count 2 "UpdateConfiguration created doesn't have the correct number of azure virtual machines"
370+
Assert-AreEqual $suc.UpdateConfiguration.NonAzureComputers.Count 0 "UpdateConfiguration doesn't have correct value of NonAzureComputers"
371+
Assert-NotNull $suc.UpdateConfiguration.Linux "Linux property of UpdateConfiguration is null"
372+
Assert-AreEqual $suc.UpdateConfiguration.Linux.IncludedPackageClassifications.Count 2 "Invalid UpdateConfiguration.Linux.IncludedPackageClassifications.Count"
373+
Assert-AreEqual $suc.UpdateConfiguration.Linux.IncludedPackageClassifications[0] Security "Invalid value of UpdateConfiguration.Linux.IncludedPackageClassifications[0]"
374+
Assert-AreEqual $suc.UpdateConfiguration.Linux.IncludedPackageClassifications[1] Other "Invalid value of UpdateConfiguration.Linux.IncludedPackageClassifications[1]"
375+
Assert-AreEqual $suc.UpdateConfiguration.Linux.ExcludedPackageNameMasks.Count 2
376+
Assert-AreEqual $suc.UpdateConfiguration.Linux.ExcludedPackageNameMasks[0] "Mask-exc-01"
377+
Assert-AreEqual $suc.UpdateConfiguration.Linux.ExcludedPackageNameMasks[1] "Mask-exc-02"
378+
379+
WaitForProvisioningState $name "Succeeded"
380+
}
381+
382+
<#
383+
Test-CreateWindowsMonthlySoftwareUpdateConfiguration
384+
#>
385+
function Test-CreateWindowsMonthlySoftwareUpdateConfiguration() {
386+
$name = "mo-monthly-01"
387+
$startTime = ([DateTime]::Now).AddMinutes(10)
388+
$duration = New-TimeSpan -Hours 2
389+
$s = New-AzureRmAutomationSchedule -ResourceGroupName $rg `
390+
-AutomationAccountName $aa `
391+
-Name $name `
392+
-Description test-OneTime `
393+
-MonthInterval 1 `
394+
-DaysOfMonth Two,Five `
395+
-StartTime $startTime `
396+
-ForUpdate
397+
398+
$suc = New-AzureRmAutomationSoftwareUpdateConfiguration -ResourceGroupName $rg `
399+
-AutomationAccountName $aa `
400+
-Schedule $s `
401+
-Windows `
402+
-AzureVMResourceIds $azureVMIdsW `
403+
-Duration $duration `
404+
-IncludedUpdateClassifications Critical,Security `
405+
-ExcludedKbNumbers @("KB-01", "KB-02")
406+
407+
408+
Assert-NotNull $suc "New-AzureRmAutomationSoftwareUpdateConfiguration returned null"
409+
Assert-AreEqual $suc.Name $name "Name of created software update configuration didn't match given name"
410+
Assert-NotNull $suc.UpdateConfiguration "UpdateConfiguration of the software update configuration object is null"
411+
Assert-NotNull $suc.ScheduleConfiguration "ScheduleConfiguration of the software update configuration object is null"
412+
Assert-AreEqual $suc.ProvisioningState "Provisioning" "software update configuration provisioning state was not expected"
413+
Assert-AreEqual $suc.UpdateConfiguration.OperatingSystem "Windows" "UpdateConfiguration Operating system is not expected"
414+
Assert-AreEqual $suc.UpdateConfiguration.Duration $duration "UpdateConfiguration Duration is not expected"
415+
Assert-AreEqual $suc.UpdateConfiguration.AzureVirtualMachines.Count 2 "UpdateConfiguration created doesn't have the correct number of azure virtual machines"
416+
Assert-AreEqual $suc.UpdateConfiguration.NonAzureComputers.Count 0 "UpdateConfiguration doesn't have correct value of NonAzureComputers"
417+
Assert-NotNull $suc.UpdateConfiguration.Windows "Linux property of UpdateConfiguration is null"
418+
Assert-AreEqual $suc.UpdateConfiguration.Windows.IncludedUpdateClassifications.Count 2 "Invalid UpdateConfiguration.Linux.IncludedPackageClassifications.Count"
419+
Assert-AreEqual $suc.UpdateConfiguration.Windows.IncludedUpdateClassifications[0] Critical "Invalid value of UpdateConfiguration.Linux.IncludedPackageClassifications[0]"
420+
Assert-AreEqual $suc.UpdateConfiguration.Windows.IncludedUpdateClassifications[1] Security "Invalid value of UpdateConfiguration.Linux.IncludedPackageClassifications[1]"
421+
Assert-AreEqual $suc.UpdateConfiguration.Windows.ExcludedKbNumbers.Count 2
422+
Assert-AreEqual $suc.UpdateConfiguration.Windows.ExcludedKbNumbers[0] "KB-01"
423+
Assert-AreEqual $suc.UpdateConfiguration.Windows.ExcludedKbNumbers[1] "KB-02"
424+
425+
WaitForProvisioningState $name "Succeeded"
426+
}

0 commit comments

Comments
 (0)