Skip to content

Commit 567550b

Browse files
committed
User Story 38467: Backport mac server name fix
- Backported part of #3494 and all of #3591: - Added configurable test jobs timeout, defaulting to 90 minutes. - Reduced generated database names to 96 chars to try to fix macOS test failures.
1 parent d2f2f26 commit 567550b

File tree

8 files changed

+67
-3
lines changed

8 files changed

+67
-3
lines changed

eng/pipelines/common/templates/jobs/ci-run-tests-job.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,18 @@ parameters:
7373
- Project
7474
- Package
7575

76+
# The timeout, in minutes, for this job.
77+
- name: timeout
78+
type: string
79+
default: 90
80+
7681
jobs:
7782
- job: ${{ format('{0}', coalesce(parameters.jobDisplayName, parameters.image, 'unknown_image')) }}
7883

84+
# Some of our tests take longer than the default 60 minutes to run on some
85+
# OSes and configurations.
86+
timeoutInMinutes: ${{ parameters.timeout }}
87+
7988
pool:
8089
name: '${{ parameters.poolName }}'
8190
${{ if eq(parameters.hostedPool, true) }}:

eng/pipelines/common/templates/jobs/run-tests-package-reference-job.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@ parameters:
2020
- name: isPreview
2121
type: boolean
2222

23+
# The timeout, in minutes, for this job.
24+
- name: timeout
25+
type: string
26+
default: 90
27+
2328
jobs:
2429
- job: run_tests_package_reference
2530
displayName: 'Run tests with package reference'
2631
${{ if ne(parameters.dependsOn, 'empty')}}:
2732
dependsOn: '${{parameters.dependsOn }}'
33+
34+
# Some of our tests take longer than the default 60 minutes to run on some
35+
# OSes and configurations.
36+
timeoutInMinutes: ${{ parameters.timeout }}
37+
2838
pool:
2939
type: windows # read more about custom job pool types at https://aka.ms/obpipelines/yaml/jobs
3040
isCustom: true

eng/pipelines/common/templates/stages/ci-run-tests-stage.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ parameters:
3030
type: jobList
3131
default: []
3232

33+
# The timeout, in minutes, for each test job.
34+
- name: testsTimeout
35+
type: string
36+
default: 90
37+
3338
stages:
3439
- ${{ each config in parameters.testConfigurations }}:
3540
- ${{ each image in config.value.images }}:
@@ -47,6 +52,7 @@ stages:
4752
parameters:
4853
debug: ${{ parameters.debug }}
4954
buildType: ${{ parameters.buildType }}
55+
timeout: ${{ parameters.testsTimeout }}
5056
poolName: ${{ config.value.pool }}
5157
hostedPool: ${{ eq(config.value.hostedPool, true) }}
5258
image: ${{ image.value }}
@@ -72,6 +78,7 @@ stages:
7278
parameters:
7379
debug: ${{ parameters.debug }}
7480
buildType: ${{ parameters.buildType }}
81+
timeout: ${{ parameters.testsTimeout }}
7582
poolName: ${{ config.value.pool }}
7683
hostedPool: ${{ eq(config.value.hostedPool, true) }}
7784
image: ${{ image.value }}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ parameters:
8181
type: boolean
8282
default: false
8383

84+
# The timeout, in minutes, for each test job.
85+
- name: testsTimeout
86+
type: string
87+
default: 90
88+
8489
variables:
8590
- template: libraries/ci-build-variables.yml@self
8691

@@ -119,6 +124,7 @@ stages:
119124
parameters:
120125
debug: ${{ parameters.debug }}
121126
buildType: ${{ parameters.buildType }}
127+
testsTimeout: ${{ parameters.testsTimeout }}
122128
${{ if eq(parameters.buildType, 'Package') }}:
123129
dependsOn: build_nugets
124130

eng/pipelines/dotnet-sqlclient-ci-package-reference-pipeline.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ parameters: # parameters are shown up in ADO UI in a build queue time
9393
type: boolean
9494
default: false
9595

96+
# The timeout, in minutes, for each test job.
97+
- name: testsTimeout
98+
displayName: 'Tests timeout (in minutes)'
99+
type: string
100+
default: 90
101+
96102
extends:
97103
template: dotnet-sqlclient-ci-core.yml@self
98104
parameters:
@@ -106,3 +112,4 @@ extends:
106112
buildType: ${{ parameters.buildType }}
107113
buildConfiguration: ${{ parameters.buildConfiguration }}
108114
enableStressTests: ${{ parameters.enableStressTests }}
115+
testsTimeout: ${{ parameters.testsTimeout }}

eng/pipelines/dotnet-sqlclient-ci-project-reference-pipeline.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ parameters: # parameters are shown up in ADO UI in a build queue time
8585
type: boolean
8686
default: false
8787

88+
# The timeout, in minutes, for each test job.
89+
- name: testsTimeout
90+
displayName: 'Tests timeout (in minutes)'
91+
type: string
92+
default: 90
93+
8894
extends:
8995
template: dotnet-sqlclient-ci-core.yml@self
9096
parameters:
@@ -98,3 +104,4 @@ extends:
98104
buildType: ${{ parameters.buildType }}
99105
buildConfiguration: ${{ parameters.buildConfiguration }}
100106
enableStressTests: ${{ parameters.enableStressTests }}
107+
testsTimeout: ${{ parameters.testsTimeout }}

eng/pipelines/dotnet-sqlclient-signing-pipeline.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ parameters: # parameters are shown up in ADO UI in a build queue time
6262
type: boolean
6363
default: false
6464

65+
# The timeout, in minutes, for each test job.
66+
- name: testsTimeout
67+
displayName: 'Tests timeout (in minutes)'
68+
type: string
69+
default: 90
70+
6571
variables:
6672
- template: /eng/pipelines/libraries/variables.yml@self
6773
- name: packageFolderName
@@ -161,6 +167,7 @@ extends:
161167
parameters:
162168
packageFolderName: $(packageFolderName)
163169
isPreview: ${{ parameters['isPreview'] }}
170+
timeout: ${{ parameters.testsTimeout }}
164171
downloadPackageStep:
165172
download: current
166173
artifact: $(packageFolderName)

src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ public static string GetUniqueName(string prefix, bool withBracket = true)
587587
/// </summary>
588588
/// <param name="prefix">Add the prefix to the generate string.</param>
589589
/// <param name="withBracket">Database name must be pass with brackets by default.</param>
590-
/// <returns>Unique name by considering the Sql Server naming rules.</returns>
590+
/// <returns>Unique name by considering the Sql Server naming rules, never longer than 96 characters.</returns>
591591
public static string GetUniqueNameForSqlServer(string prefix, bool withBracket = true)
592592
{
593593
string extendedPrefix = string.Format(
@@ -597,10 +597,21 @@ public static string GetUniqueNameForSqlServer(string prefix, bool withBracket =
597597
Environment.MachineName,
598598
DateTime.Now.ToString("yyyy_MM_dd", CultureInfo.InvariantCulture));
599599
string name = GetUniqueName(extendedPrefix, withBracket);
600-
if (name.Length > 128)
600+
601+
// Truncate to no more than 96 characters.
602+
const int maxLen = 96;
603+
if (name.Length > maxLen)
601604
{
602-
throw new ArgumentOutOfRangeException("the name is too long - SQL Server names are limited to 128");
605+
if (withBracket)
606+
{
607+
name = name.Substring(0, maxLen - 1) + ']';
608+
}
609+
else
610+
{
611+
name = name.Substring(0, maxLen);
612+
}
603613
}
614+
604615
return name;
605616
}
606617

0 commit comments

Comments
 (0)