Use AWS JDBC Wrapper in CI tests. Resolves #27123

Signed-off-by: Ryan Emerson <remerson@redhat.com>
This commit is contained in:
Ryan Emerson 2024-02-19 11:11:25 +00:00 committed by Alexander Schwartz
parent 5a71e68c22
commit a2f027ee00
4 changed files with 56 additions and 21 deletions

View file

@ -372,7 +372,7 @@ jobs:
./aws_ec2.sh create ${REGION}
./keycloak_ec2_installer.sh ${REGION} /tmp/keycloak.zip
./mvn_ec2_runner.sh ${REGION} "clean install -B -DskipTests -Pdistribution"
./mvn_ec2_runner.sh ${REGION} "clean install -B -DskipTests -pl testsuite/integration-arquillian/servers/auth-server/quarkus -Pauth-server-quarkus -Dmaven.build.cache.enabled=true"
./mvn_ec2_runner.sh ${REGION} "clean install -B -DskipTests -pl testsuite/integration-arquillian/servers/auth-server/quarkus -Pauth-server-quarkus -Pdb-aurora-postgres -Dmaven.build.cache.enabled=true"
./mvn_ec2_runner.sh ${REGION} "test -B ${{ env.SUREFIRE_RETRY }} -Pauth-server-quarkus -Pdb-${{ matrix.db }} $PROPS -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base 2>&1 | misc/log/trimmer.sh"
# Copy returned surefire-report directories to workspace root to ensure they're discovered

View file

@ -505,19 +505,19 @@
<profile>
<id>db-aurora-postgres</id>
<properties>
<keycloak.storage.connections.vendor>postgres</keycloak.storage.connections.vendor>
<keycloak.connectionsJpa.driver>org.postgresql.Driver</keycloak.connectionsJpa.driver>
<keycloak.storage.connections.vendor>aurora-postgres</keycloak.storage.connections.vendor>
<keycloak.connectionsJpa.driver>software.amazon.jdbc.Driver</keycloak.connectionsJpa.driver>
<keycloak.connectionsJpa.database>keycloak</keycloak.connectionsJpa.database>
<keycloak.connectionsJpa.user>keycloak</keycloak.connectionsJpa.user>
<keycloak.connectionsJpa.password>secret99</keycloak.connectionsJpa.password>
<keycloak.connectionsJpa.jdbcParameters/>
<keycloak.connectionsJpa.url>jdbc:postgresql://${auth.server.db.host}/${keycloak.connectionsJpa.database}${keycloak.connectionsJpa.jdbcParameters}</keycloak.connectionsJpa.url>
<keycloak.connectionsJpa.url>jdbc:aws-wrapper:postgresql://${auth.server.db.host}/${keycloak.connectionsJpa.database}${keycloak.connectionsJpa.jdbcParameters}</keycloak.connectionsJpa.url>
<!-- JDBC properties point to "default" JDBC driver for the particular DB -->
<!-- For EAP testing, it is recommended to override those with system properties pointing to GAV of more appropriate JDBC driver -->
<!-- for the particular EAP version -->
<jdbc.mvn.groupId>org.postgresql</jdbc.mvn.groupId>
<jdbc.mvn.artifactId>postgresql</jdbc.mvn.artifactId>
<jdbc.mvn.version>${postgresql-jdbc.version}</jdbc.mvn.version>
<jdbc.mvn.groupId>software.amazon.jdbc</jdbc.mvn.groupId>
<jdbc.mvn.artifactId>aws-advanced-jdbc-wrapper</jdbc.mvn.artifactId>
<jdbc.mvn.version>${aws-jdbc-wrapper.version}</jdbc.mvn.version>
</properties>
</profile>
<profile>

View file

@ -387,5 +387,36 @@
</plugins>
</build>
</profile>
<profile>
<id>db-aurora-postgres</id>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>includeProprietaryDependencies</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>software.amazon.jdbc</groupId>
<artifactId>aws-advanced-jdbc-wrapper</artifactId>
<version>${aws-jdbc-wrapper.version}</version>
<type>jar</type>
<outputDirectory>${auth.server.home}/providers</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View file

@ -31,27 +31,31 @@ public enum StoreProvider {
JPA("jpa") {
@Override
public void addStoreOptions(List<String> commands) {
getDbVendor().ifPresent(vendor -> commands.add("--db=" + vendor));
commands.add("--db-username=" + System.getProperty("keycloak.connectionsJpa.user"));
commands.add("--db-password=" + System.getProperty("keycloak.connectionsJpa.password"));
if ("mssql".equals(getDbVendor().orElse(null))){
commands.add("--transaction-xa-enabled=false");
}
commands.add("--db-url=" + System.getProperty("keycloak.connectionsJpa.url"));
addOptions("--", commands);
}
@Override
public List<String> getStoreOptionsToKeycloakConfImport() {
List<String> options = new ArrayList<>();
getDbVendor().ifPresent(vendor -> options.add("db=" + vendor));
options.add("db-url=" + System.getProperty("keycloak.connectionsJpa.url"));
options.add("db-username=" + System.getProperty("keycloak.connectionsJpa.user"));
options.add("db-password=" + System.getProperty("keycloak.connectionsJpa.password"));
if ("mssql".equals(getDbVendor().orElse(null))){
options.add("transaction-xa-enabled=false");
}
addOptions("", options);
return options;
}
private void addOptions(String prefix, List<String> options) {
getDbVendor().ifPresent(vendor -> {
if ("mssql".equals(vendor)) {
options.add(prefix + "transaction-xa-enabled=false");
} else if ("aurora-postgres".equals(vendor)){
vendor = "postgres";
options.add(prefix + "db-driver=" + System.getProperty("keycloak.connectionsJpa.driver"));
options.add(prefix + "transaction-xa-enabled=false");
}
options.add(prefix + "db=" + vendor);
});
options.add(prefix + "db-username=" + System.getProperty("keycloak.connectionsJpa.user"));
options.add(prefix + "db-password=" + System.getProperty("keycloak.connectionsJpa.password"));
options.add(prefix + "db-url=" + System.getProperty("keycloak.connectionsJpa.url"));
}
},
DEFAULT("default") {
@Override