Run new test framework db tests on Azure (#45735)

* Run new test framework db tests on Azure

Closes: #45658

Signed-off-by: Peter Zaoral <pepo48@gmail.com>

* Run new test framework db tests on Azure

Closes: #45658

Signed-off-by: Peter Zaoral <pepo48@gmail.com>

---------

Signed-off-by: Peter Zaoral <pepo48@gmail.com>
This commit is contained in:
Peter Zaoral 2026-01-27 09:11:37 +01:00 committed by GitHub
parent 521c826003
commit d2be206a9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 89 additions and 4 deletions

View file

@ -19,7 +19,7 @@ runs:
- name: Run new base tests
shell: bash
run: |
KC_TEST_DATABASE=${{ inputs.db }} KC_TEST_DATABASE_REUSE=true TESTCONTAINERS_REUSE_ENABLE=true ./mvnw package -f tests/pom.xml -Dtest=DatabaseTestSuite -Dkeycloak.distribution.start.timeout=360
KC_TEST_DATABASE=${{ inputs.db }} KC_TEST_DATABASE_REUSE=true TESTCONTAINERS_REUSE_ENABLE=true ./mvnw package -f tests/pom.xml -Dtest=DatabaseTestSuite -Dkc.test.server.start.timeout=360
- name: Database container port
shell: bash

View file

@ -24,6 +24,8 @@
async: 86400
poll: 10
register: result
# Allow playbook to continue to collect test results even when tests fail
ignore_errors: yes
- debug: var=result
@ -52,3 +54,8 @@
mode: pull
with_items:
- "{{ output.files }}"
- name: Fail if Maven command failed
fail:
msg: "Maven command failed with return code {{ result.rc }}: {{ result.stderr | default('') }}"
when: result.rc != 0

View file

@ -0,0 +1,7 @@
-- Clear all tables from dbo schema (MSSQL equivalent of PostgreSQL schema reset)
-- Drop all foreign key constraints first
EXEC sp_executesql N'DECLARE @sql NVARCHAR(MAX) = N''''; SELECT @sql += N''ALTER TABLE '' + QUOTENAME(s.name) + ''.'' + QUOTENAME(t.name) + '' DROP CONSTRAINT '' + QUOTENAME(f.name) + '';'' FROM sys.foreign_keys f INNER JOIN sys.tables t ON f.parent_object_id = t.object_id INNER JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE s.name = ''dbo''; EXEC sp_executesql @sql;'
-- Drop all tables
EXEC sp_executesql N'DECLARE @sql NVARCHAR(MAX) = N''''; SELECT @sql += N''DROP TABLE '' + QUOTENAME(s.name) + ''.'' + QUOTENAME(t.name) + '';'' FROM sys.tables t INNER JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE s.name = ''dbo''; EXEC sp_executesql @sql;'

View file

@ -588,7 +588,7 @@ jobs:
AWS_REGION=${{ steps.aurora-init.outputs.region }}
cd .github/scripts/ansible
./mvn_remote_runner.sh ${AWS_REGION} ${EC2_CLUSTER_NAME} "-Pexecute-sql -f tests/base/pom.xml sql:execute@clear-schema -Dautocommit=true -Ddriver=software.amazon.jdbc.Driver -Durl=\"jdbc:aws-wrapper:postgresql://${{ steps.aurora-create.outputs.endpoint }}/keycloak${{ steps.aurora-init.outputs.jdbc_params }}\" -Dusername=keycloak -Dpassword=${{ steps.aurora-init.outputs.aurora-cluster-password }}"
./mvn_remote_runner.sh ${AWS_REGION} ${EC2_CLUSTER_NAME} "-Pexecute-sql -f tests/base/pom.xml sql:execute@clear-schema-psql -Dautocommit=true -Ddriver=software.amazon.jdbc.Driver -Durl=\"jdbc:aws-wrapper:postgresql://${{ steps.aurora-create.outputs.endpoint }}/keycloak${{ steps.aurora-init.outputs.jdbc_params }}\" -Dusername=keycloak -Dpassword=${{ steps.aurora-init.outputs.aurora-cluster-password }}"
- name: Run Aurora new database tests on EC2
id: aurora-new-integration-tests
@ -620,7 +620,7 @@ jobs:
- name: EC2 Maven Logs
if: failure()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: aurora-new-integration-tests-mvn-logs
path: .github/scripts/ansible/files
@ -775,6 +775,7 @@ jobs:
# Copy returned surefire-report directories to workspace root to ensure they're discovered
results=(files/keycloak/results/*)
rsync -a $results/* ../../../
rm -rf $results
- uses: ./.github/actions/upload-flaky-tests
name: Upload flaky tests
@ -783,6 +784,63 @@ jobs:
with:
job-name: AzureDB IT
- name: Azure VM Maven Logs
if: failure()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: azure-integration-tests-mvn-logs
path: .github/scripts/ansible/files
- name: Clear Azure DB schema
id: azure-clear-db-schema
run: |
AZ_VM_CLUSTER_NAME=${{ steps.vm-create.outputs.az_vm_cluster }}
AZURE_REGION=${{ steps.azure-init.outputs.region }}
cd .github/scripts/ansible
./mvn_remote_runner.sh ${AZURE_REGION} ${AZ_VM_CLUSTER_NAME} "-Pexecute-sql -f tests/base/pom.xml sql:execute@clear-schema-mssql -Dautocommit=true -Ddriver=com.microsoft.sqlserver.jdbc.SQLServerDriver -Durl=\"jdbc:sqlserver://${{ steps.azure-create.outputs.endpoint }}:1433;databaseName=${{ steps.azure-create.outputs.db }};encrypt=true;trustServerCertificate=false\" -Dusername=${{ steps.azure-create.outputs.username }} -Dpassword=${{ env.AZURE_DB_PASSWORD }}"
- name: Run Azure new database tests on VM
id: azure-new-integration-tests
run: |
AZ_VM_CLUSTER_NAME=${{ steps.vm-create.outputs.az_vm_cluster }}
AZURE_REGION=${{ steps.azure-init.outputs.region }}
PROPS="-Dkc.test.database=remote -Dkc.test.database.vendor=mssql"
PROPS+=" -Dkc.test.database.user=${{ steps.azure-create.outputs.username }}"
PROPS+=" -Dkc.test.database.password=${{ env.AZURE_DB_PASSWORD }}"
PROPS+=" -Dkc.test.database.url=\"jdbc:sqlserver://${{ steps.azure-create.outputs.endpoint }}:1433;databaseName=${{ steps.azure-create.outputs.db }};encrypt=true;trustServerCertificate=false;sendStringParametersAsUnicode=false\""
PROPS+=" -Dkc.test.database.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver"
PROPS+=" -Dkc.test.database.driver.artifact=com.microsoft.sqlserver:mssql-jdbc"
PROPS+=" -Dkc.test.server.start.timeout=360"
cd .github/scripts/ansible
set +e
./mvn_remote_runner.sh ${AZURE_REGION} ${AZ_VM_CLUSTER_NAME} "$PROPS package -f tests/pom.xml -Dtest=DatabaseTestSuite"
MVN_EXIT=$?
set -e
# Copy returned surefire-report directories to workspace root to ensure they're discovered
results=(files/keycloak/results/*)
rsync -a $results/* ../../../
rm -rf $results
exit $MVN_EXIT
- uses: ./.github/actions/upload-flaky-tests
name: Upload flaky tests
env:
GH_TOKEN: ${{ github.token }}
with:
job-name: AzureDB IT
- name: Azure VM Maven Logs
if: failure()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: azure-new-integration-tests-mvn-logs
path: .github/scripts/ansible/files
- name: Delete all Azure resources (resource group)
if: always()
working-directory: .github/scripts/ansible

View file

@ -160,16 +160,29 @@
<artifactId>postgresql</artifactId>
<version>${postgresql-jdbc.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${mssql-jdbc.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>clear-schema</id>
<id>clear-schema-psql</id>
<configuration>
<srcFiles>
<srcFile>../../.github/scripts/aws/rds/pg_clear.sql</srcFile>
</srcFiles>
</configuration>
</execution>
<execution>
<id>clear-schema-mssql</id>
<configuration>
<srcFiles>
<srcFile>../../.github/scripts/azure/sql/mssql_clear.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>