Skip to content
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

Allow sni version override for testing #3184

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
81 changes: 81 additions & 0 deletions eng/pipelines/common/templates/steps/override-sni-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#################################################################################
# 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. #
#################################################################################

parameters:
- name: SNIVersion
type: string

- name: SNIValidationFeed
type: string

steps:
- task: PowerShell@2
displayName: Add SNI Validation Feed in Nuget.config
inputs:
targetType: inline
script: |
Write-Host "SNI validation feed to use = ${{parameters.SNIValidationFeed}}"

# define file to update
$NugetCfg = Join-Path -Path '.' -ChildPath 'NuGet.config'
type $NugetCfg

# load content of xml from file defined above
$xml = New-Object XML
$xml.Load($NugetCfg)

# define namespace used to read a node
$nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable)
$nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI)

# get the package sources node
$packageSources = $xml.SelectSingleNode('//ns:packageSources', $nsm)

# define new package source
$newSource = $xml.CreateElement("add")
$newSource.SetAttribute("key","SNIValidation")
$newSource.SetAttribute("value","${{parameters.SNIValidationFeed}}")

# add the new package source
$packageSources.AppendChild($newSource)

# save the xml file
$xml.Save($NugetCfg)
type $NugetCfg
- task: PowerShell@2
displayName: Update SNI Version in Versions.props
inputs:
targetType: inline
script: |
Write-Host "SNI Version to test = ${{parameters.SNIVersion}}"

# define file to update
$PropsPath = Join-Path -Path '.' -ChildPath 'tools\props\Versions.props'
type $PropsPath

# load content of xml from file defined above
$xml = New-Object XML
$xml.Load($PropsPath)

# define namespace used to read a node
$nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable)
$nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI)

# update the node inner text for netfx
$netFxSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSniVersion', $nsm)
Write-Host "Current .NET Framework SNI Version = $($netFxSniVersion.InnerText)"
$netFxSniVersion.InnerText = "${{parameters.SNIVersion}}"

# update the node inner text for net core
$netCoreSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSNIRuntimeVersion', $nsm)
Write-Host "Current .NET Core SNI Version = $($netCoreSniVersion.InnerText)"
$netCoreSniVersion.InnerText = "${{parameters.SNIVersion}}"

# save the xml file
$xml.Save($PropsPath)
type $PropsPath
- task: NuGetAuthenticate@1
displayName: 'NuGet Authenticate with SNI Validation Feed'
42 changes: 36 additions & 6 deletions eng/pipelines/dotnet-sqlclient-ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ parameters:
type: object
default: [false, true]

- name: SNIVersion
displayName: |
SNI Version Override
type: string
default: ''

- name: SNIValidationFeed
displayName: |
SNI Version Override Nuget Feed
type: string
default: https://sqlclientdrivers.pkgs.visualstudio.com/ADO.Net/_packaging/SNIValidation/nuget/v3/index.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After spending so much time on the AKV pipeline, I've got a lot of preferences about style for pipeline yaml. On the one hand, I could lay it all out in this PR and make things annoying. On the other hand, I anticipate rewriting this pipeline as well, and we can hold off on stylistic changes until then. Which would you prefer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're ok with waiting, I'd prefer that. I don't anticipate this to be a long term solution. I had other approaches in mind to facilitate SNI testing, but they were blocked on this pipeline migrating to onebranch. My idea was to keep this small and easily removable.

I'd also be happy to standardize on an IDE and formatter for yaml. Raw yaml editing is not the way to go.


- name: codeCovTargetFrameworks
displayName: 'Code Coverage Target Frameworks'
type: object
Expand Down Expand Up @@ -73,6 +85,12 @@ stages:
- template: common/templates/jobs/ci-build-nugets-job.yml@self
parameters:
artifactName: $(artifactName)
${{if ne(parameters.SNIVersion, '')}}:
prebuildSteps:
- template: common/templates/steps/override-sni-version.yml@self
parameters:
SNIVersion: ${{parameters.SNIVersion}}
SNIValidationFeed: ${{parameters.SNIValidationFeed}}

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

prebuildSteps: # steps to run prior to building and running tests on each job
- template: common/templates/steps/ci-prebuild-step.yml@self
parameters:
debug: ${{ parameters.debug }}
artifactName: $(artifactName)
buildType: ${{ parameters.buildType }}
${{if ne(parameters.SNIVersion, '')}}:
prebuildSteps: # steps to run prior to building and running tests on each job
- template: common/templates/steps/override-sni-version.yml@self
parameters:
SNIVersion: ${{parameters.SNIVersion}}
SNIValidationFeed: ${{parameters.SNIValidationFeed}}
- template: common/templates/steps/ci-prebuild-step.yml@self
parameters:
debug: ${{ parameters.debug }}
artifactName: $(artifactName)
buildType: ${{ parameters.buildType }}
${{else}}:
prebuildSteps: # steps to run prior to building and running tests on each job
- template: common/templates/steps/ci-prebuild-step.yml@self
parameters:
debug: ${{ parameters.debug }}
artifactName: $(artifactName)
buildType: ${{ parameters.buildType }}

${{ if eq(parameters.buildType, 'Project') }}: # only run the code coverage job if the build type is project
postTestJobs: # jobs to run after the tests are done
Expand Down
43 changes: 43 additions & 0 deletions override.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#Purpose: Updates SNI Version
Write-Host "SNI Version to test = 123"

##Get the shared SNI Version from the downloaded artifact
#$SharedSNIVersion = Get-Content -path "$(Pipeline.Workspace)/SharedSNIVersion.txt"

#Get the SNI Version to test from the user entered version.
$SharedSNIVersion = "123"

