Skip to content

Commit b242b89

Browse files
authored
Allow sni version override for testing (#3184)
1 parent 91f238c commit b242b89

File tree

4 files changed

+164
-9
lines changed

4 files changed

+164
-9
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#################################################################################
2+
# Licensed to the .NET Foundation under one or more agreements. #
3+
# The .NET Foundation licenses this file to you under the MIT license. #
4+
# See the LICENSE file in the project root for more information. #
5+
#################################################################################
6+
7+
parameters:
8+
- name: SNIVersion
9+
type: string
10+
11+
- name: SNIValidationFeed
12+
type: string
13+
14+
steps:
15+
- task: PowerShell@2
16+
displayName: Add SNI Validation Feed in Nuget.config
17+
inputs:
18+
targetType: inline
19+
script: |
20+
Write-Host "SNI validation feed to use = ${{parameters.SNIValidationFeed}}"
21+
22+
# define file to update
23+
$NugetCfg = Join-Path -Path '.' -ChildPath 'NuGet.config'
24+
type $NugetCfg
25+
26+
# load content of xml from file defined above
27+
$xml = New-Object XML
28+
$xml.Load($NugetCfg)
29+
30+
# define namespace used to read a node
31+
$nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable)
32+
$nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI)
33+
34+
# get the package sources node
35+
$packageSources = $xml.SelectSingleNode('//ns:packageSources', $nsm)
36+
37+
# define new package source
38+
$newSource = $xml.CreateElement("add")
39+
$newSource.SetAttribute("key","SNIValidation")
40+
$newSource.SetAttribute("value","${{parameters.SNIValidationFeed}}")
41+
42+
# add the new package source
43+
$packageSources.AppendChild($newSource)
44+
45+
# save the xml file
46+
$xml.Save($NugetCfg)
47+
type $NugetCfg
48+
- task: PowerShell@2
49+
displayName: Update SNI Version in Versions.props
50+
inputs:
51+
targetType: inline
52+
script: |
53+
Write-Host "SNI Version to test = ${{parameters.SNIVersion}}"
54+
55+
# define file to update
56+
$PropsPath = Join-Path -Path '.' -ChildPath 'tools\props\Versions.props'
57+
type $PropsPath
58+
59+
# load content of xml from file defined above
60+
$xml = New-Object XML
61+
$xml.Load($PropsPath)
62+
63+
# define namespace used to read a node
64+
$nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable)
65+
$nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI)
66+
67+
# update the node inner text for netfx
68+
$netFxSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSniVersion', $nsm)
69+
Write-Host "Current .NET Framework SNI Version = $($netFxSniVersion.InnerText)"
70+
$netFxSniVersion.InnerText = "${{parameters.SNIVersion}}"
71+
72+
# update the node inner text for net core
73+
$netCoreSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSNIRuntimeVersion', $nsm)
74+
Write-Host "Current .NET Core SNI Version = $($netCoreSniVersion.InnerText)"
75+
$netCoreSniVersion.InnerText = "${{parameters.SNIVersion}}"
76+
77+
# save the xml file
78+
$xml.Save($PropsPath)
79+
type $PropsPath
80+
- task: NuGetAuthenticate@1
81+
displayName: 'NuGet Authenticate with SNI Validation Feed'

eng/pipelines/dotnet-sqlclient-ci-core.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ parameters:
4141
type: object
4242
default: [false, true]
4343

44+
- name: SNIVersion
45+
displayName: |
46+
SNI Version Override
47+
type: string
48+
default: ''
49+
50+
- name: SNIValidationFeed
51+
displayName: |
52+
SNI Version Override Nuget Feed
53+
type: string
54+
default: https://sqlclientdrivers.pkgs.visualstudio.com/ADO.Net/_packaging/SNIValidation/nuget/v3/index.json
55+
4456
- name: codeCovTargetFrameworks
4557
displayName: 'Code Coverage Target Frameworks'
4658
type: object
@@ -73,6 +85,12 @@ stages:
7385
- template: common/templates/jobs/ci-build-nugets-job.yml@self
7486
parameters:
7587
artifactName: $(artifactName)
88+
${{if ne(parameters.SNIVersion, '')}}:
89+
prebuildSteps:
90+
- template: common/templates/steps/override-sni-version.yml@self
91+
parameters:
92+
SNIVersion: ${{parameters.SNIVersion}}
93+
SNIValidationFeed: ${{parameters.SNIValidationFeed}}
7694

