Skip to content

Commit

Permalink
Update tests to take IndexProvider.bless into account.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvest committed Jan 16, 2019
1 parent 4979cf1 commit bfaccd9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Expand Up @@ -26,6 +26,7 @@
import org.junit.rules.Timeout; import org.junit.rules.Timeout;


import java.util.Optional; import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;


import org.neo4j.collection.primitive.Primitive; import org.neo4j.collection.primitive.Primitive;
Expand Down Expand Up @@ -132,8 +133,9 @@ public void createAndRetainRelationshipFulltextIndex() throws Exception
IndexReference indexReference; IndexReference indexReference;
try ( KernelTransactionImplementation transaction = getKernelTransaction() ) try ( KernelTransactionImplementation transaction = getKernelTransaction() )
{ {
MultiTokenSchemaDescriptor schemaDescriptor = multiToken( new int[]{0, 1, 2}, EntityType.RELATIONSHIP, 0, 1, 2, 3 ); MultiTokenSchemaDescriptor multiTokenSchemaDescriptor = multiToken( new int[]{0, 1, 2}, EntityType.RELATIONSHIP, 0, 1, 2, 3 );
indexReference = transaction.schemaWrite().indexCreate( schemaDescriptor, DESCRIPTOR.name(), Optional.of( "fulltext" ) ); FulltextSchemaDescriptor schema = new FulltextSchemaDescriptor( multiTokenSchemaDescriptor, new Properties() );
indexReference = transaction.schemaWrite().indexCreate( schema, DESCRIPTOR.name(), Optional.of( "fulltext" ) );
transaction.success(); transaction.success();
} }
await( indexReference ); await( indexReference );
Expand Down Expand Up @@ -164,8 +166,9 @@ public void createAndQueryFulltextRelationshipIndex() throws Exception
IndexReference indexReference; IndexReference indexReference;
try ( KernelTransactionImplementation transaction = getKernelTransaction() ) try ( KernelTransactionImplementation transaction = getKernelTransaction() )
{ {
MultiTokenSchemaDescriptor schemaDescriptor = multiToken( new int[]{0, 1, 2}, EntityType.RELATIONSHIP, 0, 1, 2, 3 ); MultiTokenSchemaDescriptor multiTokenSchemaDescriptor = multiToken( new int[]{0, 1, 2}, EntityType.RELATIONSHIP, 0, 1, 2, 3 );
indexReference = transaction.schemaWrite().indexCreate( schemaDescriptor, DESCRIPTOR.name(), Optional.of( "fulltext" ) ); FulltextSchemaDescriptor schema = new FulltextSchemaDescriptor( multiTokenSchemaDescriptor, new Properties() );
indexReference = transaction.schemaWrite().indexCreate( schema, DESCRIPTOR.name(), Optional.of( "fulltext" ) );
transaction.success(); transaction.success();
} }
await( indexReference ); await( indexReference );
Expand Down Expand Up @@ -367,8 +370,9 @@ private IndexReference createIndex( int[] entityTokens, int[] propertyIds )
IndexReference fulltext; IndexReference fulltext;
try ( KernelTransactionImplementation transaction = getKernelTransaction() ) try ( KernelTransactionImplementation transaction = getKernelTransaction() )
{ {
MultiTokenSchemaDescriptor schemaDescriptor = multiToken( entityTokens, EntityType.NODE, propertyIds ); MultiTokenSchemaDescriptor multiTokenSchemaDescriptor = multiToken( entityTokens, EntityType.NODE, propertyIds );
fulltext = transaction.schemaWrite().indexCreate( schemaDescriptor, DESCRIPTOR.name(), Optional.of( NAME ) ); FulltextSchemaDescriptor schema = new FulltextSchemaDescriptor( multiTokenSchemaDescriptor, new Properties() );
fulltext = transaction.schemaWrite().indexCreate( schema, DESCRIPTOR.name(), Optional.of( NAME ) );
transaction.success(); transaction.success();
} }
return fulltext; return fulltext;
Expand Down
Expand Up @@ -36,6 +36,7 @@
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.Transaction;
import org.neo4j.internal.kernel.api.TokenRead; import org.neo4j.internal.kernel.api.TokenRead;
import org.neo4j.internal.kernel.api.exceptions.schema.MisconfiguredIndexException;
import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor;
import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.PageCache; import org.neo4j.io.pagecache.PageCache;
Expand All @@ -53,6 +54,7 @@
import org.neo4j.kernel.impl.index.schema.CollectingIndexUpdater; import org.neo4j.kernel.impl.index.schema.CollectingIndexUpdater;
import org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant; import org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant;
import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.storageengine.api.schema.IndexSample; import org.neo4j.storageengine.api.schema.IndexSample;
import org.neo4j.storageengine.api.schema.StoreIndexDescriptor; import org.neo4j.storageengine.api.schema.StoreIndexDescriptor;
import org.neo4j.test.TestGraphDatabaseFactory; import org.neo4j.test.TestGraphDatabaseFactory;
Expand Down Expand Up @@ -168,11 +170,12 @@ private Node createNode( Map<String, Object> properties, Label ... labels )
} }


