-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11441 from tinwelint/3.4-cheap-migration
Avoid unnecessary 3.3 -> 3.4 migration
- Loading branch information
Showing
14 changed files
with
240 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
community/kernel/src/test/java/org/neo4j/kernel/impl/store/format/BaseRecordFormatsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.store.format; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import org.neo4j.test.rule.RandomRule; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
import static org.neo4j.helpers.collection.Iterators.array; | ||
|
||
public class BaseRecordFormatsTest | ||
{ | ||
private static final Capability[] CAPABILITIES = Capability.values(); | ||
private static final CapabilityType[] CAPABILITY_TYPES = CapabilityType.values(); | ||
|
||
@Rule | ||
public final RandomRule random = new RandomRule(); | ||
|
||
@Test | ||
public void shouldReportCompatibilityBetweenTwoEqualSetsOfCapabilities() | ||
{ | ||
// given | ||
Capability[] capabilities = random.selection( CAPABILITIES, CAPABILITIES.length / 2, CAPABILITIES.length, false ); | ||
|
||
// then | ||
assertCompatibility( capabilities, capabilities, true, CAPABILITY_TYPES ); | ||
} | ||
|
||
@Test | ||
public void shouldReportCompatibilityForAdditiveAdditionalCapabilities() | ||
{ | ||
// given | ||
Capability[] from = array( Capability.SCHEMA ); | ||
Capability[] to = array( Capability.SCHEMA, Capability.POINT_PROPERTIES, Capability.TEMPORAL_PROPERTIES ); | ||
|
||
// then | ||
assertCompatibility( from, to, true, CAPABILITY_TYPES ); | ||
} | ||
|
||
@Test | ||
public void shouldReportIncompatibilityForChangingAdditionalCapabilities() | ||
{ | ||
// given | ||
Capability[] from = array( Capability.SCHEMA ); | ||
Capability[] to = array( Capability.SCHEMA, Capability.DENSE_NODES ); | ||
|
||
// then | ||
assertCompatibility( from, to, false, CapabilityType.STORE ); | ||
} | ||
|
||
@Test | ||
public void shouldReportIncompatibilityForAdditiveRemovedCapabilities() | ||
{ | ||
// given | ||
Capability[] from = array( Capability.SCHEMA, Capability.POINT_PROPERTIES, Capability.TEMPORAL_PROPERTIES ); | ||
Capability[] to = array( Capability.SCHEMA ); | ||
|
||
// then | ||
assertCompatibility( from, to, false, CapabilityType.STORE ); | ||
} | ||
|
||
private void assertCompatibility( Capability[] from, Capability[] to, boolean compatible, CapabilityType... capabilityTypes ) | ||
{ | ||
for ( CapabilityType type : capabilityTypes ) | ||
{ | ||
assertEquals( compatible, format( from ).hasCompatibleCapabilities( format( to ), type ) ); | ||
} | ||
} | ||
|
||
private RecordFormats format( Capability... capabilities ) | ||
{ | ||
RecordFormats formats = mock( BaseRecordFormats.class ); | ||
when( formats.capabilities() ).thenReturn( capabilities ); | ||
when( formats.hasCompatibleCapabilities( any( RecordFormats.class ), any( CapabilityType.class ) ) ).thenCallRealMethod(); | ||
return formats; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...el/src/test/java/org/neo4j/kernel/impl/storemigration/participant/CountsMigratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.storemigration.participant; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.neo4j.kernel.configuration.Config; | ||
import org.neo4j.kernel.impl.store.format.StoreVersion; | ||
import org.neo4j.kernel.impl.util.monitoring.SilentProgressReporter; | ||
import org.neo4j.test.rule.TestDirectory; | ||
import org.neo4j.test.rule.fs.EphemeralFileSystemRule; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.neo4j.kernel.impl.store.StoreFile.COUNTS_STORE_LEFT; | ||
import static org.neo4j.kernel.impl.store.StoreFile.COUNTS_STORE_RIGHT; | ||
import static org.neo4j.kernel.impl.storemigration.StoreFileType.STORE; | ||
|
||
public class CountsMigratorTest | ||
{ | ||
@Rule | ||
public final EphemeralFileSystemRule fs = new EphemeralFileSystemRule(); | ||
@Rule | ||
public final TestDirectory directory = TestDirectory.testDirectory( fs ); | ||
|
||
@Test | ||
public void shouldNotAccidentallyDeleteStoreFilesIfNoMigrationWasRequired() throws IOException | ||
{ | ||
// given | ||
CountsMigrator migrator = new CountsMigrator( fs, null, Config.defaults() ); | ||
File storeDir = directory.graphDbDir(); | ||
File countsStoreFileA = new File( storeDir, COUNTS_STORE_LEFT.fileName( STORE ) ); | ||
File countsStoreFileB = new File( storeDir, COUNTS_STORE_RIGHT.fileName( STORE ) ); | ||
fs.create( countsStoreFileA ); | ||
fs.create( countsStoreFileB ); | ||
File migrationDir = new File( storeDir, "migration" ); | ||
fs.mkdirs( migrationDir ); | ||
String versionToMigrateFrom = StoreVersion.STANDARD_V3_2.versionString(); | ||
String versionToMigrateTo = StoreVersion.STANDARD_V3_4.versionString(); | ||
migrator.migrate( storeDir, migrationDir, SilentProgressReporter.INSTANCE, versionToMigrateFrom, versionToMigrateTo ); | ||
assertEquals( "Invalid test assumption: There should not have been migration for those versions", 0, | ||
fs.listFiles( migrationDir ).length ); | ||
|
||
// when | ||
migrator.moveMigratedFiles( migrationDir, storeDir, versionToMigrateFrom, versionToMigrateTo ); | ||
|
||
// then | ||
assertTrue( fs.fileExists( countsStoreFileA ) ); | ||
assertTrue( fs.fileExists( countsStoreFileB ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.