-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Adding data factory CRUD scenario test #3774
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
50 changes: 50 additions & 0 deletions
50
src/SDKs/DataFactory/DataFactory.Tests/ScenarioTests/DataFactoryScenarioTests.cs
This file contains 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,50 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for | ||
// license information. | ||
|
||
using DataFactory.Tests.Utils; | ||
using Microsoft.Azure.Management.DataFactory; | ||
using Microsoft.Azure.Management.DataFactory.Models; | ||
using Microsoft.Rest.Azure; | ||
using System; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace DataFactory.Tests.ScenarioTests | ||
{ | ||
public class DataFactoryScenarioTests : ScenarioTestBase<DataFactoryScenarioTests> | ||
{ | ||
[Fact] | ||
[Trait(TraitName.TestType, TestType.Scenario)] | ||
public void DataFactoryCrud() | ||
{ | ||
var expectedFactory = new Factory(location: FactoryLocation); | ||
|
||
Action<DataFactoryManagementClient> action = (client) => | ||
{ | ||
Factory createResponse = client.Factories.CreateOrUpdate(ResourceGroupName, DataFactoryName, expectedFactory); | ||
this.ValidateFactory(createResponse); | ||
|
||
Factory getResponse = client.Factories.Get(ResourceGroupName, DataFactoryName); | ||
this.ValidateFactory(getResponse); | ||
|
||
IPage<Factory> listByResourceGroupResponse = client.Factories.ListByResourceGroup(ResourceGroupName); | ||
this.ValidateFactory(listByResourceGroupResponse.First()); | ||
}; | ||
|
||
Action<DataFactoryManagementClient> finallyAction = (client) => | ||
{ | ||
client.Factories.Delete(ResourceGroupName, DataFactoryName); | ||
}; | ||
|
||
this.RunTest(action, finallyAction); | ||
} | ||
|
||
private void ValidateFactory(Factory actualFactory) | ||
{ | ||
Assert.Equal(DataFactoryName, actualFactory.Name); | ||
Assert.Equal(FactoryLocation, actualFactory.Location); | ||
Assert.Equal("Succeeded", actualFactory.ProvisioningState); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/SDKs/DataFactory/DataFactory.Tests/ScenarioTests/ScenarioTestBase.cs
This file contains 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,38 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for | ||
// license information. | ||
|
||
using Microsoft.Azure.Management.DataFactory; | ||
using Microsoft.Rest.ClientRuntime.Azure.TestFramework; | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace DataFactory.Tests.ScenarioTests | ||
{ | ||
public abstract class ScenarioTestBase<T> | ||
{ | ||
protected const string ResourceGroupName = "sdktesting"; | ||
protected const string DataFactoryName = "sdktestingfactory"; | ||
protected const string FactoryLocation = "East US 2"; | ||
protected static string ClassName = typeof(T).FullName; | ||
|
||
protected void RunTest(Action<DataFactoryManagementClient> initialAction, Action<DataFactoryManagementClient> finallyAction = null, [CallerMemberName] string methodName = "") | ||
{ | ||
using (MockContext mockContext = MockContext.Start(ClassName, methodName)) | ||
{ | ||
DataFactoryManagementClient client = mockContext.GetServiceClient<DataFactoryManagementClient>(TestEnvironmentFactory.GetTestEnvironment()); | ||
try | ||
{ | ||
initialAction.Invoke(client); | ||
} | ||
finally | ||
{ | ||
if (finallyAction != null) | ||
{ | ||
finallyAction.Invoke(client); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
276 changes: 276 additions & 0 deletions
276
...sionRecords/DataFactory.Tests.ScenarioTests.DataFactoryScenarioTests/DataFactoryCrud.json
This file contains 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,276 @@ | ||
{ | ||
"Entries": [ | ||
{ | ||
"RequestUri": "/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory?api-version=2017-09-01-preview", | ||
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODc2NDA3YmItNWJkMy00NWM0LTljMDctY2Q3NGE5NjRiMmZjL3Jlc291cmNlR3JvdXBzL3Nka3Rlc3RpbmcvcHJvdmlkZXJzL01pY3Jvc29mdC5EYXRhRmFjdG9yeS9mYWN0b3JpZXMvc2RrdGVzdGluZ2ZhY3Rvcnk/YXBpLXZlcnNpb249MjAxNy0wOS0wMS1wcmV2aWV3", | ||
"RequestMethod": "PUT", | ||
"RequestBody": "{\r\n \"location\": \"East US 2\"\r\n}", | ||
"RequestHeaders": { | ||
"Content-Type": [ | ||
"application/json; charset=utf-8" | ||
], | ||
"Content-Length": [ | ||
"31" | ||
], | ||
"x-ms-client-request-id": [ | ||
"ccc12cc7-9c24-457d-8c23-f6f0a67a11d1" | ||
], | ||
"accept-language": [ | ||
"en-US" | ||
], | ||
"User-Agent": [ | ||
"FxVersion/4.6.25211.01", | ||
"Microsoft.Azure.Management.DataFactory.DataFactoryManagementClient/0.2.0.0" | ||
] | ||
}, | ||
"ResponseBody": "{\r\n \"name\": \"sdktestingfactory\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"loggingStorageAccountKey\": \"**********\",\r\n \"createTime\": \"2017-10-11T18:05:17.8196041Z\",\r\n \"version\": \"2017-09-01-preview\"\r\n },\r\n \"id\": \"/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory\",\r\n \"type\": \"Microsoft.DataFactory/factories\",\r\n \"location\": \"East US 2\"\r\n}", | ||
"ResponseHeaders": { | ||
"Content-Type": [ | ||
"application/json; charset=utf-8" | ||
], | ||
"Expires": [ | ||
"-1" | ||
], | ||
"Cache-Control": [ | ||
"no-cache" | ||
], | ||
"Date": [ | ||
"Wed, 11 Oct 2017 18:05:26 GMT" | ||
], | ||
"Pragma": [ | ||
"no-cache" | ||
], | ||
"Transfer-Encoding": [ | ||
"chunked" | ||
], | ||
"Server": [ | ||
"Microsoft-IIS/8.5" | ||
], | ||
"Vary": [ | ||
"Accept-Encoding" | ||
], | ||
"x-ms-request-id": [ | ||
"4aff2f3a-da68-47c8-bf58-09bbd1fb0147" | ||
], | ||
"Strict-Transport-Security": [ | ||
"max-age=31536000; includeSubDomains" | ||
], | ||
"X-Content-Type-Options": [ | ||
"nosniff" | ||
], | ||
"X-Powered-By": [ | ||
"ASP.NET" | ||
], | ||
"x-ms-ratelimit-remaining-subscription-writes": [ | ||
"1134" | ||
], | ||
"x-ms-correlation-request-id": [ | ||
"7a17a3b9-ef1c-4c93-8eae-f398d85a78d2" | ||
], | ||
"x-ms-routing-request-id": [ | ||
"CENTRALUS:20171011T180526Z:7a17a3b9-ef1c-4c93-8eae-f398d85a78d2" | ||
] | ||
}, | ||
"StatusCode": 200 | ||
}, | ||
{ | ||
"RequestUri": "/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory?api-version=2017-09-01-preview", | ||
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODc2NDA3YmItNWJkMy00NWM0LTljMDctY2Q3NGE5NjRiMmZjL3Jlc291cmNlR3JvdXBzL3Nka3Rlc3RpbmcvcHJvdmlkZXJzL01pY3Jvc29mdC5EYXRhRmFjdG9yeS9mYWN0b3JpZXMvc2RrdGVzdGluZ2ZhY3Rvcnk/YXBpLXZlcnNpb249MjAxNy0wOS0wMS1wcmV2aWV3", | ||
"RequestMethod": "GET", | ||
"RequestBody": "", | ||
"RequestHeaders": { | ||
"x-ms-client-request-id": [ | ||
"a61d9ce4-8db6-414e-abf2-56b6d92c48cd" | ||
], | ||
"accept-language": [ | ||
"en-US" | ||
], | ||
"User-Agent": [ | ||
"FxVersion/4.6.25211.01", | ||
"Microsoft.Azure.Management.DataFactory.DataFactoryManagementClient/0.2.0.0" | ||
] | ||
}, | ||
"ResponseBody": "{\r\n \"name\": \"sdktestingfactory\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"loggingStorageAccountKey\": \"**********\",\r\n \"createTime\": \"2017-10-11T18:05:17.8196041Z\",\r\n \"version\": \"2017-09-01-preview\"\r\n },\r\n \"id\": \"/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory\",\r\n \"type\": \"Microsoft.DataFactory/factories\",\r\n \"location\": \"East US 2\"\r\n}", | ||
"ResponseHeaders": { | ||
"Content-Type": [ | ||
"application/json; charset=utf-8" | ||
], | ||
"Expires": [ | ||
"-1" | ||
], | ||
"Cache-Control": [ | ||
"no-cache" | ||
], | ||
"Date": [ | ||
"Wed, 11 Oct 2017 18:05:29 GMT" | ||
], | ||
"Pragma": [ | ||
"no-cache" | ||
], | ||
"Transfer-Encoding": [ | ||
"chunked" | ||
], | ||
"Server": [ | ||
"Microsoft-IIS/8.5" | ||
], | ||
"Vary": [ | ||
"Accept-Encoding" | ||
], | ||
"x-ms-request-id": [ | ||
"2a201819-702c-4230-9f02-6b55725f891a" | ||
], | ||
"Strict-Transport-Security": [ | ||
"max-age=31536000; includeSubDomains" | ||
], | ||
"X-Content-Type-Options": [ | ||
"nosniff" | ||
], | ||
"X-Powered-By": [ | ||
"ASP.NET" | ||
], | ||
"x-ms-ratelimit-remaining-subscription-reads": [ | ||
"14740" | ||
], | ||
"x-ms-correlation-request-id": [ | ||
"6bad86c9-4ceb-4bd8-953f-d4708be7a264" | ||
], | ||
"x-ms-routing-request-id": [ | ||
"CENTRALUS:20171011T180530Z:6bad86c9-4ceb-4bd8-953f-d4708be7a264" | ||
] | ||
}, | ||
"StatusCode": 200 | ||
}, | ||
{ | ||
"RequestUri": "/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories?api-version=2017-09-01-preview", | ||
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODc2NDA3YmItNWJkMy00NWM0LTljMDctY2Q3NGE5NjRiMmZjL3Jlc291cmNlR3JvdXBzL3Nka3Rlc3RpbmcvcHJvdmlkZXJzL01pY3Jvc29mdC5EYXRhRmFjdG9yeS9mYWN0b3JpZXM/YXBpLXZlcnNpb249MjAxNy0wOS0wMS1wcmV2aWV3", | ||
"RequestMethod": "GET", | ||
"RequestBody": "", | ||
"RequestHeaders": { | ||
"x-ms-client-request-id": [ | ||
"12eb2527-80ac-4266-8114-33389f4862f9" | ||
], | ||
"accept-language": [ | ||
"en-US" | ||
], | ||
"User-Agent": [ | ||
"FxVersion/4.6.25211.01", | ||
"Microsoft.Azure.Management.DataFactory.DataFactoryManagementClient/0.2.0.0" | ||
] | ||
}, | ||
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"name\": \"sdktestingfactory\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"loggingStorageAccountKey\": \"**********\",\r\n \"createTime\": \"2017-10-11T18:05:17.8196041Z\",\r\n \"version\": \"2017-09-01-preview\"\r\n },\r\n \"id\": \"/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory\",\r\n \"type\": \"Microsoft.DataFactory/factories\",\r\n \"location\": \"East US 2\"\r\n }\r\n ]\r\n}", | ||
"ResponseHeaders": { | ||
"Content-Type": [ | ||
"application/json; charset=utf-8" | ||
], | ||
"Expires": [ | ||
"-1" | ||
], | ||
"Cache-Control": [ | ||
"no-cache" | ||
], | ||
"Date": [ | ||
"Wed, 11 Oct 2017 18:05:29 GMT" | ||
], | ||
"Pragma": [ | ||
"no-cache" | ||
], | ||
"Transfer-Encoding": [ | ||
"chunked" | ||
], | ||
"Server": [ | ||
"Microsoft-IIS/8.5" | ||
], | ||
"Vary": [ | ||
"Accept-Encoding" | ||
], | ||
"x-ms-request-id": [ | ||
"b2858e9d-e52b-47b2-b3fc-e6b276b2f59e" | ||
], | ||
"Strict-Transport-Security": [ | ||
"max-age=31536000; includeSubDomains" | ||
], | ||
"X-Content-Type-Options": [ | ||
"nosniff" | ||
], | ||
"X-Powered-By": [ | ||
"ASP.NET" | ||
], | ||
"x-ms-ratelimit-remaining-subscription-reads": [ | ||
"14739" | ||
], | ||
"x-ms-correlation-request-id": [ | ||
"f4667a02-1925-4eb4-9a3e-c53bd8bd1f13" | ||
], | ||
"x-ms-routing-request-id": [ | ||
"CENTRALUS:20171011T180530Z:f4667a02-1925-4eb4-9a3e-c53bd8bd1f13" | ||
] | ||
}, | ||
"StatusCode": 200 | ||
}, | ||
{ | ||
"RequestUri": "/subscriptions/876407bb-5bd3-45c4-9c07-cd74a964b2fc/resourceGroups/sdktesting/providers/Microsoft.DataFactory/factories/sdktestingfactory?api-version=2017-09-01-preview", | ||
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvODc2NDA3YmItNWJkMy00NWM0LTljMDctY2Q3NGE5NjRiMmZjL3Jlc291cmNlR3JvdXBzL3Nka3Rlc3RpbmcvcHJvdmlkZXJzL01pY3Jvc29mdC5EYXRhRmFjdG9yeS9mYWN0b3JpZXMvc2RrdGVzdGluZ2ZhY3Rvcnk/YXBpLXZlcnNpb249MjAxNy0wOS0wMS1wcmV2aWV3", | ||
"RequestMethod": "DELETE", | ||
"RequestBody": "", | ||
"RequestHeaders": { | ||
"x-ms-client-request-id": [ | ||
"bf2f6c61-8a27-486a-9439-4124cf50b1c9" | ||
], | ||
"accept-language": [ | ||
"en-US" | ||
], | ||
"User-Agent": [ | ||
"FxVersion/4.6.25211.01", | ||
"Microsoft.Azure.Management.DataFactory.DataFactoryManagementClient/0.2.0.0" | ||
] | ||
}, | ||
"ResponseBody": "", | ||
"ResponseHeaders": { | ||
"Content-Length": [ | ||
"0" | ||
], | ||
"Expires": [ | ||
"-1" | ||
], | ||
"Cache-Control": [ | ||
"no-cache" | ||
], | ||
"Date": [ | ||
"Wed, 11 Oct 2017 18:05:34 GMT" | ||
], | ||
"Pragma": [ | ||
"no-cache" | ||
], | ||
"Server": [ | ||
"Microsoft-IIS/8.5" | ||
], | ||
"x-ms-request-id": [ | ||
"dec4559d-6f11-490f-9b98-70817ec6dc4c" | ||
], | ||
"Strict-Transport-Security": [ | ||
"max-age=31536000; includeSubDomains" | ||
], | ||
"X-Content-Type-Options": [ | ||
"nosniff" | ||
], | ||
"X-Powered-By": [ | ||
"ASP.NET" | ||
], | ||
"x-ms-ratelimit-remaining-subscription-writes": [ | ||
"1131" | ||
], | ||
"x-ms-correlation-request-id": [ | ||
"06d8f20a-0a2e-4ab2-87f5-895545f25e0a" | ||
], | ||
"x-ms-routing-request-id": [ | ||
"CENTRALUS:20171011T180534Z:06d8f20a-0a2e-4ab2-87f5-895545f25e0a" | ||
] | ||
}, | ||
"StatusCode": 200 | ||
} | ||
], | ||
"Names": {}, | ||
"Variables": { | ||
"SubscriptionId": "876407bb-5bd3-45c4-9c07-cd74a964b2fc" | ||
} | ||
} |
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.
@bgold09 just FYI, we have not started using traits in SDK tests yet. All tests are executed as of now. But if you would like to categorize tests, go ahead do it. But please be aware the categories can be different when we introduce categories for the entire repo.
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.
sounds good, we were using these only for organizational purposes within our own test project