Skip to content

Commit 452308f

Browse files
committed
Merge pull request #15 from huangpf/fixdep
Fixdep
2 parents 1073910 + 11a93ef commit 452308f

File tree

13 files changed

+229
-69
lines changed

13 files changed

+229
-69
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/Commands.ServiceManagement.Test.csproj

Lines changed: 108 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -423,64 +423,134 @@
423423
<None Include="AzureRTExtensions.playlist" />
424424
<None Include="AzureRTFull.playlist" />
425425
<None Include="Resources\HelloWorld_SDK20.cspkg">
426-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
426+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
427427
</None>
428428
<None Include="Resources\ServiceConfiguration.cscfg">
429-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
429+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
430430
</None>
431431
<None Include="MSSharedLibKey.snk" />
432432
<None Include="packages.config" />
433-
<None Include="Resources\affinityGroupData.csv" />
434-
<None Include="Resources\certificateData.csv" />
433+
<None Include="Resources\affinityGroupData.csv">
434+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
435+
</None>
436+
<None Include="Resources\certificateData.csv">
437+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
438+
</None>
435439
<None Include="Resources\CustomData.bin">
436440
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
437441
</None>
438442
<None Include="Resources\cloudinittest.sh">
439443
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
440444
</None>
441-
<None Include="Resources\download_VHD.csv" />
445+
<None Include="Resources\download_VHD.csv">
446+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
447+
</None>
442448
<None Include="Resources\DSC\DscExtensionTestConfigurationData.psd1" />
443-
<None Include="Resources\HelloNoDiag.cscfg" />
444-
<None Include="Resources\nodiagpackage.csv" />
445-
<None Include="Resources\OneWebOneWorker.cscfg" />
446-
<None Include="Resources\OneWebOneWorkerRDP.cscfg" />
447-
<None Include="Resources\overwrite_VHD.csv" />
448-
<None Include="Resources\package.csv" />
449-
<None Include="Resources\packageADDomain.csv" />
450-
<None Include="Resources\packageReservedIP.csv" />
451-
<None Include="Resources\packageScenario.csv" />
452-
<None Include="Resources\patch_VHD.csv" />
453-
<None Include="Resources\rdpcert.pfx" />
454-
<None Include="Resources\ReservedIPConfig1.cscfg" />
455-
<None Include="Resources\ReservedIPConfig1update.cscfg" />
456-
<None Include="Resources\ReservedIPConfig2.cscfg" />
457-
<None Include="Resources\ReservedIPConfig2update.cscfg" />
458-
<None Include="Resources\resume_VHD.csv" />
459-
<None Include="Resources\SampleAppV1.cscfg" />
460-
<None Include="Resources\SampleAppV2.cscfg" />
461-
<None Include="Resources\SampleAppV3.cscfg" />
462-
<None Include="Resources\StaticCAvnetconfig.netcfg" />
463-
<None Include="Resources\storageAccountTestData.csv" />
449+
<None Include="Resources\HelloNoDiag.cscfg">
450+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
451+
</None>
452+
<None Include="Resources\nodiagpackage.csv">
453+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
454+
</None>
455+
<None Include="Resources\OneWebOneWorker.cscfg">
456+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
457+
</None>
458+
<None Include="Resources\OneWebOneWorkerRDP.cscfg">
459+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
460+
</None>
461+
<None Include="Resources\overwrite_VHD.csv">
462+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
463+
</None>
464+
<None Include="Resources\package.csv">
465+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
466+
</None>
467+
<None Include="Resources\packageADDomain.csv">
468+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
469+
</None>
470+
<None Include="Resources\packageReservedIP.csv">
471+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
472+
</None>
473+
<None Include="Resources\packageScenario.csv">
474+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
475+
</None>
476+
<None Include="Resources\patch_VHD.csv">
477+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
478+
</None>
479+
<None Include="Resources\rdpcert.pfx">
480+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
481+
</None>
482+
<None Include="Resources\ReservedIPConfig1.cscfg">
483+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
484+
</None>
485+
<None Include="Resources\ReservedIPConfig1update.cscfg">
486+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
487+
</None>
488+
<None Include="Resources\ReservedIPConfig2.cscfg">
489+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
490+
</None>
491+
<None Include="Resources\ReservedIPConfig2update.cscfg">
492+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
493+
</None>
494+
<None Include="Resources\resume_VHD.csv">
495+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
496+
</None>
497+
<None Include="Resources\SampleAppV1.cscfg">
498+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
499+
</None>
500+
<None Include="Resources\SampleAppV2.cscfg">
501+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
502+
</None>
503+
<None Include="Resources\SampleAppV3.cscfg">
504+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
505+
</None>
506+
<None Include="Resources\StaticCAvnetconfig.netcfg">
507+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
508+
</None>
509+
<None Include="Resources\storageAccountTestData.csv">
510+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
511+
</None>
464512
<None Include="Resources\DSC\DscExtensionTestConfiguration.ps1" />
465-
<None Include="Resources\test1.ps1" />
466-
<None Include="Resources\test2.ps1" />
467-
<None Include="Resources\thread_VHD.csv" />
468-
<None Include="Resources\upload_VHD.csv" />
469-
<None Include="Resources\vnetconfig.netcfg" />
513+
<None Include="Resources\test1.ps1">
514+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
515+
</None>
516+
<None Include="Resources\test2.ps1">
517+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
518+
</None>
519+
<None Include="Resources\thread_VHD.csv">
520+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
521+
</None>
522+
<None Include="Resources\upload_VHD.csv">
523+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
524+
</None>
525+
<None Include="Resources\vnetconfig.netcfg">
526+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
527+
</None>
470528
<None Include="Resources\VnetconfigWithLocation.netcfg">
471-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
529+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
530+
</None>
531+
<None Include="Resources\wrongPara_VHD.csv">
532+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
472533
</None>
473-
<None Include="Resources\wrongPara_VHD.csv" />
474534
</ItemGroup>
475535
<ItemGroup>
476536
<Content Include="FunctionalTests\ExtensionTests\MicrosoftAntimalware\AntimalwareConfig.xml" />
477537
<Content Include="FunctionalTests\Readme.txt" />
478538
<Content Include="lib\Security.Cryptography.dll" />
479-
<Content Include="Resources\clxtshar.dll" />
480-
<Content Include="Resources\da.xml" />
481-
<Content Include="Resources\PrivateConfig.xml" />
482-
<Content Include="Resources\PublicConfig.xml" />
483-
<Content Include="Resources\VmAccessExtensionConfiguration.xml" />
539+
<Content Include="Resources\clxtshar.dll">
540+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
541+
</Content>
542+
<Content Include="Resources\da.xml">
543+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
544+
</Content>
545+
<Content Include="Resources\PrivateConfig.xml">
546+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
547+
</Content>
548+
<Content Include="Resources\PublicConfig.xml">
549+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
550+
</Content>
551+
<Content Include="Resources\VmAccessExtensionConfiguration.xml">
552+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
553+
</Content>
484554
</ItemGroup>
485555
<ItemGroup>
486556
<Folder Include="TestScripts\" />

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/FunctionalTest.cs

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,23 +539,29 @@ public void AzureDeploymentTest()
539539
Assert.IsTrue(File.Exists(configPath3.FullName), "file not exist={0}", configPath3);
540540

