Adding E2E test for VM Put bug for protected members#2945
Conversation
| // StorageAccountType = StorageAccountTypes.StandardLRS | ||
| // } | ||
| // } | ||
| //}, |
There was a problem hiding this comment.
why do you keep this commented code?
There was a problem hiding this comment.
@hovsepm I was planning on to use it, but then decided not to. Will remove.
|
|
||
| /// <summary> | ||
| /// Constructor | ||
| /// </summary> |
There was a problem hiding this comment.
useless comments. please remove
There was a problem hiding this comment.
@hovsepm I am used to StyleCop, so I keep adding xml comments for public functions.
| /// <summary> | ||
| /// Constructor | ||
| /// </summary> | ||
| /// <param name="vm"></param> |
There was a problem hiding this comment.
please remove these comments.
| //if (vmCustomizer != null) | ||
| //{ | ||
| // vmCustomizer(inputVM); | ||
| //} |
There was a problem hiding this comment.
please remove all the commented code in this file
| "Microsoft.Rest.ClientRuntime.Azure.TestFramework": { | ||
| "target": "project", | ||
| "type": "build" | ||
| }, |
There was a problem hiding this comment.
please decouple ClientRutnimes tests and TestFramework. Do a nuget package reference instead.
There was a problem hiding this comment.
@hovsepm we are writing E2E tests for client runtime, so we will need to take dependency on Test Framework.
Having nugget for Testframework does not add any value.
Taking project dependency help in, testing the latest version that is in repo as well as helps with debugging.
Unless there is something I am failing to understand.
| "projects": [ "Microsoft.Rest.ClientRuntime", "Microsoft.Rest.ClientRuntime.Azure.Authentication", "Microsoft.Rest.ClientRuntime.Etw", | ||
| "Microsoft.Rest.ClientRuntime.Tests", "Microsoft.Rest.ClientRuntime.Azure", "Microsoft.Rest.ClientRuntime.Azure.Tests", | ||
| "Microsoft.Rest.ClientRuntime.Log4Net", "Microsoft.Rest.ClientRuntime.Tracing.Tests" ] | ||
| "projects": [ "../TestFramework" ] |
There was a problem hiding this comment.
../TestFramework [](start = 17, length = 16)
we shouldn't create this dependency.
There was a problem hiding this comment.
@hovsepm maybe I am not sure I understand your concern here, for test projects we will have to take dependency on TestFramework.
| EndProject | ||
| Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestFramework", "..\TestFramework\Microsoft.Rest.ClientRuntime.Azure.TestFramework\TestFramework.xproj", "{C4C4E1C8-B99D-4D90-8C27-6D0C0A268BA5}" | ||
| EndProject | ||
| Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Management.Compute", "..\ResourceManagement\Compute\Microsoft.Azure.Management.Compute\Microsoft.Azure.Management.Compute.xproj", "{CBE97730-45F5-448E-88E9-55DF94D65B77}" |
There was a problem hiding this comment.
I don't think we need this in there, we should just be able to take a nuget dependency.
There was a problem hiding this comment.
@markcowl I missed removing this, I will remove Compute.
| @@ -0,0 +1,88 @@ | |||
| namespace Microsoft.Rest.ClientRuntime.E2E.Tests.ScenarioTests | |||
| @@ -0,0 +1,793 @@ | |||
| namespace Microsoft.Rest.ClientRuntime.E2E.Tests.ScenarioTests | |||
|
|
||
| MockContext _mockContext; | ||
| ResourceManagementClient _resourceClient; | ||
| //ComputeManagementClient _computeClient; |
| bool created = false; | ||
| while (!created) | ||
| { | ||
| System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10)); |
There was a problem hiding this comment.
Use the Wait method from the test framework: https://github.com/Azure/azure-sdk-for-net/blob/AutoRest/src/TestFramework/Microsoft.Rest.ClientRuntime.Azure.TestFramework/Utilities/TestUtilities.cs#L84
| }); | ||
| } | ||
| } | ||
| catch |
There was a problem hiding this comment.
why catch the exception to throw it? Just let the exception bubble up
There was a problem hiding this comment.
@markcowl will remove, lot of code is remnant of trial and error in this really long running test.
| protected string CreateAvailabilitySet(string rgName, string asName, bool hasManagedDisks = false) | ||
| { | ||
| // Setup availability set | ||
| AvailabilitySet inputAvailabilitySet = null; |
There was a problem hiding this comment.
Why are we including all of this complication in the test - I don't think we need network to run the test effectively - we need to be able to create and update a VM, but we don't care that it's a functional VM.
There was a problem hiding this comment.
@markcowl I modeled it after a simple test from compute. So I don't see a point in now removing it. Plus we don't know for sure at this stage if that is possible. So I am not going to experiment with this, as this is a really long running test and doing anything to experiment at this stage is not something I am planning on to do. If you feel strongly, we can create a issue and plan it.
| } | ||
| catch(Exception ex) | ||
| { | ||
| Debug.WriteLine(ex.ToString()); |
There was a problem hiding this comment.
I don't think we should catch exceptions, exceptions should cause the test to fail, right?
There was a problem hiding this comment.
@markcowl yes I should not simply swallow exception, will throw. Catching helps during debugging, hence will leave it, but will throw.
| Assert.False(requestContentStr.Contains("VmId")); | ||
|
|
||
| //Get VM Object | ||
| VirtualMachine getVm = res.Body; |
There was a problem hiding this comment.
So, this is going to be null, right? The VM update hasn't completed because we called BeginCreateOrUpdate, which returns immediately. I don't think we need this extra check, because the BeginUpdate request would have failed with a 400 otherwise, and we already checked the request.
There was a problem hiding this comment.
@markcowl request returned by BeginCreateOrUpdateWithHttpMessages will not have empty body, plus it will not return immediately. Also this check will help to verify if my updated property was rejected (hence not serialized).
| @@ -0,0 +1,70 @@ | |||
| using Microsoft.Azure.Management.Compute; | |||
|
@azuresdkci retest this please |
Adding E2E test for VM Creation and Update.
Testing PUT request for VM succeeds even if Protected Properties are changed.