-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from fabiobrz/add-rhsso-template-prov
[issue 105] - Adding the RHSSO Template provisioner
- Loading branch information
Showing
14 changed files
with
517 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...c/test/java/org/jboss/intersmash/testsuite/provision/openshift/RhSsoTemplateTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.jboss.intersmash.testsuite.provision.openshift; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.jboss.intersmash.testsuite.junit5.categories.NotForCommunityExecutionProfile; | ||
import org.jboss.intersmash.tools.application.openshift.RhSsoTemplateOpenShiftApplication; | ||
import org.jboss.intersmash.tools.provision.openshift.RhSsoTemplateOpenShiftProvisioner; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import cz.xtf.core.openshift.OpenShift; | ||
import cz.xtf.core.openshift.OpenShifts; | ||
import cz.xtf.junit5.annotations.CleanBeforeAll; | ||
|
||
@CleanBeforeAll | ||
@NotForCommunityExecutionProfile | ||
public class RhSsoTemplateTestCase { | ||
private static final OpenShift openShift = OpenShifts.master(); | ||
private static final RhSsoTemplateOpenShiftApplication application = OpenShiftProvisionerTestBase.getHttpsRhSso(); | ||
private static final RhSsoTemplateOpenShiftProvisioner provisioner = new RhSsoTemplateOpenShiftProvisioner(application); | ||
|
||
@BeforeAll | ||
public static void deploy() { | ||
provisioner.preDeploy(); | ||
provisioner.deploy(); | ||
} | ||
|
||
@AfterAll | ||
public static void undeploy() { | ||
provisioner.undeploy(); | ||
provisioner.postUndeploy(); | ||
} | ||
|
||
@Test | ||
public void scale() { | ||
provisioner.scale(1, true); | ||
openShift.waiters().areExactlyNPodsReady(1, application.getName()).waitFor(); | ||
provisioner.scale(2, true); | ||
openShift.waiters().areExactlyNPodsReady(2, application.getName()).waitFor(); | ||
} | ||
|
||
@Test | ||
public void pods() { | ||
provisioner.scale(2, true); | ||
Assertions.assertThat(provisioner.getPods().size()).isEqualTo(2); | ||
provisioner.scale(3, true); | ||
Assertions.assertThat(provisioner.getPods().size()).isEqualTo(3); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...a/org/jboss/intersmash/tools/application/openshift/RhSsoTemplateOpenShiftApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.jboss.intersmash.tools.application.openshift; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.jboss.intersmash.tools.application.openshift.template.RhSsoTemplate; | ||
|
||
/** | ||
* End user Application interface which presents RH-SSO template application on OpenShift Container Platform. | ||
* <p> | ||
* RH-SSO application that is supposed to run on OpenShift needs to implement this interface. | ||
* Usage: | ||
* <pre> | ||
* @Appsint( | ||
* @Service(RhssoApp.class) | ||
* }) | ||
* </pre> | ||
* The application will be deployed by: | ||
* <ul> | ||
* <li>{@link RhSsoTemplateOpenShiftProvisioner}</li> | ||
* </ul> | ||
* <p> | ||
* See {@link RhSsoTemplate} for available templates the | ||
* application can represent. | ||
*/ | ||
public interface RhSsoTemplateOpenShiftApplication extends TemplateApplication<RhSsoTemplate>, HasSecrets { | ||
|
||
default String getName() { | ||
return "rh-sso"; | ||
} | ||
|
||
/** | ||
* Realm configuration in json format for Keycloak partial import | ||
* <p> | ||
* https://www.keycloak.org/docs/9.0/server_admin/index.html#importing-a-realm-from-exported-json-file | ||
* <p> | ||
* Requires template parameters SSO_REALM, SSO_SERVICE_USERNAME, SSO_SERVICE_PASSWORD to be set | ||
* | ||
* @return Instance of {@link Path} representing a YAML definition for the desired realm configuration | ||
*/ | ||
default Path getRealmConfigurationFilePath() { | ||
return null; | ||
} | ||
|
||
/** | ||
* Non x509 templates expose an HTTP route named after the application name; | ||
* x509 templates don't expose an HTTP route; | ||
* | ||
* @return The service HTTP route | ||
*/ | ||
default String getHttpRouteName() { | ||
return getTemplate().isX509() ? null : getName(); | ||
} | ||
|
||
/** | ||
* Non x509 templates expose an HTTPS route named after the application name with the "secure-" prefix; | ||
* x509 templates expose an HTTPS route named after the application name; | ||
* | ||
* @return The service HTTPS route | ||
*/ | ||
default String getHttpsRouteName() { | ||
return getTemplate().isX509() ? getName() : String.format("secure-%s", getName()); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...rc/main/java/org/jboss/intersmash/tools/application/openshift/template/RhSsoTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.jboss.intersmash.tools.application.openshift.template; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.jboss.intersmash.tools.provision.openshift.template.OpenShiftTemplate; | ||
|
||
/** | ||
* OpenShift template for RH-SSO. | ||
* <p> | ||
* See https://github.com/jboss-container-images/redhat-sso-7-openshift-image | ||
*/ | ||
public enum RhSsoTemplate implements OpenShiftTemplate { | ||
HTTPS("https"), | ||
POSTGRESQL("postgresql"), | ||
POSTGRESQL_PERSISTENT("postgresql-persistent"), | ||
X509_HTTPS("x509-https"), | ||
X509_POSTGRESQL_PERSISTENT("x509-postgresql-persistent"); | ||
|
||
private static final Map<String, RhSsoTemplate> BY_LABEL = new HashMap<>(); | ||
|
||
static { | ||
for (RhSsoTemplate e : values()) { | ||
BY_LABEL.put(e.label, e); | ||
} | ||
} | ||
|
||
private String label; | ||
|
||
RhSsoTemplate(String label) { | ||
this.label = label; | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public boolean isX509() { | ||
return label.contains("x509"); | ||
} | ||
|
||
public static RhSsoTemplate valueOfLabel(String label) { | ||
return BY_LABEL.get(label); | ||
} | ||
} |
Oops, something went wrong.