7795
- template: common/templates/stages/ci-run-tests-stage.yml@self
7896
parameters:
@@ -81,12 +99,24 @@ stages:
8199
${{ if eq(parameters.buildType, 'Package') }}:
82100
dependsOn: build_nugets
83101

84-
prebuildSteps: # steps to run prior to building and running tests on each job
85-
- template: common/templates/steps/ci-prebuild-step.yml@self
86-
parameters:
87-
debug: ${{ parameters.debug }}
88-
artifactName: $(artifactName)
89-
buildType: ${{ parameters.buildType }}
102+
${{if ne(parameters.SNIVersion, '')}}:
103+
prebuildSteps: # steps to run prior to building and running tests on each job
104+
- template: common/templates/steps/override-sni-version.yml@self
105+
parameters:
106+
SNIVersion: ${{parameters.SNIVersion}}
107+
SNIValidationFeed: ${{parameters.SNIValidationFeed}}
108+
- template: common/templates/steps/ci-prebuild-step.yml@self
109+
parameters:
110+
debug: ${{ parameters.debug }}
111+
artifactName: $(artifactName)
112+
buildType: ${{ parameters.buildType }}
113+
${{else}}:
114+
prebuildSteps: # steps to run prior to building and running tests on each job
115+
- template: common/templates/steps/ci-prebuild-step.yml@self
116+
parameters:
117+
debug: ${{ parameters.debug }}
118+
artifactName: $(artifactName)
119+
buildType: ${{ parameters.buildType }}
90120

91121
${{ if eq(parameters.buildType, 'Project') }}: # only run the code coverage job if the build type is project
92122
postTestJobs: # jobs to run after the tests are done

override.ps1

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#Purpose: Updates SNI Version
2+
Write-Host "SNI Version to test = 123"
3+
4+
##Get the shared SNI Version from the downloaded artifact
5+
#$SharedSNIVersion = Get-Content -path "$(Pipeline.Workspace)/SharedSNIVersion.txt"
6+
7+
#Get the SNI Version to test from the user entered version.
8+
$SharedSNIVersion = "123"
9+
10+
# define file to update
11+
$PropsPath = 'C:\Users\mdaigle\SqlClient\tools\props\Versions.props'
12+
type $PropsPath
13+
14+
# new version number to update to
15+
##Write-Host "SNI Version to test = $(SNIValidationVersion)"
16+
Write-Host "SNI Version to test = $SharedSNIVersion"
17+
18+
19+
# define an xml object
20+
$xml = New-Object XML
21+
22+
# load content of xml from file defined above
23+
$xml.Load($PropsPath)
24+
25+
# define namespace used to read a node
26+
$nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable)
27+
$nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI)
28+
$netFxSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSniVersion', $nsm)
29+
30+
Write-Host "Node NetFx SNI Version = $($netFxSniVersion.InnerText)"
31+
32+
# update the node inner text
33+
$netFxSniVersion.InnerText = "$SharedSNIVersion"
34+
35+
$netCoreSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSNIRuntimeVersion', $nsm)
36+
37+
# update the node inner text
38+
$netCoreSniVersion.InnerText = "$SharedSNIVersion"
39+
40+
# save the xml file
41+
$xml.Save($PropsPath)
42+
43+
type $PropsPath

