use of org.graylog2.migrations.V20191121145100_FixDefaultGrokPatterns.MigrationCompleted in project graylog2-server by Graylog2.
the class V20191129134600_CreateInitialUrlWhitelist method upgrade.
@Override
public void upgrade() {
final MigrationCompleted migrationCompleted = configService.get(MigrationCompleted.class);
if (migrationCompleted != null) {
log.debug("Migration already completed.");
return;
}
UrlWhitelist whitelist = createWhitelist();
whitelistService.saveWhitelist(whitelist);
configService.write(MigrationCompleted.create(whitelist.toString()));
}
use of org.graylog2.migrations.V20191121145100_FixDefaultGrokPatterns.MigrationCompleted in project graylog2-server by Graylog2.
the class V20191121145100_FixDefaultGrokPatternsTest method alreadyMigrated.
@Test
public void alreadyMigrated() {
final MigrationCompleted migrationCompleted = MigrationCompleted.create(Collections.singleton(PATTERN_NAME));
when(configService.get(MigrationCompleted.class)).thenReturn(migrationCompleted);
migration.upgrade();
verifyZeroInteractions(grokPatternService);
}
use of org.graylog2.migrations.V20191121145100_FixDefaultGrokPatterns.MigrationCompleted in project graylog2-server by Graylog2.
the class V20161215163900_MoveIndexSetDefaultConfigTest method upgrade.
@Test
@MongoDBFixtures("V20161215163900_MoveIndexSetDefaultConfigTest.json")
public void upgrade() throws Exception {
final long count = collection.count();
migration.upgrade();
final MigrationCompleted migrationCompleted = clusterConfigService.get(MigrationCompleted.class);
assertThat(collection.count()).withFailMessage("No document should be deleted by the migration!").isEqualTo(count);
assertThat(collection.count(Filters.exists("default"))).withFailMessage("The migration should have deleted the \"default\" field from the documents!").isEqualTo(0L);
assertThat(clusterConfigService.get(DefaultIndexSetConfig.class)).withFailMessage("The DefaultIndexSetConfig should have been written to cluster config!").isNotNull();
assertThat(clusterConfigService.get(DefaultIndexSetConfig.class).defaultIndexSetId()).isEqualTo("57f3d721a43c2d59cb750001");
assertThat(migrationCompleted).isNotNull();
assertThat(migrationCompleted.indexSetIds()).containsExactlyInAnyOrder("57f3d721a43c2d59cb750001", "57f3d721a43c2d59cb750003");
}
use of org.graylog2.migrations.V20191121145100_FixDefaultGrokPatterns.MigrationCompleted in project graylog2-server by Graylog2.
the class V20170110150100_FixAlertConditionsMigrationTest method upgrade.
@Test
@MongoDBFixtures("V20170110150100_FixAlertConditionsMigration.json")
public void upgrade() throws Exception {
// First check all types of the existing documents
AlertConditionAssertions.assertThat(getAlertCondition("2fa6a415-ce0c-4a36-accc-dd9519eb06d9")).hasParameter("backlog", 2).hasParameter("grace", 1).hasParameter("threshold_type", "MORE").hasParameter("threshold", "5").hasParameter("time", "1");
AlertConditionAssertions.assertThat(getAlertCondition("393fd8b2-9b17-42d3-86b0-6e55d0f5343a")).hasParameter("backlog", 0).hasParameter("field", "bar").hasParameter("grace", "0").hasParameter("value", "baz");
AlertConditionAssertions.assertThat(getAlertCondition("0e75404f-c0ee-40b0-8872-b1aec441ba1c")).hasParameter("backlog", "0").hasParameter("field", "foo").hasParameter("grace", "0").hasParameter("threshold_type", "HIGHER").hasParameter("threshold", "0").hasParameter("time", "5").hasParameter("type", "MAX");
// Run the migration that should convert all affected fields to integers
migration.upgrade();
// Check all types again
AlertConditionAssertions.assertThat(getAlertCondition("2fa6a415-ce0c-4a36-accc-dd9519eb06d9")).hasParameter("backlog", 2).hasParameter("grace", 1).hasParameter("threshold_type", "MORE").hasParameter("threshold", 5).hasParameter("time", 1);
AlertConditionAssertions.assertThat(getAlertCondition("393fd8b2-9b17-42d3-86b0-6e55d0f5343a")).hasParameter("backlog", 0).hasParameter("field", "bar").hasParameter("grace", 0).hasParameter("value", "baz");
AlertConditionAssertions.assertThat(getAlertCondition("0e75404f-c0ee-40b0-8872-b1aec441ba1c")).hasParameter("backlog", 0).hasParameter("field", "foo").hasParameter("grace", 0).hasParameter("threshold_type", "HIGHER").hasParameter("threshold", 0).hasParameter("time", 5).hasParameter("type", "MAX");
final MigrationCompleted migrationCompleted = clusterConfigService.get(MigrationCompleted.class);
assertThat(migrationCompleted).isNotNull();
assertThat(migrationCompleted.streamIds()).containsOnly("58458e442f857c314491344e", "58458e442f857c314491345e");
assertThat(migrationCompleted.alertConditionIds()).containsOnly("2fa6a415-ce0c-4a36-accc-dd9519eb06d9", "393fd8b2-9b17-42d3-86b0-6e55d0f5343a", "0e75404f-c0ee-40b0-8872-b1aec441ba1c");
}
use of org.graylog2.migrations.V20191121145100_FixDefaultGrokPatterns.MigrationCompleted in project graylog2-server by Graylog2.
the class V20201103145400_LegacyAuthServiceMigration method upgrade.
@Override
public void upgrade() {
final MigrationCompleted migrationState = clusterConfigService.getOrDefault(MigrationCompleted.class, MigrationCompleted.createEmpty());
final ImmutableSet.Builder<String> migratedConfigsBuilder = ImmutableSet.builder();
// While the LDAP settings collection could contain more than one document, in practice we only expect a
// single one. That's why we are using the ID of the last created auth service for the notification.
String lastCreatedAuthServiceId = null;
// Add all configs that have already been migrated
migratedConfigsBuilder.addAll(migrationState.migratedConfigs());
for (final Document document : ldapSettings.find().sort(Sorts.ascending("_id"))) {
final String idString = document.getObjectId("_id").toHexString();
if (!document.getBoolean("enabled")) {
LOG.debug("Skipping disabled configuration <{}>", idString);
continue;
}
if (migrationState.isDone(idString)) {
LOG.debug("Configuration <{}> already migrated", idString);
continue;
}
final AuthServiceBackendDTO newConfig;
if (document.getBoolean("active_directory")) {
newConfig = buildActiveDirectoryConfig(document);
} else {
newConfig = buildLDAPConfig(document);
}
final AuthServiceBackendDTO savedConfig = authServiceBackendService.save(newConfig);
for (final MigrationModule migrationModule : migrationModules) {
migrationModule.upgrade(document, savedConfig);
}
lastCreatedAuthServiceId = savedConfig.id();
migratedConfigsBuilder.add(idString);
}
final ImmutableSet<String> migratedConfigs = migratedConfigsBuilder.build();
clusterConfigService.write(MigrationCompleted.create(migratedConfigs));
if (lastCreatedAuthServiceId != null) {
final Notification notification = notificationService.buildNow().addType(Notification.Type.LEGACY_LDAP_CONFIG_MIGRATION).addSeverity(Notification.Severity.URGENT).addDetail("auth_service_id", lastCreatedAuthServiceId);
notificationService.publishIfFirst(notification);
}
}
Aggregations