Skip to content

Commit 98825bb

Browse files
authored
Support multiple Spring Boot versions for integration tests (#41170)
1 parent a71d3e5 commit 98825bb

15 files changed

+347
-119
lines changed

eng/pipelines/templates/jobs/live.tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ parameters:
1616
UsePlatformContainer: false
1717
DisableAzureResourceCreation: false
1818
BuildParallelization: '2C'
19+
BuildOptions: ''
1920
TestGoals: $(TestGoals)
2021
TestOptions: $(TestOptions)
2122
TestParallelization: '1'
@@ -139,6 +140,7 @@ jobs:
139140
parameters:
140141
ParallelTestPlayback: 'false'
141142
BuildParallelization: ${{ parameters.BuildParallelization }}
143+
BuildOptions: ${{ parameters.BuildOptions }}
142144
IsLiveTest: true
143145
TestGoals: ${{ parameters.TestGoals }}
144146
TestOptions: ${{ parameters.TestOptions }}

eng/pipelines/templates/stages/archetype-sdk-tests-isolated.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ parameters:
4444
- name: Location
4545
type: string
4646
default: ''
47+
- name: PreGenerationSteps
48+
type: stepList
49+
default: []
50+
- name: BuildOptions
51+
type: string
52+
default: ''
4753
- name: ServiceDirectory
4854
type: string
4955
default: not-specified
@@ -117,6 +123,9 @@ parameters:
117123
- name: UseFederatedAuth
118124
type: boolean
119125
default: false
126+
- name: AdditionalSparseCheckoutPaths
127+
type: object
128+
default: []
120129

121130
stages:
122131
- ${{ each cloud in parameters.CloudConfig }}:
@@ -138,10 +147,12 @@ stages:
138147
jobs:
139148
- template: /eng/common/pipelines/templates/jobs/generate-job-matrix.yml
140149
parameters:
150+
PreGenerationSteps: ${{ parameters.PreGenerationSteps }}
141151
SparseCheckoutPaths:
142152
- "sdk/${{ parameters.ServiceDirectory }}/**/*.json"
143153
- '!sdk/**/test-recordings/*'
144154
- '!sdk/**/session-records/*'
155+
- ${{ parameters.AdditionalSparseCheckoutPaths }}
145156
JobTemplatePath: /eng/pipelines/templates/jobs/live.tests.yml
146157
AdditionalParameters:
147158
PreSteps:
@@ -150,6 +161,7 @@ stages:
150161
PostSteps:
151162
- ${{ parameters.PlatformPostSteps }}
152163
- ${{ parameters.PostSteps }}
164+
BuildOptions: ${{ parameters.BuildOptions }}
153165
EnvVars: ${{ parameters.EnvVars }}
154166
MaxParallel: ${{ parameters.MaxParallel }}
155167
TimeoutInMinutes: ${{ parameters.TimeoutInMinutes }}

eng/pipelines/templates/steps/build-and-test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ parameters:
22
- name: BuildParallelization
33
type: string
44
default: '2C'
5+
- name: BuildOptions
6+
type: string
7+
default: ''
58
- name: TestGoals
69
type: string
710
default: $(TestGoals)
@@ -47,7 +50,7 @@ steps:
4750
displayName: 'Build for non-From Source run'
4851
inputs:
4952
mavenPomFile: pom.xml
50-
options: $(DefaultOptions) -DskipTests $(DefaultSkipOptions) -Djacoco.skip=true -T ${{ parameters.BuildParallelization }} -pl $(ProjectList) -am
53+
options: $(DefaultOptions) -DskipTests $(DefaultSkipOptions) -Djacoco.skip=true ${{ parameters.BuildOptions }} -T ${{ parameters.BuildParallelization }} -pl $(ProjectList) -am
5154
mavenOptions: '$(MemoryOptions) $(LoggingOptions)'
5255
javaHomeOption: 'JDKVersion'
5356
jdkVersionOption: $(JavaTestVersion)
@@ -165,7 +168,7 @@ steps:
165168
# bloated the ci.yml files' AdditionalModules because we ended up having to list every transitive azure client
166169
# dependency. Note: The -T 1C says spin up a build thread per core. Since we're building
167170
# all the track 2, client, libraries (which is now over 100) this effectively cuts the build time in half.
168-
options: $(DefaultOptions) -DskipTests $(DefaultSkipOptions) -Djacoco.skip=true -T ${{ parameters.BuildParallelization }}
171+
options: $(DefaultOptions) -DskipTests $(DefaultSkipOptions) -Djacoco.skip=true ${{ parameters.BuildOptions }} -T ${{ parameters.BuildParallelization }}
169172
mavenOptions: '$(MemoryOptions) $(LoggingOptions)'
170173
javaHomeOption: 'JDKVersion'
171174
jdkVersionOption: $(JavaTestVersion)
@@ -196,7 +199,7 @@ steps:
196199
$env:AZURESUBSCRIPTION_CLIENT_ID = $account.Id
197200
$env:AZURESUBSCRIPTION_TENANT_ID = $account.Tenants
198201
199-
mvn --% -f $(Build.SourcesDirectory)/ClientFromSourcePom.xml ${{ parameters.TestGoals }} $(DefaultTestOptions) -DAZURE_TEST_DEBUG=$(IsDebug) -Dparallel-test-playback=${{ parameters.ParallelTestPlayback }} ${{ parameters.TestOptions }} $(LiveTestSourceParams) -T ${{ parameters.TestParallelization }}
202+
mvn --% -f $(Build.SourcesDirectory)/ClientFromSourcePom.xml ${{ parameters.TestGoals }} $(DefaultTestOptions) -DAZURE_TEST_DEBUG=$(IsDebug) -Dparallel-test-playback=${{ parameters.ParallelTestPlayback }} ${{ parameters.TestOptions }} $(LiveTestSourceParams) ${{ parameters.BuildOptions }} -T ${{ parameters.TestParallelization }}
200203
exit $LASTEXITCODE
201204
env:
202205
# PowerShellJavaHome is set in the 'Set PowerShellJavaHome'

sdk/spring/compatibility-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ stages:
2323
PreGenerationSteps:
2424
- script: |
2525
python -m pip install termcolor
26-
displayName: 'python module install'
26+
displayName: 'Install python module'
2727
- script: |
2828
python ./sdk/spring/scripts/compatibility_update_supported_version_matrix_json.py --target-version-prefix 3. --non-target-version-prefix-list 3.0.
29-
displayName: 'update test version'
29+
displayName: 'Update supported Spring versions'
3030
MatrixFilters:
3131
- JavaTestVersion=^(?!1.8|1.11).*

sdk/spring/pipeline/compatibility-tests-job.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
matrix: $[ ${{ parameters.Matrix }} ]
1414
variables:
1515
- template: ../../../eng/pipelines/templates/variables/globals.yml
16+
- name: SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION
17+
value: ${{ parameters.Matrix.SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION }}
1618
steps:
1719
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
1820
parameters:
@@ -24,22 +26,22 @@ jobs:
2426
- 'sdk/jdbc'
2527
- script: |
2628
python -m pip install termcolor
27-
displayName: 'Python module install'
29+
displayName: 'Install python module'
2830
- bash: |
2931
echo "##vso[task.setVariable variable=SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION]$(python ./sdk/spring/scripts/compatibility_get_spring_cloud_version.py -b $(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION))"
30-
displayName: 'Set env'
32+
displayName: 'Set supported Spring version to environment variables'
3133
- bash: |
3234
echo "$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION):"
3335
echo "https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION)/spring-boot-dependencies-$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION).pom"
3436
echo "$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION):"
3537
echo "https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION)/spring-cloud-dependencies-$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION).pom"
36-
displayName: 'Print version maven pom'
38+
displayName: 'Log Spring version and Maven pom path'
3739
- script: |
3840
python ./sdk/spring/scripts/compatibility_insert_dependencymanagement.py -b $(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION) -c $(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION)
39-
displayName: 'Insert dependency management'
41+
displayName: 'Insert Spring dependency managements'
4042
- script: |
4143
python ./sdk/spring/scripts/compatibility_delete_version.py -b $(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION)
42-
displayName: 'Remove unused version'
44+
displayName: 'Remove unused dependency versions'
4345
- task: Maven@3
4446
displayName: 'Run tests'
4547
inputs:

sdk/spring/pipeline/cosmos-integration-matrix.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"displayNames": {
3+
4+
},
25
"matrix": {
36
"Cosmos": {
47
"Session_Integration": {
@@ -10,6 +13,9 @@
1013
}
1114
},
1215
"TestFromSource": true,
13-
"JavaTestVersion": ["1.17", "1.21"]
16+
"JavaTestVersion": ["1.17", "1.21"],
17+
"SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION": [
18+
19+
]
1420
}
1521
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
parameters:
2+
- name: TestName
3+
type: string
4+
default: 'SpringIntegration'
5+
- name: PreSteps
6+
type: object
7+
default: []
8+
- name: EnvVars
9+
type: object
10+
default: {}
11+
- name: Artifacts
12+
type: object
13+
default: []
14+
- name: TimeoutInMinutes
15+
type: number
16+
default: 60
17+
- name: BuildOptions
18+
type: string
19+
default: '-Denforcer.skip=true'
20+
- name: TestResourceDirectories
21+
type: object
22+
default:
23+
- name: MatrixConfigs
24+
type: object
25+
default:
26+
- Name: Spring_Boot_Supported_Version_Tests
27+
Path: sdk/spring/pipeline/tests-supported-version-matrix.json
28+
Selection: sparse
29+
GenerateVMJobs: true
30+
NonSparseParameters:
31+
- SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION
32+
- name: TestOptions
33+
type: string
34+
default: $(TestOptions)
35+
- name: MatrixConfigFileName
36+
type: string
37+
default: ''
38+
39+
stages:
40+
- template: /eng/pipelines/templates/stages/archetype-sdk-tests-isolated.yml
41+
parameters:
42+
UseFederatedAuth: true
43+
SupportedClouds: "Public,UsGov,China"
44+
Clouds: "Public"
45+
CloudConfig:
46+
Public:
47+
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
48+
ServiceConnection: azure-sdk-tests
49+
SubscriptionConfigurationFilePaths:
50+
- eng/common/TestResources/sub-config/AzurePublicMsft.json
51+
UsGov:
52+
SubscriptionConfiguration: $(sub-config-gov-test-resources)
53+
ServiceConnection: usgov_azure-sdk-tests
54+
China:
55+
SubscriptionConfiguration: $(sub-config-cn-test-resources)
56+
ServiceConnection: china_azure-sdk-tests
57+
Location: "chinanorth3"
58+
TestResourceDirectories: ${{ parameters.TestResourceDirectories }}
59+
Artifacts: ${{ parameters.Artifacts }}
60+
TimeoutInMinutes: ${{ parameters.TimeoutInMinutes }}
61+
ServiceDirectory: spring
62+
TestName: ${{ parameters.TestName }}
63+
BuildOptions: ${{ parameters.BuildOptions }}
64+
EnvVars: ${{ parameters.EnvVars }}
65+
TestGoals: "clean verify"
66+
TestOptions: ${{ parameters.TestOptions }}
67+
MatrixConfigs: ${{ parameters.MatrixConfigs }}
68+
PreGenerationSteps:
69+
- script: |
70+
python -m pip install termcolor
71+
displayName: 'Install python module'
72+
- script: |
73+
python ./sdk/spring/scripts/compatibility_update_supported_version_matrix_json.py -mcp ${{ parameters.MatrixConfigs[0].Path }}
74+
displayName: 'Update supported Spring versions'
75+
MatrixFilters:
76+
- JavaTestVersion=^(?!1.8|1.11).*
77+
AdditionalSparseCheckoutPaths:
78+
- 'sdk/spring'
79+
PreSteps:
80+
- ${{ parameters.PreSteps }}
81+
- script: |
82+
python -m pip install termcolor requests
83+
displayName: 'Install python modules'
84+
- bash: |
85+
echo "##vso[task.setVariable variable=SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION]$(python ./sdk/spring/scripts/compatibility_get_spring_cloud_version.py -b $(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION))"
86+
displayName: 'Set supported Spring version to environment variables'
87+
- bash: |
88+
echo "$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION):"
89+
echo "https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION)/spring-boot-dependencies-$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION).pom"
90+
echo "$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION):"
91+
echo "https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION)/spring-cloud-dependencies-$(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION).pom"
92+
displayName: 'Log Spring version and Maven pom path'
93+
- script: |
94+
python ./sdk/spring/scripts/compatibility_insert_dependencymanagement.py -b $(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION) -c $(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_CLOUD_VERSION) --usage integration
95+
displayName: 'Insert Spring dependency managements'
96+
- script: |
97+
python ./sdk/spring/scripts/compatibility_delete_version.py -b $(SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION) --usage integration
98+
displayName: 'Remove unused dependency versions'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"matrix": {
3+
"$IMPORT": "eng/pipelines/templates/stages/platform-matrix.json",
4+
"SPRING_CLOUD_AZURE_TEST_SUPPORTED_SPRING_BOOT_VERSION": [
5+
6+
]
7+
},
8+
"displayNames": {
9+
"true": "TestFromSource"
10+
}
11+
}

sdk/spring/scripts/_constants.py

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,66 @@
11

2+
SPRING_BOOT_MAJOR_2_VERSION_NAME = '2'
23
SPRING_BOOT_MAJOR_2_VERSION_TAG_PREFIX = ''
4+
SPRING_BOOT_MAJOR_3_VERSION_NAME = '3'
35
SPRING_BOOT_MAJOR_3_VERSION_TAG_PREFIX = 'springboot3_'
4-
SPRING_BOOT_MAJOR_2_VERSION_NAME = 'v2'
5-
SPRING_BOOT_MAJOR_3_VERSION_NAME = 'v3'
6-
SPRING_BOOT_MAJOR_VERSION_PREFIX_MAP = {
7-
'v2': SPRING_BOOT_MAJOR_2_VERSION_TAG_PREFIX,
8-
'v3': SPRING_BOOT_MAJOR_3_VERSION_TAG_PREFIX
6+
SPRING_BOOT_MAJOR_VERSION_PREFIX_DICT = {
7+
SPRING_BOOT_MAJOR_2_VERSION_NAME: SPRING_BOOT_MAJOR_2_VERSION_TAG_PREFIX,
8+
SPRING_BOOT_MAJOR_3_VERSION_NAME: SPRING_BOOT_MAJOR_3_VERSION_TAG_PREFIX
99
}
1010

1111

12-
def get_spring_boot_major_version_tag_prefix(spring_boot_version):
13-
if spring_boot_version.startswith('3.'):
14-
return SPRING_BOOT_MAJOR_VERSION_PREFIX_MAP['v3']
15-
elif spring_boot_version.startswith('2.'):
16-
return SPRING_BOOT_MAJOR_VERSION_PREFIX_MAP['v2']
12+
def get_spring_boot_version_tag_prefix(spring_boot_version):
13+
if spring_boot_version.startswith('3.') or spring_boot_version == SPRING_BOOT_MAJOR_3_VERSION_NAME:
14+
return SPRING_BOOT_MAJOR_VERSION_PREFIX_DICT[SPRING_BOOT_MAJOR_3_VERSION_NAME]
15+
elif spring_boot_version.startswith('2.') or spring_boot_version == SPRING_BOOT_MAJOR_2_VERSION_NAME:
16+
return SPRING_BOOT_MAJOR_VERSION_PREFIX_DICT[SPRING_BOOT_MAJOR_2_VERSION_NAME]
1717
else:
1818
return ''
19+
20+
21+
# Since Spring Cloud Azure uses multiple versions of external dependencies managed by Spring Boot,
22+
# the modules that still use Spring Boot 2 to manage dependencies will be skipped.
23+
SKIP_ADDING_DEPENDENCY_MANAGEMENT_ARTIFACTS = [
24+
'spring-cloud-azure-starter-monitor-test',
25+
'spring-cloud-azure-starter-monitor'
26+
]
27+
# Since some features are based on a higher Spring Boot version, it is sufficient to let the modules
28+
# corresponding to these special Spring Boot versions use the latest Spring Boot version.
29+
SKIP_ADDING_DEPENDENCY_MANAGEMENT_ARTIFACTS_WITH_SPRING_BOOT_VERSION = {
30+
'3.0': [
31+
# skip for test containers
32+
'spring-cloud-azure-autoconfigure',
33+
'spring-cloud-azure-testcontainers'
34+
]
35+
}
36+
# The artifact will be updated with different Spring versions of external dependencies to run the tests.
37+
INTEGRATION_TESTS_ARTIFACTS = [
38+
'spring-cloud-azure-integration-tests',
39+
'spring-cloud-azure-integration-test-appconfiguration-config'
40+
]
41+
COMPATIBILITY_USAGE_TYPE = 'compatibility'
42+
INTEGRATION_USAGE_TYPE = 'integration'
43+
44+
def should_skip_artifacts_when_adding_dependency_management(file_path):
45+
for artifact in SKIP_ADDING_DEPENDENCY_MANAGEMENT_ARTIFACTS:
46+
if artifact in file_path:
47+
return True
48+
else:
49+
return False
50+
51+
52+
def should_skip_artifacts_when_adding_dependency_management_with_spring_version(spring_boot_version, file_path):
53+
version_prefix = spring_boot_version[0:spring_boot_version.rindex('.')]
54+
if version_prefix in list(SKIP_ADDING_DEPENDENCY_MANAGEMENT_ARTIFACTS_WITH_SPRING_BOOT_VERSION.keys()):
55+
for artifact in SKIP_ADDING_DEPENDENCY_MANAGEMENT_ARTIFACTS_WITH_SPRING_BOOT_VERSION[version_prefix]:
56+
if artifact in file_path:
57+
return True
58+
return False
59+
60+
61+
def is_integration_tests_artifact(file_path):
62+
for artifact in INTEGRATION_TESTS_ARTIFACTS:
63+
if artifact in file_path:
64+
return True
65+
else:
66+
return False

0 commit comments

Comments
 (0)