Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -423,64 +423,134 @@
<None Include="AzureRTExtensions.playlist" />
<None Include="AzureRTFull.playlist" />
<None Include="Resources\HelloWorld_SDK20.cspkg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\ServiceConfiguration.cscfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="MSSharedLibKey.snk" />
<None Include="packages.config" />
<None Include="Resources\affinityGroupData.csv" />
<None Include="Resources\certificateData.csv" />
<None Include="Resources\affinityGroupData.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\certificateData.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\CustomData.bin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\cloudinittest.sh">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\download_VHD.csv" />
<None Include="Resources\download_VHD.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\DSC\DscExtensionTestConfigurationData.psd1" />
<None Include="Resources\HelloNoDiag.cscfg" />
<None Include="Resources\nodiagpackage.csv" />
<None Include="Resources\OneWebOneWorker.cscfg" />
<None Include="Resources\OneWebOneWorkerRDP.cscfg" />
<None Include="Resources\overwrite_VHD.csv" />
<None Include="Resources\package.csv" />
<None Include="Resources\packageADDomain.csv" />
<None Include="Resources\packageReservedIP.csv" />
<None Include="Resources\packageScenario.csv" />
<None Include="Resources\patch_VHD.csv" />
<None Include="Resources\rdpcert.pfx" />
<None Include="Resources\ReservedIPConfig1.cscfg" />
<None Include="Resources\ReservedIPConfig1update.cscfg" />
<None Include="Resources\ReservedIPConfig2.cscfg" />
<None Include="Resources\ReservedIPConfig2update.cscfg" />
<None Include="Resources\resume_VHD.csv" />
<None Include="Resources\SampleAppV1.cscfg" />
<None Include="Resources\SampleAppV2.cscfg" />
<None Include="Resources\SampleAppV3.cscfg" />
<None Include="Resources\StaticCAvnetconfig.netcfg" />
<None Include="Resources\storageAccountTestData.csv" />
<None Include="Resources\HelloNoDiag.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\nodiagpackage.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\OneWebOneWorker.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\OneWebOneWorkerRDP.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\overwrite_VHD.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\package.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\packageADDomain.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\packageReservedIP.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\packageScenario.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\patch_VHD.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\rdpcert.pfx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\ReservedIPConfig1.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\ReservedIPConfig1update.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\ReservedIPConfig2.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\ReservedIPConfig2update.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\resume_VHD.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\SampleAppV1.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\SampleAppV2.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\SampleAppV3.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\StaticCAvnetconfig.netcfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\storageAccountTestData.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\DSC\DscExtensionTestConfiguration.ps1" />
<None Include="Resources\test1.ps1" />
<None Include="Resources\test2.ps1" />
<None Include="Resources\thread_VHD.csv" />
<None Include="Resources\upload_VHD.csv" />
<None Include="Resources\vnetconfig.netcfg" />
<None Include="Resources\test1.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\test2.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\thread_VHD.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\upload_VHD.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\vnetconfig.netcfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\VnetconfigWithLocation.netcfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\wrongPara_VHD.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\wrongPara_VHD.csv" />
</ItemGroup>
<ItemGroup>
<Content Include="FunctionalTests\ExtensionTests\MicrosoftAntimalware\AntimalwareConfig.xml" />
<Content Include="FunctionalTests\Readme.txt" />
<Content Include="lib\Security.Cryptography.dll" />
<Content Include="Resources\clxtshar.dll" />
<Content Include="Resources\da.xml" />
<Content Include="Resources\PrivateConfig.xml" />
<Content Include="Resources\PublicConfig.xml" />
<Content Include="Resources\VmAccessExtensionConfiguration.xml" />
<Content Include="Resources\clxtshar.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\da.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\PrivateConfig.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\PublicConfig.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\VmAccessExtensionConfiguration.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="TestScripts\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,23 +539,29 @@ public void AzureDeploymentTest()
Assert.IsTrue(File.Exists(configPath3.FullName), "file not exist={0}", configPath3);

string deploymentName = "deployment1";
string deploymentName2 = "deployment2";
string deploymentLabel = "label1";
DeploymentInfoContext result;

PSCredential cred = new PSCredential(username, Utilities.convertToSecureString(password));
ExtensionConfigurationInput rdpExtCfg = vmPowershellCmdlets.NewAzureServiceRemoteDesktopExtensionConfig(cred);

