Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .devcontainer/setup-sqlserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"

# Write test config file so the test suite can find the connection string.
CONFIG_DIR="${REPO_ROOT}/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities"
CONFIG_DEFAULT_FILE="${CONFIG_DIR}/config.default.json"
CONFIG_FILE="${CONFIG_DIR}/config.json"
CONFIG_DEFAULT_FILE="${CONFIG_DIR}/config.default.jsonc"
CONFIG_FILE="${CONFIG_DIR}/config.jsonc"
echo "Writing test config to ${CONFIG_FILE} (based on ${CONFIG_DEFAULT_FILE})..."
TCP_CONN_STR="Data Source=tcp:${SQL_HOST},${SQL_PORT};Database=Northwind;User Id=sa;Password=${SA_PASSWORD};Encrypt=false;TrustServerCertificate=true"
# config.default.json contains JS-style comments (// ...) which are not valid JSON.
# config.default.jsonc contains JS-style comments (// ...) which are not valid JSON.
# Strip single-line comments before feeding to jq.
sed 's|//.*||' "${CONFIG_DEFAULT_FILE}" \
| jq --arg cs "${TCP_CONN_STR}" \
Expand Down
10 changes: 5 additions & 5 deletions .github/instructions/testing.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ src/Microsoft.Data.SqlClient/tests/
├── UnitTests/ # Unit tests with minimal dependencies
└── tools/
└── Microsoft.Data.SqlClient.TestUtilities/
├── config.default.json # Template configuration
└── config.json # Local test configuration (git-ignored)
├── config.default.jsonc # Template configuration
└── config.jsonc # Local test configuration (git-ignored)
```

## Test Categories
Expand All @@ -34,14 +34,14 @@ src/Microsoft.Data.SqlClient/tests/

### Manual Tests (`ManualTests/`)
- Full integration tests with SQL Server
- Require `config.json` setup
- Require `config.jsonc` setup
- Test real database operations
- Include Always Encrypted, Entra ID tests

## Test Configuration

### Setting Up `config.json`
Copy `config.default.json` to `config.json` and configure:
### Setting Up `config.jsonc`
Copy `config.default.jsonc` to `config.jsonc` and configure:

```json
Comment thread
benrr101 marked this conversation as resolved.
Comment thread
benrr101 marked this conversation as resolved.
{
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ node_modules/

# Config Json file
**/config.json
**/config.jsonc

# Generated Milestone PR metadata files
.milestone-prs/
Expand Down
22 changes: 10 additions & 12 deletions TESTGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,22 @@ conditional tests are skipped.
## Manual Test Configuration

Edit the source configuration file at `src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/
config.json`. The test utilities project copies that file to the test output directory, where the manual tests load it
config.jsonc`. The test utilities project copies that file to the test output directory, where the manual tests load it
by default.
Comment thread
benrr101 marked this conversation as resolved.
Comment thread
benrr101 marked this conversation as resolved.
Comment thread
benrr101 marked this conversation as resolved.

The template file is:

[src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json](src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json)
[src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.jsonc](src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.jsonc)

`config.json` is git-ignored. If it does not exist, the test utilities project copies `config.default.json` to
`config.json` before compile. You can also create it manually:
`config.jsonc` is git-ignored. If it does not exist, the test utilities project copies `config.default.jsonc` to
`config.jsonc` before compile. You can also create it manually:
Comment thread
benrr101 marked this conversation as resolved.

```bash
cp src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json \
src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.json
cp src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.jsonc \
src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.jsonc
```

Update `config.json` for your environment before running manual tests. The most important values for a basic run are `TCPConnectionString` and `NPConnectionString`.
Update `config.jsonc` for your environment before running manual tests. The most important values for a basic run are `TCPConnectionString` and `NPConnectionString`.

```jsonc
{
Expand All @@ -230,16 +230,16 @@ For SQL Server in a Linux container, WSL, or another host where SQL authenticati
}
```

You can override the config file path with the `MDS_TEST_CONFIG` environment variable:
You can override the config file path with the `TEST_MDS_CONFIG` environment variable:

```bash
MDS_TEST_CONFIG=/path/to/config.json dotnet build -t:TestSqlClientManual -p:TestSet=2
TEST_MDS_CONFIG=/path/to/config.jsonc dotnet build -t:TestSqlClientManual -p:TestSet=2
Comment thread
benrr101 marked this conversation as resolved.
```

On PowerShell:

```powershell
$env:MDS_TEST_CONFIG = "C:\path\to\config.json"
$env:TEST_MDS_CONFIG = "C:\path\to\config.jsonc"
dotnet build -t:TestSqlClientManual -p:TestSet=2
Comment thread
benrr101 marked this conversation as resolved.
```

Expand All @@ -263,15 +263,13 @@ dotnet build -t:TestSqlClientManual -p:TestSet=2
| `SupportsIntegratedSecurity` | Whether the user running tests has integrated-security access to the target SQL Server. | `true` or `false`. |
| `LocalDbAppName` | Optional LocalDB instance name. Empty disables LocalDB testing. | `MSSQLLocalDB` or another local instance. |
| `LocalDbSharedInstanceName` | Optional shared LocalDB instance name. | Used only when testing shared LocalDB. |
| `SupportsFileStream` | Whether FileStream tests are supported by the target. | `true` or `false`. |
| `FileStreamDirectory` | Directory used for FileStream database setup. | Use an escaped absolute path in JSON. |
| `UseManagedSNIOnWindows` | Enables Managed SNI on Windows test coverage. | `true` or `false`. |
| `DNSCachingConnString` | Optional connection string for DNS caching tests. | Used with DNS caching server settings. |
| `DNSCachingServerCR` | Optional DNS caching control-ring server. | Feature-specific tests only. |
| `DNSCachingServerTR` | Optional DNS caching tenant-ring server. | Feature-specific tests only. |
| `IsDNSCachingSupportedCR` | Enables DNS caching control-ring tests. | `true` or `false`. |
| `IsDNSCachingSupportedTR` | Enables DNS caching tenant-ring tests. | `true` or `false`. |
| `IsAzureSynapse` | Marks the target as Azure Synapse. | Some SQL Server-specific tests are skipped when `true`. |
| `EnclaveAzureDatabaseConnString` | Optional Azure SQL database connection string for enclave tests. | Feature-specific tests only. |
| `ManagedIdentitySupported` | Whether managed identity tests should run. | Defaults to `true`. Set `false` if unavailable. |
| `UserManagedIdentityClientId` | Optional client ID for user-assigned managed identity tests. | Feature-specific tests only. |
Expand Down
8 changes: 1 addition & 7 deletions eng/pipelines/common/templates/jobs/ci-run-tests-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ parameters:
# template expansion.
#
# EnclaveEnabled
# IsAzureSynapse
# IsDNSCachingSupportedCR
# IsDNSCachingSupportedTR
# ManagedIdentitySupported
# SupportsFileStream
# SupportsIntegratedSecurity
# TracingEnabled
#
Expand Down Expand Up @@ -236,7 +234,7 @@ jobs:
referenceType: Project

- ${{ if ne(parameters.configProperties, '{}') }}:
- template: /eng/pipelines/common/templates/steps/update-config-file-step.yml@self # update config.json file
- template: /eng/pipelines/common/templates/steps/update-config-file-step.yml@self # update config.jsonc file
parameters:
debug: ${{ parameters.debug }}
saPassword: ${{ parameters.saPassword }}
Expand Down Expand Up @@ -279,8 +277,6 @@ jobs:
AliasName: ${{ parameters.configProperties.AliasName }}
${{ if parameters.configProperties.SupportsIntegratedSecurity }}:
SupportsIntegratedSecurity: ${{ eq(parameters.configProperties.SupportsIntegratedSecurity, 'true') }}
${{ if parameters.configProperties.SupportsFileStream }}:
SupportsFileStream: ${{ eq(parameters.configProperties.SupportsFileStream, 'true') }}
${{ if parameters.configProperties.DNSCachingConnString }}:
DNSCachingConnString: ${{ parameters.configProperties.DNSCachingConnString }}
${{ if parameters.configProperties.DNSCachingServerCR }}:
Expand All @@ -293,8 +289,6 @@ jobs:
IsDNSCachingSupportedCR: ${{ eq(parameters.configProperties.IsDNSCachingSupportedCR, 'true') }}
${{ if parameters.configProperties.IsDNSCachingSupportedTR }}:
IsDNSCachingSupportedTR: ${{ eq(parameters.configProperties.IsDNSCachingSupportedTR, 'true') }}
${{ if parameters.configProperties.IsAzureSynapse }}:
IsAzureSynapse: ${{ eq(parameters.configProperties.IsAzureSynapse, 'true') }}
${{ if parameters.configProperties.ManagedIdentitySupported }}:
ManagedIdentitySupported: ${{ eq(parameters.configProperties.ManagedIdentitySupported, 'true') }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ parameters:
type: boolean
default: false

- name: SupportsFileStream
type: boolean
default: false

- name: DNSCachingConnString
type: string
default: ''
Expand All @@ -121,10 +117,6 @@ parameters:
type: boolean
default: false

- name: IsAzureSynapse
type: boolean
default: false

- name: ManagedIdentitySupported
type: boolean
default: true
Expand All @@ -151,9 +143,9 @@ steps:
Write-Host "##vso[task.setvariable variable=Password;isSecret=true]$password"
displayName: Set Connection String Password

# All properties should be added here, and this template should be used for any manipulation of the config.json file.
# All properties should be added here, and this template should be used for any manipulation of the config.jsonc file.
- pwsh: |
$jdata = Get-Content -Raw "config.default.json" | ConvertFrom-Json
$jdata = Get-Content -Raw "config.default.jsonc" | ConvertFrom-Json
Comment thread
benrr101 marked this conversation as resolved.
Comment thread
benrr101 marked this conversation as resolved.
Comment thread
benrr101 marked this conversation as resolved.
foreach ($p in $jdata)
{
$p.TCPConnectionString="${{parameters.TCPConnectionString }}"
Expand Down Expand Up @@ -188,8 +180,6 @@ steps:

$p.DNSCachingConnString="${{parameters.DNSCachingConnString }}"

$p.SupportsFileStream="${{parameters.SupportsFileStream }}"

$p.LocalDbAppName="${{parameters.LocalDbAppName }}"

$p.TCPConnectionStringAASSGX="${{parameters.TCPConnectionStringAASSGX }}"
Expand All @@ -201,20 +191,19 @@ steps:
$p.UseManagedSNIOnWindows=[System.Convert]::ToBoolean("${{parameters.UseManagedSNIOnWindows }}")
$p.SupportsIntegratedSecurity=[System.Convert]::ToBoolean("${{parameters.SupportsIntegratedSecurity }}")
$p.ManagedIdentitySupported=[System.Convert]::ToBoolean("${{parameters.ManagedIdentitySupported }}")
$p.IsAzureSynapse=[System.Convert]::ToBoolean("${{parameters.IsAzureSynapse }}")
$p.IsDNSCachingSupportedTR=[System.Convert]::ToBoolean("${{parameters.IsDNSCachingSupportedTR }}")
$p.IsDNSCachingSupportedCR=[System.Convert]::ToBoolean("${{parameters.IsDNSCachingSupportedCR }}")
$p.TracingEnabled=[System.Convert]::ToBoolean("${{parameters.TracingEnabled }}")
$p.EnclaveEnabled=[System.Convert]::ToBoolean("${{parameters.EnclaveEnabled }}")
$p.WorkloadIdentityFederationServiceConnectionId="${{parameters.WorkloadIdentityFederationServiceConnectionId }}"
}
$jdata | ConvertTo-Json | Set-Content "config.json"
$jdata | ConvertTo-Json | Set-Content "config.jsonc"
workingDirectory: src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities
displayName: 'Update config.json'
displayName: 'Update config.jsonc'

- ${{ if eq(parameters.debug, true) }}:
- pwsh: |
$jdata = Get-Content -Raw "config.json" | ConvertFrom-Json
$jdata = Get-Content -Raw "config.jsonc" | ConvertFrom-Json
foreach ($p in $jdata)
{
foreach ($prop in $p.PSObject.Properties)
Expand All @@ -223,4 +212,4 @@ steps:
}
}
workingDirectory: src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities
displayName: '[Debug] Emit config.json'
displayName: '[Debug] Emit config.jsonc'
2 changes: 1 addition & 1 deletion eng/pipelines/dotnet-sqlclient-ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ stages:
useManagedSNI: ${{parameters.useManagedSNI }}
configSqlFor: local
operatingSystem: Windows
# config.json properties
# config.jsonc properties
Comment thread
benrr101 marked this conversation as resolved.
configProperties:
TCPConnectionString: $(SQL_TCP_CONN_STRING)
NPConnectionString: $(SQL_NP_CONN_STRING)
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/jobs/test-azure-package-ci-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ jobs:
debug: ${{ parameters.debug }}
saPassword: ${{ parameters.saPassword }}

# The config.json file has many options, but only some of them are
# The config.jsonc file has many options, but only some of them are
# used by the Azure package tests. We only specify the ones that are
# necessary here.

Expand Down
12 changes: 6 additions & 6 deletions eng/pipelines/kerberos/sqlclient-kerberos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ stages:
# requires compile-time parameters.
- pwsh: |
$managedSni = [System.Convert]::ToBoolean($env:MANAGED_SNI)
$jdata = Get-Content -Raw "config.default.json" | ConvertFrom-Json
$jdata = Get-Content -Raw "config.default.jsonc" | ConvertFrom-Json
Comment thread
benrr101 marked this conversation as resolved.
foreach ($p in $jdata) {
$p.TCPConnectionString = $env:REMOTE_TCP_CONN_STRING
$p.NPConnectionString = $env:REMOTE_NP_CONN_STRING
$p.SupportsIntegratedSecurity = $true
$p.UseManagedSNIOnWindows = $managedSni
}
$jdata | ConvertTo-Json | Set-Content "config.json"
$jdata | ConvertTo-Json | Set-Content "config.jsonc"
Comment thread
benrr101 marked this conversation as resolved.
Comment thread
benrr101 marked this conversation as resolved.
workingDirectory: src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities
displayName: Update test config.json
displayName: Update test config.jsonc
env:
REMOTE_TCP_CONN_STRING: $(REMOTE_TCP_CONN_STRING)
REMOTE_NP_CONN_STRING: $(REMOTE_NP_CONN_STRING)
Expand Down Expand Up @@ -234,17 +234,17 @@ stages:

# --- Update test configuration (with Kerberos credentials) ---
- pwsh: |
$jdata = Get-Content -Raw "config.default.json" | ConvertFrom-Json
$jdata = Get-Content -Raw "config.default.jsonc" | ConvertFrom-Json
Comment thread
benrr101 marked this conversation as resolved.
foreach ($p in $jdata) {
$p.TCPConnectionString = $env:REMOTE_TCP_CONN_STRING
$p.NPConnectionString = $env:REMOTE_NP_CONN_STRING
$p.SupportsIntegratedSecurity = $true
}
$jdata | Add-Member -NotePropertyName "KerberosDomainUser" -NotePropertyValue $env:KERBEROS_DOMAIN_USER -Force
$jdata | Add-Member -NotePropertyName "KerberosDomainPassword" -NotePropertyValue $env:KERBEROS_DOMAIN_PASSWORD -Force
$jdata | ConvertTo-Json | Set-Content "config.json"
$jdata | ConvertTo-Json | Set-Content "config.jsonc"
workingDirectory: src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities
displayName: Update test config.json (Kerberos)
displayName: Update test config.jsonc (Kerberos)
env:
REMOTE_TCP_CONN_STRING: $(REMOTE_TCP_CONN_STRING)
REMOTE_NP_CONN_STRING: $(REMOTE_NP_CONN_STRING)
Expand Down
6 changes: 3 additions & 3 deletions eng/pipelines/stress/stress-tests-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
"@

# Write the JSON content to the config file.
$content | Out-File -FilePath "config.json"
$content | Out-File -FilePath "config.jsonc"

# Authenticate with NuGet feeds so that upstream packages (e.g. runtime host packs) can be
# fetched through the ADO Artifacts feed. This is required on hosted pool agents (macOS)
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
inputs:
command: run
projects: $(project)
arguments: $(runArguments) --no-build -f ${{ runtime }} -e STRESS_CONFIG_FILE=config.json -- $(testArguments)
arguments: $(runArguments) --no-build -f ${{ runtime }} -e STRESS_CONFIG_FILE=config.jsonc -- $(testArguments)

# Run the stress tests for each .NET Framework runtime.
- ${{ each runtime in parameters.netFrameworkTestRuntimes }}:
Expand All @@ -219,4 +219,4 @@ jobs:
inputs:
command: run
projects: $(project)
arguments: $(runArguments) --no-build -f ${{ runtime }} -e STRESS_CONFIG_FILE=config.json -- $(testArguments)
arguments: $(runArguments) --no-build -f ${{ runtime }} -e STRESS_CONFIG_FILE=config.jsonc -- $(testArguments)
Loading
Loading