# define file to update
$PropsPath = 'C:\Users\mdaigle\SqlClient\tools\props\Versions.props'
type $PropsPath

# new version number to update to
##Write-Host "SNI Version to test = $(SNIValidationVersion)"
Write-Host "SNI Version to test = $SharedSNIVersion"


# define an xml object
$xml = New-Object XML

# load content of xml from file defined above
$xml.Load($PropsPath)

# define namespace used to read a node
$nsm = New-Object Xml.XmlNamespaceManager($xml.NameTable)
$nsm.AddNamespace('ns', $xml.DocumentElement.NamespaceURI)
$netFxSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSniVersion', $nsm)

Write-Host "Node NetFx SNI Version = $($netFxSniVersion.InnerText)"

# update the node inner text
$netFxSniVersion.InnerText = "$SharedSNIVersion"

$netCoreSniVersion = $xml.SelectSingleNode('//ns:MicrosoftDataSqlClientSNIRuntimeVersion', $nsm)

# update the node inner text
$netCoreSniVersion.InnerText = "$SharedSNIVersion"

# save the xml file
$xml.Save($PropsPath)

type $PropsPath
7 changes: 4 additions & 3 deletions src/Microsoft.Data.SqlClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "steps", "steps", "{EABE3A3E
..\eng\pipelines\common\templates\steps\copy-dlls-for-test-step.yml = ..\eng\pipelines\common\templates\steps\copy-dlls-for-test-step.yml
..\eng\pipelines\common\templates\steps\esrp-code-signing-step.yml = ..\eng\pipelines\common\templates\steps\esrp-code-signing-step.yml
..\eng\pipelines\common\templates\steps\generate-nuget-package-step.yml = ..\eng\pipelines\common\templates\steps\generate-nuget-package-step.yml
..\eng\pipelines\common\templates\steps\override-sni-version.yml = ..\eng\pipelines\common\templates\steps\override-sni-version.yml
..\eng\pipelines\common\templates\steps\pre-build-step.yml = ..\eng\pipelines\common\templates\steps\pre-build-step.yml
..\eng\pipelines\common\templates\steps\prepare-test-db-step.yml = ..\eng\pipelines\common\templates\steps\prepare-test-db-step.yml
..\eng\pipelines\common\templates\steps\publish-symbols-step.yml = ..\eng\pipelines\common\templates\steps\publish-symbols-step.yml
Expand Down Expand Up @@ -559,6 +560,8 @@ Global
{8DC9D1A0-351B-47BC-A90F-B9DA542550E9} = {0CC4817A-12F3-4357-912C-09315FAAD008}
{D2D1E2D1-B6E0-489F-A36D-1F3047AB87B9} = {0CC4817A-12F3-4357-912C-09315FAAD008}
{37431336-5307-4184-9356-C4B7E47DC714} = {28E5EFE6-C9DD-4FF9-9FEC-532F72DFFA6E}
{28E5EFE6-C9DD-4FF9-9FEC-532F72DFFA6E} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
{3FDD425C-FE01-4B56-863E-1FCDD0677CF5} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
{D1392B54-998A-4F27-BC17-4CE149117BCC} = {CDE508A5-F5D0-4A59-A4EF-978833830727}
{45DB5F86-7AE3-45C6-870D-F9357B66BDB5} = {0CC4817A-12F3-4357-912C-09315FAAD008}
{6C88F00F-9597-43AD-9E5F-9B344DA3B16F} = {CDE508A5-F5D0-4A59-A4EF-978833830727}
Expand All @@ -568,6 +571,7 @@ Global
{1C9FC4B8-54BC-4B6C-BB3A-F5CD59D80A9B} = {A2E7E470-5EFF-4828-B55E-FCBA3650F51C}
{771F3F1E-7A68-4A9D-ADA8-A24F1D5BE71D} = {3FDD425C-FE01-4B56-863E-1FCDD0677CF5}
{412BCCC8-19F6-489A-B594-E9A506816155} = {771F3F1E-7A68-4A9D-ADA8-A24F1D5BE71D}
{9073ABEF-92E0-4702-BB23-2C99CEF9BDD7} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
{71F356DC-DFA3-4163-8BFE-D268722CE189} = {ED952CF7-84DF-437A-B066-F516E9BE1C2C}
{908C7DD3-C999-40A6-9433-9F5ACA7C36F5} = {71F356DC-DFA3-4163-8BFE-D268722CE189}
{0CE216CE-8072-4985-B248-61F0D0BE9C2E} = {71F356DC-DFA3-4163-8BFE-D268722CE189}
Expand All @@ -584,9 +588,6 @@ Global
{869A9BCC-D303-4365-9BF7-958CD6387916} = {71F356DC-DFA3-4163-8BFE-D268722CE189}
{CDE508A5-F5D0-4A59-A4EF-978833830727} = {0CC4817A-12F3-4357-912C-09315FAAD008}
{9A8996A8-6484-4AA7-B50F-F861430EDE2F} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
{9073ABEF-92E0-4702-BB23-2C99CEF9BDD7} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
{28E5EFE6-C9DD-4FF9-9FEC-532F72DFFA6E} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
{3FDD425C-FE01-4B56-863E-1FCDD0677CF5} = {4F3CD363-B1E6-4D6D-9466-97D78A56BE45}
{4CAE9195-4F1A-4D48-854C-1C9FBC512C66} = {4600328C-C134-499F-AAE2-964E8AD5472C}
{FD4D7A96-79B1-4F89-B64D-29FACCC9232F} = {4CAE9195-4F1A-4D48-854C-1C9FBC512C66}
{E76A4ED5-9137-4E4B-AE91-7AEDB2683823} = {FD4D7A96-79B1-4F89-B64D-29FACCC9232F}
Expand Down
Loading