Skip to content

Commit abc71e6

Browse files
committed
[issues-93] - WildFLy + remote Infinispan distributed timers test
1 parent bead963 commit abc71e6

13 files changed

Lines changed: 1316 additions & 5 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
/testsuite/wildfly-web-cache-offload-infinispan/target/
1515
/testsuite/wildfly-web-cache-offload-infinispan/tmp/
1616
/testsuite/intersmash-tests-testsuite.iml
17+
/testsuite/log/

testsuite/src/test/java/org/jboss/intersmash/tests/wildfly/web/cache/offload/infinispan/Infinispan2ReplicasService.java renamed to testsuite/src/test/java/org/jboss/intersmash/tests/infinispan/Infinispan2ReplicasService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.jboss.intersmash.tests.wildfly.web.cache.offload.infinispan;
16+
package org.jboss.intersmash.tests.infinispan;
1717

1818
import io.fabric8.kubernetes.api.model.Secret;
1919
import io.fabric8.kubernetes.api.model.SecretBuilder;
@@ -28,7 +28,6 @@
2828
import org.infinispan.v2alpha1.Cache;
2929
import org.jboss.intersmash.application.openshift.OpenShiftApplication;
3030
import org.jboss.intersmash.application.operator.InfinispanOperatorApplication;
31-
import org.jboss.intersmash.tests.wildfly.web.cache.offload.infinispan.util.InfinispanSecretUtils;
3231

