Search in sources :

Example 1 with MigrationCompleted

use of org.graylog2.migrations.V20161215163900_MoveIndexSetDefaultConfig.MigrationCompleted in project graylog2-server by Graylog2.

the class V20161215163900_MoveIndexSetDefaultConfigTest method upgrade.

@Test
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()).containsExactly("57f3d721a43c2d59cb750001", "57f3d721a43c2d59cb750003");
}
Also used : DefaultIndexSetConfig(org.graylog2.indexer.indexset.DefaultIndexSetConfig) MigrationCompleted(org.graylog2.migrations.V20161215163900_MoveIndexSetDefaultConfig.MigrationCompleted) Test(org.junit.Test)

Example 2 with MigrationCompleted

use of org.graylog2.migrations.V20161215163900_MoveIndexSetDefaultConfig.MigrationCompleted in project graylog2-server by Graylog2.

the class V20170110150100_FixAlertConditionsMigrationTest method upgrade.

@Test
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");
}
Also used : MigrationCompleted(org.graylog2.migrations.V20170110150100_FixAlertConditionsMigration.MigrationCompleted) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DefaultIndexSetConfig (org.graylog2.indexer.indexset.DefaultIndexSetConfig)1 MigrationCompleted (org.graylog2.migrations.V20161215163900_MoveIndexSetDefaultConfig.MigrationCompleted)1 MigrationCompleted (org.graylog2.migrations.V20170110150100_FixAlertConditionsMigration.MigrationCompleted)1