Skip to content

Commit 13b1f46

Browse files
authored
Minimal modifications to stress tests for Linux (#3548)
* Minimal modifications to get the stress tests building and running on Linux. * Updated sample config to avoid a dummy password.
1 parent 55cc333 commit 13b1f46

File tree

14 files changed

+139
-147
lines changed

14 files changed

+139
-147
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<!-- Empty to inhibit searching up the directory tree. -->
5+
6+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<PropertyGroup>
5+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
6+
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<!-- <PackageVersion Include="Microsoft.Data.SqlClient" Version="6.0.2" /> -->
11+
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.1.0-preview2.25178.5" />
12+
</ItemGroup>
13+
14+
</Project>

src/Microsoft.Data.SqlClient/tests/StressTests/IMonitorLoader/IMonitorLoader.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<RootNamespace>Monitoring</RootNamespace>
44
<AssemblyName>Monitoring</AssemblyName>
5-
<TargetFrameworks>net9.0;net48</TargetFrameworks>
5+
<TargetFrameworks>net481;net9.0</TargetFrameworks>
66
<LangVersion>latest</LangVersion>
77
</PropertyGroup>
8-
</Project>
8+
</Project>

src/Microsoft.Data.SqlClient/tests/StressTests/Readme.md

Lines changed: 91 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,163 +2,182 @@
22

33
This Stress testing application for `Microsoft.Data.SqlClient` is under progress.
44
This project intends to help finding a certain level of effectiveness under unfavorable conditions, and verifying the mode of failures.
5-
This is a console application with targeting frameworks `.Net Framework 4.8`, `.NET 9.0` under driver's supported operating systems and SQL Servers.
5+
This is a console application with targeting frameworks `.Net Framework 4.8.1`, `.NET 9.0` under driver's supported operating systems and SQL Servers.
66

77
## Purpose of application for developers
88

99
Define fuzz tests for all new features/APIs in the driver and to be run before every GA release.
1010

11-
# Pre-Requisites
11+
## Pre-Requisites
1212

13-
required in StressTest.config:
13+
Required in StressTest.config:
1414

15-
"name": stress testing source configuration name.
16-
"type": only `SqlServer` is acceptable.
17-
"isDefault": If there is a source node with `isDefault=true`, this node is returned.
18-
"dataSource": SQL Server data source name.
19-
"database": targeting database name in the SQL Server.
20-
"user": user Id to connect the server.
21-
"password": paired password with the user.
22-
"supportsWindowsAuthentication": tries to use integrated security in connection string mixed with SQL Server authentication if it set to `true` by applying the randomization.
23-
"isLocal": `true` means database is local.
24-
"disableMultiSubnetFailover": tries to add Multi-subnet Failover fake host entries when it equals `true`,
25-
"disableNamedPipes": `true` means the connections will create just using tcp protocol.
26-
"encrypt": assigns the encrypt property of the connection strings.
15+
|Field|Values|Description|
16+
|-|-|-|
17+
|`name`||Stress testing source configuration name.|
18+
|`type`|`SqlServer`|Only `SqlServer` is acceptable.|
19+
|`isDefault`|`true`, `false`|If there is a source node with `isDefault=true`, this node is returned.|
20+
|`dataSource`||SQL Server data source name.|
21+
|`database`||Targeting database name in the SQL Server.|
22+
|`user`||User Id to connect the server.|
23+
|`password`||Paired password with the user.|
24+
|`supportsWindowsAuthentication`|`true`, `false`|Tries to use integrated security in connection string mixed with SQL Server authentication if it set to `true` by applying the randomization.|
25+
|`isLocal`|`true`, `false`|`true` means database is local.|
26+
|`disableMultiSubnetFailover`|`true`, `false`|Tries to add Multi-subnet Failover fake host entries when it equals `true`.|
27+
|`disableNamedPipes`|`true`, `false`|`true` means the connections will create just using tcp protocol.|
28+
|`encrypt`|`true`, `false`|Assigns the encrypt property of the connection strings.|
2729

28-
# Adding new Tests
29-
- [ToDO]
30+
## Adding new Tests
3031

31-
# Building the application
32+
- [ToDo]
3233

33-
To build the application we need to run the command: 'dotnet build <-f|--framework <FRAMEWORK>> [-c|--configuration <Release|Debug>]'
34-
The path should be pointing to SqlClient.Stress.Runner.csproj file.
34+
## Building the application
35+
36+
To build the application we need to run the command:
3537

3638
```bash
37-
# Default Build Configuration:
39+
dotnet build <-f|--framework <FRAMEWORK>> [-c|--configuration <Release|Debug>]
40+
```
3841

39-
> dotnet build
42+
The path should be pointing to SqlClient.Stress.Runner.csproj file.
43+
44+
```bash
4045
# Builds the application for the Client Os in `Debug` Configuration for `AnyCpu` platform.
4146
# All supported target frameworks, .NET Framework (NetFx) and .NET Core drivers are built by default (as supported by Client OS).
47+
48+
> dotnet build
4249
```
4350

4451
```bash
45-
> dotnet build -f netcoreapp3.1
46-
# Build the application for .Net core 3.1 with `Debug` configuration.
52+
# Build the application for .Net framework 4.8.1 with `Debug` configuration.
4753

48-
> dotnet build -f net48
49-
# Build the application for .Net framework 4.8 with `Debug` configuration.
54+
> dotnet build -f net481
5055
```
5156

5257
```bash
53-
> dotnet build -f net5.0 -c Release
54-
# Build the application for .Net 5.0 with `Release` configuration.
58+
# Build the application for .Net 9.0 with `Release` configuration.
5559

56-
> dotnet build -f net48 -c Release
57-
# Build the application for .Net framework 4.8 with `Release` configuration.
60+
> dotnet build -f net9.0 -c Release
5861
```
5962

6063
```bash
61-
> dotnet clean
6264
# Cleans all build directories
65+
66+
> dotnet clean
6367
```
6468

65-
# Running tests
69+
## Running tests
6670

6771
After building the application, find the built folder with target framework and run the `stresstest.exe` file with required arguments.
6872
Find the result in a log file inside the `logs` folder besides the command prompt.
6973

7074
## Command prompt
7175

72-
```bash
73-
> stresstest.exe [-a <module name>] <arguments>
74-
75-
-a <module name> should specify path to the assembly containing the tests.
76-
```
77-
78-
## Supported arguments
79-
80-
-all Run all tests - best for debugging, not perf measurements.
76+
You must run the stress tests from the root of the Stress Tests project
77+
directory (i.e. the same directory this readme file is in).
8178

82-
-verify Run in functional verification mode. [not implemented]
83-
84-
-duration <n> Duration of the test in seconds. Default value is 1 second.
85-
86-
-threads <n> Number of threads to use. Default value is 16.
87-
88-
-override <name> <value> Override the value of a test property.
89-
90-
-test <name1;name2> Run specific test(s).
79+
```bash
80+
# Linux
81+
$ cd /home/paul/dev/SqlClient/src/Microsoft.Data.SqlClient/tests/StressTests
9182

92-
-debug Print process ID in the beginning and wait for Enter (to give your time to attach the debugger).
83+
# Via dotnet run CLI:
84+
$ dotnet run -no-build -f net9.0 --project SqlClient.Stress.Runner/SqlClient.Stress.Runner.csproj -- -a SqlClient.Stress.Tests
9385

94-
-exceptionThreshold <n> An optional limit on exceptions which will be caught. When reached, test will halt.
86+
# Via dotnet CLI:
87+
$ dotnet SqlClient.Stress.Runner/bin/Debug/net9.0/stresstest.dll -a SqlClient.Stress.Tests
88+
```
9589

96-
-monitorenabled True or False to enable monitoring. Default is false [not implemented]
90+
```powershell
91+
# Windows
92+
> cd \dev\SqlClient\src\Microsoft.Data.SqlClient\tests\StressTests
9793
98-
-randomSeed Enables setting of the random number generator used internally. This serves both the purpose
99-
of helping to improve reproducibility and making it deterministic from Chess's perspective
100-
for a given schedule. Default is 0.
94+
# Via dotnet run CLI:
95+
$ dotnet run -no-build -f net9.0 --project SqlClient.Stress.Runner\SqlClient.Stress.Runner.csproj -- -a SqlClient.Stress.Tests
10196
102-
-filter Run tests whose stress test attributes match the given filter. Filter is not applied if attribute
103-
does not implement ITestAttributeFilter. Example: -filter TestType=Query,Update;IsServerTest=True
97+
# Via executable:
98+
> .\SqlClient.Stress.Runner\bin\Debug\net481\stresstest.exe -a SqlClient.Stress.Tests
99+
```
104100

105-
-printMethodName Print tests' title in console window
101+
## Supported arguments
106102

107-
-deadlockdetection True or False to enable deadlock detection. Default is `false`.
103+
|Argument|Values|Description|
104+
|-|-|-|
105+
|-all||Run all tests - best for debugging, not perf measurements.|
106+
|-verify||Run in functional verification mode. [not implemented]|
107+
|-duration|&lt;n&gt;|Duration of the test in seconds. Default value is 1 second.|
108+
|-threads|&lt;n&gt;|Number of threads to use. Default value is 16.|
109+
|-override|&lt;name&gt; &lt;value&gt;|Override the value of a test property.|
110+
|-test|&lt;name1;name2&gt;|Run specific test(s).|
111+
|-debug||Print process ID in the beginning and wait for Enter (to give your time to attach the debugger).|
112+
|-exceptionThreshold|&lt;n&gt;|An optional limit on exceptions which will be caught. When reached, test will halt.|
113+
|-monitorenabled|true, false|True or False to enable monitoring. Default is false [not implemented]|
114+
|-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.|
115+
|-filter|&lt;filter&gt;|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|
116+
|-printMethodName||Print tests' title in console window|
117+
|-deadlockdetection|true, false|True or False to enable deadlock detection. Default is `false`.|
108118

109119
```bash
110-
> stresstest.exe -a SqlClient.Stress.Tests -all
111120
# Run the application for a built target framework and all discovered tests without debugger attached.
121+
122+
> .\stresstest.exe -a SqlClient.Stress.Tests -all
112123
```
113124

114125
```bash
115-
> stresstest.exe -a SqlClient.Stress.Tests -all -printMethodName
116126
# Run the application for a built target framework and all discovered tests without debugger attached and shows the test methods' names.
127+
128+
> .\stresstest.exe -a SqlClient.Stress.Tests -all -printMethodName
117129
```
118130

119131
```bash
120-
> stresstest.exe -a SqlClient.Stress.Tests -all -debug
121132
# Run the application for a built target framework and all discovered tests and will wait for debugger to be attached.
133+
134+
> .\stresstest.exe -a SqlClient.Stress.Tests -all -debug
122135
```
123136

124137
```bash
125-
> stresstest.exe -a SqlClient.Stress.Tests -test TestExecuteXmlReaderAsyncCancellation
126138
# Run the application for a built target framework and "TestExecuteXmlReaderAsyncCancellation" test without debugger attached.
139+
140+
> .\stresstest.exe -a SqlClient.Stress.Tests -test TestExecuteXmlReaderAsyncCancellation
127141
```
128142

129143
```bash
130-
> stresstest.exe -a SqlClient.Stress.Tests -test TestExecuteXmlReaderAsyncCancellation
131144
# Run the application for a built target framework and "TestExecuteXmlReaderAsyncCancellation" test without debugger attached.
145+
146+
> .\stresstest.exe -a SqlClient.Stress.Tests -test TestExecuteXmlReaderAsyncCancellation
132147
```
133148

134149
```bash
135-
> stresstest.exe -a SqlClient.Stress.Tests -all -duration 10
136150
# Run the application for a built target framework and all discovered tests without debugger attached for 10 seconds.
151+
152+
> .\stresstest.exe -a SqlClient.Stress.Tests -all -duration 10
137153
```
138154

139155
```bash
140-
> stresstest.exe -a SqlClient.Stress.Tests -all -threads 5
141156
# Run the application for a built target framework and all discovered tests without debugger attached with 5 threads.
157+
158+
> .\stresstest.exe -a SqlClient.Stress.Tests -all -threads 5
142159
```
143160

144161
```bash
145-
> stresstest.exe -a SqlClient.Stress.Tests -all -deadlockdetection true
146162
# Run the application for a built target framework and all discovered tests without debugger attached and dead lock detection process.
163+
164+
> .\stresstest.exe -a SqlClient.Stress.Tests -all -deadlockdetection true
147165
```
148166

149167
```bash
150-
> stresstest.exe -a SqlClient.Stress.Tests -all -override Weight 15
151168
# Run the application for a built target framework and all discovered tests without debugger attached with overriding the weight property with value 15.
169+
170+
> .\stresstest.exe -a SqlClient.Stress.Tests -all -override Weight 15
152171
```
153172

154173
```bash
155-
> stresstest.exe -a SqlClient.Stress.Tests -all -randomSeed 5
156174
# Run the application for a built target framework and all discovered tests without debugger attached with injecting random seed of 5.
175+
176+
> .\stresstest.exe -a SqlClient.Stress.Tests -all -randomSeed 5
157177
```
158178

159-
# Further thoughts
179+
## Further thoughts
160180

161181
- Implement the uncompleted arguments.
162-
- Add support `dotnet run` command.
163182
- Add more tests.
164183
- Add support running tests with **System.Data.SqlClient** too.

src/Microsoft.Data.SqlClient/tests/StressTests/SqlClient.Stress.Common/SqlClient.Stress.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net9.0;net48</TargetFrameworks>
4+
<TargetFrameworks>net481;net9.0</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
66
</PropertyGroup>
77

src/Microsoft.Data.SqlClient/tests/StressTests/SqlClient.Stress.Framework/DataStressFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ protected void BuildUserTables(List<TableMetadata> TableMetadataList)
789789
}
790790
else
791791
{
792-
throw de;
792+
throw;
793793
}
794794
}
795795

