From 7d324016cec9f39b973c8e3e18d7be426a6ece54 Mon Sep 17 00:00:00 2001 From: panbha Date: Thu, 11 Jun 2015 19:20:39 +0530 Subject: [PATCH] BackUpAndRecoveryScenario --- .../BackupServices.Tests.csproj | 4 ++ .../ScenarioTests/BackUpTests.cs | 40 +++++++++++ .../ScenarioTests/RecoveryPointTests.cs | 40 +++++++++++ .../TriggerBackUpTest.json | 69 +++++++++++++++++++ .../ListRecoveryPointTest.json | 69 +++++++++++++++++++ .../BackupServices.Tests/app.config | 10 ++- 6 files changed, 229 insertions(+), 3 deletions(-) create mode 100644 src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/BackUpTests.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/RecoveryPointTests.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServices.Tests/SessionRecords/BackupServices.Tests.BackUpTests/TriggerBackUpTest.json create mode 100644 src/ResourceManagement/AzureBackup/BackupServices.Tests/SessionRecords/BackupServices.Tests.RecoveryPointTests/ListRecoveryPointTest.json diff --git a/src/ResourceManagement/AzureBackup/BackupServices.Tests/BackupServices.Tests.csproj b/src/ResourceManagement/AzureBackup/BackupServices.Tests/BackupServices.Tests.csproj index e23c604185e9e..670d38c3e11d1 100644 --- a/src/ResourceManagement/AzureBackup/BackupServices.Tests/BackupServices.Tests.csproj +++ b/src/ResourceManagement/AzureBackup/BackupServices.Tests/BackupServices.Tests.csproj @@ -10,7 +10,9 @@ + + @@ -28,7 +30,9 @@ + + diff --git a/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/BackUpTests.cs b/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/BackUpTests.cs new file mode 100644 index 0000000000000..3350949c78392 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/BackUpTests.cs @@ -0,0 +1,40 @@ +using Microsoft.Azure.Management.BackupServices.Models; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Test; +using System.Net; +using Xunit; +using System.Configuration; +using System; + +namespace BackupServices.Tests +{ + public class BackUpTests : BackupServicesTestsBase + { + [Fact] + public void TriggerBackUpTest() + { + using (UndoContext context = UndoContext.Current) + { + context.Start(); + var client = GetServiceClient(); + + string containerName = ConfigurationManager.AppSettings["ContainerName"]; + string dataSourceType = ConfigurationManager.AppSettings["DataSourceType"]; + string dataSourceId = ConfigurationManager.AppSettings["DataSourceId"]; + + var response = client.BackUp.TriggerBackUp(GetCustomRequestHeaders(), containerName, dataSourceType, dataSourceId); + + + /* + foreach (var ppo in response.RecoveryPoints.Objects) + { + Assert.True(!string.IsNullOrEmpty(ppo.InstanceId), "RecoveryPointId can't be null or empty"); + Assert.True((ppo.RecoveryPointTime != null), "RecoveryPointTime can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ppo.RecoveryPointType), "RecoveryPointType can't be null or empty"); + } + */ + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + } + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/RecoveryPointTests.cs b/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/RecoveryPointTests.cs new file mode 100644 index 0000000000000..6c4a26cce4c66 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/RecoveryPointTests.cs @@ -0,0 +1,40 @@ +using Microsoft.Azure.Management.BackupServices.Models; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Test; +using System.Net; +using Xunit; +using System.Configuration; +using System; + +namespace BackupServices.Tests +{ + public class RecoveryPointTests : BackupServicesTestsBase + { + [Fact] + public void ListRecoveryPointTest() + { + using (UndoContext context = UndoContext.Current) + { + context.Start(); + var client = GetServiceClient(); + + string containerName = ConfigurationManager.AppSettings["ContainerName"]; + string dataSourceType = ConfigurationManager.AppSettings["DataSourceType"]; + string dataSourceId = ConfigurationManager.AppSettings["DataSourceId"]; + + var response = client.RecoveryPoint.List(GetCustomRequestHeaders(), containerName, dataSourceType, dataSourceId); + + Assert.True(response.RecoveryPoints.ResultCount > 0, "Recovery Points Result count can't be less than 1"); + + foreach (var ppo in response.RecoveryPoints.Objects) + { + Assert.True(!string.IsNullOrEmpty(ppo.InstanceId), "RecoveryPointId can't be null or empty"); + Assert.True((ppo.RecoveryPointTime != null), "RecoveryPointTime can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ppo.RecoveryPointType), "RecoveryPointType can't be null or empty"); + } + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + } + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServices.Tests/SessionRecords/BackupServices.Tests.BackUpTests/TriggerBackUpTest.json b/src/ResourceManagement/AzureBackup/BackupServices.Tests/SessionRecords/BackupServices.Tests.BackUpTests/TriggerBackUpTest.json new file mode 100644 index 0000000000000..5237d509f0fc0 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServices.Tests/SessionRecords/BackupServices.Tests.BackUpTests/TriggerBackUpTest.json @@ -0,0 +1,69 @@ +{ + "Entries": [ + { + "RequestUri": "/Subscriptions/f5303a0b-fae4-4cdb-b44d-0e4c032dde26/resourceGroups/backuprg/providers/Microsoft.Backupseadev01/BackupVault/backuprn/containers/iaasvmcontainer%3Bdev01testing%3Bdev01testing/datasources/VM/17593283453810/backup?api-version=2014-09-01", + "EncodedRequestUri": "L1N1YnNjcmlwdGlvbnMvZjUzMDNhMGItZmFlNC00Y2RiLWI0NGQtMGU0YzAzMmRkZTI2L3Jlc291cmNlR3JvdXBzL2JhY2t1cHJnL3Byb3ZpZGVycy9NaWNyb3NvZnQuQmFja3Vwc2VhZGV2MDEvQmFja3VwVmF1bHQvYmFja3Vwcm4vY29udGFpbmVycy9pYWFzdm1jb250YWluZXIlM0JkZXYwMXRlc3RpbmclM0JkZXYwMXRlc3RpbmcvZGF0YXNvdXJjZXMvVk0vMTc1OTMyODM0NTM4MTAvYmFja3VwP2FwaS12ZXJzaW9uPTIwMTQtMDktMDE=", + "RequestMethod": "POST", + "RequestBody": "", + "RequestHeaders": { + "Accept-Language": [ + "en-us" + ], + "User-Agent": [ + "Microsoft.Azure.Management.BackupServices.BackupServicesManagementClient/0.0.0.0" + ] + }, + "ResponseBody": "\"47ac4ee3-a249-4d8d-b737-b67bd0d9ada1\"", + "ResponseHeaders": { + "Content-Length": [ + "38" + ], + "Content-Type": [ + "application/json" + ], + "Expires": [ + "-1" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-request-id": [ + "959bc754-f55e-461b-aeff-d32b56c6218d" + ], + "x-ms-client-request-id": [ + "380700e8-5f65-4790-b6a9-77085f633b6d", + "380700e8-5f65-4790-b6a9-77085f633b6d" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-correlation-request-id": [ + "959bc754-f55e-461b-aeff-d32b56c6218d" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20150611T105041Z:959bc754-f55e-461b-aeff-d32b56c6218d" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Thu, 11 Jun 2015 10:50:40 GMT" + ], + "Server": [ + "Microsoft-IIS/8.0" + ], + "X-Powered-By": [ + "ASP.NET" + ] + }, + "StatusCode": 202 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "f5303a0b-fae4-4cdb-b44d-0e4c032dde26" + } +} \ No newline at end of file diff --git a/src/ResourceManagement/AzureBackup/BackupServices.Tests/SessionRecords/BackupServices.Tests.RecoveryPointTests/ListRecoveryPointTest.json b/src/ResourceManagement/AzureBackup/BackupServices.Tests/SessionRecords/BackupServices.Tests.RecoveryPointTests/ListRecoveryPointTest.json new file mode 100644 index 0000000000000..91f2429b3339e --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServices.Tests/SessionRecords/BackupServices.Tests.RecoveryPointTests/ListRecoveryPointTest.json @@ -0,0 +1,69 @@ +{ + "Entries": [ + { + "RequestUri": "/Subscriptions/f5303a0b-fae4-4cdb-b44d-0e4c032dde26/resourceGroups/backuprg/providers/Microsoft.Backupseadev01/BackupVault/backuprn/containers/iaasvmcontainer%3Bdev01testing%3Bdev01testing/datasources/VM/17593283453810/recoverypoints?api-version=2014-09-01", + "EncodedRequestUri": "L1N1YnNjcmlwdGlvbnMvZjUzMDNhMGItZmFlNC00Y2RiLWI0NGQtMGU0YzAzMmRkZTI2L3Jlc291cmNlR3JvdXBzL2JhY2t1cHJnL3Byb3ZpZGVycy9NaWNyb3NvZnQuQmFja3Vwc2VhZGV2MDEvQmFja3VwVmF1bHQvYmFja3Vwcm4vY29udGFpbmVycy9pYWFzdm1jb250YWluZXIlM0JkZXYwMXRlc3RpbmclM0JkZXYwMXRlc3RpbmcvZGF0YXNvdXJjZXMvVk0vMTc1OTMyODM0NTM4MTAvcmVjb3Zlcnlwb2ludHM/YXBpLXZlcnNpb249MjAxNC0wOS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "Accept-Language": [ + "en-us" + ], + "User-Agent": [ + "Microsoft.Azure.Management.BackupServices.BackupServicesManagementClient/0.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"Objects\": [\r\n {\r\n \"RecoveryPointType\": \"AppConsistent\",\r\n \"RecoveryPointTime\": \"2015-06-11T10:52:30.0345282Z\",\r\n \"RecoveryPointAdditionalInfo\": \"\",\r\n \"InstanceId\": \"19591702463836\",\r\n \"Name\": null,\r\n \"OperationInProgress\": false\r\n }\r\n ],\r\n \"ResultCount\": 1,\r\n \"Skiptoken\": null\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "238" + ], + "Content-Type": [ + "application/json" + ], + "Expires": [ + "-1" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-request-id": [ + "309bda36-8fc0-4708-ac3c-3ba1a6dd791e" + ], + "x-ms-client-request-id": [ + "750381bf-21f7-4a9c-b4db-d0a4dbfc86f9", + "750381bf-21f7-4a9c-b4db-d0a4dbfc86f9" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14999" + ], + "x-ms-correlation-request-id": [ + "309bda36-8fc0-4708-ac3c-3ba1a6dd791e" + ], + "x-ms-routing-request-id": [ + "CENTRALUS:20150611T114322Z:309bda36-8fc0-4708-ac3c-3ba1a6dd791e" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Thu, 11 Jun 2015 11:43:21 GMT" + ], + "Server": [ + "Microsoft-IIS/8.0" + ], + "X-Powered-By": [ + "ASP.NET" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "f5303a0b-fae4-4cdb-b44d-0e4c032dde26" + } +} \ No newline at end of file diff --git a/src/ResourceManagement/AzureBackup/BackupServices.Tests/app.config b/src/ResourceManagement/AzureBackup/BackupServices.Tests/app.config index d92f4ccb41d79..a7c11b984ae70 100644 --- a/src/ResourceManagement/AzureBackup/BackupServices.Tests/app.config +++ b/src/ResourceManagement/AzureBackup/BackupServices.Tests/app.config @@ -1,9 +1,13 @@  - - - + + + + + + +