541541
string deploymentName = "deployment1";
542+
string deploymentName2 = "deployment2";
542543
string deploymentLabel = "label1";
543544
DeploymentInfoContext result;
544545

546+
PSCredential cred = new PSCredential(username, Utilities.convertToSecureString(password));
547+
ExtensionConfigurationInput rdpExtCfg = vmPowershellCmdlets.NewAzureServiceRemoteDesktopExtensionConfig(cred);
548+
545549
try
546550
{
547551
vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
548552
Console.WriteLine("service, {0}, is created.", serviceName);
549553

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

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

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

560566
// Move the deployment from 'Staging' to 'Production'
561567
Utilities.RetryActionUntilSuccess(() =>
@@ -564,9 +570,60 @@ public void AzureDeploymentTest()
564570
}, "The server encountered an internal error. Please retry the request.", 10, 30);
565571
result = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production);
566572
pass &= Utilities.PrintAndCompareDeployment(result, serviceName, deploymentName, deploymentLabel, DeploymentSlotType.Production, null, 1);
567-
Console.WriteLine("successfully moved");
573+
Console.WriteLine("successfully moved.");
574+
575+
ExtensionContext extResult1 = vmPowershellCmdlets.GetAzureServiceExtension(serviceName, DeploymentSlotType.Production)[0];
576+
Utilities.PrintContext(extResult1);
577+
578+
Assert.IsTrue(string.Equals(extResult0.Id, extResult1.Id));
579+
580+
// Check until the deployment moving is done, and the staging slot is empty.
581+
Utilities.RetryActionUntilSuccess(() =>
582+
{
583+
try
584+
{
585+
result = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Staging);
586+
Assert.IsNull(result);
587+
}
588+
catch (Exception e)
589+
{
590+
const string errorMessage = "No deployments were found.";
591+
Assert.IsTrue(e.ToString().Contains(errorMessage) || (e.InnerException != null && e.InnerException.ToString().Contains(errorMessage)));
592+
}
593+
}, "Assert", 10, 60);
594+
Console.WriteLine("successfully checked original deployment has been moved away.");
595+
596+
// Re-create the Staging depoyment with the extension
597+
Utilities.RetryActionUntilSuccess(() =>
598+
{
599+
vmPowershellCmdlets.NewAzureDeployment(serviceName, packagePath2.FullName, configPath2.FullName, DeploymentSlotType.Staging, deploymentLabel, deploymentName2, false, false, rdpExtCfg);
600+
}, "Windows Azure is currently performing an operation on this hosted service that requires exclusive access.", 10, 60);
601+
602+
result = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Staging);
603+
pass = Utilities.PrintAndCompareDeployment(result, serviceName, deploymentName2, deploymentLabel, DeploymentSlotType.Staging, null, 2);
604+
Console.WriteLine(string.Format("Successfully re-deployed the package #2 to the {0} slot.", DeploymentSlotType.Staging));
605+
606+
ExtensionContext extResult2 = vmPowershellCmdlets.GetAzureServiceExtension(serviceName, DeploymentSlotType.Staging)[0];
607+
Utilities.PrintContext(extResult2);
608+
609+
// Update the deployment with the extension
610+
Utilities.RetryActionUntilSuccess(() =>
611+
{
612+
vmPowershellCmdlets.SetAzureDeploymentConfig(serviceName, DeploymentSlotType.Staging, configPath2.FullName, rdpExtCfg);
613+
}, "The server encountered an internal error. Please retry the request.", 10, 30);
614+
result = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Staging);
615+
pass &= Utilities.PrintAndCompareDeployment(result, serviceName, deploymentName2, deploymentLabel, DeploymentSlotType.Staging, null, 2);
616+
Console.WriteLine("successfully updated the deployment #2");
617+
618+
ExtensionContext extResult3 = vmPowershellCmdlets.GetAzureServiceExtension(serviceName, DeploymentSlotType.Staging)[0];
619+
Utilities.PrintContext(extResult3);
620+
621+
Assert.IsTrue(!string.Equals(extResult2.Id, extResult3.Id));
622+
623+
// Remove the deployment #2
624+
vmPowershellCmdlets.RemoveAzureDeployment(serviceName, DeploymentSlotType.Staging, true);
568625

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

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

587-
// Upgrade the deployment
644+
// Upgrade the deployment #1
588645
DateTime start = DateTime.Now;
589646
Utilities.RetryActionUntilSuccess(() =>
590647
{

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/IaasCmdletInfo/SetAzureDeploymentCmdletInfo.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions;
1516
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
1617

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

4041

41-
public static SetAzureDeploymentCmdletInfo SetAzureDeploymentConfigCmdletInfo(string serviceName, string slot, string configPath)
42+
public static SetAzureDeploymentCmdletInfo SetAzureDeploymentConfigCmdletInfo(string serviceName, string slot, string configPath, ExtensionConfigurationInput extConfig = null)
4243
{
4344
SetAzureDeploymentCmdletInfo result = new SetAzureDeploymentCmdletInfo(serviceName, slot);
4445

4546
result.cmdletParams.Add(new CmdletParam("Config"));
4647
result.cmdletParams.Add(new CmdletParam("Configuration", configPath));
48+
result.cmdletParams.Add(new CmdletParam("ExtensionConfiguration", extConfig));
4749

4850
return result;
4951
}

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementCmdletTestHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,9 @@ public ManagementOperationContext SetAzureDeploymentStatus(string serviceName, s
454454
return SetAzureDeployment(SetAzureDeploymentCmdletInfo.SetAzureDeploymentStatusCmdletInfo(serviceName, slot, newStatus));
455455
}
456456

457-
public ManagementOperationContext SetAzureDeploymentConfig(string serviceName, string slot, string configPath)
457+
public ManagementOperationContext SetAzureDeploymentConfig(string serviceName, string slot, string configPath, ExtensionConfigurationInput extConfig = null)
458458
{
459-
return SetAzureDeployment(SetAzureDeploymentCmdletInfo.SetAzureDeploymentConfigCmdletInfo(serviceName, slot, configPath));
459+
return SetAzureDeployment(SetAzureDeploymentCmdletInfo.SetAzureDeploymentConfigCmdletInfo(serviceName, slot, configPath, extConfig));
460460
}
461461

462462
public ManagementOperationContext SetAzureDeploymentUpgrade(string serviceName, string slot, string mode, string packagePath, string configPath)

src/ServiceManagement/Compute/Commands.ServiceManagement/Extensions/ADDomain/SetAzureServiceADDomainExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public void ExecuteCommand()
238238
Roles = new ExtensionRoleList(Role != null && Role.Any() ? Role.Select(r => new ExtensionRole(r)) : Enumerable.Repeat(new ExtensionRole(), 1))
239239
};
240240

241-
var extConfig = ExtensionManager.InstallExtension(context, Slot, Deployment.ExtensionConfiguration);
241+
var extConfig = ExtensionManager.InstallExtension(context, Slot, Deployment.ExtensionConfiguration, PeerDeployment.ExtensionConfiguration);
242242
ChangeDeployment(extConfig);
243243
}
244244

