Skip to content

Adding E2E test for VM Put bug for protected members#2945

Merged
markcowl merged 2 commits into
Azure:AutoRestfrom
shahabhijeet:VmPutBugTest
Mar 20, 2017
Merged

Adding E2E test for VM Put bug for protected members#2945
markcowl merged 2 commits into
Azure:AutoRestfrom
shahabhijeet:VmPutBugTest

Conversation

@shahabhijeet
Copy link
Copy Markdown
Contributor

Adding E2E test for VM Creation and Update.
Testing PUT request for VM succeeds even if Protected Properties are changed.

@hovsepm
Copy link
Copy Markdown
Contributor

hovsepm commented Mar 16, 2017

using System.Reflection;

Something is missing at the top of the file :)


Refers to: src/ClientRuntime/Microsoft.Rest.ClientRuntime.E2E.Tests/Properties/AssemblyInfo.cs:1 in 3179142. [](commit_id = 3179142, deletion_comment = False)

// StorageAccountType = StorageAccountTypes.StandardLRS
// }
// }
//},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you keep this commented code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hovsepm I was planning on to use it, but then decided not to. Will remove.

@hovsepm
Copy link
Copy Markdown
Contributor

hovsepm commented Mar 16, 2017

namespace Microsoft.Rest.ClientRuntime.E2E.Tests.ScenarioTests

Missing license


Refers to: src/ClientRuntime/Microsoft.Rest.ClientRuntime.E2E.Tests/ScenarioTests/E2ETestBase.cs:1 in 3179142. [](commit_id = 3179142, deletion_comment = False)

@hovsepm
Copy link
Copy Markdown
Contributor

hovsepm commented Mar 16, 2017

namespace Microsoft.Rest.ClientRuntime.E2E.Tests.ScenarioTests

Missing license


Refers to: src/ClientRuntime/Microsoft.Rest.ClientRuntime.E2E.Tests/ScenarioTests/VMTests.cs:1 in 3179142. [](commit_id = 3179142, deletion_comment = False)


/// <summary>
/// Constructor
/// </summary>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless comments. please remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hovsepm I am used to StyleCop, so I keep adding xml comments for public functions.

@hovsepm
Copy link
Copy Markdown
Contributor

hovsepm commented Mar 16, 2017

using Microsoft.Azure.Management.Compute;

Missing license


Refers to: src/ClientRuntime/Microsoft.Rest.ClientRuntime.E2E.Tests/TestAssets/ExtendingTypes.cs:1 in 3179142. [](commit_id = 3179142, deletion_comment = False)

/// <summary>
/// Constructor
/// </summary>
/// <param name="vm"></param>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove these comments.

Copy link
Copy Markdown
Contributor Author

@shahabhijeet shahabhijeet Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hovsepm will add more text to it

//if (vmCustomizer != null)
//{
// vmCustomizer(inputVM);
//}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove all the commented code in this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"Microsoft.Rest.ClientRuntime.Azure.TestFramework": {
"target": "project",
"type": "build"
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please decouple ClientRutnimes tests and TestFramework. Do a nuget package reference instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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" ]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

../TestFramework [](start = 17, length = 16)

we shouldn't create this dependency.

Copy link
Copy Markdown
Contributor Author

@shahabhijeet shahabhijeet Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hovsepm maybe I am not sure I understand your concern here, for test projects we will have to take dependency on TestFramework.

Comment thread src/ClientRuntime/ClientRuntime.sln Outdated
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}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this in there, we should just be able to take a nuget dependency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markcowl I missed removing this, I will remove Compute.

@@ -0,0 +1,88 @@
namespace Microsoft.Rest.ClientRuntime.E2E.Tests.ScenarioTests
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license header

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,793 @@
namespace Microsoft.Rest.ClientRuntime.E2E.Tests.ScenarioTests
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license header

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


MockContext _mockContext;
ResourceManagementClient _resourceClient;
//ComputeManagementClient _computeClient;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

bool created = false;
while (!created)
{
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

});
}
}
catch
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why catch the exception to throw it? Just let the exception bubble up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should catch exceptions, exceptions should cause the test to fail, right?

Copy link
Copy Markdown
Contributor Author

@shahabhijeet shahabhijeet Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license header

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@shahabhijeet
Copy link
Copy Markdown
Contributor Author

@azuresdkci retest this please

@markcowl markcowl merged commit 7303669 into Azure:AutoRest Mar 20, 2017
@shahabhijeet shahabhijeet deleted the VmPutBugTest branch September 4, 2017 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants