Skip to content

Commit 96db80f

Browse files
perf: Parallelize multi-tenant integration tests (#433)
* perf: Parallelize multi-tenancy integration tests - Split workflow into setup + parallel test jobs using matrix strategy - Run 4 test combinations (tokenFlow x tenant) in parallel instead of sequentially - Reduces execution time from ~2 hours to ~30 minutes - Added test artifact uploads for each matrix job - Added test-summary job to aggregate results - Updated deprecated ::set-output syntax to GITHUB_OUTPUT * fix: Move CF login and credential fetch into each parallel job GitHub Actions blocks passing secrets via job outputs for security. Each parallel job now does its own CF login and fetches credentials within the same job using step outputs instead of job outputs. * perf: Further optimize with test class parallelization and caching - Add testClass dimension to matrix (3 classes Γ— 2 tokenFlows Γ— 2 tenants = 12 parallel jobs) - Each job runs only one test class instead of all 3 - Add Maven dependency caching via setup-java - Add CF CLI caching - Expected time: ~15-20 mins (down from ~50 mins) * perf: Parallelize integration tests in deploy workflows * updated workflow file to test the senario * updated the workflow file * perf: Parallelize single-tenant integration tests * perf: Parallelize single-tenant deploy integration tests
1 parent 1cf22d0 commit 96db80f

6 files changed

Lines changed: 292 additions & 83 deletions

β€Ž.github/workflows/multi tenancy_Integration.ymlβ€Ž

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ on:
1515
default: develop
1616

1717
jobs:
18+
# Parallel integration tests using matrix strategy
1819
integration-test:
1920
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
tokenFlow: [namedUser, technicalUser]
25+
tenant: [TENANT1, TENANT2]
26+
testClass:
27+
- IntegrationTest_SingleFacet
28+
- IntegrationTest_MultipleFacet
29+
- IntegrationTest_Chapters_MultipleFacet
2030

2131
steps:
2232
- name: Checkout repository βœ…
@@ -29,14 +39,29 @@ jobs:
2939
with:
3040
java-version: 17
3141
distribution: 'temurin'
42+
cache: 'maven'
43+
44+
- name: Cache CF CLI πŸ“¦
45+
id: cache-cf-cli
46+
uses: actions/cache@v4
47+
with:
48+
path: /usr/bin/cf8
49+
key: cf-cli-v8-${{ runner.os }}
3250

3351
- name: Install Cloud Foundry CLI and jq πŸ“¦
52+
if: steps.cache-cf-cli.outputs.cache-hit != 'true'
3453
run: |
35-
echo "πŸ”§ Installing Cloud Foundry CLI and jq..."
54+
echo "πŸ”§ Installing Cloud Foundry CLI..."
3655
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
3756
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
3857
sudo apt-get update
39-
sudo apt-get install cf8-cli jq
58+
sudo apt-get install cf8-cli
59+
60+
- name: Install jq πŸ“¦
61+
run: |
62+
if ! command -v jq &> /dev/null; then
63+
sudo apt-get update && sudo apt-get install -y jq
64+
fi
4065
4166
- name: Determine Cloud Foundry Space 🌌
4267
id: determine_space
@@ -47,7 +72,7 @@ jobs:
4772
space="${{ github.event.inputs.cf_space }}"
4873
fi
4974
echo "🌍 Space determined: $space"
50-
echo "::set-output name=space::$space"
75+
echo "space=$space" >> $GITHUB_OUTPUT
5176
5277
- name: Login to Cloud Foundry πŸ”‘
5378
run: |
@@ -88,8 +113,8 @@ jobs:
88113
fi
89114
echo "::add-mask::$clientID"
90115
91-
echo "::set-output name=CLIENT_SECRET::$escapedClientSecret"
92-
echo "::set-output name=CLIENT_ID::$clientID"
116+
echo "CLIENT_SECRET=$escapedClientSecret" >> $GITHUB_OUTPUT
117+
echo "CLIENT_ID=$clientID" >> $GITHUB_OUTPUT
93118
echo "βœ… Client details fetched successfully!"
94119
95120
- name: Fetch and Escape Client Details for multi tenant πŸ”
@@ -122,18 +147,18 @@ jobs:
122147
fi
123148
echo "::add-mask::$clientID_mt"
124149
125-
echo "::set-output name=CLIENT_SECRET_MT::$escapedClientSecret_mt"
126-
echo "::set-output name=CLIENT_ID_MT::$clientID_mt"
150+
echo "CLIENT_SECRET_MT=$escapedClientSecret_mt" >> $GITHUB_OUTPUT
151+
echo "CLIENT_ID_MT=$clientID_mt" >> $GITHUB_OUTPUT
127152
echo "βœ… Multi-tenant client details fetched successfully!"
128153
129-
- name: Run integration tests 🎯
154+
- name: Prepare credentials file πŸ“
130155
env:
131156
CLIENT_SECRET: ${{ steps.fetch_credentials.outputs.CLIENT_SECRET }}
132157
CLIENT_ID: ${{ steps.fetch_credentials.outputs.CLIENT_ID }}
133158
CLIENT_SECRET_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_SECRET_MT }}
134159
CLIENT_ID_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_ID_MT }}
135160
run: |
136-
echo "πŸš€ Starting integration tests..."
161+
echo "πŸš€ Preparing credentials for ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}..."
137162
set -e
138163
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
139164
appUrl="${{ secrets.CF_ORG }}-${{ steps.determine_space.outputs.space }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
@@ -188,10 +213,35 @@ jobs:
188213
noSDMRoleUsername=$noSDMRoleUsername
189214
noSDMRoleUserPassword=$noSDMRoleUserPassword
190215
EOL
216+
echo "βœ… Credentials file prepared!"
217+
218+
- name: Run integration tests (${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}) 🎯
219+
run: |
220+
echo "🎯 Running Maven integration tests: testClass=${{ matrix.testClass }}, tokenFlow=${{ matrix.tokenFlow }}, tenant=${{ matrix.tenant }}"
221+
mvn clean verify -P integration-tests -DtokenFlow=${{ matrix.tokenFlow }} -DtenancyModel=multi -Dtenant=${{ matrix.tenant }} -DskipUnitTests -Dfailsafe.includes="**/${{ matrix.testClass }}.java"
222+
echo "βœ… Integration tests completed for ${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}!"
191223
192-
echo "🎯 Running Maven integration tests"
193-
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests
194-
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests
195-
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests
196-
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests
197-
echo "βœ… Integration tests completed!"
224+
- name: Upload test results πŸ“Š
225+
if: always()
226+
uses: actions/upload-artifact@v4
227+
with:
228+
name: test-results-${{ matrix.testClass }}-${{ matrix.tokenFlow }}-${{ matrix.tenant }}
229+
path: |
230+
sdm/target/surefire-reports/
231+
sdm/target/failsafe-reports/
232+
retention-days: 7
233+
234+
# Summary job to aggregate results
235+
test-summary:
236+
runs-on: ubuntu-latest
237+
needs: integration-test
238+
if: always()
239+
steps:
240+
- name: Check test results πŸ“‹
241+
run: |
242+
if [ "${{ needs.integration-test.result }}" == "success" ]; then
243+
echo "βœ… All integration tests passed!"
244+
else
245+
echo "❌ Some integration tests failed. Check individual job results for details."
246+
exit 1
247+
fi

