Remove Legacy migration tests from testsuite (#14310)

Closes #14300
This commit is contained in:
Martin Bartoš 2022-09-14 05:29:53 -04:00 committed by GitHub
parent 45765d2e19
commit ed3d003d65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 39 additions and 495 deletions

View file

@ -171,39 +171,13 @@ mvn -f testsuite/integration-arquillian/pom.xml \
### DB migration test ### DB migration test
This test will: This test will:
- start MySQL DB on docker container. Docker on your laptop is a requirement for this test. - start MariaDB on docker container. Docker/Podman on your laptop is a requirement for this test.
- start Keycloak 4.8.3.Final (replace with the other version if needed) - start Keycloak 17.0.0 (replace with the other version if needed)
- import realm and add some data to MySQL DB - import realm and add some data to MariaDB
- stop Keycloak 4.8.3.Final - stop Keycloak 17.0.0
- start latest Keycloak, which automatically updates DB from 4.8.3.Final - start latest Keycloak, which automatically updates DB from 17.0.0
- Perform couple of tests to verify data after the update are correct - Perform a couple of tests to verify data after the update are correct
- Stop MySQL DB docker container. In case of a test failure, the MySQL container is not stopped, so you can manually inspect the database. - Stop MariaDB docker container. In case of a test failure, the MariaDB container is not stopped, so you can manually inspect the database.
Run the test (Update according to your DB connection, versions etc):
export OLD_KEYCLOAK_VERSION=4.8.3.Final
mvn -B -f testsuite/integration-arquillian/pom.xml \
clean install \
-Pjpa,auth-server-wildfly,db-mariadb,auth-server-migration-legacy \
-Dauth.server.jboss.startup.timeout=900 \
-Dtest=MigrationTest \
-Dmigration.mode=auto \
-Dmigrated.auth.server.version=$OLD_KEYCLOAK_VERSION \
-Dprevious.product.unpacked.folder.name=keycloak-$OLD_KEYCLOAK_VERSION \
-Dmigration.import.file.name=migration-realm-$OLD_KEYCLOAK_VERSION.json \
-Dauth.server.ssl.required=false \
-Djdbc.mvn.version=2.2.4 \
-Dsurefire.failIfNoSpecifiedTests=false
For the available versions of old keycloak server, you can take a look to [this directory](tests/base/src/test/resources/migration-test) .
### DB migration test with Quarkus
It is possible to execute DB migration tests for Keycloak with Quarkus distribution by specifying auth server as `-Pauth-server-quarkus`
and instead of the `auth-server-migration-legacy`, use only `auth-server-migration`.
The first version of Keycloak on Quarkus is version `17.0.0`. The first version of Keycloak on Quarkus is version `17.0.0`.
Therefore, it is not possible to define the older version. Therefore, it is not possible to define the older version.
@ -224,6 +198,8 @@ mvn -B -f testsuite/integration-arquillian/pom.xml \
-Dsurefire.failIfNoSpecifiedTests=false -Dsurefire.failIfNoSpecifiedTests=false
``` ```
For the available versions of old keycloak server, you can take a look to [this directory](tests/base/src/test/resources/migration-test) .
### DB migration test with manual mode ### DB migration test with manual mode
Same test as above, but it uses manual migration mode. During startup of the new Keycloak server, Liquibase won't automatically perform DB update, but it Same test as above, but it uses manual migration mode. During startup of the new Keycloak server, Liquibase won't automatically perform DB update, but it

View file

@ -1,154 +0,0 @@
<?xml version="1.0"?>
<!--
~ Copyright 2022 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.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-migration-server-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>integration-arquillian-migration-server-legacy</artifactId>
<packaging>pom</packaging>
<name>Migration Server Legacy</name>
<properties>
<common.resources>${basedir}/../../auth-server/jboss/common</common.resources>
<ant.scenario>scenario-standalone</ant.scenario>
<auth.server.dist.artifactId>keycloak-server-dist</auth.server.dist.artifactId>
<auth.server.output.directory>auth-server-migration-legacy</auth.server.output.directory>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-keystore</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${auth.server.home}/standalone/configuration</outputDirectory>
<resources>
<resource>
<directory>${common.resources}/keystore</directory>
<includes>
<include>keycloak.jks</include>
<include>keycloak.truststore</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>configure-server-jpa</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant antfile="${common.resources}/ant/configure.xml" target="configure-server-jpa-legacy">
<!-- These properties become equivalent to properties defined on the command line. -->
<!-- Without specifying those the default values would be used regardless what is -->
<!-- defined via -Dproperty=value when executing maven command -->
<property name="jdbc.driver.tmp.dir">${jdbc.driver.tmp.dir}</property>
<property name="jdbc.mvn.artifactId">${jdbc.mvn.artifactId}</property>
<property name="jdbc.mvn.version">${jdbc.mvn.version}</property>
<property name="keycloak.connectionsJpa.url">${keycloak.connectionsJpa.url}</property>
<property name="keycloak.connectionsJpa.user">${keycloak.connectionsJpa.user}</property>
<property name="keycloak.connectionsJpa.password">${keycloak.connectionsJpa.password}</property>
<property name="keycloak.connectionsJpa.schema">${keycloak.connectionsJpa.schema}</property>
</ant>
</target>
</configuration>
</execution>
<execution>
<id>inject-truststore</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant antfile="${common.resources}/ant/configure.xml" target="inject-truststore" />
</target>
</configuration>
</execution>
<execution>
<id>ant-apply-prepared-clis</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant antfile="${common.resources}/ant/configure.xml" target="apply-cli-scripts" />
</target>
</configuration>
</execution>
<execution>
<!-- to workaround the fact that in older wildlfy/eap versions was missing the option -->
<!-- 'module-root-dir' when adding module we need to move it manually afterwards -->
<id>move-driver-module</id>
<phase>process-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<move file="${auth.server.home}/modules/test" todir="${auth.server.home}/modules/system/layers/base/" verbose="true" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>create-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>../assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -25,14 +25,15 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>integration-arquillian-migration-server-parent</artifactId> <artifactId>integration-arquillian-migration-server</artifactId>
<name>Migration Server Parent</name>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Migration Server Quarkus</name>
<properties> <properties>
<auth.server.output.directory>auth-server-migration</auth.server.output.directory>
<auth.server.home>${project.build.directory}/unpacked/keycloak-${migrated.auth.server.version} <auth.server.home>${project.build.directory}/unpacked/keycloak-${migrated.auth.server.version}
</auth.server.home> </auth.server.home>
<auth.server.dist.artifactId>keycloak-quarkus-dist</auth.server.dist.artifactId>
<jdbc.driver.tmp.dir>${project.build.directory}/jdbc-driver</jdbc.driver.tmp.dir> <jdbc.driver.tmp.dir>${project.build.directory}/jdbc-driver</jdbc.driver.tmp.dir>
</properties> </properties>
@ -101,7 +102,7 @@
<artifactItems> <artifactItems>
<artifactItem> <artifactItem>
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
<artifactId>${auth.server.dist.artifactId}</artifactId> <artifactId>keycloak-quarkus-dist</artifactId>
<version>${migrated.auth.server.version}</version> <version>${migrated.auth.server.version}</version>
<type>zip</type> <type>zip</type>
<outputDirectory>${project.build.directory}/unpacked</outputDirectory> <outputDirectory>${project.build.directory}/unpacked</outputDirectory>
@ -130,30 +131,29 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>create-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles> <profiles>
<profile>
<id>auth-server-migration-legacy</id>
<modules>
<module>legacy</module>
</modules>
<properties>
<auth.server.dist.artifactId>keycloak-server-dist</auth.server.dist.artifactId>
</properties>
</profile>
<profile>
<id>auth-server-migration</id>
<modules>
<module>quarkus</module>
</modules>
<properties>
<auth.server.dist.artifactId>keycloak-quarkus-dist</auth.server.dist.artifactId>
</properties>
</profile>
<profile> <profile>
<id>community</id> <id>community</id>
<activation> <activation>
@ -182,7 +182,8 @@
</property> </property>
</activation> </activation>
<properties> <properties>
<auth.server.home>${project.build.directory}/unpacked/${previous.product.unpacked.folder.name}</auth.server.home> <auth.server.home>${project.build.directory}/unpacked/${previous.product.unpacked.folder.name}
</auth.server.home>
</properties> </properties>
</profile> </profile>
</profiles> </profiles>

View file

@ -1,62 +0,0 @@
<?xml version="1.0"?>
<!--
~ Copyright 2022 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.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-migration-server-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>integration-arquillian-migration-server-quarkus</artifactId>
<packaging>pom</packaging>
<name>Migration Server Quarkus</name>
<properties>
<auth.server.dist.artifactId>keycloak-quarkus-dist</auth.server.dist.artifactId>
<auth.server.output.directory>auth-server-migration</auth.server.output.directory>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>create-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>../assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -66,13 +66,6 @@
</modules> </modules>
</profile> </profile>
<profile>
<id>auth-server-migration-legacy</id>
<modules>
<module>migration</module>
</modules>
</profile>
<profile> <profile>
<id>win</id> <id>win</id>
<activation> <activation>

View file

@ -330,7 +330,7 @@ public class AuthServerTestEnricher {
// init migratedAuthServerInfo // init migratedAuthServerInfo
for (ContainerInfo container : suiteContext.getContainers()) { for (ContainerInfo container : suiteContext.getContainers()) {
// migrated auth server // migrated auth server
if (container.getQualifier().equals("auth-server-jboss-migration") || container.getQualifier().equals("auth-server-migration")) { if (container.getQualifier().equals("auth-server-migration")) {
updateWithAuthServerInfo(container); updateWithAuthServerInfo(container);
suiteContext.setMigratedAuthServerInfo(container); suiteContext.setMigratedAuthServerInfo(container);
} }
@ -338,7 +338,7 @@ public class AuthServerTestEnricher {
// validate setup // validate setup
if (suiteContext.getMigratedAuthServerInfo() == null) { if (suiteContext.getMigratedAuthServerInfo() == null) {
throw new RuntimeException("Migration test was enabled but no auth server from which to migrate was activated. " throw new RuntimeException("Migration test was enabled but no auth server from which to migrate was activated. "
+ "A container matching 'auth-server-jboss-migration' or 'auth-server-migration' needs to be enabled in arquillian.xml."); + "A container matching 'auth-server-migration' needs to be enabled in arquillian.xml.");
} }
} }

View file

@ -25,13 +25,13 @@ import org.keycloak.testsuite.arquillian.migration.Migration;
import javax.ws.rs.NotFoundException; import javax.ws.rs.NotFoundException;
import java.util.List; import java.util.List;
import org.keycloak.models.RealmModel;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer; import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer;
import static org.keycloak.testsuite.auth.page.AuthRealm.MASTER; import static org.keycloak.testsuite.auth.page.AuthRealm.MASTER;
/** /**
* Test for DB migration with legacy JPA store
*
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a> * @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
*/ */
public class MigrationTest extends AbstractMigrationTest { public class MigrationTest extends AbstractMigrationTest {
@ -70,111 +70,4 @@ public class MigrationTest extends AbstractMigrationTest {
testMigrationTo20_x(); testMigrationTo20_x();
} }
@Test
@Migration(versionPrefix = "9.")
@AuthServerContainerExclude(AuthServer.QUARKUS)
public void migration9_xTest() throws Exception {
testMigratedData(false);
testMigrationTo12_x(true);
testMigrationTo18_x();
testMigrationTo19_x();
testMigrationTo20_x();
// Always test offline-token login during migration test
testOfflineTokenLogin();
testExtremelyLongClientAttribute(migrationRealm);
}
@Test
@Migration(versionPrefix = "4.")
@AuthServerContainerExclude(AuthServer.QUARKUS)
public void migration4_xTest() throws Exception {
testMigratedData();
testMigrationTo5_x();
testMigrationTo6_x();
testMigrationTo7_x(true);
testMigrationTo8_x();
testMigrationTo9_x();
testMigrationTo12_x(true);
testMigrationTo18_x();
testMigrationTo19_x();
testMigrationTo20_x();
// Always test offline-token login during migration test
testOfflineTokenLogin();
testExtremelyLongClientAttribute(migrationRealm);
}
@Test
@Migration(versionPrefix = "3.")
@AuthServerContainerExclude(AuthServer.QUARKUS)
public void migration3_xTest() throws Exception {
testMigratedData();
testMigrationTo4_x();
testMigrationTo5_x();
testMigrationTo6_x();
testMigrationTo7_x(true);
testMigrationTo8_x();
testMigrationTo9_x();
testMigrationTo12_x(true);
testMigrationTo18_x();
testMigrationTo19_x();
testMigrationTo20_x();
// Always test offline-token login during migration test
testOfflineTokenLogin();
}
@Test
@Migration(versionPrefix = "2.")
@AuthServerContainerExclude(AuthServer.QUARKUS)
public void migration2_xTest() throws Exception {
//the realm with special characters in its id was successfully migrated (no error during migration)
//removing it now as testMigratedData() expects specific clients and roles
//we need to perform the removal via run on server to workaround escaping parameters when using rest call
testingClient.server().run(session -> {
RealmModel realm = session.realms().getRealmByName("test ' and ; and -- and \"");
new RealmManager(session).removeRealm(realm);
});
testMigratedData();
testMigrationTo3_x();
testMigrationTo4_x();
testMigrationTo5_x();
testMigrationTo6_x();
testMigrationTo7_x(true);
testMigrationTo8_x();
testMigrationTo9_x();
testMigrationTo12_x(false);
testMigrationTo18_x();
testMigrationTo19_x();
testMigrationTo20_x();
// Always test offline-token login during migration test
testOfflineTokenLogin();
}
@Test
@Migration(versionPrefix = "1.")
@AuthServerContainerExclude(AuthServer.QUARKUS)
public void migration1_xTest() throws Exception {
testMigratedData(false);
testMigrationTo2_x();
testMigrationTo3_x();
testMigrationTo4_x(false, false);
testMigrationTo5_x();
testMigrationTo6_x();
testMigrationTo7_x(false);
testMigrationTo8_x();
testMigrationTo9_x();
testMigrationTo12_x(false);
testMigrationTo18_x();
testMigrationTo19_x();
testMigrationTo20_x();
// Always test offline-token login during migration test
testOfflineTokenLogin();
}
} }

View file

@ -706,25 +706,6 @@
<!-- PREVIOUS VERSION OF KEYCLOAK FOR MIGRATION TESTS --> <!-- PREVIOUS VERSION OF KEYCLOAK FOR MIGRATION TESTS -->
<container qualifier="auth-server-jboss-migration" mode="manual" >
<configuration>
<property name="enabled">${auth.server.migration.legacy}</property>
<property name="adapterImplClass">org.jboss.as.arquillian.container.managed.ManagedDeployableContainer</property>
<property name="jbossHome">${keycloak.migration.home}</property>
<property name="javaVmArguments">
-Djboss.as.management.blocking.timeout=${auth.server.jboss.startup.timeout}
-Djboss.socket.binding.port-offset=${auth.server.port.offset}
${migration.import.props.previous}
${auth.server.memory.settings}
-Dauth.server.truststore=${auth.server.truststore}
-Dauth.server.truststore.password=${auth.server.truststore.password}
-Dauth.server.db.host=${auth.server.db.host}
</property>
<property name="managementPort">${auth.server.management.port}</property>
<property name="startupTimeoutInSeconds">${auth.server.jboss.startup.timeout}</property>
</configuration>
</container>
<container qualifier="auth-server-migration" mode="manual"> <container qualifier="auth-server-migration" mode="manual">
<configuration> <configuration>
<property name="enabled">${auth.server.migration}</property> <property name="enabled">${auth.server.migration}</property>

View file

@ -1706,90 +1706,6 @@
</profile> </profile>
<!-- Profiles for migration tests--> <!-- Profiles for migration tests-->
<profile>
<id>auth-server-migration-legacy</id>
<properties>
<migration.import.file>target/test-classes/migration-test/migration-realm-${migrated.auth.server.version}.json</migration.import.file>
<migration.import.props.previous>
-Dkeycloak.migration.action=import
-Dkeycloak.migration.provider=singleFile
-Dkeycloak.migration.file=${migration.import.file}
-Dkeycloak.migration.strategy=OVERWRITE_EXISTING
</migration.import.props.previous>
<skip.add.user.json>true</skip.add.user.json>
</properties>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>migrated.auth.server.version</property>
</requireProperty>
<requireProperty>
<property>migration.mode</property>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-migrated-auth-server-jboss</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-migration-server-legacy</artifactId>
<version>${project.version}</version>
<type>zip</type>
</artifactItem>
</artifactItems>
<outputDirectory>${containers.home}</outputDirectory>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<migrated.auth.server.version>${migrated.auth.server.version}</migrated.auth.server.version>
<auth.server.migration.legacy>true</auth.server.migration.legacy>
<keycloak.migration.home>${containers.home}/auth-server-migration-legacy</keycloak.migration.home>
<migration.import.props.previous>${migration.import.props.previous}</migration.import.props.previous>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile> <profile>
<id>auth-server-migration</id> <id>auth-server-migration</id>
<properties> <properties>