@@ -808,7 +808,7 @@ protected void BuildUserTables(List<TableMetadata> TableMetadataList)
808808
}
809809
else
810810
{
811-
throw de;
811+
throw;
812812
}
813813
}
814814

src/Microsoft.Data.SqlClient/tests/StressTests/SqlClient.Stress.Framework/DataTestGroup.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,8 @@ protected bool OpenConnection(DataStressConnection conn)
158158
// MultiSubnetFailover=true only works with TCP/IP protocol and will result in exception when using with named pipes.
159159
return false;
160160
}
161-
else
162-
{
163-
throw e;
164-
}
161+
162+
throw;
165163
}
166164
}
167165

src/Microsoft.Data.SqlClient/tests/StressTests/SqlClient.Stress.Framework/SqlClient.Stress.Framework.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
<PropertyGroup>
44
<RootNamespace>Stress.Data</RootNamespace>
5-
<TargetFrameworks>net9.0;net48</TargetFrameworks>
5+
<TargetFrameworks>net481;net9.0</TargetFrameworks>
66
<LangVersion>latest</LangVersion>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.1.0-preview2.25178.5" />
10+
<PackageReference Include="Microsoft.Data.SqlClient" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

src/Microsoft.Data.SqlClient/tests/StressTests/SqlClient.Stress.Framework/StressTest.config

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
<dataStressSettings>
44
<sources>
55
<source
6-
name="LocalSqlServer"
6+
name="My Favourite SQL Server"
77
type="SqlServer"
88
isDefault="true"
9-
dataSource="(local)"
10-
database="stress"
9+
dataSource="127.0.0.1,1433"
10+
database="master"
1111
user="sa"
1212
password=""
13-
supportsWindowsAuthentication="true"
14-
isLocal='true'
15-
disableMultiSubnetFailover = 'true'
16-
disableNamedPipes = 'true'
17-
encrypt ='false'>
13+
supportsWindowsAuthentication="false"
14+
isLocal="false"
15+
disableMultiSubnetFailover = "true"
16+
disableNamedPipes = "true"
17+
encrypt ="false">
1818
</source>
1919
</sources>
2020
</dataStressSettings>

src/Microsoft.Data.SqlClient/tests/StressTests/SqlClient.Stress.Runner/SqlClient.Stress.Runner.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<AssemblyName>stresstest</AssemblyName>
6-
<TargetFrameworks>net9.0;net48</TargetFrameworks>
6+
<TargetFrameworks>net481;net9.0</TargetFrameworks>
77
<LangVersion>latest</LangVersion>
88
</PropertyGroup>
99

0 commit comments

Comments
 (0)