src/Microsoft.Data.SqlClient.sln

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "steps", "steps", "{EABE3A3E
263263
..\eng\pipelines\common\templates\steps\copy-dlls-for-test-step.yml = ..\eng\pipelines\common\templates\steps\copy-dlls-for-test-step.yml
264264
..\eng\pipelines\common\templates\steps\esrp-code-signing-step.yml = ..\eng\pipelines\common\templates\steps\esrp-code-signing-step.yml
265265
..\eng\pipelines\common\templates\steps\generate-nuget-package-step.yml = ..\eng\pipelines\common\templates\steps\generate-nuget-package-step.yml
266+
..\eng\pipelines\common\templates\steps\override-sni-version.yml = ..\eng\pipelines\common\templates\steps\override-sni-version.yml
266267
..\eng\pipelines\common\templates\steps\pre-build-step.yml = ..\eng\pipelines\common\templates\steps\pre-build-step.yml
267268
..\eng\pipelines\common\templates\steps\prepare-test-db-step.yml = ..\eng\pipelines\common\templates\steps\prepare-test-db-step.yml
268269
..\eng\pipelines\common\templates\steps\publish-symbols-step.yml = ..\eng\pipelines\common\templates\steps\publish-symbols-step.yml
@@ -583,6 +584,8 @@ Global
583584
{8DC9D1A0-351B-47BC-A90F-B9DA542550E9} = {0CC4817A-12F3-4357-912C-09315FAAD008}
584585
{D2D1E2D1-B6E0-489F-A36D-1F3047AB87B9} = {0CC4817A-12F3-4357-912C-09315FAAD008}
585586
{37431336-5307-4184-9356-C4B7E47DC714} = {28E5EFE6-C9DD-4FF9-9FEC-532F72DFFA6E}
587+
{28E5EFE6-C9DD-4FF9-9FEC-532F72DFFA6E} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
588+
{3FDD425C-FE01-4B56-863E-1FCDD0677CF5} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
586589
{D1392B54-998A-4F27-BC17-4CE149117BCC} = {CDE508A5-F5D0-4A59-A4EF-978833830727}
587590
{45DB5F86-7AE3-45C6-870D-F9357B66BDB5} = {0CC4817A-12F3-4357-912C-09315FAAD008}
588591
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F} = {CDE508A5-F5D0-4A59-A4EF-978833830727}
@@ -592,6 +595,7 @@ Global
592595
{1C9FC4B8-54BC-4B6C-BB3A-F5CD59D80A9B} = {A2E7E470-5EFF-4828-B55E-FCBA3650F51C}
593596
{771F3F1E-7A68-4A9D-ADA8-A24F1D5BE71D} = {3FDD425C-FE01-4B56-863E-1FCDD0677CF5}
594597
{412BCCC8-19F6-489A-B594-E9A506816155} = {771F3F1E-7A68-4A9D-ADA8-A24F1D5BE71D}
598+
{9073ABEF-92E0-4702-BB23-2C99CEF9BDD7} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
595599
{71F356DC-DFA3-4163-8BFE-D268722CE189} = {ED952CF7-84DF-437A-B066-F516E9BE1C2C}
596600
{908C7DD3-C999-40A6-9433-9F5ACA7C36F5} = {71F356DC-DFA3-4163-8BFE-D268722CE189}
597601
{0CE216CE-8072-4985-B248-61F0D0BE9C2E} = {71F356DC-DFA3-4163-8BFE-D268722CE189}
@@ -608,9 +612,6 @@ Global
608612
{869A9BCC-D303-4365-9BF7-958CD6387916} = {71F356DC-DFA3-4163-8BFE-D268722CE189}
609613
{CDE508A5-F5D0-4A59-A4EF-978833830727} = {0CC4817A-12F3-4357-912C-09315FAAD008}
610614
{9A8996A8-6484-4AA7-B50F-F861430EDE2F} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
611-
{9073ABEF-92E0-4702-BB23-2C99CEF9BDD7} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
612-
{28E5EFE6-C9DD-4FF9-9FEC-532F72DFFA6E} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
613-
{3FDD425C-FE01-4B56-863E-1FCDD0677CF5} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
614615
{4CAE9195-4F1A-4D48-854C-1C9FBC512C66} = {4600328C-C134-499F-AAE2-964E8AD5472C}
615616
{FD4D7A96-79B1-4F89-B64D-29FACCC9232F} = {4CAE9195-4F1A-4D48-854C-1C9FBC512C66}
616617
{E76A4ED5-9137-4E4B-AE91-7AEDB2683823} = {FD4D7A96-79B1-4F89-B64D-29FACCC9232F}

0 commit comments

Comments
 (0)