try
{
vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
Console.WriteLine("service, {0}, is created.", serviceName);

Utilities.RetryActionUntilSuccess(() =>
{
vmPowershellCmdlets.NewAzureDeployment(serviceName, packagePath1.FullName, configPath1.FullName, DeploymentSlotType.Staging, deploymentLabel, deploymentName, false, false);
vmPowershellCmdlets.NewAzureDeployment(serviceName, packagePath1.FullName, configPath1.FullName, DeploymentSlotType.Staging, deploymentLabel, deploymentName, false, false, rdpExtCfg);
}, "Windows Azure is currently performing an operation on this hosted service that requires exclusive access.", 10, 30);

result = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Staging);
pass = Utilities.PrintAndCompareDeployment(result, serviceName, deploymentName, deploymentLabel, DeploymentSlotType.Staging, null, 1);
Console.WriteLine("successfully deployed the package");

ExtensionContext extResult0 = vmPowershellCmdlets.GetAzureServiceExtension(serviceName, DeploymentSlotType.Staging)[0];
Utilities.PrintContext(extResult0);

// Move the deployment from 'Staging' to 'Production'
Utilities.RetryActionUntilSuccess(() =>
Expand All @@ -564,9 +570,60 @@ public void AzureDeploymentTest()
}, "The server encountered an internal error. Please retry the request.", 10, 30);
result = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production);
pass &= Utilities.PrintAndCompareDeployment(result, serviceName, deploymentName, deploymentLabel, DeploymentSlotType.Production, null, 1);
Console.WriteLine("successfully moved");
Console.WriteLine("successfully moved.");

ExtensionContext extResult1 = vmPowershellCmdlets.GetAzureServiceExtension(serviceName, DeploymentSlotType.Production)[0];
Utilities.PrintContext(extResult1);

Assert.IsTrue(string.Equals(extResult0.Id, extResult1.Id));

// Check until the deployment moving is done, and the staging slot is empty.
Utilities.RetryActionUntilSuccess(() =>
{
try
{
result = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Staging);
Assert.IsNull(result);
}
catch (Exception e)
{
const string errorMessage = "No deployments were found.";
Assert.IsTrue(e.ToString().Contains(errorMessage) || (e.InnerException != null && e.InnerException.ToString().Contains(errorMessage)));
}
}, "Assert", 10, 60);
Console.WriteLine("successfully checked original deployment has been moved away.");

// Re-create the Staging depoyment with the extension
Utilities.RetryActionUntilSuccess(() =>
{
vmPowershellCmdlets.NewAzureDeployment(serviceName, packagePath2.FullName, configPath2.FullName, DeploymentSlotType.Staging, deploymentLabel, deploymentName2, false, false, rdpExtCfg);
}, "Windows Azure is currently performing an operation on this hosted service that requires exclusive access.", 10, 60);

result = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Staging);
pass = Utilities.PrintAndCompareDeployment(result, serviceName, deploymentName2, deploymentLabel, DeploymentSlotType.Staging, null, 2);
Console.WriteLine(string.Format("Successfully re-deployed the package #2 to the {0} slot.", DeploymentSlotType.Staging));

ExtensionContext extResult2 = vmPowershellCmdlets.GetAzureServiceExtension(serviceName, DeploymentSlotType.Staging)[0];
Utilities.PrintContext(extResult2);

// Update the deployment with the extension
Utilities.RetryActionUntilSuccess(() =>
{
vmPowershellCmdlets.SetAzureDeploymentConfig(serviceName, DeploymentSlotType.Staging, configPath2.FullName, rdpExtCfg);
}, "The server encountered an internal error. Please retry the request.", 10, 30);
result = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Staging);
pass &= Utilities.PrintAndCompareDeployment(result, serviceName, deploymentName2, deploymentLabel, DeploymentSlotType.Staging, null, 2);
Console.WriteLine("successfully updated the deployment #2");

ExtensionContext extResult3 = vmPowershellCmdlets.GetAzureServiceExtension(serviceName, DeploymentSlotType.Staging)[0];
Utilities.PrintContext(extResult3);

Assert.IsTrue(!string.Equals(extResult2.Id, extResult3.Id));

// Remove the deployment #2
vmPowershellCmdlets.RemoveAzureDeployment(serviceName, DeploymentSlotType.Staging, true);

