-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Azure/dev
Merge from Azure
- Loading branch information
Showing
56 changed files
with
70,265 additions
and
118,136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
...agement/Common/Commands.ScenarioTest/Resources/SqlIaaSExtension/SqlIaaSExtensionTests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
$PLACEHOLDER = "PLACEHOLDER1@"; | ||
|
||
<# | ||
.SYNOPSIS | ||
End to end Sql IaaS extension test that tests Get-AzureVMSqlServerExtension cmdlet. It does the following: | ||
1) Creates cloud service and a VM with SQL 2016 Image. | ||
2) Installs the extension by calling Set-AzureVMSqlServerExtension cmdlet on the VM. | ||
3) Calls Get-AzureVMSqlServerExtension cmdlet to check the status of the extension installation. | ||
4) Sets Auto Patching and Auto Backup settings by calling Set-AzureVMDscExtension cmdlet on the VM. | ||
5) Calls Get-AzureVMSqlServerExtension cmdlet to get extension details and verify it with values updated with Set-AzureVMSqlServerExtension. | ||
#> | ||
function Test-GetAzureVMSqlIaaSExtension | ||
{ | ||
Set-StrictMode -Version latest; $ErrorActionPreference = 'Stop' | ||
|
||
# Setup | ||
$location = Get-DefaultLocation | ||
$storageName = getAssetName | ||
|
||
try | ||
{ | ||
New-AzureStorageAccount -StorageAccountName $storageName -Location $location | ||
Set-CurrentStorageAccountName $storageName | ||
|
||
$vmName = "pshelltestvm1" | ||
$svcName = Get-CloudServiceName | ||
|
||
# Get latest SQL 2016 VM Image | ||
$family = "SQL Server 2016 RTM Enterprise on Windows Server 2012 R2" | ||
$image = Get-AzureVMImage | where { $_.ImageFamily -eq $family } | sort PublishedDate -Descending | select -ExpandProperty ImageName -First 1 | ||
|
||
# Create new cloud service | ||
New-AzureService -ServiceName $svcName -Location $location | ||
|
||
# Create the VM config | ||
$vmsize = "A5" | ||
$vm1 = New-AzureVMConfig -Name $vmname -InstanceSize $vmsize -ImageName $image | ||
|
||
# Create the SQL VM | ||
$user = "localadmin"; | ||
$password = $PLACEHOLDER; | ||
$vm1 | Add-AzureProvisioningConfig -Windows -AdminUsername $user -Password $password | ||
New-AzureVM –ServiceName $svcname -VMs $vm1 | ||
|
||
#Do actual changes and work here | ||
|
||
# 1) Installs the SqlIaaS extension by calling Set-AzureVMSqlServerExtension cmdlet on a VM. | ||
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName | ||
$vm | Set-AzureVMSqlServerExtension | Update-AzureVM | ||
|
||
# 2) Calls Get-AzureRmVMSqlServerExtension cmdlet to verify the status of the extension installation. | ||
$extension = $vm | Get-AzureVMSqlServerExtension | ||
Assert-NotNull $extension | ||
Assert-NotNull $extension.ExtensionName | ||
Assert-NotNull $extension.Publisher | ||
Assert-NotNull $extension.Version | ||
|
||
# Repeat until the extension is ready. | ||
[TimeSpan] $timeout = [TimeSpan]::FromMinutes(30) | ||
$maxTime = [datetime]::Now + $timeout | ||
|
||
while($true) | ||
{ | ||
if($extension -ne $null -and $extension.ExtensionStatus -ne $null) | ||
{ | ||
if(($extension.ExtensionStatus -eq "Ready")) | ||
{ | ||
break; | ||
} | ||
} | ||
|
||
if([datetime]::Now -gt $maxTime) | ||
{ | ||
Throw "The Sql Server Extension did not report any status within the given timeout from VM [$vmName]" | ||
} | ||
|
||
if ($env:AZURE_TEST_MODE -eq "Record"){ | ||
sleep -Seconds 15 | ||
} | ||
|
||
$extension = $vm | Get-AzureVMSqlServerExtension | ||
} | ||
|
||
# 3) Update Auto Patching and Auto Backup settings | ||
$storageContext = (Get-AzureStorageAccount -StorageAccountName $storageName).Context | ||
$aps = New-AzureVMSqlServerAutoPatchingConfig -Enable -DayOfWeek "Thursday" -MaintenanceWindowStartingHour 20 ` | ||
-MaintenanceWindowDuration 120 -PatchCategory "Important" | ||
$abs = New-AzureVMSqlServerAutoBackupConfig -Enable -RetentionPeriodInDays 20 -StorageContext $storageContext -BackupScheduleType Manual ` | ||
-BackupSystemDbs -FullBackupStartHour 10 -FullBackupWindowInHours 5 -FullBackupFrequency Daily -LogBackupFrequencyInMinutes 30 | ||
Get-AzureVM -ServiceName $svcName -Name $vmName | Set-AzureVMSqlServerExtension -AutoPatchingSettings $aps -AutoBackupSettings $abs | Update-AzureVM | ||
|
||
# Wait few minutes for the settings to be applied and to cover the lag for guest agent to pick up updated status. | ||
if ($env:AZURE_TEST_MODE -eq "Record"){ | ||
sleep -Seconds 300 | ||
} | ||
|
||
# 4) Get the extension and verify the values. | ||
$extension = Get-AzureVM -ServiceName $svcName -Name $vmName | Get-AzureVMSqlServerExtension | ||
|
||
Assert-AreEqual $extension.AutoPatchingSettings.DayOfWeek "Thursday" | ||
Assert-AreEqual $extension.AutoPatchingSettings.MaintenanceWindowStartingHour 20 | ||
Assert-AreEqual $extension.AutoPatchingSettings.MaintenanceWindowDuration 120 | ||
Assert-AreEqual $extension.AutoPatchingSettings.PatchCategory "Important" | ||
|
||
Assert-AreEqual $extension.AutoBackupSettings.RetentionPeriod 20 | ||
Assert-AreEqual $extension.AutoBackupSettings.Enable $true | ||
Assert-AreEqual $extension.AutoBackupSettings.BackupScheduleType "Manual" | ||
Assert-AreEqual $extension.AutoBackupSettings.FullBackupFrequency "Daily" | ||
Assert-AreEqual $extension.AutoBackupSettings.BackupSystemDbs $true | ||
Assert-AreEqual $extension.AutoBackupSettings.FullBackupStartTime 10 | ||
Assert-AreEqual $extension.AutoBackupSettings.FullBackupWindowHours 5 | ||
Assert-AreEqual $extension.AutoBackupSettings.LogBackupFrequency 30 | ||
|
||
# Uninstall Extension | ||
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName | Set-AzureVMSqlServerExtension -Uninstall | Update-AzureVM | ||
} | ||
finally | ||
{ | ||
# Cleanup | ||
Remove-AzureStorageAccount -StorageAccountName $storageName -ErrorAction SilentlyContinue | ||
Cleanup-CloudService $svcName | ||
} | ||
} |
15,744 changes: 15,744 additions & 0 deletions
15,744
...dowsAzure.Commands.ScenarioTest.SqlIaaSExtensionTests/TestGetAzureVMSqlIaaSExtension.json
Large diffs are not rendered by default.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
...iceManagement/Common/Commands.ScenarioTest/SqlIaaSExtensionTests/SqlIaaSExtensionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using Microsoft.Azure.Test; | ||
using Microsoft.WindowsAzure.Management; | ||
using Microsoft.WindowsAzure.Management.Compute; | ||
using Microsoft.WindowsAzure.Management.Network; | ||
using Microsoft.WindowsAzure.Management.Storage; | ||
using Microsoft.WindowsAzure.Commands.Utilities.Common; | ||
using Xunit; | ||
using Microsoft.Azure.Commands.Common.Authentication; | ||
using Xunit.Abstractions; | ||
using Microsoft.WindowsAzure.ServiceManagemenet.Common.Models; | ||
|
||
namespace Microsoft.WindowsAzure.Commands.ScenarioTest | ||
{ | ||
public class SqlIaaSExtensionTests | ||
{ | ||
private EnvironmentSetupHelper helper = new EnvironmentSetupHelper(); | ||
|
||
public SqlIaaSExtensionTests(ITestOutputHelper output) | ||
{ | ||
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output)); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
[Trait(Category.AcceptanceType, Category.BVT)] | ||
public void TestGetAzureVMSqlIaaSExtension() | ||
{ | ||
this.RunPowerShellTest("Test-GetAzureVMSqlIaaSExtension"); | ||
} | ||
|
||
protected void SetupManagementClients() | ||
{ | ||
var rdfeTestFactory = new RDFETestEnvironmentFactory(); | ||
var managementClient = TestBase.GetServiceClient<ManagementClient>(rdfeTestFactory); | ||
var computeClient = TestBase.GetServiceClient<ComputeManagementClient>(rdfeTestFactory); | ||
var networkClient = TestBase.GetServiceClient<NetworkManagementClient>(rdfeTestFactory); | ||
var storageClient = TestBase.GetServiceClient<StorageManagementClient>(rdfeTestFactory); | ||
|
||
helper.SetupSomeOfManagementClients( | ||
managementClient, | ||
computeClient, | ||
networkClient, | ||
storageClient); | ||
} | ||
|
||
protected void RunPowerShellTest(params string[] scripts) | ||
{ | ||
using (UndoContext context = UndoContext.Current) | ||
{ | ||
context.Start(TestUtilities.GetCallingClass(1), TestUtilities.GetCurrentMethodName(2)); | ||
|
||
SetupManagementClients(); | ||
|
||
var modules = new List<string> | ||
{ | ||
"Resources\\SqlIaaSExtension\\SqlIaaSExtensionTests.ps1", | ||
"Resources\\ServiceManagement\\Common.ps1", | ||
".\\Assert.ps1", | ||
@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Compute\AzurePreview.psd1" | ||
}; | ||
|
||
helper.SetupEnvironment(AzureModule.AzureServiceManagement); | ||
helper.SetupModules(AzureModule.AzureServiceManagement, modules.ToArray()); | ||
|
||
|
||
var scriptEnvPath = new List<string>(); | ||
scriptEnvPath.Add( | ||
string.Format( | ||
"$env:PSModulePath=\"{0};$env:PSModulePath\"", | ||
@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Compute".AsAbsoluteLocation())); | ||
|
||
helper.RunPowerShellTest(scriptEnvPath, scripts); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.