Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
/testsuite/wildfly-web-cache-offload-infinispan/target/
/testsuite/wildfly-web-cache-offload-infinispan/tmp/
/testsuite/intersmash-tests-testsuite.iml
/testsuite/log/
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.intersmash.tests.wildfly.web.cache.offload.infinispan;
package org.jboss.intersmash.tests.infinispan;

import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.kubernetes.api.model.SecretBuilder;
Expand All @@ -28,7 +28,6 @@
import org.infinispan.v2alpha1.Cache;
import org.jboss.intersmash.application.openshift.OpenShiftApplication;
import org.jboss.intersmash.application.operator.InfinispanOperatorApplication;
import org.jboss.intersmash.tests.wildfly.web.cache.offload.infinispan.util.InfinispanSecretUtils;

/**
* Application descriptor that represents an Infinispan/Red Hat Data Grid service deployed by the related Operator, and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.intersmash.tests.wildfly.web.cache.offload.infinispan.util;
package org.jboss.intersmash.tests.infinispan;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* Copyright (C) 2026 Red Hat, Inc.
*
* 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.jboss.intersmash.tests.wildfly.distributed.timers.infinispan;

import cz.xtf.core.openshift.OpenShifts;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.api.model.Secret;
import java.io.IOException;
import java.util.Base64;
import java.util.Collections;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.infinispan.v1.InfinispanBuilder;
import org.infinispan.v1.infinispanspec.Expose;
import org.infinispan.v1.infinispanspec.security.EndpointEncryption;
import org.infinispan.v1.infinispanspec.security.EndpointEncryptionBuilder;
import org.jboss.intersmash.application.openshift.OpenShiftApplication;
import org.jboss.intersmash.tests.infinispan.Infinispan2ReplicasService;
import org.jboss.intersmash.util.CommandLineBasedKeystoreGenerator;

/**
* An Infinispan basic service, which is supposed to be provisioned by
* {@link org.jboss.intersmash.provision.openshift.InfinispanOpenShiftOperatorProvisioner}
*
* This class extends {@link @Infinispan2ReplicasService} in order to configure the Infinispan CR with a
* route that exposes the service and allows for consuming the REST APIs to perform test assertions.
*/
public class InfinispanOperatorWithExternalRouteApplication extends Infinispan2ReplicasService
implements OpenShiftApplication {

public InfinispanOperatorWithExternalRouteApplication() throws IOException {

// Here we're crating a Secret that holds the certificates needed to secure the communication with
// Infinispan/Red Hat Data Grid service
final String hostName = OpenShifts.master().generateHostname(INFINISPAN_APP_NAME);
final CommandLineBasedKeystoreGenerator.GeneratedPaths certPaths = CommandLineBasedKeystoreGenerator
.generateCerts(hostName);
Secret tlsSecret = new io.fabric8.kubernetes.api.model.SecretBuilder()
.withNewMetadata()
.withName(TLS_SECRET_NAME)
.withLabels(Collections.singletonMap("app", INFINISPAN_APP_NAME))
.endMetadata()
.addToData(Map.of("tls.crt",
Base64.getEncoder().encodeToString(FileUtils.readFileToByteArray(certPaths.certPem.toFile()))))
.addToData(Map.of("tls.key",
Base64.getEncoder().encodeToString(FileUtils.readFileToByteArray(certPaths.keyPem.toFile()))))
.build();
secrets.add(tlsSecret);

// https://access.redhat.com/documentation/en-us/red_hat_data_grid/8.1/html/running_data_grid_on_openshift/start_operator#minimal_crd-start
// Override parent class Infinispan instance definition
infinispan = new InfinispanBuilder()
.withMetadata(new ObjectMetaBuilder()
.withName(this.getName())
.withLabels(Map.of("app", "datagrid"))
.build())
.withNewSpec()
.withReplicas(2)
.withNewSecurity()
// The superclass sets the secret for Infinispan/Red Hat Data Grid identities credentials,
// and we'll reuse it here
.withEndpointSecretName(INFINISPAN_CUSTOM_CREDENTIALS_SECRET_NAME)
.withEndpointEncryption(new EndpointEncryptionBuilder()
.withCertSecretName(TLS_SECRET_NAME)
.withType(EndpointEncryption.Type.Secret)
.build())
.endSecurity()
.withNewExpose().withType(Expose.Type.Route).endExpose()
.endSpec().build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Copyright (C) 2026 Red Hat, Inc.
*
* 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.jboss.intersmash.tests.wildfly.distributed.timers.infinispan;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.jboss.intersmash.application.openshift.PostgreSQLTemplateOpenShiftApplication;
import org.jboss.intersmash.application.openshift.template.PostgreSQLTemplate;

/**
* Deploy the PostgreSQL database using the {@link PostgreSQLTemplate#POSTGRESQL_EPHEMERAL} template to implement
* the persistence store holding distributed timers expirations.
* Uses the template default parameters.
*/
public class PostgresqlTimerExpirationStoreApplication implements PostgreSQLTemplateOpenShiftApplication {

public static final String POSTGRESQL_NAME = "postgresql";
public static final String POSTGRESQL_DATABASE = "theData";
public static final String POSTGRESQL_PASSWORD = "thePassword";
public static final String POSTGRESQL_USER = "theUser";

private final Map<String, String> parameters = new HashMap<>();

public PostgresqlTimerExpirationStoreApplication() {
parameters.put("POSTGRESQL_DATABASE", POSTGRESQL_DATABASE);
parameters.put("POSTGRESQL_PASSWORD", POSTGRESQL_PASSWORD);
parameters.put("POSTGRESQL_USER", POSTGRESQL_USER);
}

@Override
public PostgreSQLTemplate getTemplate() {
return PostgreSQLTemplate.POSTGRESQL_EPHEMERAL;
}

@Override
public String getName() {
return POSTGRESQL_NAME;
}

@Override
public Map<String, String> getParameters() {
return Collections.unmodifiableMap(parameters);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/**
* Copyright (C) 2026 Red Hat, Inc.
*
* 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.jboss.intersmash.tests.wildfly.distributed.timers.infinispan;

import com.google.common.base.Strings;
import cz.xtf.builder.builders.SecretBuilder;
import cz.xtf.core.openshift.OpenShifts;
import io.fabric8.kubernetes.api.model.EnvVar;
import io.fabric8.kubernetes.api.model.EnvVarBuilder;
import io.fabric8.kubernetes.api.model.Secret;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.jboss.intersmash.IntersmashConfig;
import org.jboss.intersmash.application.input.BuildInput;
import org.jboss.intersmash.application.input.BuildInputBuilder;
import org.jboss.intersmash.application.openshift.WildflyImageOpenShiftApplication;
import org.jboss.intersmash.tests.wildfly.WildflyApplicationConfiguration;
import org.jboss.intersmash.util.CommandLineBasedKeystoreGenerator;

/**
* Set up a WildFly/JBoss EAP 8 application that starts a configured server, which configures Infinispan distributed
* timers on a remote Infinispan cluster.
*/
public class WildFlyDistributedTimersApplication
implements WildflyImageOpenShiftApplication, WildflyApplicationConfiguration {

public static final String NAME = "distributed-ejb-timers";
private final BuildInput buildInput;
final String applicationDir = "wildfly/distributed-timers-infinispan";
private final List<EnvVar> environmentVariables = new ArrayList<>();
private final List<Secret> secrets = new ArrayList<>();

public WildFlyDistributedTimersApplication() throws IOException {

final String truststorePassword = CommandLineBasedKeystoreGenerator.getPassword();
// Set up client OpenShift secret for SSL
secrets.add(new SecretBuilder("infinispan-client-secret")
.addData("truststore.jks", CommandLineBasedKeystoreGenerator.getTruststore())
.addRawData("trustStorePassword", truststorePassword)
.build());

// Set the build input
buildInput = new BuildInputBuilder()
.uri(IntersmashConfig.deploymentsRepositoryUrl())
.ref(IntersmashConfig.deploymentsRepositoryRef())
.build();

// configure KUBE_PING, an invalidation-cache requires a functioning JGroups cluster.
environmentVariables.add(new EnvVarBuilder()
.withName("KUBERNETES_NAMESPACE")
.withValue(OpenShifts.master().getNamespace())
.build());

// set up environment variables
environmentVariables.add(new EnvVarBuilder()
.withName("JDG_HOST")
.withValue("$(RHDG_SERVICE_HOST)")
.build());
environmentVariables.add(new EnvVarBuilder()
.withName("JDG_PORT")
.withValue("$(RHDG_SERVICE_PORT)")
.build());
environmentVariables.add(new EnvVarBuilder()
.withName("TRUSTSTORE_PASSWORD")
.withValue(truststorePassword)
.build());

// credentials from Infinispan/Red Hat Data Grid custom secret
environmentVariables.add(new EnvVarBuilder()
.withName("CACHE_USERNAME")
.withValue(InfinispanOperatorWithExternalRouteApplication.INFINISPAN_CUSTOM_CREDENTIALS_USERNAME)
.build());
environmentVariables.add(new EnvVarBuilder()
.withName("CACHE_PASSWORD")
.withValue(InfinispanOperatorWithExternalRouteApplication.INFINISPAN_CUSTOM_CREDENTIALS_PASSWORD)
.build());
environmentVariables.add(new EnvVarBuilder()
.withName("TIMER_EXPIRATION_API_BASE_URL")
.withValue("http://timer-expiration-store:8080").build());

// More env vars
// TODO: this appears in many application descriptors that implement WildflyImageOpenShiftApplication and
// WildflyApplicationConfiguration, therefore it might be refactored into a unique interface method
environmentVariables.add(
new EnvVarBuilder().withName("MAVEN_S2I_ARTIFACT_DIRS")
.withValue(applicationDir + "/target")
.build());

String mavenAdditionalArgs = generateAdditionalMavenArgs()
.concat(" -pl " + applicationDir + " -am");

final String mavenMirrorUrl = this.getMavenMirrorUrl();
if (!Strings.isNullOrEmpty(mavenMirrorUrl)) {
environmentVariables.add(
new EnvVarBuilder().withName("MAVEN_MIRROR_URL")
.withValue(mavenMirrorUrl)
.build());
mavenAdditionalArgs = mavenAdditionalArgs.concat(" -Dinsecure.repositories=WARN");
}

environmentVariables.add(
new EnvVarBuilder().withName("MAVEN_ARGS_APPEND")
.withValue(mavenAdditionalArgs)
.build());

environmentVariables.add(new EnvVarBuilder()
.withName("SCRIPT_DEBUG").withValue(IntersmashConfig.scriptDebug()).build());
}

@Override
public String getName() {
return NAME;
}

@Override
public BuildInput getBuildInput() {
return buildInput;
}

@Override
public List<EnvVar> getEnvVars() {
return Collections.unmodifiableList(environmentVariables);
}

@Override
public List<Secret> getSecrets() {
return secrets;
}
}
Loading