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

ISPN-7530 InfinispanStoreRocksDBIT leaves files in the current directory #4902

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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-->
Copy link
Contributor

Choose a reason for hiding this comment

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

Changes in this file could be probably removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I really want to keep this in because the existing commented javaVmArguments were incomplete, and it was frustrating when I enabled debugging and the test wouldn't run.

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, could you please add a comment with those switches at the beginning of the file? Let's now throw rubbish all around :D

Copy link
Member Author

Choose a reason for hiding this comment

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

@slaskawi I could remove the comment altogether, but I would definitely not leave the comment as it was before...

<!-- -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