Skip to content

Commit

Permalink
Fixes for a recent migration commit.
Browse files Browse the repository at this point in the history
 - Fixed remaining hard references to legacy version v0.9.9 instead of using
   LegacyStore.LEGACY_VERSION.
 - Increased expected max ID of node store in a test due to the previous
   store migration code increasing max ID one too much even if the last ID
   wasn't in use.
  • Loading branch information
tinwelint committed Mar 18, 2013
1 parent 38c134c commit 8288187
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Expand Up @@ -296,7 +296,7 @@ private void setBlockSize( File file, int blockSize, String oldVersionToSet ) th
buffer.flip(); buffer.flip();
channel.write( buffer ); channel.write( buffer );


// It's the same length as the current version v0.9.9 // It's the same length as the current version
channel.position( channel.size() - UTF8.encode( oldVersionToSet ).length ); channel.position( channel.size() - UTF8.encode( oldVersionToSet ).length );
buffer = ByteBuffer.wrap( UTF8.encode( oldVersionToSet ) ); buffer = ByteBuffer.wrap( UTF8.encode( oldVersionToSet ) );
channel.write( buffer ); channel.write( buffer );
Expand Down
Expand Up @@ -91,7 +91,7 @@ public void shouldAbortOnCorruptStore() throws IOException
assertTrue( allStoreFilesHaveVersion( fileSystem, workingDirectory, LEGACY_VERSION ) ); assertTrue( allStoreFilesHaveVersion( fileSystem, workingDirectory, LEGACY_VERSION ) );
truncateFile(fileSystem, new File( workingDirectory, truncateFile(fileSystem, new File( workingDirectory,
"neostore.propertystore.db.index.keys" ), "neostore.propertystore.db.index.keys" ),
"StringPropertyStore v0.9.9" ); "StringPropertyStore " + LEGACY_VERSION );


Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
params.put( Config.ALLOW_STORE_UPGRADE, "true" ); params.put( Config.ALLOW_STORE_UPGRADE, "true" );
Expand Down
Expand Up @@ -28,6 +28,7 @@
import static org.neo4j.kernel.impl.storemigration.MigrationTestUtils.changeVersionNumber; import static org.neo4j.kernel.impl.storemigration.MigrationTestUtils.changeVersionNumber;
import static org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile; import static org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile;
import static org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateToFixedLength; import static org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateToFixedLength;
import static org.neo4j.kernel.impl.storemigration.legacystore.LegacyStore.LEGACY_VERSION;
import static org.neo4j.kernel.impl.util.FileUtils.copyRecursively; import static org.neo4j.kernel.impl.util.FileUtils.copyRecursively;


import java.io.File; import java.io.File;
Expand Down Expand Up @@ -92,7 +93,7 @@ public void shouldRejectStoresIfOneFileHasNoVersionAsIfNotShutDownCleanly() thro


copyRecursively( resourceDirectory, workingDirectory ); copyRecursively( resourceDirectory, workingDirectory );


truncateFile( fileSystem, new File( workingDirectory, "neostore.nodestore.db" ), "StringPropertyStore v0.9.9" ); truncateFile( fileSystem, new File( workingDirectory, "neostore.nodestore.db" ), "StringPropertyStore " + LEGACY_VERSION );


assertFalse( new UpgradableDatabase(fileSystem).storeFilesUpgradeable( new File( workingDirectory, "neostore" ) ) ); assertFalse( new UpgradableDatabase(fileSystem).storeFilesUpgradeable( new File( workingDirectory, "neostore" ) ) );
} }
Expand All @@ -110,7 +111,7 @@ public void shouldRejectStoresIfOneFileShorterThanExpectedVersionString() throws
copyRecursively( resourceDirectory, workingDirectory ); copyRecursively( resourceDirectory, workingDirectory );


int shortFileLength = 5 /* (RelationshipTypeStore.RECORD_SIZE) */ * 3; int shortFileLength = 5 /* (RelationshipTypeStore.RECORD_SIZE) */ * 3;
assertTrue( shortFileLength < UTF8.encode( "StringPropertyStore v0.9.9" ).length ); assertTrue( shortFileLength < UTF8.encode( "StringPropertyStore " + LEGACY_VERSION ).length );
truncateToFixedLength( fileSystem, new File( workingDirectory, "neostore.relationshiptypestore.db" ), shortFileLength ); truncateToFixedLength( fileSystem, new File( workingDirectory, "neostore.relationshiptypestore.db" ), shortFileLength );


assertFalse( new UpgradableDatabase(fileSystem).storeFilesUpgradeable( new File( workingDirectory, "neostore" ) ) ); assertFalse( new UpgradableDatabase(fileSystem).storeFilesUpgradeable( new File( workingDirectory, "neostore" ) ) );
Expand Down Expand Up @@ -140,7 +141,7 @@ public void shouldCommunicateWhatCausesInabilityToUpgrade() throws IOException
catch (StoreUpgrader.UnableToUpgradeException e) catch (StoreUpgrader.UnableToUpgradeException e)
{ {
assertThat( e.getMessage(), is("'neostore.nodestore.db' has a store version number that we cannot upgrade " + assertThat( e.getMessage(), is("'neostore.nodestore.db' has a store version number that we cannot upgrade " +
"from. Expected 'NodeStore v0.9.9' but file is version 'NodeStore v0.9.5'.") ); "from. Expected 'NodeStore " + LEGACY_VERSION + "' but file is version 'NodeStore v0.9.5'.") );
} }
} }
} }
Expand Up @@ -38,7 +38,7 @@ public void shouldReadNodeRecords() throws IOException
URL nodeStoreFile = getClass().getResource( "exampledb/neostore.nodestore.db" ); URL nodeStoreFile = getClass().getResource( "exampledb/neostore.nodestore.db" );


LegacyNodeStoreReader nodeStoreReader = new LegacyNodeStoreReader( fs, new File( nodeStoreFile.getFile() ) ); LegacyNodeStoreReader nodeStoreReader = new LegacyNodeStoreReader( fs, new File( nodeStoreFile.getFile() ) );
assertEquals( 1001, nodeStoreReader.getMaxId() ); assertEquals( 1002, nodeStoreReader.getMaxId() );
Iterable<NodeRecord> records = nodeStoreReader.readNodeStore(); Iterable<NodeRecord> records = nodeStoreReader.readNodeStore();
int nodeCount = 0; int nodeCount = 0;
for ( NodeRecord record : records ) for ( NodeRecord record : records )
Expand Down

0 comments on commit 8288187

Please sign in to comment.