-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Update Azurestack DiskRP admin SDK #4644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e750538
Update AzureStack Compute Admin - for Managed Disk
shanswmicrosoft ad44565
Update azurestack managed disk - add more tests
shanswmicrosoft 6d7ead9
Update Azurestack managed disk - for test code
shanswmicrosoft ff4669d
Update AzureStack Compute Test code.
shanswmicrosoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file--> | ||
| <PropertyGroup> | ||
| <AzureApiTag>Compute.Admin_2015-12-01-preview;Compute.Admin_2018-02-09;</AzureApiTag> | ||
| <AzureApiTag>Compute.Admin_2018-07-30-preview;Compute.Admin_2015-12-01-preview;Compute.Admin_2018-02-09;</AzureApiTag> | ||
| <PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags> | ||
| </PropertyGroup> | ||
| </Project> |
416 changes: 416 additions & 0 deletions
416
...ComputeAdmin/Compute.Admin.Tests/SessionRecords/ComputeAdminClient/TestDiskMigration.json
Large diffs are not rendered by default.
Oops, something went wrong.
355 changes: 355 additions & 0 deletions
355
.../Compute.Admin.Tests/SessionRecords/ComputeAdminClient/TestDiskMigrationInvalidInput.json
Large diffs are not rendered by default.
Oops, something went wrong.
142 changes: 142 additions & 0 deletions
142
...Admin/ComputeAdmin/Compute.Admin.Tests/SessionRecords/ComputeAdminClient/TestGetDisk.json
Large diffs are not rendered by default.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
...omputeAdmin/Compute.Admin.Tests/SessionRecords/ComputeAdminClient/TestGetDiskInvalid.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| { | ||
| "Entries": [ | ||
| { | ||
| "RequestUri": "/subscriptions/c69f350f-01b9-417d-bb90-08a397934964/providers/Microsoft.Compute.Admin/locations/local/disks/454E5E28-8D5E-41F9-929E-BFF6A7E1A253?api-version=2018-07-30-preview", | ||
| "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvYzY5ZjM1MGYtMDFiOS00MTdkLWJiOTAtMDhhMzk3OTM0OTY0L3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29tcHV0ZS5BZG1pbi9sb2NhdGlvbnMvbG9jYWwvZGlza3MvNDU0RTVFMjgtOEQ1RS00MUY5LTkyOUUtQkZGNkE3RTFBMjUzP2FwaS12ZXJzaW9uPTIwMTgtMDctMzAtcHJldmlldw==", | ||
| "RequestMethod": "GET", | ||
| "RequestBody": "", | ||
| "RequestHeaders": { | ||
| "x-ms-client-request-id": [ | ||
| "4e863a57-76fb-452d-88a0-0f02536482c4" | ||
| ], | ||
| "accept-language": [ | ||
| "en-US" | ||
| ], | ||
| "User-Agent": [ | ||
| "FxVersion/4.6.26020.03", | ||
| "Microsoft.AzureStack.Management.Compute.Admin.ComputeAdminClient/0.3.0.0" | ||
| ] | ||
| }, | ||
| "ResponseHeaders": { | ||
| "Cache-Control": [ | ||
| "no-cache" | ||
| ], | ||
| "Date": [ | ||
| "Thu, 09 Aug 2018 06:05:35 GMT" | ||
| ], | ||
| "Pragma": [ | ||
| "no-cache" | ||
| ], | ||
| "Server": [ | ||
| "Microsoft-HTTPAPI/2.0" | ||
| ], | ||
| "WWW-Authenticate": [ | ||
| "oYG3MIG0oAMKAQChCwYJKoZIgvcSAQICooGfBIGcYIGZBgkqhkiG9xIBAgICAG+BiTCBhqADAgEFoQMCAQ+iejB4oAMCARKicQRvjIutUf86si1PznOxO46jZQoJpHzmbKpfCyvgxna+bM0QZeMSLg3+oXjDYvFcH4XZZO7xel4mEqfwVL014pnxwvP4Wbw7Y76vkIsHL5yXg+zw12stsD3/bGcayVkZVHeb1psmHvCI7swotWiODA3x" | ||
| ], | ||
| "Strict-Transport-Security": [ | ||
| "max-age=31536000; includeSubDomains" | ||
| ], | ||
| "x-ms-served-by": [ | ||
| "00000000-0000-0000-0000-000000000000_0" | ||
| ], | ||
| "x-ms-correlation-request-id": [ | ||
| "cbe90dad-de09-4f3d-8266-9c494514767e" | ||
| ], | ||
| "x-ms-ratelimit-remaining-subscription-reads": [ | ||
| "14972" | ||
| ], | ||
| "x-ms-request-id": [ | ||
| "cbe90dad-de09-4f3d-8266-9c494514767e" | ||
| ], | ||
| "x-ms-routing-request-id": [ | ||
| "LOCAL:20180809T060536Z:cbe90dad-de09-4f3d-8266-9c494514767e" | ||
| ], | ||
| "X-Content-Type-Options": [ | ||
| "nosniff" | ||
| ], | ||
| "Content-Length": [ | ||
| "92" | ||
| ], | ||
| "Content-Type": [ | ||
| "application/json; charset=utf-8" | ||
| ], | ||
| "Expires": [ | ||
| "-1" | ||
| ] | ||
| }, | ||
| "ResponseBody": "{\r\n \"error\": {\r\n \"code\": \"NotFound\",\r\n \"message\": \"The entity was not found.\"\r\n }\r\n}", | ||
| "StatusCode": 404 | ||
| } | ||
| ], | ||
| "Names": {}, | ||
| "Variables": { | ||
| "SubscriptionId": "c69f350f-01b9-417d-bb90-08a397934964" | ||
| } | ||
| } |
343 changes: 343 additions & 0 deletions
343
...min/ComputeAdmin/Compute.Admin.Tests/SessionRecords/ComputeAdminClient/TestListDisks.json
Large diffs are not rendered by default.
Oops, something went wrong.
115 changes: 115 additions & 0 deletions
115
src/AzureStack/Admin/ComputeAdmin/Compute.Admin.Tests/src/DiskMigrationJobTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| | ||
| using Microsoft.AzureStack.Management.Compute.Admin; | ||
| using Microsoft.AzureStack.Management.Compute.Admin.Models; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Net; | ||
| using System.Threading; | ||
| using Xunit; | ||
|
|
||
| namespace Compute.Tests | ||
| { | ||
| public class DiskMigrationJobTests : ComputeTestBase | ||
| { | ||
| private void ValidateDiskMigration(DiskMigrationJob diskMigration) | ||
| { | ||
| Assert.NotNull(diskMigration); | ||
| Assert.NotNull(diskMigration.CreationTime); | ||
| Assert.NotNull(diskMigration.Id); | ||
| Assert.NotNull(diskMigration.Location); | ||
| Assert.NotNull(diskMigration.Name); | ||
| Assert.NotNull(diskMigration.Status); | ||
| Assert.NotNull(diskMigration.TargetShare); | ||
| Assert.NotNull(diskMigration.Type); | ||
| Assert.NotNull(diskMigration.MigrationId); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void TestDiskMigration() | ||
| { | ||
| string targetShare = @"\\SU1FileServer.azurestack.local\SU1_ObjStore\"; | ||
| RunTest((client) => { | ||
| var disks = client.Disks.List(Location); | ||
| List<Disk> toMigrationDisks = new List<Disk>(); | ||
| foreach(var disk in disks) | ||
| { | ||
| if (toMigrationDisks.Count < 3) | ||
| { | ||
| toMigrationDisks.Add(disk); | ||
| } | ||
| else | ||
| { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| var migrationId = "ba0644a4-c2ed-4e3c-a167-089a32865297";// This guid should be the same as the ones in sessionRecord | ||
|
|
||
| var migration = client.DiskMigrationJobs.Create(Location, migrationId, targetShare, toMigrationDisks); | ||
| ValidateDiskMigration(migration); | ||
|
|
||
| migration = client.DiskMigrationJobs.Cancel(Location, migrationId); | ||
| ValidateDiskMigration(migration); | ||
|
|
||
| var migrationFromGet = client.DiskMigrationJobs.Get(Location, migrationId); | ||
| ValidateDiskMigration(migrationFromGet); | ||
|
|
||
| var migrationList = client.DiskMigrationJobs.List(Location); | ||
| migrationList.ForEach(ValidateDiskMigration); | ||
|
|
||
| var migrationSucceededList = client.DiskMigrationJobs.List(Location, status: "Succeeded"); | ||
| migrationSucceededList.ForEach(ValidateDiskMigration); | ||
| }); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void TestDiskMigrationInvalidInput() | ||
| { | ||
| string targetShare = @"\\SU1FileServer.azurestack.local\SU1_ObjStore_Invalid\"; | ||
| RunTest((client) => { | ||
| var disks = client.Disks.List(Location); | ||
| List<Disk> toMigrationDisks = new List<Disk>(); | ||
| if (disks.Count() > 0) | ||
| { | ||
| toMigrationDisks.Add(disks.First()); | ||
|
|
||
| var migrationId = "A50E9E6B-CFC2-4BC7-956B-0F7C35035DF2";// This guid should be the same as the ones in sessionRecord | ||
|
|
||
| ValidateExpectedReturnCode( | ||
| () => client.DiskMigrationJobs.Create(Location, migrationId, targetShare, toMigrationDisks), | ||
| HttpStatusCode.BadRequest | ||
| ); | ||
|
|
||
| ValidateExpectedReturnCode( | ||
| () => client.DiskMigrationJobs.Get(Location, migrationId), | ||
| HttpStatusCode.NotFound | ||
| ); | ||
|
|
||
| toMigrationDisks[0].DiskId = "454E5E28-8D5E-41F9-929E-BFF6A7E1A253"; //Use some not exist disk | ||
| targetShare = @"\\SU1FileServer.azurestack.local\SU1_ObjStore\"; | ||
|
|
||
| var migration = client.DiskMigrationJobs.Create(Location, migrationId, targetShare, toMigrationDisks); | ||
| int times = 0; | ||
| do | ||
| { | ||
| Thread.Sleep(3); | ||
| migration = client.DiskMigrationJobs.Get(Location, migrationId); | ||
| if (migration.Subtasks[0].MigrationSubtaskStatus.Equals("Skipped")) | ||
| { | ||
| break; | ||
| } | ||
| times++; | ||
| Thread.Sleep(3); | ||
| } | ||
| while (times < 50); | ||
|
|
||
| if(!migration.Subtasks[0].MigrationSubtaskStatus.Equals("Skipped")) | ||
| { | ||
| throw new Exception("Migration Status is not expected"); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| } | ||
109 changes: 109 additions & 0 deletions
109
src/AzureStack/Admin/ComputeAdmin/Compute.Admin.Tests/src/DiskTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| | ||
| using Microsoft.AzureStack.Management.Compute.Admin; | ||
| using Microsoft.AzureStack.Management.Compute.Admin.Models; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Net; | ||
| using Xunit; | ||
|
|
||
| namespace Compute.Tests | ||
| { | ||
| public class DiskTests : ComputeTestBase | ||
| { | ||
| private void ValidateDisk(Disk disk) | ||
| { | ||
| Assert.NotNull(disk); | ||
| Assert.NotNull(disk.ActualSizeGB); | ||
| Assert.NotNull(disk.ProvisionSizeGB); | ||
| Assert.NotNull(disk.DiskSku); | ||
| Assert.NotNull(disk.DiskType); | ||
| Assert.NotNull(disk.SharePath); | ||
| Assert.NotNull(disk.Status); | ||
| Assert.NotNull(disk.UserResourceId); | ||
| Assert.NotNull(disk.Type); | ||
| Assert.NotNull(disk.Id); | ||
| Assert.NotNull(disk.Name); | ||
| Assert.NotNull(disk.Location); | ||
| Assert.NotNull(disk.DiskId); | ||
| } | ||
|
|
||
| private void ValidateDiskTheSame(Disk diskRight, Disk diskLeft) | ||
| { | ||
| Assert.NotNull(diskRight); | ||
| Assert.NotNull(diskLeft); | ||
|
|
||
| Assert.True(diskRight.Id == diskLeft.Id); | ||
| } | ||
|
|
||
| private void ValidateDisksTheSame(IEnumerable<Disk> disksRight, IEnumerable<Disk> disksLeft) | ||
| { | ||
| Assert.NotNull(disksRight); | ||
| Assert.NotNull(disksLeft); | ||
| Assert.Equal(disksRight.Count(), disksLeft.Count()); | ||
|
|
||
| disksRight.ForEach(disk => Assert.True(IsDiskExistsInCollection(disk, disksLeft))); | ||
| } | ||
|
|
||
| private bool IsDiskExistsInCollection(Disk disk, IEnumerable<Disk> disks) | ||
| { | ||
| return disks.Any(diskInCollection => diskInCollection.UserResourceId.Equals(disk.UserResourceId, StringComparison.OrdinalIgnoreCase)); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void TestListDisks() | ||
| { | ||
| RunTest((client) => { | ||
| var disks = client.Disks.List(Location); | ||
| disks.ForEach(ValidateDisk); | ||
|
|
||
| if(disks.Count()>0) | ||
| { | ||
| var firstDisk = disks.First(); | ||
| var tenantSubscriptionId = firstDisk.UserResourceId.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)[1]; | ||
|
|
||
| var disksForSubscription = client.Disks.List(Location, userSubscriptionId: tenantSubscriptionId); | ||
| ValidateDisksTheSame(disks.Where(disk => disk.UserResourceId.Contains(tenantSubscriptionId)), disksForSubscription); | ||
|
|
||
| var disksForStatus = client.Disks.List(Location, status: firstDisk.Status); | ||
| ValidateDisksTheSame(disks.Where(disk => disk.Status.Equals(firstDisk.Status, StringComparison.OrdinalIgnoreCase)), disksForStatus); | ||
|
|
||
| var disksForShare = client.Disks.List(Location, sharePath: firstDisk.SharePath); | ||
| ValidateDisksTheSame(disks.Where(disk => disk.SharePath.Equals(firstDisk.SharePath, StringComparison.OrdinalIgnoreCase)), disksForShare); | ||
|
|
||
| if (disks.Count() >= 2) | ||
| { | ||
| var disksWithCountAndStart = client.Disks.List(Location, count: 1, start: 1); | ||
| ValidateDisksTheSame(new List<Disk>() { disks.ElementAt(1) }, disksWithCountAndStart); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void TestGetDisk() | ||
| { | ||
| RunTest((client) => { | ||
| var disks = client.Disks.List(Location); | ||
| disks.ForEach(ValidateDisk); | ||
|
|
||
| if (disks.Count() > 0) | ||
| { | ||
| var firstDisk = disks.First(); | ||
| var diskFromServer = client.Disks.Get(Location, firstDisk.DiskId); | ||
| ValidateDiskTheSame(firstDisk, diskFromServer); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void TestGetDiskInvalid() | ||
| { | ||
| RunTest((client) => { | ||
| ValidateExpectedReturnCode( | ||
| () => client.Disks.Get(Location, "454E5E28-8D5E-41F9-929E-BFF6A7E1A253"), | ||
| HttpStatusCode.NotFound); | ||
| }); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do tests that should fail? For instance try to migrate to a share that doesn't exist or with a disk that is invalid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try
Assert.FalseorAssert.Exceptionconstructs.If you wish to add the tests but enable them at a later time, you could always skip the tests, hope this helps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added more tests.