Skip to content

Commit

Permalink
Switch to default file system and specific test directory to make win…
Browse files Browse the repository at this point in the history
…dows build pass in couple of tests.
  • Loading branch information
MishaDemianenko committed Jan 21, 2016
1 parent e4eb96c commit 64919f7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
Expand Up @@ -168,10 +168,6 @@ public void drop() throws IOException

public void flush() throws IOException
{
if (!open)
{
return;
}
commitCloseLock.lock();
try
{
Expand Down
Expand Up @@ -108,7 +108,10 @@ public void force()
{
try
{
luceneIndex.flush();
if ( luceneIndex.isOpen() )
{
luceneIndex.flush();
}
}
catch ( IOException e )
{
Expand Down
Expand Up @@ -20,6 +20,7 @@
package org.neo4j.kernel.api.impl.index;

import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
Expand All @@ -45,9 +46,8 @@
public class PartitionedLuceneLabelScanWriter implements LabelScanWriter
{

// TODO: Integer.MAX_VALUE usually used as sentinel marker in lucene, test can we use it as max partition size ?
private final Integer MAXIMUM_PARTITION_SIZE =
Integer.getInteger( "labelScanStore.maxPartitionSize", Integer.MAX_VALUE );
Integer.getInteger( "labelScanStore.maxPartitionSize", IndexWriter.MAX_DOCS );

private final BitmapDocumentFormat format;

Expand Down
Expand Up @@ -28,6 +28,7 @@
import java.util.Collections;

import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction;
import org.neo4j.io.fs.DefaultFileSystemAbstraction;
import org.neo4j.kernel.api.impl.index.builder.LuceneSchemaIndexBuilder;
import org.neo4j.kernel.api.impl.index.populator.DeferredConstraintVerificationUniqueLuceneIndexPopulator;
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory;
Expand All @@ -40,6 +41,7 @@
import org.neo4j.test.CleanupRule;
import org.neo4j.test.OtherThreadExecutor;
import org.neo4j.test.OtherThreadExecutor.WorkerCommand;
import org.neo4j.test.TargetDirectory;

import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.SECONDS;
Expand All @@ -56,6 +58,8 @@ public class DeferredConstraintVerificationUniqueLuceneIndexPopulatorTest
{
@Rule
public final CleanupRule cleanup = new CleanupRule();
@Rule
public TargetDirectory.TestDirectory testDir = TargetDirectory.testDirForTest( getClass() );

private static final int LABEL_ID = 1;
private static final int PROPERTY_KEY_ID = 2;
Expand Down Expand Up @@ -456,9 +460,9 @@ public void shouldReleaseSearcherProperlyAfterVerifyingDeferredConstraints() thr

private DeferredConstraintVerificationUniqueLuceneIndexPopulator newPopulator() throws IOException
{
EphemeralFileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction();
indexStorage = new PartitionedIndexStorage( directoryFactory, fileSystem, new File(
"/target/whatever" ), INDEX_IDENTIFIER );
DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
indexStorage = new PartitionedIndexStorage( directoryFactory, fileSystem,
testDir.directory( "folder" ), INDEX_IDENTIFIER );
LuceneSchemaIndex index = LuceneSchemaIndexBuilder.create()
.withIndexStorage( indexStorage )
.build();
Expand Down
Expand Up @@ -22,14 +22,12 @@
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeQuery;
import org.junit.Test;

import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.TestCase.assertEquals;
import static org.neo4j.kernel.api.impl.index.LuceneDocumentStructure.NODE_ID_KEY;
Expand Down
Expand Up @@ -31,7 +31,6 @@
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -48,7 +47,8 @@
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.api.index.IndexStoreView;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
import org.neo4j.test.EphemeralFileSystemRule;
import org.neo4j.test.DefaultFileSystemRule;
import org.neo4j.test.TargetDirectory;

import static java.lang.Long.parseLong;
import static java.util.Arrays.asList;
Expand All @@ -59,7 +59,10 @@
public class LuceneSchemaIndexPopulatorTest
{
@Rule
public final EphemeralFileSystemRule fs = new EphemeralFileSystemRule();
public final DefaultFileSystemRule fs = new DefaultFileSystemRule();
@Rule
public TargetDirectory.TestDirectory testDir = TargetDirectory.testDirForTest( getClass() );

private IndexDescriptor indexDescriptor;
private IndexStoreView indexStoreView;
private LuceneSchemaIndexProvider provider;
Expand All @@ -76,7 +79,7 @@ public void before() throws Exception
directory = new RAMDirectory();
DirectoryFactory directoryFactory = new DirectoryFactory.Single(
new DirectoryFactory.UncloseableDirectory( directory ) );
provider = new LuceneSchemaIndexProvider( fs.get(), directoryFactory, new File( "/target/whatever" ) );
provider = new LuceneSchemaIndexProvider( fs.get(), directoryFactory, testDir.directory( "folder" ) );
indexDescriptor = new IndexDescriptor( 42, propertyKeyId );
indexStoreView = mock( IndexStoreView.class );
IndexConfiguration indexConfig = IndexConfiguration.NON_UNIQUE;
Expand Down
Expand Up @@ -26,21 +26,23 @@
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

import org.neo4j.io.IOUtils;
import org.neo4j.kernel.api.impl.index.builder.LuceneSchemaIndexBuilder;
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory;
import org.neo4j.test.EphemeralFileSystemRule;
import org.neo4j.test.DefaultFileSystemRule;
import org.neo4j.test.TargetDirectory;

import static org.junit.Assert.assertTrue;

public class LuceneSchemaIndexTest
{
@Rule
public final EphemeralFileSystemRule fs = new EphemeralFileSystemRule();
public final DefaultFileSystemRule fs = new DefaultFileSystemRule();
@Rule
public TargetDirectory.TestDirectory testDir = TargetDirectory.testDirForTest( getClass() );

private final DirectoryFactory dirFactory = new DirectoryFactory.InMemoryDirectoryFactory();
private LuceneSchemaIndex index;
Expand Down Expand Up @@ -138,7 +140,7 @@ private LuceneSchemaIndex newSchemaIndex( boolean unique )
builder = builder.uniqueIndex();
}
return builder
.withIndexRootFolder( new File( "/graph.db" ) )
.withIndexRootFolder( testDir.directory( "index" ) )
.withDirectoryFactory( dirFactory )
.withFileSystem( fs.get() )
.withIndexIdentifier( "testIndex" )
Expand Down

0 comments on commit 64919f7

Please sign in to comment.