Skip to content

Commit

Permalink
ISPN-7530 InfinispanStoreRocksDBIT leaves files in the current directory
Browse files Browse the repository at this point in the history
  • Loading branch information
danberindei authored and pruivo committed Mar 8, 2017
1 parent 1f3ad7b commit e28b8c2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
Expand Up @@ -3,8 +3,11 @@
import static java.io.File.separator;
import static org.junit.Assert.assertEquals;

import java.io.File;

import org.infinispan.Cache;
import org.infinispan.Version;
import org.infinispan.commons.util.Util;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.global.GlobalConfigurationBuilder;
import org.infinispan.manager.DefaultCacheManager;
Expand All @@ -19,6 +22,8 @@
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
import org.jboss.shrinkwrap.descriptor.api.spec.se.manifest.ManifestDescriptor;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -30,6 +35,8 @@
*/
@RunWith(Arquillian.class)
public class InfinispanStoreRocksDBIT {
private static String dataDir = tmpDirectory(InfinispanStoreRocksDBIT.class) + File.separator + "rocksdb-testcache";
private static String expiredDir = tmpDirectory(InfinispanStoreRocksDBIT.class) + File.separator + "rocksdb-expiredtestcache";

@Deployment
public static Archive<?> deployment() {
Expand All @@ -42,6 +49,13 @@ private static Asset manifest() {
return new StringAsset(manifest);
}

@Before
@After
public void removeDataFilesIfExists() {
Util.recursiveFileRemove(dataDir);
Util.recursiveFileRemove(expiredDir);
}

/**
* To avoid pulling in TestingUtil and its plethora of dependencies
*/
Expand All @@ -56,8 +70,10 @@ public void testCacheManager() {
gcb.globalJmxStatistics().allowDuplicateDomains(true);

ConfigurationBuilder builder = new ConfigurationBuilder();
builder.persistence().addStore(RocksDBStoreConfigurationBuilder.class)
.location(tmpDirectory(this.getClass()));
builder.persistence()
.addStore(RocksDBStoreConfigurationBuilder.class)
.location(dataDir)
.expiredLocation(expiredDir);

EmbeddedCacheManager cm = new DefaultCacheManager(gcb.build(), builder.build());
Cache<String, String> cache = cm.getCache();
Expand Down
Expand Up @@ -14,7 +14,10 @@
-Djgroups.bind_addr=127.0.0.1 -Djgroups.join_timeout=2000
</property>
<!-- To debug the Arquillian managed application server: -->
<!-- property name="javaVmArguments">-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y -Xmx512m -Dorg.jboss.remoting-jmx.timeout=300 -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property-->
<!--<property name="javaVmArguments">-Xrunjdwp:transport=dt_socket,address=8000,server=n,suspend=y -Dorg.jboss.remoting-jmx.timeout=300-->
<!-- -Djboss.socket.binding.port-offset=100 -Xmx512m -Djava.net.preferIPv4Stack=true-->
<!-- -Djgroups.bind_addr=127.0.0.1 -Djgroups.join_timeout=2000-->
<!--</property>-->
<property name="managementPort">10090</property>
</configuration>
</container>
Expand Down
Expand Up @@ -26,6 +26,8 @@
import org.jboss.arquillian.container.test.api.ContainerController;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -58,18 +60,15 @@ public class RocksDBCacheStoreIT {

private final TestMarshaller clientMarshaller = new TestMarshaller();

private void removeDataFilesIfExists() {
if (dataDir.exists()) {
Util.recursiveFileRemove(dataDir);
}
if (expiredDir.exists()) {
Util.recursiveFileRemove(expiredDir);
}
@Before
@After
public void removeDataFilesIfExists() {
Util.recursiveFileRemove(dataDir);
Util.recursiveFileRemove(expiredDir);
}

@Test
public void testDataSurvivesRestart() throws Exception {
removeDataFilesIfExists();
controller.start(CONTAINER);
RemoteInfinispanCacheManager managerJmx = server.getCacheManager("local");
RemoteInfinispanCache cacheJmx = managerJmx.getCache("testcache");
Expand Down Expand Up @@ -97,7 +96,6 @@ public void testDataSurvivesRestart() throws Exception {

@Test
public void testDataRetrievableViaRocksDbApi() throws Exception {
removeDataFilesIfExists();
controller.start(CONTAINER);
RemoteInfinispanCacheManager managerJmx = server.getCacheManager("local");
RemoteInfinispanCache cacheJmx = managerJmx.getCache("testcache");
Expand Down

0 comments on commit e28b8c2

Please sign in to comment.