@Before @Before
public void before() public void before() throws MisconfiguredIndexException
{ {
when( mockedIndexProvider.getProviderDescriptor() ).thenReturn( PROVIDER_DESCRIPTOR ); when( mockedIndexProvider.getProviderDescriptor() ).thenReturn( PROVIDER_DESCRIPTOR );
when( mockedIndexProvider.storeMigrationParticipant( any( FileSystemAbstraction.class ), any( PageCache.class ) ) ) when( mockedIndexProvider.storeMigrationParticipant( any( FileSystemAbstraction.class ), any( PageCache.class ) ) )
.thenReturn( StoreMigrationParticipant.NOT_PARTICIPATING ); .thenReturn( StoreMigrationParticipant.NOT_PARTICIPATING );
when( mockedIndexProvider.bless( any( IndexDescriptor.class ) ) ).thenCallRealMethod();
TestGraphDatabaseFactory factory = new TestGraphDatabaseFactory(); TestGraphDatabaseFactory factory = new TestGraphDatabaseFactory();
factory.setFileSystem( fs.get() ); factory.setFileSystem( fs.get() );
factory.setKernelExtensions( factory.setKernelExtensions(
Expand Down
Expand Up @@ -26,6 +26,7 @@


import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
Expand All @@ -39,6 +40,7 @@
import org.neo4j.graphdb.schema.IndexDefinition; import org.neo4j.graphdb.schema.IndexDefinition;
import org.neo4j.graphdb.schema.Schema; import org.neo4j.graphdb.schema.Schema;
import org.neo4j.internal.kernel.api.InternalIndexState; import org.neo4j.internal.kernel.api.InternalIndexState;
import org.neo4j.internal.kernel.api.exceptions.schema.MisconfiguredIndexException;
import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor; import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor;
import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.PageCache; import org.neo4j.io.pagecache.PageCache;
Expand All @@ -59,6 +61,7 @@
import org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo; import org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo;
import org.neo4j.kernel.impl.transaction.log.rotation.LogRotation; import org.neo4j.kernel.impl.transaction.log.rotation.LogRotation;
import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.storageengine.api.schema.IndexDescriptor;
import org.neo4j.storageengine.api.schema.IndexSample; import org.neo4j.storageengine.api.schema.IndexSample;
import org.neo4j.storageengine.api.schema.StoreIndexDescriptor; import org.neo4j.storageengine.api.schema.StoreIndexDescriptor;
import org.neo4j.test.TestGraphDatabaseFactory; import org.neo4j.test.TestGraphDatabaseFactory;
Expand Down Expand Up @@ -241,11 +244,12 @@ public void shouldKeepFailedIndexesAsFailedAfterRestart() throws Exception
private final Label myLabel = label( "MyLabel" ); private final Label myLabel = label( "MyLabel" );


@Before @Before
public void setUp() public void setUp() throws MisconfiguredIndexException
{ {
when( mockedIndexProvider.getProviderDescriptor() ).thenReturn( PROVIDER_DESCRIPTOR ); when( mockedIndexProvider.getProviderDescriptor() ).thenReturn( PROVIDER_DESCRIPTOR );
when( mockedIndexProvider.storeMigrationParticipant( any( FileSystemAbstraction.class ), any( PageCache.class ) ) ) when( mockedIndexProvider.storeMigrationParticipant( any( FileSystemAbstraction.class ), any( PageCache.class ) ) )
.thenReturn( StoreMigrationParticipant.NOT_PARTICIPATING ); .thenReturn( StoreMigrationParticipant.NOT_PARTICIPATING );
when( mockedIndexProvider.bless( any( IndexDescriptor.class ) ) ).thenCallRealMethod();
} }


private void startDb() private void startDb()
Expand All @@ -257,7 +261,7 @@ private void startDb()


TestGraphDatabaseFactory factory = new TestGraphDatabaseFactory(); TestGraphDatabaseFactory factory = new TestGraphDatabaseFactory();
factory.setFileSystem( fs.get() ); factory.setFileSystem( fs.get() );
factory.setKernelExtensions( Arrays.asList( mockedIndexProviderFactory ) ); factory.setKernelExtensions( Collections.singletonList( mockedIndexProviderFactory ) );
db = (GraphDatabaseAPI) factory.newImpermanentDatabaseBuilder() db = (GraphDatabaseAPI) factory.newImpermanentDatabaseBuilder()
.setConfig( GraphDatabaseSettings.default_schema_provider, PROVIDER_DESCRIPTOR.name() ).newGraphDatabase(); .setConfig( GraphDatabaseSettings.default_schema_provider, PROVIDER_DESCRIPTOR.name() ).newGraphDatabase();
} }
Expand Down

0 comments on commit bfaccd9

Please sign in to comment.