Skip to content
80 changes: 65 additions & 15 deletions .github/workflows/multi tenancy_Integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ on:
default: develop

jobs:
# Parallel integration tests using matrix strategy
integration-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tokenFlow: [namedUser, technicalUser]
tenant: [TENANT1, TENANT2]
testClass:
- IntegrationTest_SingleFacet
- IntegrationTest_MultipleFacet
- IntegrationTest_Chapters_MultipleFacet

steps:
- name: Checkout repository ✅
Expand All @@ -29,14 +39,29 @@ jobs:
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'

- name: Cache CF CLI 📦
id: cache-cf-cli
uses: actions/cache@v4
with:
path: /usr/bin/cf8
key: cf-cli-v8-${{ runner.os }}

- name: Install Cloud Foundry CLI and jq 📦
if: steps.cache-cf-cli.outputs.cache-hit != 'true'
run: |
echo "🔧 Installing Cloud Foundry CLI and jq..."
echo "🔧 Installing Cloud Foundry CLI..."
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli jq
sudo apt-get install cf8-cli

- name: Install jq 📦
run: |
if ! command -v jq &> /dev/null; then
sudo apt-get update && sudo apt-get install -y jq
fi

- name: Determine Cloud Foundry Space 🌌
id: determine_space
Expand All @@ -47,7 +72,7 @@ jobs:
space="${{ github.event.inputs.cf_space }}"
fi
echo "🌍 Space determined: $space"
echo "::set-output name=space::$space"
echo "space=$space" >> $GITHUB_OUTPUT

- name: Login to Cloud Foundry 🔑
run: |
Expand Down Expand Up @@ -88,8 +113,8 @@ jobs:
fi
echo "::add-mask::$clientID"

echo "::set-output name=CLIENT_SECRET::$escapedClientSecret"
echo "::set-output name=CLIENT_ID::$clientID"
echo "CLIENT_SECRET=$escapedClientSecret" >> $GITHUB_OUTPUT
echo "CLIENT_ID=$clientID" >> $GITHUB_OUTPUT
echo "✅ Client details fetched successfully!"

- name: Fetch and Escape Client Details for multi tenant 🔍
Expand Down Expand Up @@ -122,18 +147,18 @@ jobs:
fi
echo "::add-mask::$clientID_mt"

echo "::set-output name=CLIENT_SECRET_MT::$escapedClientSecret_mt"
echo "::set-output name=CLIENT_ID_MT::$clientID_mt"
echo "CLIENT_SECRET_MT=$escapedClientSecret_mt" >> $GITHUB_OUTPUT
echo "CLIENT_ID_MT=$clientID_mt" >> $GITHUB_OUTPUT
echo "✅ Multi-tenant client details fetched successfully!"

- name: Run integration tests 🎯
- name: Prepare credentials file 📝
env:
CLIENT_SECRET: ${{ steps.fetch_credentials.outputs.CLIENT_SECRET }}
CLIENT_ID: ${{ steps.fetch_credentials.outputs.CLIENT_ID }}
CLIENT_SECRET_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_SECRET_MT }}
CLIENT_ID_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_ID_MT }}
run: |
echo "🚀 Starting integration tests..."
echo "🚀 Preparing credentials for ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}..."
set -e
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
appUrl="${{ secrets.CF_ORG }}-${{ steps.determine_space.outputs.space }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
Expand Down Expand Up @@ -188,10 +213,35 @@ jobs:
noSDMRoleUsername=$noSDMRoleUsername
noSDMRoleUserPassword=$noSDMRoleUserPassword
EOL
echo "✅ Credentials file prepared!"

- name: Run integration tests (${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}) 🎯
run: |
echo "🎯 Running Maven integration tests: testClass=${{ matrix.testClass }}, tokenFlow=${{ matrix.tokenFlow }}, tenant=${{ matrix.tenant }}"
mvn clean verify -P integration-tests -DtokenFlow=${{ matrix.tokenFlow }} -DtenancyModel=multi -Dtenant=${{ matrix.tenant }} -DskipUnitTests -Dfailsafe.includes="**/${{ matrix.testClass }}.java"
echo "✅ Integration tests completed for ${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}!"

echo "🎯 Running Maven integration tests"
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests
echo "✅ Integration tests completed!"
- name: Upload test results 📊
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.testClass }}-${{ matrix.tokenFlow }}-${{ matrix.tenant }}
path: |
sdm/target/surefire-reports/
sdm/target/failsafe-reports/
retention-days: 7

# Summary job to aggregate results
test-summary:
runs-on: ubuntu-latest
needs: integration-test
if: always()
steps:
- name: Check test results 📋
run: |
if [ "${{ needs.integration-test.result }}" == "success" ]; then
echo "✅ All integration tests passed!"
else
echo "❌ Some integration tests failed. Check individual job results for details."
exit 1
fi
80 changes: 65 additions & 15 deletions .github/workflows/multiTenant_deploy_and_Integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
types: [closed]
branches:
- develop

