use of org.sonar.server.platform.db.migration.step.MigrationSteps in project sonarqube by SonarSource.
the class SQDatabase method executeDbMigrations.
private void executeDbMigrations(NoopDatabase noopDatabase) {
SpringComponentContainer container = new SpringComponentContainer();
container.add(noopDatabase);
MigrationConfigurationModule migrationConfigurationModule = new MigrationConfigurationModule();
migrationConfigurationModule.configure(container);
// dependencies required by DB migrations
container.add(SonarRuntimeImpl.forSonarQube(Version.create(8, 0), SonarQubeSide.SERVER, SonarEdition.COMMUNITY));
container.add(UuidFactoryFast.getInstance());
container.add(System2.INSTANCE);
container.add(MapSettings.class);
container.startComponents();
MigrationContainer migrationContainer = new MigrationContainerImpl(container, H2StepExecutor.class);
MigrationSteps migrationSteps = migrationContainer.getComponentByType(MigrationSteps.class);
MigrationStepsExecutor executor = migrationContainer.getComponentByType(MigrationStepsExecutor.class);
executor.execute(migrationSteps.readAll());
}
use of org.sonar.server.platform.db.migration.step.MigrationSteps in project sonarqube by SonarSource.
the class MigrationHistoryMeddlerTest method verifyUpdateLastMigrationNumber.
public void verifyUpdateLastMigrationNumber(long oldVersion, long expectedNewVersion) {
when(migrationHistory.getLastMigrationNumber()).thenReturn(Optional.of(oldVersion));
List<RegisteredMigrationStep> stepsFromNewLastMigrationNumber = IntStream.range(0, 1 + new Random().nextInt(30)).mapToObj(i -> new RegisteredMigrationStep(i, "desc_" + i, MigrationStep.class)).collect(Collectors.toList());
when(migrationSteps.readFrom(expectedNewVersion)).thenReturn(stepsFromNewLastMigrationNumber);
underTest.meddle(migrationHistory);
verify(migrationHistory).getLastMigrationNumber();
verify(migrationSteps).readFrom(expectedNewVersion);
verify(migrationHistory).done(stepsFromNewLastMigrationNumber.get(0));
verifyNoMoreInteractions(migrationHistory, migrationSteps);
}
use of org.sonar.server.platform.db.migration.step.MigrationSteps in project sonarqube by SonarSource.
the class MigrationContainerPopulatorImpl method populateFromMigrationSteps.
private static void populateFromMigrationSteps(MigrationContainer container) {
MigrationSteps migrationSteps = container.getComponentByType(MigrationSteps.class);
Set<Class<? extends MigrationStep>> classes = new HashSet<>();
migrationSteps.readAll().forEach(step -> {
Class<? extends MigrationStep> stepClass = step.getStepClass();
if (!classes.contains(stepClass)) {
container.add(stepClass);
classes.add(stepClass);
}
});
}
Aggregations