Tests | Introduce RAII SQL object primitives#4050
Open
edwardneal wants to merge 9 commits intodotnet:mainfrom
Open
Tests | Introduce RAII SQL object primitives#4050edwardneal wants to merge 9 commits intodotnet:mainfrom
edwardneal wants to merge 9 commits intodotnet:mainfrom
Conversation
This contains GenerateLongName and GenerateShortName, which are lifted from DataTestUtility.GetLongName and GetShortName in ManualTests.
This eliminates DropUserDefinedType from DataTestUtility.
Contributor
|
What does RAII mean exactly? |
Contributor
Author
|
Resource Acquisition Is Initialization - so we create SQL objects when a |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This change is designed to make sure that the manual tests clean up after themselves and to introduce some consistency.
Many of the manual tests need to create objects - usually tables, stored procedures and UDTs. There are a handful of ways to do this. Some of the AlwaysEncrypted tests have a set of objects describing tables, column encryption keys, etc. The
DataTestUtilityclass hasCreateSP,DropSPand similar methods. Some tests have their own helper methods and others manually construct DDL statements. These are also used in various combinations, and most of the time the logic to delete these temporary objects is located in afinallyblock.Separately, the objects are created in different scopes - sometimes they're passed as fixtures to the test class, sometimes they're created by the constructor of a test class which implements
IDisposablebut most of the time they're created by each test.Lastly, the naming of these is sometimes odd. Sometimes the tests request a random object name, other times they'll use existing helper methods in
DataTestUtility, and other times still they'll attempt to use their own logic to generate a unique name.I'd like to simplify this with a consistent set of RAII-style types which represent database objects, returning its name post-hoc.
This PR starts the process by introducing types for a table, a UDT or an SP. It then applies these to a handful of tests (ApiShould, JsonStreamTest, JsonTest, SqlGraphTable, ParametersTest) to prove that they handle the edge cases. In a few cases (the two changed JsonStream tests) we eliminate test bugs which would always leave a JSON-based table behind, or which would leave files behind on the filesystem if an exception was thrown at the wrong time.
I expect it to take a while to migrate to the RAII types, but it should cut down on resource leaks in the Azure databases.
Issues
None.
Testing
Automated tests should continue to pass.