32
32
using Microsoft . WindowsAzure . Commands . ServiceManagement . Extensions ;
33
33
using Microsoft . WindowsAzure . Commands . ServiceManagement . Model ;
34
34
using Microsoft . WindowsAzure . Commands . ServiceManagement . Test . FunctionalTests . ConfigDataInfo ;
35
+ using Microsoft . WindowsAzure . Commands . Common . Storage ;
36
+ using Microsoft . WindowsAzure . Storage . Auth ;
37
+ using Microsoft . WindowsAzure . Storage ;
35
38
36
39
namespace Microsoft . WindowsAzure . Commands . ServiceManagement . Test . FunctionalTests
37
40
{
@@ -1009,7 +1012,6 @@ public void AzureServiceDiagnosticsExtensionConfigScenarioTest()
1009
1012
[ Ignore ]
1010
1013
public void AzureServiceDiagnosticsExtensionTest ( )
1011
1014
{
1012
-
1013
1015
StartTest ( MethodBase . GetCurrentMethod ( ) . Name , testStartTime ) ;
1014
1016
1015
1017
// Choose the package and config files from local machine
@@ -1026,41 +1028,110 @@ public void AzureServiceDiagnosticsExtensionTest()
1026
1028
DeploymentInfoContext result ;
1027
1029
1028
1030
string storage = defaultAzureSubscription . CurrentStorageAccountName ;
1029
- string daConfig = @".\ da.xml" ;
1031
+ string daConfig = @"da.xml" ;
1030
1032
1031
1033
string defaultExtensionId = string . Format ( "Default-{0}-Production-Ext-0" , Utilities . PaaSDiagnosticsExtensionName ) ;
1032
1034
1033
- try
1034
- {
1035
- serviceName = Utilities . GetUniqueShortName ( serviceNamePrefix ) ;
1036
- vmPowershellCmdlets . NewAzureService ( serviceName , serviceName , locationName ) ;
1037
- Console . WriteLine ( "service, {0}, is created." , serviceName ) ;
1035
+ serviceName = Utilities . GetUniqueShortName ( serviceNamePrefix ) ;
1036
+ vmPowershellCmdlets . NewAzureService ( serviceName , serviceName , locationName ) ;
1037
+ Console . WriteLine ( "service, {0}, is created." , serviceName ) ;
1038
1038
1039
- vmPowershellCmdlets . NewAzureDeployment ( serviceName , packagePath1 . FullName , configPath1 . FullName , DeploymentSlotType . Production , deploymentLabel , deploymentName , false , false ) ;
1039
+ vmPowershellCmdlets . NewAzureDeployment ( serviceName , packagePath1 . FullName , configPath1 . FullName , DeploymentSlotType . Production , deploymentLabel , deploymentName , false , false ) ;
1040
1040
1041
- result = vmPowershellCmdlets . GetAzureDeployment ( serviceName , DeploymentSlotType . Production ) ;
1042
- pass = Utilities . PrintAndCompareDeployment ( result , serviceName , deploymentName , deploymentLabel , DeploymentSlotType . Production , null , 2 ) ;
1043
- Console . WriteLine ( "successfully deployed the package" ) ;
1041
+ result = vmPowershellCmdlets . GetAzureDeployment ( serviceName , DeploymentSlotType . Production ) ;
1042
+ pass = Utilities . PrintAndCompareDeployment ( result , serviceName , deploymentName , deploymentLabel , DeploymentSlotType . Production , null , 2 ) ;
1043
+ Console . WriteLine ( "successfully deployed the package" ) ;
1044
1044
1045
- vmPowershellCmdlets . SetAzureServiceDiagnosticsExtension ( serviceName , storage , daConfig , null , null ) ;
1045
+ string storageKey = vmPowershellCmdlets . GetAzureStorageAccountKey ( storage ) . Primary ;
1046
1046
1047
- DiagnosticExtensionContext resultContext = vmPowershellCmdlets . GetAzureServiceDiagnosticsExtension ( serviceName ) [ 0 ] ;
1047
+ StorageCredentials creds = new StorageCredentials ( storage , storageKey ) ;
1048
+ CloudStorageAccount csa = new WindowsAzure . Storage . CloudStorageAccount ( creds , true ) ;
1049
+ var storageContext = new AzureStorageContext ( csa ) ;
1048
1050
1049
- VerifyDiagExtContext ( resultContext , "AllRoles" , defaultExtensionId , storage , daConfig ) ;
1051
+ vmPowershellCmdlets . SetAzureServiceDiagnosticsExtension ( serviceName , storageContext , daConfig , null , null ) ;
1050
1052
1051
- vmPowershellCmdlets . RemoveAzureServiceDiagnosticsExtension ( serviceName , true ) ;
1053
+ DiagnosticExtensionContext resultContext = vmPowershellCmdlets . GetAzureServiceDiagnosticsExtension ( serviceName ) [ 0 ] ;
1052
1054
1053
- Assert . AreEqual ( vmPowershellCmdlets . GetAzureServiceDiagnosticsExtension ( serviceName ) . Count , 0 ) ;
1055
+ VerifyDiagExtContext ( resultContext , "AllRoles" , defaultExtensionId , storage , daConfig ) ;
1054
1056
1055
- vmPowershellCmdlets . RemoveAzureDeployment ( serviceName , DeploymentSlotType . Production , true ) ;
1057
+ vmPowershellCmdlets . RemoveAzureServiceDiagnosticsExtension ( serviceName , true ) ;
1056
1058
1057
- pass &= Utilities . CheckRemove ( vmPowershellCmdlets . GetAzureDeployment , serviceName , DeploymentSlotType . Production ) ;
1058
- }
1059
- catch ( Exception e )
1060
- {
1061
- pass = false ;
1062
- Assert . Fail ( "Exception occurred: {0}" , e . ToString ( ) ) ;
1063
- }
1059
+ Assert . AreEqual ( vmPowershellCmdlets . GetAzureServiceDiagnosticsExtension ( serviceName ) . Count , 0 ) ;
1060
+
1061
+ vmPowershellCmdlets . RemoveAzureDeployment ( serviceName , DeploymentSlotType . Production , true ) ;
1062
+
1063
+ pass &= Utilities . CheckRemove ( vmPowershellCmdlets . GetAzureDeployment , serviceName , DeploymentSlotType . Production ) ;
1064
+ }
1065
+
1066
+ [ TestMethod ( ) , TestCategory ( Category . Scenario ) , TestProperty ( "Feature" , "PAAS" ) , Priority ( 1 ) , Owner ( "hylee" ) , Description ( "Test the cmdlet ((Get,Set,Remove)-AzureServiceRemoteDesktopExtension)" ) ]
1067
+ [ DataSource ( "Microsoft.VisualStudio.TestTools.DataSource.CSV" , "|DataDirectory|\\ Resources\\ nodiagpackage.csv" , "nodiagpackage#csv" , DataAccessMethod . Sequential ) ]
1068
+ [ Ignore ]
1069
+ public void VipSwapWithDiagnosticsExtensionTest ( )
1070
+ {
1071
+ StartTest ( MethodBase . GetCurrentMethod ( ) . Name , testStartTime ) ;
1072
+
1073
+ // Choose the package and config files from local machine
1074
+ string packageName = Convert . ToString ( TestContext . DataRow [ "packageName" ] ) ;
1075
+ string configName = Convert . ToString ( TestContext . DataRow [ "configName" ] ) ;
1076
+ var packagePath = new FileInfo ( Directory . GetCurrentDirectory ( ) + "\\ " + packageName ) ;
1077
+ var configPath = new FileInfo ( Directory . GetCurrentDirectory ( ) + "\\ " + configName ) ;
1078
+
1079
+ Assert . IsTrue ( File . Exists ( packagePath . FullName ) , "Package file not exist={0}" , packagePath ) ;
1080
+ Assert . IsTrue ( File . Exists ( configPath . FullName ) , "Config file not exist={0}" , configPath ) ;
1081
+
1082
+ string deploymentName = "deployment1" ;
1083
+ string deploymentLabel = "label1" ;
1084
+ DeploymentInfoContext result ;
1085
+
1086
+ string storage = defaultAzureSubscription . CurrentStorageAccountName ;
1087
+ string daConfig = @"da.xml" ;
1088
+
1089
+ string storageKey = vmPowershellCmdlets . GetAzureStorageAccountKey ( storage ) . Primary ;
1090
+ StorageCredentials creds = new StorageCredentials ( storage , storageKey ) ;
1091
+ CloudStorageAccount csa = new WindowsAzure . Storage . CloudStorageAccount ( creds , true ) ;
1092
+ var storageContext = new AzureStorageContext ( csa ) ;
1093
+
1094
+ serviceName = Utilities . GetUniqueShortName ( serviceNamePrefix ) ;
1095
+ vmPowershellCmdlets . NewAzureService ( serviceName , serviceName , locationName ) ;
1096
+ Console . WriteLine ( "service, {0}, is created." , serviceName ) ;
1097
+
1098
+ // deploy staging
1099
+ vmPowershellCmdlets . NewAzureDeployment ( serviceName , packagePath . FullName , configPath . FullName , DeploymentSlotType . Staging , deploymentLabel , deploymentName , false , false ) ;
1100
+ result = vmPowershellCmdlets . GetAzureDeployment ( serviceName , DeploymentSlotType . Staging ) ;
1101
+ pass = Utilities . PrintAndCompareDeployment ( result , serviceName , deploymentName , deploymentLabel , DeploymentSlotType . Staging , null , 2 ) ;
1102
+ Console . WriteLine ( "successfully deployed the package" ) ;
1103
+
1104
+ vmPowershellCmdlets . SetAzureServiceDiagnosticsExtension ( serviceName , storageContext , daConfig , null , slot : DeploymentSlotType . Staging ) ;
1105
+ DiagnosticExtensionContext resultContext = vmPowershellCmdlets . GetAzureServiceDiagnosticsExtension ( serviceName , slot : DeploymentSlotType . Staging ) [ 0 ] ;
1106
+ VerifyDiagExtContext ( resultContext , "AllRoles" , "Default-PaaSDiagnostics-Staging-Ext-0" , storage , daConfig ) ;
1107
+
1108
+ // swap staging -> production
1109
+ // production will be retain diagnosting config from staging, named Default-PaaSDiagnostics-Staging-Ext-0
1110
+ vmPowershellCmdlets . MoveAzureDeployment ( serviceName ) ;
1111
+
1112
+ // deploy a new staging
1113
+ deploymentName = "deployment2" ;
1114
+ deploymentLabel = "label2" ;
1115
+
1116
+ vmPowershellCmdlets . NewAzureDeployment ( serviceName , packagePath . FullName , configPath . FullName , DeploymentSlotType . Staging , deploymentLabel , deploymentName , false , false ) ;
1117
+ result = vmPowershellCmdlets . GetAzureDeployment ( serviceName , DeploymentSlotType . Staging ) ;
1118
+ pass = Utilities . PrintAndCompareDeployment ( result , serviceName , deploymentName , deploymentLabel , DeploymentSlotType . Staging , null , 2 ) ;
1119
+ Console . WriteLine ( "successfully deployed the package" ) ;
1120
+
1121
+ // should detect that Default-PaaSDiagnostics-Staging-Ext-0 is in use
1122
+ vmPowershellCmdlets . SetAzureServiceDiagnosticsExtension ( serviceName , storageContext , daConfig , null , slot : DeploymentSlotType . Staging ) ;
1123
+ DiagnosticExtensionContext resultContext2 = vmPowershellCmdlets . GetAzureServiceDiagnosticsExtension ( serviceName , slot : DeploymentSlotType . Staging ) [ 0 ] ;
1124
+ VerifyDiagExtContext ( resultContext2 , "AllRoles" , "Default-PaaSDiagnostics-Staging-Ext-1" , storage , daConfig ) ;
1125
+
1126
+ // execute again to make sure max number of extensions will handled correctly (1 for production and 1 for staging, 1 unused)
1127
+ // should not fail due to ExtensionIdLiveCycleCount limit
1128
+ vmPowershellCmdlets . SetAzureServiceDiagnosticsExtension ( serviceName , storageContext , daConfig , null , slot : DeploymentSlotType . Staging ) ;
1129
+ DiagnosticExtensionContext resultContext3 = vmPowershellCmdlets . GetAzureServiceDiagnosticsExtension ( serviceName , slot : DeploymentSlotType . Staging ) [ 0 ] ;
1130
+
1131
+ // azure splits config from All Roles to specific role in that case, so role name should not be validated
1132
+ VerifyDiagExtContext ( resultContext3 , null , "Default-PaaSDiagnostics-Staging-Ext-2" , storage , daConfig ) ;
1133
+
1134
+ vmPowershellCmdlets . RemoveAzureService ( serviceName , true ) ;
1064
1135
}
1065
1136
1066
1137
#endregion
@@ -1695,15 +1766,19 @@ private void VerifyDiagExtContext(DiagnosticExtensionContext resultContext, stri
1695
1766
{
1696
1767
Utilities . PrintContext ( resultContext ) ;
1697
1768
1698
- Assert . AreEqual ( role , resultContext . Role . RoleType . ToString ( ) , "role is not same" ) ;
1769
+ if ( role != null )
1770
+ {
1771
+ Assert . AreEqual ( role , resultContext . Role . RoleType . ToString ( ) , "role is not same" ) ;
1772
+ }
1773
+
1699
1774
Assert . AreEqual ( Utilities . PaaSDiagnosticsExtensionName , resultContext . Extension , "extension is not Diagnostics" ) ;
1775
+
1700
1776
Assert . AreEqual ( extID , resultContext . Id , "extension id is not same" ) ;
1701
- //Assert.AreEqual(storage, resultContext.StorageAccountName, "storage account name is not same");
1702
1777
1703
1778
XmlDocument doc = new XmlDocument ( ) ;
1704
- doc . Load ( "@./ da.xml" ) ;
1779
+ doc . Load ( "da.xml" ) ;
1705
1780
string inner = Utilities . GetInnerXml ( resultContext . WadCfg , "WadCfg" ) ;
1706
- Assert . IsTrue ( Utilities . CompareWadCfg ( inner , doc ) , "xml is not same" ) ;
1781
+ Utilities . CompareWadCfg ( inner , doc ) ;
1707
1782
}
1708
1783
1709
1784
private void VerifyRDPExtContext ( RemoteDesktopExtensionContext resultContext , string role , string extID , string userName , DateTime exp , string version = null )
0 commit comments