// Set the deployment status to 'Suspended'
// Set the deployment #1 status to 'Suspended'
Utilities.RetryActionUntilSuccess(() =>
{
vmPowershellCmdlets.SetAzureDeploymentStatus(serviceName, DeploymentSlotType.Production, DeploymentStatus.Suspended);
Expand All @@ -575,7 +632,7 @@ public void AzureDeploymentTest()
pass &= Utilities.PrintAndCompareDeployment(result, serviceName, deploymentName, deploymentLabel, DeploymentSlotType.Production, DeploymentStatus.Suspended, 1);
Console.WriteLine("successfully changed the status");

// Update the deployment
// Update the deployment #1
Utilities.RetryActionUntilSuccess(() =>
{
vmPowershellCmdlets.SetAzureDeploymentConfig(serviceName, DeploymentSlotType.Production, configPath2.FullName);
Expand All @@ -584,7 +641,7 @@ public void AzureDeploymentTest()
pass &= Utilities.PrintAndCompareDeployment(result, serviceName, deploymentName, deploymentLabel, DeploymentSlotType.Production, null, 2);
Console.WriteLine("successfully updated the deployment");

// Upgrade the deployment
// Upgrade the deployment #1
DateTime start = DateTime.Now;
Utilities.RetryActionUntilSuccess(() =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;

namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo
Expand All @@ -38,12 +39,13 @@ public static SetAzureDeploymentCmdletInfo SetAzureDeploymentStatusCmdletInfo(st
}


public static SetAzureDeploymentCmdletInfo SetAzureDeploymentConfigCmdletInfo(string serviceName, string slot, string configPath)
public static SetAzureDeploymentCmdletInfo SetAzureDeploymentConfigCmdletInfo(string serviceName, string slot, string configPath, ExtensionConfigurationInput extConfig = null)
{
SetAzureDeploymentCmdletInfo result = new SetAzureDeploymentCmdletInfo(serviceName, slot);

result.cmdletParams.Add(new CmdletParam("Config"));
result.cmdletParams.Add(new CmdletParam("Configuration", configPath));
result.cmdletParams.Add(new CmdletParam("ExtensionConfiguration", extConfig));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are Set-AzureDeployment with "-ExtensionConfiguration $null" parameter and Set-AzureDeployment without -ExtensionConfiguration paramter the same?
If they are the same, this line should be added when 'extConfig' is not null.
If they are not the same, we need two separate methods, with $null extConfig and without extConfig.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.


return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ public ManagementOperationContext SetAzureDeploymentStatus(string serviceName, s
return SetAzureDeployment(SetAzureDeploymentCmdletInfo.SetAzureDeploymentStatusCmdletInfo(serviceName, slot, newStatus));
}

public ManagementOperationContext SetAzureDeploymentConfig(string serviceName, string slot, string configPath)
public ManagementOperationContext SetAzureDeploymentConfig(string serviceName, string slot, string configPath, ExtensionConfigurationInput extConfig = null)
{
return SetAzureDeployment(SetAzureDeploymentCmdletInfo.SetAzureDeploymentConfigCmdletInfo(serviceName, slot, configPath));
return SetAzureDeployment(SetAzureDeploymentCmdletInfo.SetAzureDeploymentConfigCmdletInfo(serviceName, slot, configPath, extConfig));
}

public ManagementOperationContext SetAzureDeploymentUpgrade(string serviceName, string slot, string mode, string packagePath, string configPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public void ExecuteCommand()
Roles = new ExtensionRoleList(Role != null && Role.Any() ? Role.Select(r => new ExtensionRole(r)) : Enumerable.Repeat(new ExtensionRole(), 1))
};

var extConfig = ExtensionManager.InstallExtension(context, Slot, Deployment.ExtensionConfiguration);
var extConfig = ExtensionManager.InstallExtension(context, Slot, Deployment.ExtensionConfiguration, PeerDeployment.ExtensionConfiguration);
ChangeDeployment(extConfig);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public abstract class BaseAzureServiceExtensionCmdlet : ServiceManagementBaseCmd
protected XDocument PublicConfigurationXml { get; set; }
protected XDocument PrivateConfigurationXml { get; set; }
protected DeploymentGetResponse Deployment { get; set; }
protected DeploymentGetResponse PeerDeployment { get; set; }

public virtual string ServiceName { get; set; }
public virtual string Slot { get; set; }
Expand Down Expand Up @@ -109,6 +110,8 @@ protected void ValidateDeployment()
}
Deployment.ExtensionConfiguration = Deployment.ExtensionConfiguration ?? new Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration();
}

PeerDeployment = GetPeerDeployment(Slot);
}

protected void ValidateRoles()
Expand Down Expand Up @@ -285,6 +288,15 @@ protected DeploymentGetResponse GetDeployment(string slot)
return d;
}

protected DeploymentGetResponse GetPeerDeployment(string currentSlot)
{
var currentSlotType = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), currentSlot, true);
var peerSlot = currentSlotType == DeploymentSlot.Production ? DeploymentSlot.Staging : DeploymentSlot.Production;
var peerSlotStr = peerSlot.ToString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: peerSlotStr is redundant. Just call GetDeployment with peerSlot.ToString().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Thanks. Will try to fix in the next PR. Now just trying to stabilize it for tests.


return GetDeployment(peerSlotStr);
}

protected SecureString GetSecurePassword(string password)
{
SecureString securePassword = new SecureString();
Expand Down
Loading