-
Notifications
You must be signed in to change notification settings - Fork 321
Re-home stress test projects #3546
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
Merged
Merged
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions
31
src/Microsoft.Data.SqlClient/tests/StressTests/IMonitorLoader/IMonitorLoader.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System.Collections.Generic; | ||
|
|
||
| namespace Monitoring | ||
| { | ||
| public interface IMonitorLoader | ||
| { | ||
| string HostMachine { get; set; } | ||
| string AssemblyPath { get; set; } | ||
| string TestName { get; set; } | ||
| bool Enabled { get; set; } | ||
|
|
||
| void Action(MonitorLoaderUtils.MonitorAction monitoraction); | ||
| void AddPerfData(MonitorMetrics data); | ||
| Dictionary<string, MonitorMetrics> GetPerfData(); | ||
| } | ||
|
|
||
| public class MonitorLoaderUtils | ||
| { | ||
| public enum MonitorAction | ||
| { | ||
| Initialize, | ||
| Start, | ||
| Stop, | ||
| DoNothing | ||
| } | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/Microsoft.Data.SqlClient/tests/StressTests/IMonitorLoader/IMonitorLoader.csproj
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <RootNamespace>Monitoring</RootNamespace> | ||
| <AssemblyName>Monitoring</AssemblyName> | ||
| <TargetFrameworks>net9.0;net48</TargetFrameworks> | ||
| <LangVersion>latest</LangVersion> | ||
| </PropertyGroup> | ||
| </Project> |
96 changes: 96 additions & 0 deletions
96
src/Microsoft.Data.SqlClient/tests/StressTests/IMonitorLoader/MonitorMetrics.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
|
|
||
| namespace Monitoring | ||
| { | ||
| public class MonitorMetrics | ||
| { | ||
| private string _name; | ||
| private string _strValue; | ||
| private string _unit; | ||
| private bool _isPrimary; | ||
| private bool _isHigherBetter; | ||
| private double _dblValue; | ||
| private long _lngValue; | ||
| private char _valueType; // D=double, L=long, S=String | ||
|
|
||
| public MonitorMetrics(string name, string value, string unit, bool HigherIsBetter, bool Primary) | ||
| { | ||
| _name = name; | ||
| _strValue = value; | ||
| _unit = unit; | ||
| _valueType = 'S'; | ||
| _isHigherBetter = HigherIsBetter; | ||
| _isPrimary = Primary; | ||
| } | ||
|
|
||
| public MonitorMetrics(string name, double value, string unit, bool HigherIsBetter, bool Primary) | ||
| { | ||
| _name = name; | ||
| _dblValue = value; | ||
| _unit = unit; | ||
| _valueType = 'D'; | ||
| _isHigherBetter = HigherIsBetter; | ||
| _isPrimary = Primary; | ||
| } | ||
|
|
||
| public MonitorMetrics(string name, long value, string unit, bool HigherIsBetter, bool Primary) | ||
| { | ||
| _name = name; | ||
| _lngValue = value; | ||
| _unit = unit; | ||
| _valueType = 'L'; | ||
| _isHigherBetter = HigherIsBetter; | ||
| _isPrimary = Primary; | ||
| } | ||
|
|
||
| public string GetName() | ||
| { | ||
| return _name; | ||
| } | ||
|
|
||
| public string GetUnit() | ||
| { | ||
| return _unit; | ||
| } | ||
|
|
||
| public bool GetPrimary() | ||
| { | ||
| return _isPrimary; | ||
| } | ||
|
|
||
| public bool GetHigherIsBetter() | ||
| { | ||
| return _isHigherBetter; | ||
| } | ||
|
|
||
| public char GetValueType() | ||
| { | ||
| return _valueType; | ||
| } | ||
|
|
||
| public string GetStringValue() | ||
| { | ||
| if (_valueType == 'S') | ||
| return _strValue; | ||
| throw new Exception("Value is not a string"); | ||
| } | ||
|
|
||
| public double GetDoubleValue() | ||
| { | ||
| if (_valueType == 'D') | ||
| return _dblValue; | ||
| throw new Exception("Value is not a double"); | ||
| } | ||
|
|
||
| public long GetLongValue() | ||
| { | ||
| if (_valueType == 'L') | ||
| return _lngValue; | ||
| throw new Exception("Value is not a long"); | ||
| } | ||
| } | ||
| } |
164 changes: 164 additions & 0 deletions
164
src/Microsoft.Data.SqlClient/tests/StressTests/Readme.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| # Microsoft.Data.SqlClient Stress Test | ||
|
|
||
| This Stress testing application for `Microsoft.Data.SqlClient` is under progress. | ||
| This project intends to help finding a certain level of effectiveness under unfavorable conditions, and verifying the mode of failures. | ||
| This is a console application with targeting frameworks `.Net Framework 4.8`, `.NET 9.0` under driver's supported operating systems and SQL Servers. | ||
|
|
||
| ## Purpose of application for developers | ||
|
|
||
| Define fuzz tests for all new features/APIs in the driver and to be run before every GA release. | ||
|
|
||
| # Pre-Requisites | ||
|
|
||
| required in StressTest.config: | ||
|
|
||
| "name": stress testing source configuration name. | ||
| "type": only `SqlServer` is acceptable. | ||
| "isDefault": If there is a source node with `isDefault=true`, this node is returned. | ||
| "dataSource": SQL Server data source name. | ||
| "database": targeting database name in the SQL Server. | ||
| "user": user Id to connect the server. | ||
| "password": paired password with the user. | ||
| "supportsWindowsAuthentication": tries to use integrated security in connection string mixed with SQL Server authentication if it set to `true` by applying the randomization. | ||
| "isLocal": `true` means database is local. | ||
| "disableMultiSubnetFailover": tries to add Multi-subnet Failover fake host entries when it equals `true`, | ||
| "disableNamedPipes": `true` means the connections will create just using tcp protocol. | ||
| "encrypt": assigns the encrypt property of the connection strings. | ||
|
|
||
| # Adding new Tests | ||
| - [ToDO] | ||
|
|
||
| # Building the application | ||
|
|
||
| To build the application we need to run the command: 'dotnet build <-f|--framework <FRAMEWORK>> [-c|--configuration <Release|Debug>]' | ||
| The path should be pointing to SqlClient.Stress.Runner.csproj file. | ||
|
|
||
| ```bash | ||
| # Default Build Configuration: | ||
|
|
||
| > dotnet build | ||
| # Builds the application for the Client Os in `Debug` Configuration for `AnyCpu` platform. | ||
| # All supported target frameworks, .NET Framework (NetFx) and .NET Core drivers are built by default (as supported by Client OS). | ||
| ``` | ||
|
|
||
| ```bash | ||
| > dotnet build -f netcoreapp3.1 | ||
| # Build the application for .Net core 3.1 with `Debug` configuration. | ||
|
|
||
| > dotnet build -f net48 | ||
| # Build the application for .Net framework 4.8 with `Debug` configuration. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > dotnet build -f net5.0 -c Release | ||
| # Build the application for .Net 5.0 with `Release` configuration. | ||
|
|
||
| > dotnet build -f net48 -c Release | ||
| # Build the application for .Net framework 4.8 with `Release` configuration. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > dotnet clean | ||
| # Cleans all build directories | ||
| ``` | ||
|
|
||
| # Running tests | ||
|
|
||
| After building the application, find the built folder with target framework and run the `stresstest.exe` file with required arguments. | ||
| Find the result in a log file inside the `logs` folder besides the command prompt. | ||
|
|
||
| ## Command prompt | ||
|
|
||
| ```bash | ||
| > stresstest.exe [-a <module name>] <arguments> | ||
|
|
||
| -a <module name> should specify path to the assembly containing the tests. | ||
| ``` | ||
|
|
||
| ## Supported arguments | ||
|
|
||
| -all Run all tests - best for debugging, not perf measurements. | ||
|
|
||
| -verify Run in functional verification mode. [not implemented] | ||
|
|
||
| -duration <n> Duration of the test in seconds. Default value is 1 second. | ||
|
|
||
| -threads <n> Number of threads to use. Default value is 16. | ||
|
|
||
| -override <name> <value> Override the value of a test property. | ||
|
|
||
| -test <name1;name2> Run specific test(s). | ||
|
|
||
| -debug Print process ID in the beginning and wait for Enter (to give your time to attach the debugger). | ||
|
|
||
| -exceptionThreshold <n> An optional limit on exceptions which will be caught. When reached, test will halt. | ||
|
|
||
| -monitorenabled True or False to enable monitoring. Default is false [not implemented] | ||
|
|
||
| -randomSeed Enables setting of the random number generator used internally. This serves both the purpose | ||
| of helping to improve reproducibility and making it deterministic from Chess's perspective | ||
| for a given schedule. Default is 0. | ||
|
|
||
| -filter Run tests whose stress test attributes match the given filter. Filter is not applied if attribute | ||
| does not implement ITestAttributeFilter. Example: -filter TestType=Query,Update;IsServerTest=True | ||
|
|
||
| -printMethodName Print tests' title in console window | ||
|
|
||
| -deadlockdetection True or False to enable deadlock detection. Default is `false`. | ||
|
|
||
| ```bash | ||
| > stresstest.exe -a SqlClient.Stress.Tests -all | ||
| # Run the application for a built target framework and all discovered tests without debugger attached. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > stresstest.exe -a SqlClient.Stress.Tests -all -printMethodName | ||
| # Run the application for a built target framework and all discovered tests without debugger attached and shows the test methods' names. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > stresstest.exe -a SqlClient.Stress.Tests -all -debug | ||
| # Run the application for a built target framework and all discovered tests and will wait for debugger to be attached. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > stresstest.exe -a SqlClient.Stress.Tests -test TestExecuteXmlReaderAsyncCancellation | ||
| # Run the application for a built target framework and "TestExecuteXmlReaderAsyncCancellation" test without debugger attached. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > stresstest.exe -a SqlClient.Stress.Tests -test TestExecuteXmlReaderAsyncCancellation | ||
| # Run the application for a built target framework and "TestExecuteXmlReaderAsyncCancellation" test without debugger attached. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > stresstest.exe -a SqlClient.Stress.Tests -all -duration 10 | ||
| # Run the application for a built target framework and all discovered tests without debugger attached for 10 seconds. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > stresstest.exe -a SqlClient.Stress.Tests -all -threads 5 | ||
| # Run the application for a built target framework and all discovered tests without debugger attached with 5 threads. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > stresstest.exe -a SqlClient.Stress.Tests -all -deadlockdetection true | ||
| # Run the application for a built target framework and all discovered tests without debugger attached and dead lock detection process. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > stresstest.exe -a SqlClient.Stress.Tests -all -override Weight 15 | ||
| # Run the application for a built target framework and all discovered tests without debugger attached with overriding the weight property with value 15. | ||
| ``` | ||
|
|
||
| ```bash | ||
| > stresstest.exe -a SqlClient.Stress.Tests -all -randomSeed 5 | ||
| # Run the application for a built target framework and all discovered tests without debugger attached with injecting random seed of 5. | ||
| ``` | ||
|
|
||
| # Further thoughts | ||
|
|
||
| - Implement the uncompleted arguments. | ||
| - Add support `dotnet run` command. | ||
| - Add more tests. | ||
| - Add support running tests with **System.Data.SqlClient** too. | ||
16 changes: 16 additions & 0 deletions
16
...t/tests/StressTests/SqlClient.Stress.Common/Attributes/GlobalExceptionHandlerAttribute.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
|
|
||
| namespace DPStressHarness | ||
| { | ||
| [AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)] | ||
| public class GlobalExceptionHandlerAttribute : Attribute | ||
| { | ||
| public GlobalExceptionHandlerAttribute() | ||
| { | ||
| } | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
...Client/tests/StressTests/SqlClient.Stress.Common/Attributes/GlobalTestCleanupAttribute.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
|
|
||
| namespace DPStressHarness | ||
| { | ||
| [AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)] | ||
| public class GlobalTestCleanupAttribute : Attribute | ||
| { | ||
| public GlobalTestCleanupAttribute() | ||
| { | ||
| } | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
...qlClient/tests/StressTests/SqlClient.Stress.Common/Attributes/GlobalTestSetupAttribute.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
|
|
||
| namespace DPStressHarness | ||
| { | ||
| [AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)] | ||
| public class GlobalTestSetupAttribute : Attribute | ||
| { | ||
| public GlobalTestSetupAttribute() | ||
| { | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
This heading and description can be removed.