@@ -344,6 +344,7 @@ function Run-NewAzureComputeParameterObjectTests
344
344
}
345
345
}
346
346
347
+ # Run Set-AzurePlatformVMImage Cmdlet Negative Tests
347
348
function Run-AzurePlatformVMImageNegativeTest
348
349
{
349
350
$location = Get-DefaultLocation ;
@@ -363,4 +364,207 @@ function Run-AzurePlatformVMImageNegativeTest
363
364
{ Set-AzurePlatformVMImage - ImageName $imgName - Permission $mode } `
364
365
" ForbiddenError: This operation is not allowed for this subscription." ;
365
366
}
367
+ }
368
+
369
+ # Run Auto-Generated Service Extension Cmdlet Tests
370
+ function Run-AutoGeneratedServiceExtensionCmdletTests
371
+ {
372
+ # Setup
373
+ $location = Get-DefaultLocation ;
374
+
375
+ $storageName = ' pstest' + (getAssetName);
376
+ New-AzureStorageAccount - StorageAccountName $storageName - Location $location ;
377
+
378
+ # Associate the new storage account with the current subscription
379
+ Set-CurrentStorageAccountName $storageName ;
380
+
381
+ $svcName = ' pstest' + (Get-CloudServiceName );
382
+
383
+ try
384
+ {
385
+ # Create Hosted Service Parameters
386
+ $svcCreateParams = New-AzureComputeParameterObject - FriendlyName ' HostedServiceCreateParameters' ;
387
+ $svcCreateParams.ServiceName = $svcName ;
388
+ $svcCreateParams.Location = $location ;
389
+ $svcCreateParams.Description = $svcName ;
390
+ $svcCreateParams.Label = $svcName ;
391
+
392
+ # Invoke Hosted Service Create
393
+ $st = Invoke-AzureComputeMethod - MethodName ' HostedServiceCreate' - ArgumentList $svcCreateParams ;
394
+ Assert-AreEqual $st.StatusCode ' Created' ;
395
+ Assert-NotNull $st.RequestId ;
396
+
397
+ # New-AzureDeployment (in Azure.psd1)
398
+ $testMode = Get-ComputeTestMode ;
399
+ if ($testMode.ToLower () -ne ' playback' )
400
+ {
401
+ $cspkg = ' .\Resources\ServiceManagement\Files\OneWebOneWorker.cspkg' ;
402
+ }
403
+ else
404
+ {
405
+ $cspkg = " https://${storageName} .blob.azure.windows.net/blob/OneWebOneWorker.cspkg" ;
406
+ }
407
+ $cscfg = ' .\Resources\ServiceManagement\Files\OneWebOneWorker.cscfg' ;
408
+
409
+ $st = New-AzureDeployment - ServiceName $svcName - Package $cspkg - Configuration $cscfg - Label $svcName - Slot Production;
410
+
411
+ $deployment = Get-AzureDeployment - ServiceName $svcName - Slot Production;
412
+ $config = $deployment.Configuration ;
413
+
414
+ # Invoke Hosted Service Add Extension
415
+ $p1 = New-AzureComputeArgumentList - MethodName HostedServiceAddExtension;
416
+ $p1 [0 ].Value = $svcName ;
417
+ $p1 [1 ].Value.Id = ' test' ;
418
+ $p1 [1 ].Value.PublicConfiguration =
419
+ @"
420
+ <?xml version="1.0" encoding="UTF-8"?>
421
+ <PublicConfig>
422
+ <UserName>pstestuser</UserName>
423
+ <Expiration></Expiration>
424
+ </PublicConfig>
425
+ "@ ;
426
+ $p1 [1 ].Value.PrivateConfiguration =
427
+ @"
428
+ <?xml version="1.0" encoding="UTF-8"?>
429
+ <PrivateConfig>
430
+ <Password>pstestuser</Password>
431
+ </PrivateConfig>
432
+ "@ ;
433
+ $p1 [1 ].Value.ProviderNamespace = ' Microsoft.Windows.Azure.Extensions' ;
434
+ $p1 [1 ].Value.Type = ' RDP' ;
435
+ $p1 [1 ].Value.Version = ' 1.*' ;
436
+ $d1 = ($p1 | select - ExpandProperty Value);
437
+ $st = Invoke-AzureComputeMethod - MethodName HostedServiceAddExtension - ArgumentList $d1 ;
438
+
439
+ # Invoke Deployment Change Configuration
440
+ $p2 = New-AzureComputeArgumentList - MethodName DeploymentChangeConfigurationBySlot;
441
+ $p2 [0 ].Value = $svcName ;
442
+ $p2 [1 ].Value = [Microsoft.WindowsAzure.Management.Compute.Models.DeploymentSlot ]::Production;
443
+ $p2 [2 ].Value = New-Object - TypeName Microsoft.WindowsAzure.Management.Compute.Models.DeploymentChangeConfigurationParameters;
444
+ $p2 [2 ].Value.Configuration = $deployment.Configuration ;
445
+ $p2 [2 ].Value.ExtensionConfiguration = New-Object - TypeName Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration;
446
+ $p2 [2 ].Value.ExtensionConfiguration.AllRoles.Add(' test' );
447
+ $d2 = ($p2 | select - ExpandProperty Value);
448
+ $st = Invoke-AzureComputeMethod - MethodName DeploymentChangeConfigurationBySlot - ArgumentList $d2 ;
449
+
450
+ # Invoke Hosted Service Delete
451
+ $st = Invoke-AzureComputeMethod - MethodName ' HostedServiceDeleteAll' - ArgumentList $svcName ;
452
+ Assert-AreEqual $st.StatusCode ' OK' ;
453
+ Assert-NotNull $st.RequestId ;
454
+ }
455
+ finally
456
+ {
457
+ # Cleanup
458
+ Cleanup- CloudService $svcName ;
459
+ }
460
+ }
461
+
462
+ # Run Service Extension Set Cmdlet Tests
463
+ function Run-ServiceExtensionSetCmdletTests
464
+ {
465
+ # Setup
466
+ $location = Get-DefaultLocation ;
467
+ $imgName = Get-DefaultImage $location ;
468
+
469
+ $storageName = ' pstest' + (getAssetName);
470
+ New-AzureStorageAccount - StorageAccountName $storageName - Location $location ;
471
+
472
+ # Associate the new storage account with the current subscription
473
+ Set-CurrentStorageAccountName $storageName ;
474
+
475
+ $svcName = ' pstest' + (Get-CloudServiceName );
476
+ $userName = " pstestuser" ;
477
+ $password = " p@ssw0rd" ;
478
+ $sPassword = ConvertTo-SecureString $password - AsPlainText - Force;
479
+ $credential = New-Object System.Management.Automation.PSCredential ($userName , $sPassword );
480
+
481
+ # Test
482
+ New-AzureService - ServiceName $svcName - Location $location ;
483
+
484
+ try
485
+ {
486
+ # New-AzureDeployment (in Azure.psd1)
487
+ $cspkg = ' .\Resources\ServiceManagement\Files\OneWebOneWorker.cspkg' ;
488
+ $cscfg = ' .\Resources\ServiceManagement\Files\OneWebOneWorker.cscfg' ;
489
+
490
+ # Staging 1st
491
+ $st = New-AzureDeployment - ServiceName $svcName - Package $cspkg - Configuration $cscfg - Label $svcName - Slot Staging;
492
+ $st = Set-AzureServiceRemoteDesktopExtension - ServiceName $svcName - Slot Staging - Credential $credential ;
493
+ $ex = Get-AzureServiceExtension - ServiceName $svcName - Slot Staging;
494
+ $st = Move-AzureDeployment - ServiceName $svcName ;
495
+ $ex = Get-AzureServiceExtension - ServiceName $svcName - Slot Production;
496
+
497
+ # Staging 2nd
498
+ $st = New-AzureDeployment - ServiceName $svcName - Package $cspkg - Configuration $cscfg - Label $svcName - Slot Staging;
499
+ $st = Set-AzureServiceRemoteDesktopExtension - ServiceName $svcName - Slot Staging - Credential $credential ;
500
+ $ex = Get-AzureServiceExtension - ServiceName $svcName - Slot Staging;
501
+ $st = Move-AzureDeployment - ServiceName $svcName ;
502
+ $ex = Get-AzureServiceExtension - ServiceName $svcName - Slot Production;
503
+
504
+ # Set Extensions
505
+ $st = Set-AzureServiceRemoteDesktopExtension - ServiceName $svcName - Slot Production - Credential $credential ;
506
+ $st = Set-AzureServiceRemoteDesktopExtension - ServiceName $svcName - Slot Staging - Credential $credential ;
507
+ }
508
+ finally
509
+ {
510
+ # Cleanup
511
+ Cleanup- CloudService $svcName ;
512
+ }
513
+ }
514
+
515
+
516
+ # Run Service Deployment Extension Cmdlet Tests
517
+ function Run-ServiceDeploymentExtensionCmdletTests
518
+ {
519
+ # Setup
520
+ $location = Get-DefaultLocation ;
521
+ $imgName = Get-DefaultImage $location ;
522
+
523
+ $storageName = ' pstest' + (getAssetName);
524
+ New-AzureStorageAccount - StorageAccountName $storageName - Location $location ;
525
+
526
+ # Associate the new storage account with the current subscription
527
+ Set-CurrentStorageAccountName $storageName ;
528
+
529
+ $svcName = ' pstest' + (Get-CloudServiceName );
530
+ $userName = " pstestuser" ;
531
+ $password = " p@ssw0rd" ;
532
+ $sPassword = ConvertTo-SecureString $password - AsPlainText - Force;
533
+ $credential = New-Object System.Management.Automation.PSCredential ($userName , $sPassword );
534
+
535
+ # Test
536
+ New-AzureService - ServiceName $svcName - Location $location ;
537
+
538
+ try
539
+ {
540
+ # New-AzureDeployment (in Azure.psd1)
541
+ $cspkg = ' .\Resources\ServiceManagement\Files\OneWebOneWorker.cspkg' ;
542
+ $cscfg = ' .\Resources\ServiceManagement\Files\OneWebOneWorker.cscfg' ;
543
+
544
+ $rdpCfg1 = New-AzureServiceRemoteDesktopExtensionConfig - Credential $credential - Role WebRole1
545
+ $rdpCfg2 = New-AzureServiceRemoteDesktopExtensionConfig - Credential $credential - Role WorkerRole1;
546
+ $adCfg1 = New-AzureServiceADDomainExtensionConfig - Role WebRole1 - WorkgroupName ' test1' ;
547
+ $adCfg2 = New-AzureServiceADDomainExtensionConfig - Role WorkerRole1 - WorkgroupName ' test2' ;
548
+
549
+ $st = New-AzureDeployment - ServiceName $svcName - Package $cspkg - Configuration $cscfg - Label $svcName - Slot Production - ExtensionConfiguration $rdpCfg1 , $adCfg1 ;
550
+ $exts = Get-AzureServiceExtension - ServiceName $svcName - Slot Production;
551
+ Assert-True { $exts.Count -eq 2 };
552
+
553
+ $st = New-AzureDeployment - ServiceName $svcName - Package $cspkg - Configuration $cscfg - Label $svcName - Slot Staging - ExtensionConfiguration $rdpCfg2 , $adCfg2 ;
554
+ $exts = Get-AzureServiceExtension - ServiceName $svcName - Slot Staging;
555
+ Assert-True { $exts.Count -eq 2 };
556
+
557
+ $st = Set-AzureDeployment - Config - ServiceName $svcName - Configuration $cscfg - Slot Production - ExtensionConfiguration $rdpCfg2 ;
558
+ $exts = Get-AzureServiceExtension - ServiceName $svcName - Slot Production;
559
+ Assert-True { $exts.Count -eq 1 };
560
+
561
+ $st = Set-AzureDeployment - Config - ServiceName $svcName - Configuration $cscfg - Slot Staging - ExtensionConfiguration $rdpCfg1 , $adCfg1 ;
562
+ $exts = Get-AzureServiceExtension - ServiceName $svcName - Slot Staging;
563
+ Assert-True { $exts.Count -eq 2 };
564
+ }
565
+ finally
566
+ {
567
+ # Cleanup
568
+ Cleanup- CloudService $svcName ;
569
+ }
366
570
}
0 commit comments