Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds config file overload for devservices in Infinispan #38642

Merged
merged 1 commit into from
Feb 7, 2024
Merged
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
25 changes: 25 additions & 0 deletions docs/src/main/asciidoc/infinispan-dev-services.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,36 @@
- the `quarkus.infinispan-client.hosts` is configured

Dev Services for Infinispan relies on Docker to start the broker.
If your environment does not support Docker, you will need to start the broker manually, or connect to an already running broker.

Check warning on line 62 in docs/src/main/asciidoc/infinispan-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Fluff] Depending on the context, consider using 'Rewrite the sentence, or use 'must', instead of' rather than 'need to'. Raw Output: {"message": "[Quarkus.Fluff] Depending on the context, consider using 'Rewrite the sentence, or use 'must', instead of' rather than 'need to'.", "location": {"path": "docs/src/main/asciidoc/infinispan-dev-services.adoc", "range": {"start": {"line": 62, "column": 55}}}, "severity": "INFO"}
You can configure the broker address using `quarkus.infinispan-client.hosts`.

== Providing configuration to the running server
Dev Services for Infinispan will spin up an Infinispan with the infinispan.xml file by default.

Check warning on line 66 in docs/src/main/asciidoc/infinispan-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'xml'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'xml'?", "location": {"path": "docs/src/main/asciidoc/infinispan-dev-services.adoc", "range": {"start": {"line": 66, "column": 76}}}, "severity": "WARNING"}
However, there are cases where is helpful to provide some extra configuration to the server.
This can be done by adding configuration files in xml, yaml or json to the resources classpath and

Check warning on line 68 in docs/src/main/asciidoc/infinispan-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.CaseSensitiveTerms] Use 'YAML' rather than 'yaml'. Raw Output: {"message": "[Quarkus.CaseSensitiveTerms] Use 'YAML' rather than 'yaml'.", "location": {"path": "docs/src/main/asciidoc/infinispan-dev-services.adoc", "range": {"start": {"line": 68, "column": 56}}}, "severity": "INFO"}

Check warning on line 68 in docs/src/main/asciidoc/infinispan-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'yaml'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'yaml'?", "location": {"path": "docs/src/main/asciidoc/infinispan-dev-services.adoc", "range": {"start": {"line": 68, "column": 56}}}, "severity": "WARNING"}

Check warning on line 68 in docs/src/main/asciidoc/infinispan-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'json'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'json'?", "location": {"path": "docs/src/main/asciidoc/infinispan-dev-services.adoc", "range": {"start": {"line": 68, "column": 64}}}, "severity": "WARNING"}
providing the following configuration:

[source,properties]
----
quarkus.infinispan-client.devservices.config-files=server-config-override.xml <1>
----
<1> server-config-override.xml is a file under the resources folder

[source,xml]
----
<infinispan> <1>
<cache-container>
<local-cache name="my-local-cache"> <2>
<encoding media-type="application/x-protostream" />
</local-cache>
</cache-container>
</infinispan>
----
<1> The content of server-config-override.xml file
<2> By providing a cache configuration, this cache will be present on the server container

== Cross Site Replication

Check warning on line 90 in docs/src/main/asciidoc/infinispan-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Headings] Use sentence-style capitalization in 'Cross Site Replication'. Raw Output: {"message": "[Quarkus.Headings] Use sentence-style capitalization in 'Cross Site Replication'.", "location": {"path": "docs/src/main/asciidoc/infinispan-dev-services.adoc", "range": {"start": {"line": 90, "column": 4}}}, "severity": "INFO"}
If you want run the Infinispan Server container with Cross Site Replication configuration, you need to provide a site name.

Check warning on line 91 in docs/src/main/asciidoc/infinispan-dev-services.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Fluff] Depending on the context, consider using 'Rewrite the sentence, or use 'must', instead of' rather than 'need to'. Raw Output: {"message": "[Quarkus.Fluff] Depending on the context, consider using 'Rewrite the sentence, or use 'must', instead of' rather than 'need to'.", "location": {"path": "docs/src/main/asciidoc/infinispan-dev-services.adoc", "range": {"start": {"line": 91, "column": 96}}}, "severity": "INFO"}