src/ServiceManagement/Compute/Commands.ServiceManagement/Extensions/Common/BaseAzureServiceExtensionCmdlet.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public abstract class BaseAzureServiceExtensionCmdlet : ServiceManagementBaseCmd
5050
protected XDocument PublicConfigurationXml { get; set; }
5151
protected XDocument PrivateConfigurationXml { get; set; }
5252
protected DeploymentGetResponse Deployment { get; set; }
53+
protected DeploymentGetResponse PeerDeployment { get; set; }
5354

5455
public virtual string ServiceName { get; set; }
5556
public virtual string Slot { get; set; }
@@ -109,6 +110,8 @@ protected void ValidateDeployment()
109110
}
110111
Deployment.ExtensionConfiguration = Deployment.ExtensionConfiguration ?? new Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration();
111112
}
113+
114+
PeerDeployment = GetPeerDeployment(Slot);
112115
}
113116

114117
protected void ValidateRoles()
@@ -285,6 +288,15 @@ protected DeploymentGetResponse GetDeployment(string slot)
285288
return d;
286289
}
287290

291+
protected DeploymentGetResponse GetPeerDeployment(string currentSlot)
292+
{
293+
var currentSlotType = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), currentSlot, true);
294+
var peerSlot = currentSlotType == DeploymentSlot.Production ? DeploymentSlot.Staging : DeploymentSlot.Production;
295+
var peerSlotStr = peerSlot.ToString();
296+
297+
return GetDeployment(peerSlotStr);
298+
}
299+
288300
protected SecureString GetSecurePassword(string password)
289301
{
290302
SecureString securePassword = new SecureString();

0 commit comments

Comments
 (0)