β€Ž.github/workflows/multiTenant_deploy_and_Integration_test.ymlβ€Ž

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
types: [closed]
66
branches:
77
- develop
8+
89
workflow_dispatch:
910

1011
permissions:
@@ -101,6 +102,15 @@ jobs:
101102
integration-test:
102103
needs: deploy
103104
runs-on: ubuntu-latest
105+
strategy:
106+
fail-fast: false
107+
matrix:
108+
tokenFlow: [namedUser, technicalUser]
109+
tenant: [TENANT1, TENANT2]
110+
testClass:
111+
- IntegrationTest_SingleFacet
112+
- IntegrationTest_MultipleFacet
113+
- IntegrationTest_Chapters_MultipleFacet
104114

105115
steps:
106116
- name: Checkout repository βœ…
@@ -111,14 +121,29 @@ jobs:
111121
with:
112122
java-version: 17
113123
distribution: 'temurin'
124+
cache: 'maven'
125+
126+
- name: Cache CF CLI πŸ“¦
127+
id: cache-cf-cli
128+
uses: actions/cache@v4
129+
with:
130+
path: /usr/bin/cf8
131+
key: cf-cli-v8-${{ runner.os }}
114132

115133
- name: Install Cloud Foundry CLI and jq πŸ“¦
134+
if: steps.cache-cf-cli.outputs.cache-hit != 'true'
116135
run: |
117-
echo "πŸ”§ Installing Cloud Foundry CLI and jq..."
136+
echo "πŸ”§ Installing Cloud Foundry CLI..."
118137
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
119138
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
120139
sudo apt-get update
121-
sudo apt-get install cf8-cli jq
140+
sudo apt-get install cf8-cli
141+
142+
- name: Install jq πŸ“¦
143+
run: |
144+
if ! command -v jq &> /dev/null; then
145+
sudo apt-get update && sudo apt-get install -y jq
146+
fi
122147
123148
- name: Determine Cloud Foundry Space 🌌
124149
id: determine_space
@@ -129,7 +154,7 @@ jobs:
129154
space="${{ github.event.inputs.cf_space }}"
130155
fi
131156
echo "🌍 Space determined: $space"
132-
echo "::set-output name=space::$space"
157+
echo "space=$space" >> $GITHUB_OUTPUT
133158
134159
- name: Login to Cloud Foundry πŸ”‘
135160
run: |
@@ -170,8 +195,8 @@ jobs:
170195
fi
171196
echo "::add-mask::$clientID"
172197
173-
echo "::set-output name=CLIENT_SECRET::$escapedClientSecret"
174-
echo "::set-output name=CLIENT_ID::$clientID"
198+
echo "CLIENT_SECRET=$escapedClientSecret" >> $GITHUB_OUTPUT
199+
echo "CLIENT_ID=$clientID" >> $GITHUB_OUTPUT
175200
echo "βœ… Client details fetched successfully!"
176201
177202
- name: Fetch and Escape Client Details for multi tenant πŸ”
@@ -204,18 +229,18 @@ jobs:
204229
fi
205230
echo "::add-mask::$clientID_mt"
206231
207-
echo "::set-output name=CLIENT_SECRET_MT::$escapedClientSecret_mt"
208-
echo "::set-output name=CLIENT_ID_MT::$clientID_mt"
232+
echo "CLIENT_SECRET_MT=$escapedClientSecret_mt" >> $GITHUB_OUTPUT
233+
echo "CLIENT_ID_MT=$clientID_mt" >> $GITHUB_OUTPUT
209234
echo "βœ… Multi-tenant client details fetched successfully!"
210235
211-
- name: Run integration tests 🎯
236+
- name: Prepare credentials file πŸ“
212237
env:
213238
CLIENT_SECRET: ${{ steps.fetch_credentials.outputs.CLIENT_SECRET }}
214239
CLIENT_ID: ${{ steps.fetch_credentials.outputs.CLIENT_ID }}
215240
CLIENT_SECRET_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_SECRET_MT }}
216241
CLIENT_ID_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_ID_MT }}
217242
run: |
218-
echo "πŸš€ Starting integration tests..."
243+
echo "πŸš€ Preparing credentials for ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}..."
219244
set -e
220245
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
221246
appUrl="${{ secrets.CF_ORG }}-${{ secrets.CF_SPACE }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
@@ -270,10 +295,35 @@ jobs:
270295
noSDMRoleUsername=$noSDMRoleUsername
271296
noSDMRoleUserPassword=$noSDMRoleUserPassword
272297
EOL
298+
echo "βœ… Credentials file prepared!"
299+
300+
- name: Run integration tests (${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}) 🎯
301+
run: |
302+
echo "🎯 Running Maven integration tests: testClass=${{ matrix.testClass }}, tokenFlow=${{ matrix.tokenFlow }}, tenant=${{ matrix.tenant }}"
303+
mvn clean verify -P integration-tests -DtokenFlow=${{ matrix.tokenFlow }} -DtenancyModel=multi -Dtenant=${{ matrix.tenant }} -DskipUnitTests -Dfailsafe.includes="**/${{ matrix.testClass }}.java"
304+
echo "βœ… Integration tests completed for ${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}!"
273305
274-
echo "🎯 Running Maven integration tests"
275-
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests
276-
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests
277-
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests
278-
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests
279-
echo "βœ… Integration tests completed!"
306+
- name: Upload test results πŸ“Š
307+
if: always()
308+
uses: actions/upload-artifact@v4
309+
with:
310+
name: test-results-${{ matrix.testClass }}-${{ matrix.tokenFlow }}-${{ matrix.tenant }}
311+
path: |
312+
sdm/target/surefire-reports/
313+
sdm/target/failsafe-reports/
314+
retention-days: 7
315+
316+
# Summary job to aggregate results
317+
test-summary:
318+
runs-on: ubuntu-latest
319+
needs: integration-test
320+
if: always()
321+
steps:
322+
- name: Check test results πŸ“‹
323+
run: |
324+
if [ "${{ needs.integration-test.result }}" == "success" ]; then
325+
echo "βœ… All integration tests passed!"
326+
else
327+
echo "❌ Some integration tests failed. Check individual job results for details."
328+
exit 1
329+
fi

0 commit comments

Comments
Β (0)