[source,properties]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.infinispan.commons.util.Version;
import org.infinispan.server.test.core.InfinispanContainer;
import org.jboss.logging.Logger;
import org.testcontainers.containers.BindMode;

import io.quarkus.deployment.Feature;
import io.quarkus.deployment.IsNormal;
Expand Down Expand Up @@ -272,10 +273,16 @@ public QuarkusInfinispanContainer(String clientName, InfinispanDevServicesConfig
}
withUser(DEFAULT_USERNAME);
withPassword(InfinispanDevServiceProcessor.DEFAULT_PASSWORD);
String command = "";
String command = "-c infinispan.xml";
if (config.site.isPresent()) {
command = "-c infinispan-xsite.xml -Dinfinispan.site.name=" + config.site.get();
}
command = command + config.configFiles.map(files -> files.stream().map(file -> {
String userConfigFile = "/user-config/" + file;
withClasspathResourceMapping(file, userConfigFile, BindMode.READ_ONLY);
return " -c " + userConfigFile;
}).collect(Collectors.joining())).orElse("");

if (config.mcastPort.isPresent()) {
command = command + " -Djgroups.mcast_port=" + config.mcastPort.getAsInt();
}
Expand All @@ -284,10 +291,10 @@ public QuarkusInfinispanContainer(String clientName, InfinispanDevServicesConfig
command = command + " -Dotel.exporter.otlp.endpoint=" + config.exporterOtlpEndpoint.get();
command = command + " -Dotel.service.name=infinispan-server-service -Dotel.metrics.exporter=none";
}
if (!command.isEmpty()) {
withCommand(command);
}

config.artifacts.ifPresent(a -> withArtifacts(a.toArray(new String[0])));

withCommand(command);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

package io.quarkus.infinispan.test;

import static org.assertj.core.api.Assertions.assertThat;

import jakarta.enterprise.inject.Default;

import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.counter.api.CounterManager;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.arc.Arc;
import io.quarkus.test.QuarkusUnitTest;

public class CreateADefaultRemoteCacheManagerWithEmptyConfTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withConfigurationResource("empty-application-infinispan-client.properties");

@Test
public void remoteCacheManagerDefaultBeansAccessible() {
assertThat(Arc.container().instance(RemoteCacheManager.class, Default.Literal.INSTANCE).get()).isNotNull();
assertThat(Arc.container().instance(CounterManager.class, Default.Literal.INSTANCE).get()).isNotNull();
assertThat(Arc.container().listAll(RemoteCacheManager.class).size()).isEqualTo(1);
assertThat(Arc.container().listAll(CounterManager.class).size()).isEqualTo(1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

package io.quarkus.infinispan.test;

import static org.assertj.core.api.Assertions.assertThat;

import jakarta.inject.Inject;

import org.infinispan.client.hotrod.RemoteCacheManager;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;

public class OverrideContainerConfigOnDevServicesTest {

@Inject
RemoteCacheManager cacheManager;

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addAsResource("server-config-override.xml"))
.withConfigurationResource("dev-services-adds-server-config.properties");

@Test
public void remoteCacheManagerDefaultBeansAccessible() {
assertThat(cacheManager.getCacheNames()).contains("my-local-cache");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
quarkus.infinispan-client.devservices.enabled=true
quarkus.infinispan-client.devservices.config-files=server-config-override.xml

Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<infinispan>
<cache-container>
<metrics accurate-size="true"/>
<local-cache name="my-local-cache">
<encoding media-type="application/x-protostream" />
</local-cache>
</cache-container>
</infinispan>
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ public class InfinispanDevServicesConfig {
@ConfigItem
public Map<String, String> containerEnv;

/**
* Infinispan Server configuration chunks to be passed to the container.
*/
@ConfigItem
public Optional<List<String>> configFiles;

@Override
public boolean equals(Object o) {
if (this == o)
Expand Down
Loading