KEYCLOAK-4339 MigrationTest fails to run

This commit is contained in:
mposolda 2017-01-31 16:00:16 +01:00
parent 2990703aeb
commit f92dd6bd16
3 changed files with 28 additions and 7 deletions

View file

@ -64,7 +64,7 @@ mvn -f testsuite/integration-arquillian/tests/other/adapters/karaf/fuse63/pom.xm
clean install \ clean install \
-Pauth-server-wildfly \ -Pauth-server-wildfly \
-Papp-server-fuse63 \ -Papp-server-fuse63 \
-Dfuse63.version=6.3.0.redhat-198 -Dfuse63.version=6.3.0.redhat-229
```` ````
### EAP6 with Hawtio ### EAP6 with Hawtio
@ -117,23 +117,24 @@ mvn -f testsuite/integration-arquillian/tests/other/adapters/jboss/eap6-fuse/pom
### DB migration test ### DB migration test
This will: This test will:
- start Keycloak 1.9.8 - start Keycloak 1.9.8
- import realm and some data to MySQL DB - import realm and some data to MySQL DB
- stop Keycloak 1.9.8 - stop Keycloak 1.9.8
- start latest KEycloak and update DB from 1.9.8 - start latest KEycloak, which automatically updates DB from 1.9.8
- Do some test that data are correct - Do some test that data are correct
1) Prepare MySQL DB and ensure that MySQL DB is empty. See [../../misc/DatabaseTesting.md](../../misc/DatabaseTesting.md) for some hints for locally prepare Docker MySQL image. 1) Prepare MySQL DB and ensure that MySQL DB is empty. See [../../misc/DatabaseTesting.md](../../misc/DatabaseTesting.md) for some hints for locally prepare Docker MySQL image.
2) Run the test (Update according to your DB connection): 2) Run the test (Update according to your DB connection, versions etc):
```` ````
export DB_HOST=localhost export DB_HOST=localhost
mvn -f testsuite/integration-arquillian/pom.xml \ mvn -f testsuite/integration-arquillian/pom.xml \
clean install \ clean install \
-Pauth-server-wildfly,jpa,auth-server-migration \ -Pauth-server-wildfly,jpa,clean-jpa,auth-server-migration \
-Dtest=MigrationTest \ -Dtest=MigrationTest \
-Dmigration.mode=auto \ -Dmigration.mode=auto \
-Dmigrated.auth.server.version=1.9.8.Final \ -Dmigrated.auth.server.version=1.9.8.Final \
@ -146,8 +147,7 @@ mvn -f testsuite/integration-arquillian/pom.xml \
```` ````
### JSON export/import migration test ### JSON export/import migration test
This will This will start latest Keycloak and import the realm JSON file, which was previously exported from Keycloak 1.9.8.Final
- start latest Keycloak and import the file, which was previously exported from Keycloak 1.9.8.Final
```` ````
mvn -f testsuite/integration-arquillian/pom.xml \ mvn -f testsuite/integration-arquillian/pom.xml \

View file

@ -35,12 +35,17 @@ import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.getAppServ
*/ */
public class DeploymentTargetModifier extends AnnotationDeploymentScenarioGenerator { public class DeploymentTargetModifier extends AnnotationDeploymentScenarioGenerator {
// Will be replaced in runtime by real auth-server-container
public static final String AUTH_SERVER_CURRENT = "auth-server-current";
protected final Logger log = Logger.getLogger(this.getClass()); protected final Logger log = Logger.getLogger(this.getClass());
@Override @Override
public List<DeploymentDescription> generate(TestClass testClass) { public List<DeploymentDescription> generate(TestClass testClass) {
List<DeploymentDescription> deployments = super.generate(testClass); List<DeploymentDescription> deployments = super.generate(testClass);
checkAuthServerTestDeployment(deployments, testClass);
String appServerQualifier = getAppServerQualifier( String appServerQualifier = getAppServerQualifier(
testClass.getJavaClass()); testClass.getJavaClass());
@ -56,4 +61,17 @@ public class DeploymentTargetModifier extends AnnotationDeploymentScenarioGenera
return deployments; return deployments;
} }
private void checkAuthServerTestDeployment(List<DeploymentDescription> descriptions, TestClass testClass) {
for (DeploymentDescription deployment : descriptions) {
if (deployment.getTarget() != null) {
String containerQualifier = deployment.getTarget().getName();
if (AUTH_SERVER_CURRENT.equals(containerQualifier)) {
String authServerQualifier = AuthServerTestEnricher.AUTH_SERVER_CONTAINER;
log.infof("Setting target container for deployment %s.%s: %s", testClass.getName(), deployment.getName(), authServerQualifier);
deployment.setTarget(new TargetDescription(authServerQualifier));
}
}
}
}
} }

View file

@ -23,6 +23,7 @@ import java.util.stream.Collectors;
import javax.ws.rs.NotFoundException; import javax.ws.rs.NotFoundException;
import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.TargetsContainer;
import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -52,6 +53,7 @@ import org.keycloak.representations.idm.authorization.PolicyRepresentation;
import org.keycloak.storage.UserStorageProvider; import org.keycloak.storage.UserStorageProvider;
import org.keycloak.testsuite.AbstractKeycloakTest; import org.keycloak.testsuite.AbstractKeycloakTest;
import org.keycloak.testsuite.Assert; import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.arquillian.DeploymentTargetModifier;
import org.keycloak.testsuite.arquillian.migration.Migration; import org.keycloak.testsuite.arquillian.migration.Migration;
import org.keycloak.testsuite.runonserver.RunHelpers; import org.keycloak.testsuite.runonserver.RunHelpers;
import org.keycloak.testsuite.runonserver.RunOnServerDeployment; import org.keycloak.testsuite.runonserver.RunOnServerDeployment;
@ -78,6 +80,7 @@ public class MigrationTest extends AbstractKeycloakTest {
private RealmResource masterRealm; private RealmResource masterRealm;
@Deployment @Deployment
@TargetsContainer(DeploymentTargetModifier.AUTH_SERVER_CURRENT)
public static WebArchive deploy() { public static WebArchive deploy() {
return RunOnServerDeployment.create(); return RunOnServerDeployment.create();
} }