workflow_dispatch:

permissions:
Expand Down Expand Up @@ -101,6 +102,15 @@ jobs:
integration-test:
needs: deploy
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tokenFlow: [namedUser, technicalUser]
tenant: [TENANT1, TENANT2]
testClass:
- IntegrationTest_SingleFacet
- IntegrationTest_MultipleFacet
- IntegrationTest_Chapters_MultipleFacet

steps:
- name: Checkout repository ✅
Expand All @@ -111,14 +121,29 @@ jobs:
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'

- name: Cache CF CLI 📦
id: cache-cf-cli
uses: actions/cache@v4
with:
path: /usr/bin/cf8
key: cf-cli-v8-${{ runner.os }}

- name: Install Cloud Foundry CLI and jq 📦
if: steps.cache-cf-cli.outputs.cache-hit != 'true'
run: |
echo "🔧 Installing Cloud Foundry CLI and jq..."
echo "🔧 Installing Cloud Foundry CLI..."
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli jq
sudo apt-get install cf8-cli

- name: Install jq 📦
run: |
if ! command -v jq &> /dev/null; then
sudo apt-get update && sudo apt-get install -y jq
fi

- name: Determine Cloud Foundry Space 🌌
id: determine_space
Expand All @@ -129,7 +154,7 @@ jobs:
space="${{ github.event.inputs.cf_space }}"
fi
echo "🌍 Space determined: $space"
echo "::set-output name=space::$space"
echo "space=$space" >> $GITHUB_OUTPUT

- name: Login to Cloud Foundry 🔑
run: |
Expand Down Expand Up @@ -170,8 +195,8 @@ jobs:
fi
echo "::add-mask::$clientID"

echo "::set-output name=CLIENT_SECRET::$escapedClientSecret"
echo "::set-output name=CLIENT_ID::$clientID"
echo "CLIENT_SECRET=$escapedClientSecret" >> $GITHUB_OUTPUT
echo "CLIENT_ID=$clientID" >> $GITHUB_OUTPUT
echo "✅ Client details fetched successfully!"

- name: Fetch and Escape Client Details for multi tenant 🔍
Expand Down Expand Up @@ -204,18 +229,18 @@ jobs:
fi
echo "::add-mask::$clientID_mt"

echo "::set-output name=CLIENT_SECRET_MT::$escapedClientSecret_mt"
echo "::set-output name=CLIENT_ID_MT::$clientID_mt"
echo "CLIENT_SECRET_MT=$escapedClientSecret_mt" >> $GITHUB_OUTPUT
echo "CLIENT_ID_MT=$clientID_mt" >> $GITHUB_OUTPUT
echo "✅ Multi-tenant client details fetched successfully!"

- name: Run integration tests 🎯
- name: Prepare credentials file 📝
env:
CLIENT_SECRET: ${{ steps.fetch_credentials.outputs.CLIENT_SECRET }}
CLIENT_ID: ${{ steps.fetch_credentials.outputs.CLIENT_ID }}
CLIENT_SECRET_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_SECRET_MT }}
CLIENT_ID_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_ID_MT }}
run: |
echo "🚀 Starting integration tests..."
echo "🚀 Preparing credentials for ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}..."
set -e
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
appUrl="${{ secrets.CF_ORG }}-${{ secrets.CF_SPACE }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
Expand Down Expand Up @@ -270,10 +295,35 @@ jobs:
noSDMRoleUsername=$noSDMRoleUsername
noSDMRoleUserPassword=$noSDMRoleUserPassword
EOL
echo "✅ Credentials file prepared!"

- name: Run integration tests (${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}) 🎯
run: |
echo "🎯 Running Maven integration tests: testClass=${{ matrix.testClass }}, tokenFlow=${{ matrix.tokenFlow }}, tenant=${{ matrix.tenant }}"
mvn clean verify -P integration-tests -DtokenFlow=${{ matrix.tokenFlow }} -DtenancyModel=multi -Dtenant=${{ matrix.tenant }} -DskipUnitTests -Dfailsafe.includes="**/${{ matrix.testClass }}.java"
echo "✅ Integration tests completed for ${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}!"

echo "🎯 Running Maven integration tests"
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests
echo "✅ Integration tests completed!"
- name: Upload test results 📊
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.testClass }}-${{ matrix.tokenFlow }}-${{ matrix.tenant }}
path: |
sdm/target/surefire-reports/
sdm/target/failsafe-reports/
retention-days: 7

# Summary job to aggregate results
test-summary:
runs-on: ubuntu-latest
needs: integration-test
if: always()
steps:
- name: Check test results 📋
run: |
if [ "${{ needs.integration-test.result }}" == "success" ]; then
echo "✅ All integration tests passed!"
else
echo "❌ Some integration tests failed. Check individual job results for details."
exit 1
fi
Loading
Loading