forked from bisq-network/bisq2
-
Notifications
You must be signed in to change notification settings - Fork 0
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 bisq-network#2976 from alvasw/migration_Dont_keep_…
…MigrationService_in_memory migration: Don't keep MigrationService in memory
- Loading branch information
Showing
15 changed files
with
93 additions
and
58 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
2 changes: 1 addition & 1 deletion
2
...ution/migration/migrations/Migration.java → ...ation/migration/migrations/Migration.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
6 changes: 5 additions & 1 deletion
6
.../migrations/MigrationFailedException.java → .../migrations/MigrationFailedException.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
2 changes: 1 addition & 1 deletion
2
...ation/migrations/MigrationsForV2_1_2.java → ...ation/migrations/MigrationsForV2_1_2.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
3 changes: 2 additions & 1 deletion
3
...tion/migration/MigrationServiceTests.java → ...tion/migration/MigrationServiceTests.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
59 changes: 59 additions & 0 deletions
59
application/src/test/java/bisq/application/migration/MigratorTest.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,59 @@ | ||
package bisq.application.migration; | ||
|
||
import bisq.application.migration.migrations.Migration; | ||
import bisq.application.migration.migrations.MigrationFailedException; | ||
import bisq.common.application.ApplicationVersion; | ||
import bisq.common.platform.Version; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class MigratorTest { | ||
@Test | ||
void migrationSuccess(@TempDir Path dataDir) throws IOException { | ||
Path versionFilePath = dataDir.resolve("version"); | ||
Version dataDirVersion = new Version("2.1.0"); | ||
Files.writeString(versionFilePath, dataDirVersion.toString()); | ||
|
||
Version appVersion = ApplicationVersion.getVersion(); | ||
Migrator migrator = new Migrator(appVersion, dataDir, Collections.emptyList()); | ||
|
||
migrator.migrate(); | ||
|
||
String readVersion = Files.readString(dataDir.resolve("version")); | ||
assertThat(readVersion).isEqualTo(appVersion.toString()); | ||
} | ||
|
||
@Test | ||
void migrationFailure(@TempDir Path dataDir) throws IOException { | ||
Path versionFilePath = dataDir.resolve("version"); | ||
Version dataDirVersion = new Version("2.1.0"); | ||
Files.writeString(versionFilePath, dataDirVersion.toString()); | ||
|
||
Version appVersion = ApplicationVersion.getVersion(); | ||
var migration = new Migration() { | ||
@Override | ||
public void run(Path dataDir) { | ||
throw new MigrationFailedException("Migration failed."); | ||
} | ||
|
||
@Override | ||
public Version getVersion() { | ||
return new Version("2.1.1"); | ||
} | ||
}; | ||
|
||
Migrator migrator = new Migrator(appVersion, dataDir, List.of(migration, migration)); | ||
migrator.migrate(); | ||
|
||
String readVersion = Files.readString(dataDir.resolve("version")); | ||
assertThat(readVersion).isEqualTo(dataDirVersion.toString()); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
.../migrations/MigrationsForV2_1_2Tests.java → .../migrations/MigrationsForV2_1_2Tests.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
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
29 changes: 0 additions & 29 deletions
29
evolution/src/test/java/bisq/evolution/migration/MigratorTest.java
This file was deleted.
Oops, something went wrong.
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