This is an automated email from the ASF dual-hosted git repository.
tkobayas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-drools.git
The following commit(s) were added to refs/heads/main by this push:
new ab2a3d0a95 [incubator-kie-drools-6239] Review and update
EmbeddedStorageManagerTest (#6258)
ab2a3d0a95 is described below
commit ab2a3d0a9500fc621fbeb839a5eb1fd112818f97
Author: Toshiya Kobayashi <[email protected]>
AuthorDate: Wed Feb 19 18:22:04 2025 +0900
[incubator-kie-drools-6239] Review and update EmbeddedStorageManagerTest
(#6258)
* [incubator-kie-drools-6239] Review and update EmbeddedStorageManagerTest
* - fix comment
---
.../infinispan/EmbeddedStorageManager.java | 8 ++++
.../test/EmbeddedStorageManagerTest.java | 43 +++++++++-------------
2 files changed, 26 insertions(+), 25 deletions(-)
diff --git
a/drools-reliability/drools-reliability-infinispan/src/main/java/org/drools/reliability/infinispan/EmbeddedStorageManager.java
b/drools-reliability/drools-reliability-infinispan/src/main/java/org/drools/reliability/infinispan/EmbeddedStorageManager.java
index 700fdd67eb..7c2e79d3a4 100644
---
a/drools-reliability/drools-reliability-infinispan/src/main/java/org/drools/reliability/infinispan/EmbeddedStorageManager.java
+++
b/drools-reliability/drools-reliability-infinispan/src/main/java/org/drools/reliability/infinispan/EmbeddedStorageManager.java
@@ -175,6 +175,14 @@ public class EmbeddedStorageManager implements
InfinispanStorageManager {
}
+ public DefaultCacheManager getEmbeddedCacheManager() {
+ return embeddedCacheManager;
+ }
+
+ public Configuration getCacheConfiguration() {
+ return cacheConfiguration;
+ }
+
// test purpose to remove GlobalState and FileStore
private static void cleanUpGlobalStateAndFileStore() {
FileUtils.deleteDirectory(Paths.get(GLOBAL_STATE_DIR));
diff --git
a/drools-reliability/drools-reliability-tests/src/test/java/org/drools/reliability/test/EmbeddedStorageManagerTest.java
b/drools-reliability/drools-reliability-tests/src/test/java/org/drools/reliability/test/EmbeddedStorageManagerTest.java
index 60fd4949e7..04c1a0c7b0 100644
---
a/drools-reliability/drools-reliability-tests/src/test/java/org/drools/reliability/test/EmbeddedStorageManagerTest.java
+++
b/drools-reliability/drools-reliability-tests/src/test/java/org/drools/reliability/test/EmbeddedStorageManagerTest.java
@@ -20,11 +20,11 @@ package org.drools.reliability.test;
import org.drools.reliability.core.StorageManagerFactory;
import org.drools.reliability.core.TestableStorageManager;
-import org.drools.reliability.infinispan.InfinispanStorageManager;
-import org.infinispan.configuration.cache.CacheMode;
-import org.infinispan.configuration.cache.ConfigurationBuilder;
+import org.drools.reliability.infinispan.EmbeddedStorageManager;
+import org.infinispan.configuration.cache.Configuration;
import org.infinispan.manager.DefaultCacheManager;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -36,9 +36,6 @@ import static
org.drools.reliability.infinispan.InfinispanStorageManagerFactory.
import static
org.drools.reliability.test.util.TestConfigurationUtils.DROOLS_RELIABILITY_MODULE_TEST;
import static org.drools.util.Config.getConfig;
-/**
- * This class is a unit test for EmbeddedCacheManager methods with a fake
cacheManager instead of Infinispan DefaultCacheManager.
- */
@EnabledIf("isEmbeddedInfinispan")
@ExtendWith(BeforeAllMethodExtension.class)
class EmbeddedStorageManagerTest {
@@ -47,9 +44,19 @@ class EmbeddedStorageManagerTest {
System.setProperty(INFINISPAN_STORAGE_ALLOWED_PACKAGES,
"org.test.domain");
}
+ @BeforeEach
+ public void setUp() {
+ // Cache will be [METADATA_0, ___protobuf_metadata, ___script_cache,
session_0_epDefault, session_1_epDefault]
+ DefaultCacheManager cacheManager = ((EmbeddedStorageManager)
StorageManagerFactory.get().getStorageManager()).getEmbeddedCacheManager();
+ Configuration cacheConfiguration = ((EmbeddedStorageManager)
StorageManagerFactory.get().getStorageManager()).getCacheConfiguration();
+ cacheManager.createCache(SESSION_STORAGE_PREFIX + "0_" + "epDefault",
cacheConfiguration);
+ cacheManager.createCache(SESSION_STORAGE_PREFIX + "1_" + "epDefault",
cacheConfiguration);
+ cacheManager.createCache("METADATA_0", cacheConfiguration);
+ }
+
@AfterEach
public void tearDown() {
- ((TestableStorageManager)
StorageManagerFactory.get().getStorageManager()).restart(); // make sure that
FakeCacheManager is removed
+ ((TestableStorageManager)
StorageManagerFactory.get().getStorageManager()).restart();
}
static boolean isEmbeddedInfinispan() {
@@ -59,31 +66,17 @@ class EmbeddedStorageManagerTest {
@Test
void removeAllSessionCaches_shouldLeaveNonSessionCache() {
- ((InfinispanStorageManager)
StorageManagerFactory.get().getStorageManager()).setEmbeddedCacheManager(new
FakeCacheManager());
-
StorageManagerFactory.get().getStorageManager().removeAllSessionStorages();
-
assertThat(StorageManagerFactory.get().getStorageManager().getStorageNames()).contains("METADATA_0");
+
assertThat(StorageManagerFactory.get().getStorageManager().getStorageNames())
+ .containsExactlyInAnyOrder("METADATA_0",
"___protobuf_metadata", "___script_cache");
}
@Test
void removeCachesBySessionId_shouldRemoveSpecifiedCacheOnly() {
- ((InfinispanStorageManager)
StorageManagerFactory.get().getStorageManager()).setEmbeddedCacheManager(new
FakeCacheManager());
-
StorageManagerFactory.get().getStorageManager().removeStoragesBySessionId("1");
-
assertThat(StorageManagerFactory.get().getStorageManager().getStorageNames()).contains(SESSION_STORAGE_PREFIX
+ "0_" + "epDefault", "METADATA_0");
- }
-
- public static class FakeCacheManager extends DefaultCacheManager {
- public FakeCacheManager() {
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
- builder.clustering().cacheMode(CacheMode.LOCAL);
-
- this.createCache(SESSION_STORAGE_PREFIX + "0_" + "epDefault",
builder.build());
- this.createCache(SESSION_STORAGE_PREFIX + "1_" + "epDefault",
builder.build());
- this.createCache("METADATA_0", builder.build());
- }
+
assertThat(StorageManagerFactory.get().getStorageManager().getStorageNames())
+ .containsExactlyInAnyOrder(SESSION_STORAGE_PREFIX + "0_" +
"epDefault", "METADATA_0", "___protobuf_metadata", "___script_cache");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]