Skip to content

Conversation

@vidai-msft
Copy link
Contributor

@vidai-msft vidai-msft commented Jun 24, 2022

This PR has tremendous number of changes regarding the Test Framework for all the track1 management plane cmdlets. All new test cases will opt for TestRunner as the unified approach.

Description

Work done in this PR.

  • Removed all the files in the project ScenarioTest.ResourceManager and moved the followings to the TestFx
    • TestModelExtensions.cs
    • MockAccessToken.cs
    • MockAccessTokenProviders.cs
    • MockCertificateAuthenticationFactory.cs
    • MockClientFactory.cs
    • MockCommandRuntime.cs
    • MockPowerShellTokenCacheProvider.cs
    • MockTokenAuthenticationFactory.cs
    • Contants.cs
    • EnvironmentHelper.cs
    • PageExtensions.cs
    • PermissiveRecordMatcherWithApiExclusion.cs
    • PermissiveRecordMatcherWithResourceApiExclusion.cs
    • PowerShellExtensions.cs
    • PSCmdletExtensions.cs
    • RMTestBase.cs
    • TestExecutionHelpers.cs
    • XuitTracingInterceptor.cs
    • Assert.ps1
    • AzureRM.Resources.ps1
    • AzureRM.Storage.ps1
    • Common.ps1
  • Moved the following .cs files from Microsoft.Azure.Test.HttpRecorder to TestFx
    • AssetNames.cs
    • FileSystemUtils.cs
    • HttpMockServer.cs
    • HttpRecordMode.cs
    • IRecordMatcher.cs
    • RecordEntry.cs
    • RecordEntryPack.cs
    • RecorderUtilities.cs
    • Record.cs
    • SimpleRecordMatcher.cs
  • Moved the following .cs files from Microsoft.Rest.ClientRuntime.Azure.TestFramework to TestFx
    • TestUtilities.cs
    • ConnectionString.cs
    • ConnectionStringKeys.cs
    • ExtMethods.cs
    • MockContext.cs
    • ResourceGroupCleaner.cs
    • SubscriptionInfo.cs
    • TestEndpoint.cs
    • TestEnvironment.cs
    • TestEnvironmentFactory.cs
    • TokenInfo.cs
  • Refactored code in above files for TestFx internal use only to make them comply with .NET standard coding style and convention.
  • In the ConnectionStringKeys.cs file, renamed from AADTenantKey to TenantIdKey because the original name is ambiguous and the new one is more straightfrorward. Also updated the places where this key was referenced.
  • Removed reference of projects Microsoft.Azure.Test.HttpRecorder and Microsoft.Rest.ClientRuntime.Azure.TestFramework in Azure SDK from Common.Netcore.Dependencies.Test.targets
  • Added custom assembly attribute TestProjectPath in Az.Test.props
  • Made following assembly attributes auto-generated as false in Az.Shared.props
    • CompanyAttribute
    • ConfigurationAttribute
    • FileVersionAttribute
    • InformationalVersionAttribute
    • ProductAttribute
    • TitleAttribute
    • VersionAttribute
  • Migrated following test projects from TestController to TestRunner
    • Accounts
    • Batch
    • Billing
    • DataLakeStore
    • DevTestLabs
    • HPCCache
    • MachineLearning
    • RecoveryServices
    • Resources
    • Sql
  • In the Resources.Test project, renamed the TestRunner from ResourceTestRunner to ResourcesTestRunner to unify the naming convention of the TestRunner, which is {{TestProjectName}}TestRunner. Also updated the subclasses where the this parent was inherited.
  • Made minor adjustment to adapt the new API in TestFx for following test projects
    • Aks
    • AnalysisService
    • ApiManagement
    • StorageSync
  • Optimized a bit of the following test projects to remove unnecessary method invocation
    • Network
    • Synapse

Checklist

  • I have read the Submitting Changes section of CONTRIBUTING.md
  • The title of the PR is clear and informative
  • The appropriate ChangeLog.md file(s) has been updated:
    • For any service, the ChangeLog.md file can be found at src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
    • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header -- no new version header should be added
  • The PR does not introduce breaking changes
  • If applicable, the changes made in the PR have proper test coverage
  • For public API changes to cmdlets:
    • a cmdlet design review was approved for the changes in this repository (Microsoft internal only)
      • {Please put the link here}
    • the markdown help files have been regenerated using the commands listed here

Copy link
Member

Choose a reason for hiding this comment

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

Shall it be changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AADTenantKey is ambiguous while TenantIdKey is more straightforward. It only involved a few changes. Recommend updating the value.

Copy link
Member

Choose a reason for hiding this comment

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

I recommend that your don't need to rename it even it doesn't follow convention. It can reduce the size of your pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently the naming convention for the TestRunner file is {Test-Project-Name} + TestRunner. We have almost all the test projects that comply with this standard except for this one. In order to make all the test runner names consistent within the whole repo, I strongly believe this change is necessary. I concede it would reduce the size of this PR. But since it is necessary, better we can keep the class name as it is.

Copy link
Member

Choose a reason for hiding this comment

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

Similarly, it is not required. Please check.

Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to add method RunPowerShellTest in super class SqlTestRunner. Then you don't need to change below each line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrap the TestRunner.RunTestScript with the RunPowerShellTest method is not that good because it is just a wrapper without any other function like concealing the real API. If some of the test cases need to pass in additional parameters later on, the wrapper won't work. In addition, adding a wrapper cannot reduce the size of the PR as all these classes must inherit from SqlTestRunner. This is a required change.

dingmeng-xue
dingmeng-xue previously approved these changes Jul 19, 2022
@dingmeng-xue dingmeng-xue merged commit 90c1b81 into Azure:main Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants