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

Update ehcache to latest #531

Merged
merged 9 commits into from
Jun 7, 2023
Merged

Update ehcache to latest #531

merged 9 commits into from
Jun 7, 2023

Conversation

timyates
Copy link
Contributor

@timyates timyates commented Dec 5, 2022

We need to depend on a core library now, as it is no longer pulled in as a dependency of the clustered library.

Statistics are now an internal class, which doesn't feel very nice as it may change between versions.

https://stackoverflow.com/a/40462767/6509

We need to depend on a core library now, as it is no longer pulled in as a dependency of the clustered library.

Statistics are now an internal class, which doesn't feel very nice as it may change between versions.

https://stackoverflow.com/a/40462767/6509
@timyates timyates added this to the 4.0.0 milestone Dec 5, 2022
@timyates timyates self-assigned this Dec 5, 2022
@timyates timyates linked an issue Dec 5, 2022 that may be closed by this pull request
@sonarcloud
Copy link

sonarcloud bot commented Dec 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@timyates
Copy link
Contributor Author

timyates commented Dec 5, 2022

This crashes terracotta-oss with

2022-12-05 12:30:28 2022-12-05 12:30:28.880 ERROR   --- [orkerComm # 0_R] c.t.n.protocol.tcm.TCMessageHydrateSink : Error hydrating message of type CLIENT_HANDSHAKE_MESSAGE
2022-12-05 12:30:28 com.tc.net.protocol.tcm.UnknownNameException: unknown name: 10 for message class com.tc.object.msg.ClientHandshakeMessageImpl
2022-12-05 12:30:28     at com.tc.net.protocol.tcm.TCMessageImpl.hydrate(TCMessageImpl.java:179)
2022-12-05 12:30:28     at com.tc.net.protocol.tcm.TCMessageHydrateSink.putMessage(TCMessageHydrateSink.java:36)
2022-12-05 12:30:28     at com.tc.net.protocol.tcm.TCMessageRouterImpl.putMessage(TCMessageRouterImpl.java:64)
2022-12-05 12:30:28     at com.tc.net.protocol.tcm.AbstractMessageChannel.receive(AbstractMessageChannel.java:215)
2022-12-05 12:30:28     at com.tc.net.protocol.transport.MessageTransportBase.receiveToReceiveLayer(MessageTransportBase.java:138)
2022-12-05 12:30:28     at com.tc.net.protocol.transport.ServerMessageTransport.receiveTransportMessageImpl(ServerMessageTransport.java:101)
2022-12-05 12:30:28     at com.tc.net.protocol.transport.MessageTransportBase.receiveTransportMessage(MessageTransportBase.java:113)
2022-12-05 12:30:28     at com.tc.net.protocol.transport.ServerStackProvider$MessageSink.putMessage(ServerStackProvider.java:267)
2022-12-05 12:30:28     at com.tc.net.protocol.transport.WireProtocolAdaptorImpl.addReadData(WireProtocolAdaptorImpl.java:75)

Searching for that error, led me to Terracotta-OSS/docker#3

Which is the same issue, in a (recently archived) project for building the docker image

(also has a commit from graeme backing out an ehcache update for this reason)

Someone raised this in another terracotta repo Terracotta-OSS/terracotta-platform#994 and it got closed with no response...

Not sure if Terracotta is DOA... And if not if it will support ehcache 3.11... And if so, how we can replace the test

@timyates
Copy link
Contributor Author

timyates commented Dec 5, 2022

Ok, updated the terracotta server we use in test via:

diff --git a/cache-ehcache/src/test/groovy/io/micronaut/cache/ehcache/EhcacheClusteredSpec.groovy b/cache-ehcache/src/test/groovy/io/micronaut/cache/ehcache/EhcacheClusteredSpec.groovy
index c6287f88..e62d5d73 100644
--- a/cache-ehcache/src/test/groovy/io/micronaut/cache/ehcache/EhcacheClusteredSpec.groovy
+++ b/cache-ehcache/src/test/groovy/io/micronaut/cache/ehcache/EhcacheClusteredSpec.groovy
@@ -20,6 +20,8 @@ import io.micronaut.context.ApplicationContext
 import org.ehcache.CacheManager
 import org.ehcache.clustered.client.config.ClusteringServiceConfiguration
 import org.testcontainers.containers.GenericContainer
+import org.testcontainers.containers.Network
+import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy
 import org.testcontainers.spock.Testcontainers
 import spock.lang.Specification
 
@@ -28,13 +30,31 @@ import static org.ehcache.clustered.client.config.ClusteredResourceType.Types.*
 @Testcontainers
 class EhcacheClusteredSpec extends Specification {
 
-    public GenericContainer terracotta = new GenericContainer("terracotta/terracotta-server-oss:5.6.4")
+    public Network network = Network.newNetwork()
+
+    public GenericContainer terracotta = new GenericContainer("softwareag/terracotta-server:10.15.0.0")
+            .withEnv(ACCEPT_EULA: "Y")
+            .withNetwork(network)
+            .withNetworkAliases("terracotta")
             .withExposedPorts(9410)
 
+    def setup() {
+        terracotta.start()
+        new GenericContainer("softwareag/terracotta-config-tool:10.15.0.0")
+                .withCommand("activate", "-n", "MyCluster", "-s", "terracotta")
+                .withNetwork(network)
+                .withEnv(
+                        ACCEPT_EULA: "Y",
+                        LICENSE_URL: "https://www.terracotta.org/retriever.php?n=TerracottaDB101linux.xml",
+                )
+                .waitingFor(new LogMessageWaitStrategy().withRegEx(".*Command successful!.*"))
+                .start()
+    }
+
     void "it can create a clustered cache"() {
         given:
         ApplicationContext ctx = ApplicationContext.run([
-                "ehcache.cluster.uri": "terracotta://localhost:${terracotta.firstMappedPort}/my-application",
+                "ehcache.cluster.uri": "terracotta://localhost:${terracotta.getMappedPort(9410)}/my-application",
                 "ehcache.cluster.default-server-resource": "offheap-1",
                 "ehcache.cluster.resource-pools.resource-pool-a.max-size": "8Mb",
                 "ehcache.cluster.resource-pools.resource-pool-a.server-resource": "offheap-2",

But now it fails as the client is too old for terracotta

java.lang.RuntimeException: client version is not compatible than the server.  client version:5.9.5.0.0 server version:10.15.0.0.275
	at com.tc.object.handler.ClientCoordinationHandler.handleEvent(ClientCoordinationHandler.java:44)
	at com.tc.object.handler.ClientCoordinationHandler.handleEvent(ClientCoordinationHandler.java:30)
	at com.tc.async.api.EventHandler.lambda$directSink$0(EventHandler.java:54)
	at com.tc.net.protocol.tcm.TCMessageHydrateSink.putMessage(TCMessageHydrateSink.java:37)

Currently out of ideas...

@alvarosanchez
Copy link
Member

It seems to me that we no longer can useterracotta/terracotta-server-oss to test the Ehcache Clustering support.

If you download Ehcache 3.10 with clustering kit, and start it as mentioned in the docs, it starts Terracotta 5.8.5. That's the version needed. Have you found a Docker image that has that?

@timyates
Copy link
Contributor Author

@alvarosanchez No I've not found one... terracotta-oss seems to stop at 5.6.4, and the softwareag one seems to be on 10.x.x

@alvarosanchez
Copy link
Member

I've done a quick build with what comes with 3.10.0. Give alvarosanchez/terracotta-oss:latest a try, and if it works, I can maybe clean it up and make it more stable.

@AbfrmBlr
Copy link

The docker image at https://hub.docker.com/r/softwareag/terracotta-server is the enterprise version of Terracotta server with free trial license. The 10.15 is the enterprise version and should work with ehcache 3.10.

@alvarosanchez
Copy link
Member

@AbfrmBlr but it doesn't work:

client version is not compatible than the server.  client version:5.9.5.0.0 server version:10.15.0.0.

@AbfrmBlr
Copy link

@alvarosanchez looking into it, will update shortly.

@mathieucarbou
Copy link

mathieucarbou commented Jan 18, 2023

Hello guys,

Ehcache OSS Docker images have been published just now at https://hub.docker.com/u/terracotta/ with instructions on how to use them.

Also, instructions on how to build our own docker images based on a Ehcache ZIP distribution have been merged (ehcache/ehcache3#3105), with some script inside to build the images and test them.

WARNING:

The way to start and configure the server has changed since. But if you just need 1 active server in availability mode to run some tests, you can just start a server with:

docker run --detached --rm -e DEFAULT_ACTIVATE=true -h ehcache-terracotta-server --network terracotta-net terracotta/ehcache-terracotta-server:3.10.8

Then from another container in the same network you can connect to the server using URI terracotta://ehcache-terracotta-server:9410

If test are not ran from a docker container, you could otherwise expose a port and in this case connect to localhost:9410

docker run --detached --rm -e DEFAULT_ACTIVATE=true --publish 9410:9410 terracotta/ehcache-terracotta-server:3.10.8

We support OpenShift security model - you can run with any uid in group 0 (i.e. --user 1234:0).

Let me know if you need anything else @alvarosanchez / @timyates :-)

@sdelamo
Copy link
Contributor

sdelamo commented May 27, 2023

@timyates can you revisit this PR?

@wetted
Copy link
Contributor

wetted commented Jun 2, 2023

I have merged everything from master so this will build, but the EhcacheClusteredSpec still fails. I used @timyates patch above on my local build and tried some of the suggestions without success so far.

@timyates maybe we can figure this last bit out when you get back?

@wetted
Copy link
Contributor

wetted commented Jun 2, 2023

This is my version of @timyates patch

diff --git a/cache-ehcache/src/test/groovy/io/micronaut/cache/ehcache/EhcacheClusteredSpec.groovy b/cache-ehcache/src/test/groovy/io/micronaut/cache/ehcache/EhcacheClusteredSpec.groovy
--- a/cache-ehcache/src/test/groovy/io/micronaut/cache/ehcache/EhcacheClusteredSpec.groovy	(revision 70c4aff138b2d76e764bbc6d1efbdad163b9cc1f)
+++ b/cache-ehcache/src/test/groovy/io/micronaut/cache/ehcache/EhcacheClusteredSpec.groovy	(date 1685736310998)
@@ -20,6 +20,8 @@
 import org.ehcache.CacheManager
 import org.ehcache.clustered.client.config.ClusteringServiceConfiguration
 import org.testcontainers.containers.GenericContainer
+import org.testcontainers.containers.Network
+import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy
 import org.testcontainers.spock.Testcontainers
 import spock.lang.Specification
 
@@ -28,13 +30,34 @@
 @Testcontainers
 class EhcacheClusteredSpec extends Specification {
 
-    public GenericContainer terracotta = new GenericContainer("terracotta/terracotta-server-oss:5.6.4")
+    public Network network = Network.newNetwork()
+
+    public GenericContainer terracotta = new GenericContainer("terracotta/ehcache-terracotta-server:3.10.8")
+            .withEnv(ACCEPT_EULA: "Y")
+            .withNetwork(network)
+            .withNetworkAliases("terracotta-net")
             .withExposedPorts(9410)
 
+    def setup() {
+        terracotta.start()
+        new GenericContainer("terracotta/ehcache-terracotta-server:3.10.8")
+                .withCommand("-e", "DEFAULT_ACTIVATE=true",
+                        "-h", "ehcache-terracotta-server",
+                        "--network", "terracotta-net",
+                        "--name", "ehcache-terracotta-server")
+                .withNetwork(network)
+                .withEnv(
+                        ACCEPT_EULA: "Y",
+                        LICENSE_URL: "https://www.terracotta.org/retriever.php?n=TerracottaDB101linux.xml",
+                )
+                .waitingFor(new LogMessageWaitStrategy().withRegEx(".*Command successful!.*"))
+                .start()
+    }
+
     void "it can create a clustered cache"() {
         given:
         ApplicationContext ctx = ApplicationContext.run([
-                "ehcache.cluster.uri": "terracotta://localhost:${terracotta.firstMappedPort}/my-application",
+                "ehcache.cluster.uri": "terracotta://localhost:${terracotta.getMappedPort(9410)}/my-application",
                 "ehcache.cluster.default-server-resource": "offheap-1",
                 "ehcache.cluster.resource-pools.resource-pool-a.max-size": "8Mb",
                 "ehcache.cluster.resource-pools.resource-pool-a.server-resource": "offheap-2",

@mathieucarbou
Copy link

ACCEPT_EULA

FYI

  • ACCEPT_EULA is not required anymore ;-)
  • Also, you are using the OSS version so no license required

@wetted wetted assigned wetted and unassigned alvarosanchez Jun 5, 2023
@wetted wetted requested a review from sdelamo June 5, 2023 16:45
Copy link
Contributor Author

@timyates timyates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@wetted wetted linked an issue Jun 6, 2023 that may be closed by this pull request
@sonarcloud
Copy link

sonarcloud bot commented Jun 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sdelamo sdelamo merged commit eef13f1 into master Jun 7, 2023
@sdelamo sdelamo deleted the update-ehcache branch June 7, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

Update ehcache for next major release Update to major versions of Cache integrations
6 participants