3332
/**
3433
* Application descriptor that represents an Infinispan/Red Hat Data Grid service deployed by the related Operator, and

testsuite/src/test/java/org/jboss/intersmash/tests/wildfly/web/cache/offload/infinispan/util/InfinispanSecretUtils.java renamed to testsuite/src/test/java/org/jboss/intersmash/tests/infinispan/InfinispanSecretUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.jboss.intersmash.tests.wildfly.web.cache.offload.infinispan.util;
16+
package org.jboss.intersmash.tests.infinispan;
1717

1818
import java.io.ByteArrayOutputStream;
1919
import java.io.IOException;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
* Copyright (C) 2026 Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.jboss.intersmash.tests.wildfly.distributed.timers.infinispan;
17+
18+
import cz.xtf.core.openshift.OpenShifts;
19+
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
20+
import io.fabric8.kubernetes.api.model.Secret;
21+
import java.io.IOException;
22+
import java.util.Base64;
23+
import java.util.Collections;
24+
import java.util.Map;
25+
import org.apache.commons.io.FileUtils;
26+
import org.infinispan.v1.InfinispanBuilder;
27+
import org.infinispan.v1.infinispanspec.Expose;
28+
import org.infinispan.v1.infinispanspec.security.EndpointEncryption;
29+
import org.infinispan.v1.infinispanspec.security.EndpointEncryptionBuilder;
30+
import org.jboss.intersmash.application.openshift.OpenShiftApplication;
31+
import org.jboss.intersmash.tests.infinispan.Infinispan2ReplicasService;
32+
import org.jboss.intersmash.util.CommandLineBasedKeystoreGenerator;
33+
34+
/**
35+
* An Infinispan basic service, which is supposed to be provisioned by
36+
* {@link org.jboss.intersmash.provision.openshift.InfinispanOpenShiftOperatorProvisioner}
37+
*
38+
* This class extends {@link @Infinispan2ReplicasService} in order to configure the Infinispan CR with a
39+
* route that exposes the service and allows for consuming the REST APIs to perform test assertions.
40+
*/
41+
public class InfinispanOperatorWithExternalRouteApplication extends Infinispan2ReplicasService
42+
implements OpenShiftApplication {
43+
44+
public InfinispanOperatorWithExternalRouteApplication() throws IOException {
45+
46+
// Here we're crating a Secret that holds the certificates needed to secure the communication with
47+
// Infinispan/Red Hat Data Grid service
48+
final String hostName = OpenShifts.master().generateHostname(INFINISPAN_APP_NAME);
49+
final CommandLineBasedKeystoreGenerator.GeneratedPaths certPaths = CommandLineBasedKeystoreGenerator
50+
.generateCerts(hostName);
51+
Secret tlsSecret = new io.fabric8.kubernetes.api.model.SecretBuilder()
52+
.withNewMetadata()
53+
.withName(TLS_SECRET_NAME)
54+
.withLabels(Collections.singletonMap("app", INFINISPAN_APP_NAME))
55+
.endMetadata()
56+
.addToData(Map.of("tls.crt",
57+
Base64.getEncoder().encodeToString(FileUtils.readFileToByteArray(certPaths.certPem.toFile()))))
58+
.addToData(Map.of("tls.key",
59+
Base64.getEncoder().encodeToString(FileUtils.readFileToByteArray(certPaths.keyPem.toFile()))))
60+
.build();
61+
secrets.add(tlsSecret);
62+
63+
// https://access.redhat.com/documentation/en-us/red_hat_data_grid/8.1/html/running_data_grid_on_openshift/start_operator#minimal_crd-start
64+
// Override parent class Infinispan instance definition
65+
infinispan = new InfinispanBuilder()
66+
.withMetadata(new ObjectMetaBuilder()
67+
.withName(this.getName())
68+
.withLabels(Map.of("app", "datagrid"))
69+
.build())
70+
.withNewSpec()
71+
.withReplicas(2)
72+
.withNewSecurity()
73+
// The superclass sets the secret for Infinispan/Red Hat Data Grid identities credentials,
74+
// and we'll reuse it here
75+
.withEndpointSecretName(INFINISPAN_CUSTOM_CREDENTIALS_SECRET_NAME)
76+
.withEndpointEncryption(new EndpointEncryptionBuilder()
77+
.withCertSecretName(TLS_SECRET_NAME)
78+
.withType(EndpointEncryption.Type.Secret)
79+
.build())
80+
.endSecurity()
81+
.withNewExpose().withType(Expose.Type.Route).endExpose()
82+
.endSpec().build();
83+
}
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Copyright (C) 2026 Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.jboss.intersmash.tests.wildfly.distributed.timers.infinispan;
17+
18+
import java.util.Collections;
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
import org.jboss.intersmash.application.openshift.PostgreSQLTemplateOpenShiftApplication;
22+
import org.jboss.intersmash.application.openshift.template.PostgreSQLTemplate;
23+
24+
/**
25+
* Deploy the PostgreSQL database using the {@link PostgreSQLTemplate#POSTGRESQL_EPHEMERAL} template to implement
26+
* the persistence store holding distributed timers expirations.
27+
* Uses the template default parameters.
28+
*/
29+
public class PostgresqlTimerExpirationStoreApplication implements PostgreSQLTemplateOpenShiftApplication {
30+
31+
public static final String POSTGRESQL_NAME = "postgresql";
32+
public static final String POSTGRESQL_DATABASE = "theData";
33+
public static final String POSTGRESQL_PASSWORD = "thePassword";
34+
public static final String POSTGRESQL_USER = "theUser";
35+
36+
private final Map<String, String> parameters = new HashMap<>();
37+
38+
public PostgresqlTimerExpirationStoreApplication() {
39+
parameters.put("POSTGRESQL_DATABASE", POSTGRESQL_DATABASE);
40+
parameters.put("POSTGRESQL_PASSWORD", POSTGRESQL_PASSWORD);
41+
parameters.put("POSTGRESQL_USER", POSTGRESQL_USER);
42+
}
43+
44+
@Override
45+
public PostgreSQLTemplate getTemplate() {
46+
return PostgreSQLTemplate.POSTGRESQL_EPHEMERAL;
47+
}
48+
49+
@Override
50+
public String getName() {
51+
return POSTGRESQL_NAME;
52+
}
53+
54+
@Override
55+
public Map<String, String> getParameters() {
56+
return Collections.unmodifiableMap(parameters);
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/**
2+
* Copyright (C) 2026 Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.jboss.intersmash.tests.wildfly.distributed.timers.infinispan;
17+
18+
import com.google.common.base.Strings;
19+
import cz.xtf.builder.builders.SecretBuilder;
20+
import cz.xtf.core.openshift.OpenShifts;
21+
import io.fabric8.kubernetes.api.model.EnvVar;
22+
import io.fabric8.kubernetes.api.model.EnvVarBuilder;
23+
import io.fabric8.kubernetes.api.model.Secret;
24+
import java.io.IOException;
25+
import java.util.ArrayList;
26+
import java.util.Collections;
27+
import java.util.List;
28+
import org.jboss.intersmash.IntersmashConfig;
29+
import org.jboss.intersmash.application.input.BuildInput;
30+
import org.jboss.intersmash.application.input.BuildInputBuilder;
31+
import org.jboss.intersmash.application.openshift.WildflyImageOpenShiftApplication;
32+
import org.jboss.intersmash.tests.wildfly.WildflyApplicationConfiguration;
33+
import org.jboss.intersmash.util.CommandLineBasedKeystoreGenerator;
34+
35+
/**
36+
* Set up a WildFly/JBoss EAP 8 application that starts a configured server, which configures Infinispan distributed
37+
* timers on a remote Infinispan cluster.
38+
*/
39+
public class WildFlyDistributedTimersApplication
40+
implements WildflyImageOpenShiftApplication, WildflyApplicationConfiguration {
41+
42+
public static final String NAME = "distributed-ejb-timers";
43+
private final BuildInput buildInput;
44+
final String applicationDir = "wildfly/distributed-timers-infinispan";
45+
private final List<EnvVar> environmentVariables = new ArrayList<>();
46+
private final List<Secret> secrets = new ArrayList<>();
47+
48+
public WildFlyDistributedTimersApplication() throws IOException {
49+
50+
final String truststorePassword = CommandLineBasedKeystoreGenerator.getPassword();
51+
// Set up client OpenShift secret for SSL
52+
secrets.add(new SecretBuilder("infinispan-client-secret")
53+
.addData("truststore.jks", CommandLineBasedKeystoreGenerator.getTruststore())
54+
.addRawData("trustStorePassword", truststorePassword)
55+
.build());
56+
57+
// Set the build input
58+
buildInput = new BuildInputBuilder()
59+
.uri(IntersmashConfig.deploymentsRepositoryUrl())
60+
.ref(IntersmashConfig.deploymentsRepositoryRef())
61+
.build();
62+
63+
// configure KUBE_PING, an invalidation-cache requires a functioning JGroups cluster.
64+
environmentVariables.add(new EnvVarBuilder()
65+
.withName("KUBERNETES_NAMESPACE")
66+
.withValue(OpenShifts.master().getNamespace())
67+
.build());
68+
69+
// set up environment variables
70+
environmentVariables.add(new EnvVarBuilder()
71+
.withName("JDG_HOST")
72+
.withValue("$(RHDG_SERVICE_HOST)")
73+
.build());
74+
environmentVariables.add(new EnvVarBuilder()
75+
.withName("JDG_PORT")
76+
.withValue("$(RHDG_SERVICE_PORT)")
77+
.build());
78+
environmentVariables.add(new EnvVarBuilder()
79+
.withName("TRUSTSTORE_PASSWORD")
80+
.withValue(truststorePassword)
81+
.build());
82+
83+
// credentials from Infinispan/Red Hat Data Grid custom secret
84+
environmentVariables.add(new EnvVarBuilder()
85+
.withName("CACHE_USERNAME")
86+
.withValue(InfinispanOperatorWithExternalRouteApplication.INFINISPAN_CUSTOM_CREDENTIALS_USERNAME)
87+
.build());
88+
environmentVariables.add(new EnvVarBuilder()
89+
.withName("CACHE_PASSWORD")
90+
.withValue(InfinispanOperatorWithExternalRouteApplication.INFINISPAN_CUSTOM_CREDENTIALS_PASSWORD)
91+
.build());
92+
environmentVariables.add(new EnvVarBuilder()
93+
.withName("TIMER_EXPIRATION_API_BASE_URL")
94+
.withValue("http://timer-expiration-store:8080").build());
95+
96+
// More env vars
97+
// TODO: this appears in many application descriptors that implement WildflyImageOpenShiftApplication and
98+
// WildflyApplicationConfiguration, therefore it might be refactored into a unique interface method
99+
environmentVariables.add(
100+
new EnvVarBuilder().withName("MAVEN_S2I_ARTIFACT_DIRS")
101+
.withValue(applicationDir + "/target")
102+
.build());
103+
104+
String mavenAdditionalArgs = generateAdditionalMavenArgs()
105+
.concat(" -pl " + applicationDir + " -am");
106+
107+
final String mavenMirrorUrl = this.getMavenMirrorUrl();
108+
if (!Strings.isNullOrEmpty(mavenMirrorUrl)) {
109+
environmentVariables.add(
110+
new EnvVarBuilder().withName("MAVEN_MIRROR_URL")
111+
.withValue(mavenMirrorUrl)
112+
.build());
113+
mavenAdditionalArgs = mavenAdditionalArgs.concat(" -Dinsecure.repositories=WARN");
114+
}
115+
116+
environmentVariables.add(
117+
new EnvVarBuilder().withName("MAVEN_ARGS_APPEND")
118+
.withValue(mavenAdditionalArgs)
119+
.build());
120+
121+
environmentVariables.add(new EnvVarBuilder()
122+
.withName("SCRIPT_DEBUG").withValue(IntersmashConfig.scriptDebug()).build());
123+
}
124+
125+
@Override
126+
public String getName() {
127+
return NAME;
128+
}
129+
130+
@Override
131+
public BuildInput getBuildInput() {
132+
return buildInput;
133+
}
134+
135+
@Override
136+
public List<EnvVar> getEnvVars() {
137+
return Collections.unmodifiableList(environmentVariables);
138+
}
139+
140+
@Override
141+
public List<Secret> getSecrets() {
142+
return secrets;
143+
}
144+
}

0 commit comments

Comments
 (0)