KEYCLOAK-10400 KEYCLOAK-10299 DBAllocator plugin fixes. Updated oracle version to 12cR1RAC
This commit is contained in:
parent
0007bad6f3
commit
be2e1c333e
8 changed files with 134 additions and 18 deletions
|
@ -105,7 +105,7 @@ In order to use the DB Allocator Service, you must use the `jpa` profile with on
|
|||
run JPA with Auth Server Wildfly and MSSQL 2016:
|
||||
|
||||
```
|
||||
mvn -f testsuite/integration-arquillian/pom.xml \
|
||||
mvn -f testsuite/integration-arquillian/pom.xml clean verify \
|
||||
-Pjpa,auth-server-wildfly,db-allocator-db-mssql2016 \
|
||||
-Ddballocator.uri=<<db-allocator-servlet-url>> \
|
||||
-Ddballocator.user=<<db-allocator-user>> \
|
||||
|
@ -115,7 +115,11 @@ mvn -f testsuite/integration-arquillian/pom.xml \
|
|||
Using `-Dmaven.test.failure.ignore=true` is not strictly required but highly recommended. After running the tests,
|
||||
the DB Allocator Plugin should release the allocated database.
|
||||
|
||||
**NOTE**: If you killed the maven surefire test preliminary (for example with CTRL-C or `kill -9` command), it will be
|
||||
good to manually release the allocated database. Please check `dballocator.uri` and add `?operation=report` to the end of the URL.
|
||||
Find your DB in the GUI and release it manually.
|
||||
|
||||
Below is a just a sample of implemented profiles. In order to get a full list, please invoke (`mvn help:all-profiles -pl testsuite/integration-arquillian | grep -- db-allocator-db-`):
|
||||
|
||||
* `db-allocator-db-postgres` - dor testing with Postgres 9.6.x
|
||||
* `db-allocator-db-mysql` - dor testing with MySQL 5.7
|
||||
* `db-allocator-db-postgres` - for testing with Postgres 9.6.x
|
||||
* `db-allocator-db-mysql` - for testing with MySQL 5.7
|
|
@ -10,6 +10,7 @@ import org.apache.maven.plugins.annotations.Parameter;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.keycloak.testsuite.dballocator.client.data.AllocationResult;
|
||||
import org.keycloak.testsuite.dballocator.client.DBAllocatorServiceClient;
|
||||
import org.keycloak.testsuite.dballocator.client.data.EraseResult;
|
||||
import org.keycloak.testsuite.dballocator.client.exceptions.DBAllocatorException;
|
||||
import org.keycloak.testsuite.dballocator.client.retry.IncrementalBackoffRetryPolicy;
|
||||
|
||||
|
@ -147,6 +148,12 @@ public class AllocateDBMojo extends AbstractMojo {
|
|||
logger.info("-- URL: " + allocate.getURL());
|
||||
}
|
||||
|
||||
EraseResult eraseResult = client.erase(allocate);
|
||||
if (printSummary) {
|
||||
logger.info("Erased database:");
|
||||
logger.info("-- UUID: " + eraseResult.getUUID());
|
||||
}
|
||||
|
||||
} catch (DBAllocatorException e) {
|
||||
String error = e.getMessage();
|
||||
if (e.getErrorResponse() != null) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.apache.http.impl.client.HttpClientBuilder;
|
|||
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
|
||||
import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine;
|
||||
import org.keycloak.testsuite.dballocator.client.data.AllocationResult;
|
||||
import org.keycloak.testsuite.dballocator.client.data.EraseResult;
|
||||
import org.keycloak.testsuite.dballocator.client.data.ReleaseResult;
|
||||
import org.keycloak.testsuite.dballocator.client.exceptions.DBAllocatorException;
|
||||
import org.keycloak.testsuite.dballocator.client.retry.IncrementalBackoffRetryPolicy;
|
||||
|
@ -83,6 +84,21 @@ public class DBAllocatorServiceClient {
|
|||
}
|
||||
}
|
||||
|
||||
public EraseResult erase(AllocationResult allocationResult) throws DBAllocatorException {
|
||||
Objects.requireNonNull(allocationResult, "Previous allocation result must not be null");
|
||||
Objects.requireNonNull(allocationResult.getUUID(), "UUID must not be null");
|
||||
|
||||
Invocation.Builder target = restClient
|
||||
.target(allocatorServletURI)
|
||||
.queryParam("operation", "erase")
|
||||
.queryParam("uuid", allocationResult.getUUID())
|
||||
.request();
|
||||
|
||||
try (Response response = retryPolicy.retryTillHttpOk(() -> target.get())) {
|
||||
return EraseResult.successful(allocationResult.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
public ReleaseResult release(AllocationResult allocationResult) throws DBAllocatorException {
|
||||
Objects.requireNonNull(allocationResult, "Previous allocation result must not be null");
|
||||
Objects.requireNonNull(allocationResult.getUUID(), "UUID must not be null");
|
||||
|
@ -93,8 +109,8 @@ public class DBAllocatorServiceClient {
|
|||
.queryParam("uuid", allocationResult.getUUID())
|
||||
.request();
|
||||
|
||||
retryPolicy.retryTillHttpOk(() -> target.get());
|
||||
|
||||
return ReleaseResult.successful(allocationResult.getUUID());
|
||||
try (Response response = retryPolicy.retryTillHttpOk(() -> target.get())) {
|
||||
return ReleaseResult.successful(allocationResult.getUUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright 2017 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.keycloak.testsuite.dballocator.client.data;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
public class EraseResult {
|
||||
|
||||
private final String uuid;
|
||||
|
||||
private EraseResult(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public static EraseResult successful(String uuid) {
|
||||
return new EraseResult(uuid);
|
||||
}
|
||||
|
||||
public String getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EraseResult{" +
|
||||
"uuid='" + uuid + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -4,13 +4,14 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.testsuite.dballocator.client.data.AllocationResult;
|
||||
import org.keycloak.testsuite.dballocator.client.data.EraseResult;
|
||||
import org.keycloak.testsuite.dballocator.client.data.ReleaseResult;
|
||||
import org.keycloak.testsuite.dballocator.client.exceptions.DBAllocatorException;
|
||||
import org.keycloak.testsuite.dballocator.client.exceptions.DBAllocatorUnavailableException;
|
||||
import org.keycloak.testsuite.dballocator.client.mock.MockResponse;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -42,6 +43,9 @@ public class DBAllocatorServiceClientTest {
|
|||
Assert.assertEquals("username", allocationResult.getUser());
|
||||
Assert.assertEquals("password", allocationResult.getPassword());
|
||||
Assert.assertEquals("jdbc:mariadb://mariadb-101-galera.keycloak.org:3306", allocationResult.getURL());
|
||||
|
||||
EraseResult erase = client.erase(allocationResult);
|
||||
ReleaseResult result = client.release(allocationResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -74,7 +74,6 @@ public class MockResponse extends Response {
|
|||
|
||||
@Override
|
||||
public void close() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -287,6 +287,8 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<!-- Just allocate the DB now. It will be released after the tests, so the "release" is declared in the base-tests module -->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.keycloak</groupId>
|
||||
|
@ -299,12 +301,6 @@
|
|||
<goal>allocate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>release-db</id>
|
||||
<goals>
|
||||
<goal>release</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
@ -407,6 +403,9 @@
|
|||
<keycloak.connectionsJpa.password>keycloak</keycloak.connectionsJpa.password>
|
||||
<!-- Disable SSL is needed when using newer JDBC drivers like mysql 8.0.12 to avoid warnings in the log -->
|
||||
<keycloak.connectionsJpa.url>jdbc:mysql://${auth.server.db.host}/${keycloak.connectionsJpa.database}?useSSL=false</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>mysql</jdbc.mvn.groupId>
|
||||
<jdbc.mvn.artifactId>mysql-connector-java</jdbc.mvn.artifactId>
|
||||
<jdbc.mvn.version>${mysql.version}</jdbc.mvn.version>
|
||||
|
@ -420,6 +419,9 @@
|
|||
<profile>
|
||||
<id>db-allocator-db-mysql</id>
|
||||
<properties>
|
||||
<!-- 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>mysql</jdbc.mvn.groupId>
|
||||
<jdbc.mvn.artifactId>mysql-connector-java</jdbc.mvn.artifactId>
|
||||
<jdbc.mvn.version>${mysql.version}</jdbc.mvn.version>
|
||||
|
@ -435,6 +437,9 @@
|
|||
<keycloak.connectionsJpa.user>keycloak</keycloak.connectionsJpa.user>
|
||||
<keycloak.connectionsJpa.password>keycloak</keycloak.connectionsJpa.password>
|
||||
<keycloak.connectionsJpa.url>jdbc:postgresql://${auth.server.db.host}/${keycloak.connectionsJpa.database}</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.version}</jdbc.mvn.version>
|
||||
|
@ -448,6 +453,9 @@
|
|||
<profile>
|
||||
<id>db-allocator-db-postgres</id>
|
||||
<properties>
|
||||
<!-- 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.version}</jdbc.mvn.version>
|
||||
|
@ -463,6 +471,9 @@
|
|||
<keycloak.connectionsJpa.user>keycloak</keycloak.connectionsJpa.user>
|
||||
<keycloak.connectionsJpa.password>keycloak</keycloak.connectionsJpa.password>
|
||||
<keycloak.connectionsJpa.url>jdbc:mariadb://${auth.server.db.host}/${keycloak.connectionsJpa.database}</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.mariadb.jdbc</jdbc.mvn.groupId>
|
||||
<jdbc.mvn.artifactId>mariadb-java-client</jdbc.mvn.artifactId>
|
||||
<jdbc.mvn.version>${mariadb.version}</jdbc.mvn.version>
|
||||
|
@ -477,6 +488,9 @@
|
|||
<profile>
|
||||
<id>db-allocator-db-mariadb</id>
|
||||
<properties>
|
||||
<!-- 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.mariadb.jdbc</jdbc.mvn.groupId>
|
||||
<jdbc.mvn.artifactId>mariadb-java-client</jdbc.mvn.artifactId>
|
||||
<jdbc.mvn.version>${mariadb.version}</jdbc.mvn.version>
|
||||
|
@ -498,6 +512,9 @@
|
|||
<keycloak.connectionsJpa.user>sa</keycloak.connectionsJpa.user>
|
||||
<keycloak.connectionsJpa.password>vEry5tron9Pwd</keycloak.connectionsJpa.password>
|
||||
<keycloak.connectionsJpa.url>jdbc:sqlserver://${auth.server.db.host}:${docker.database.port};databaseName=${keycloak.connectionsJpa.database}</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>com.microsoft.sqlserver</jdbc.mvn.groupId>
|
||||
<jdbc.mvn.artifactId>mssql-jdbc</jdbc.mvn.artifactId>
|
||||
<jdbc.mvn.version>${mssql.version}</jdbc.mvn.version>
|
||||
|
@ -506,6 +523,9 @@
|
|||
<profile>
|
||||
<id>db-allocator-db-mssql2016</id>
|
||||
<properties>
|
||||
<!-- 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>com.microsoft.sqlserver</jdbc.mvn.groupId>
|
||||
<jdbc.mvn.artifactId>mssql-jdbc</jdbc.mvn.artifactId>
|
||||
<jdbc.mvn.version>${mssql.version}</jdbc.mvn.version>
|
||||
|
@ -528,18 +548,24 @@
|
|||
<keycloak.connectionsJpa.password>keycloak</keycloak.connectionsJpa.password>
|
||||
<keycloak.connectionsJpa.url>jdbc:oracle:thin:@${auth.server.db.host}:${docker.database.port}:${keycloak.connectionsJpa.database}</keycloak.connectionsJpa.url>
|
||||
<docker.database.postStart>bash -c while\ !\ sqlplus\ -L\ SYS/sa@localhost/XE\ AS\ SYSDBA\ <<<\ $'CREATE\ USER\ ${keycloak.connectionsJpa.user}\ IDENTIFIED\ BY\ ${keycloak.connectionsJpa.password};\n\ GRANT\ CONNECT,\ RESOURCE,\ DBA,\ GRANT\ ANY\ PRIVILEGE,\ UNLIMITED\ TABLESPACE\ TO\ ${keycloak.connectionsJpa.user};\n';\ do\ sleep\ 5;\ done</docker.database.postStart>
|
||||
<!-- 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>com.oracle</jdbc.mvn.groupId>
|
||||
<jdbc.mvn.artifactId>ojdbc7</jdbc.mvn.artifactId>
|
||||
<jdbc.mvn.version>12.1.0</jdbc.mvn.version>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>db-allocator-db-oracle11g</id>
|
||||
<id>db-allocator-db-oracle12cR1RAC</id>
|
||||
<properties>
|
||||
<!-- 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>com.oracle</jdbc.mvn.groupId>
|
||||
<jdbc.mvn.artifactId>ojdbc7</jdbc.mvn.artifactId>
|
||||
<jdbc.mvn.version>12.1.0</jdbc.mvn.version>
|
||||
<dballocator.type>oracle11gR1</dballocator.type>
|
||||
<jdbc.mvn.artifactId>ojdbc8</jdbc.mvn.artifactId>
|
||||
<jdbc.mvn.version>12.2.0.1</jdbc.mvn.version>
|
||||
<dballocator.type>oracle12cR1RAC</dballocator.type>
|
||||
<dballocator.skip>false</dballocator.skip>
|
||||
</properties>
|
||||
</profile>
|
||||
|
|
|
@ -384,6 +384,21 @@
|
|||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- DB will be released after the test -->
|
||||
<plugin>
|
||||
<groupId>org.keycloak</groupId>
|
||||
<artifactId>db-allocator-plugin</artifactId>
|
||||
<inherited>false</inherited>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>release-db</id>
|
||||
<goals>
|
||||
<goal>release</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
|
Loading…
Reference in a new issue