-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow deletion of index ranges that are no longer manged (#17841)
* allow deletion of index ranges that are no longer managed by an index set * add changelog * clean up
- Loading branch information
1 parent
ca5ca2c
commit efcc2ef
Showing
5 changed files
with
147 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type = "fixed" | ||
message = "Allow the index range clean up periodcal to delete index ranges that are no longer managed by an index set" | ||
|
||
issues = ["17815"] | ||
pulls = ["17841"] |
77 changes: 77 additions & 0 deletions
77
full-backend-tests/src/test/java/org/graylog2/periodical/IndexRangesCleanUpIT.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,77 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* 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 | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
package org.graylog2.periodical; | ||
|
||
import com.github.rholder.retry.RetryException; | ||
import com.github.rholder.retry.RetryerBuilder; | ||
import com.github.rholder.retry.StopStrategies; | ||
import com.github.rholder.retry.WaitStrategies; | ||
import org.graylog.testing.completebackend.Lifecycle; | ||
import org.graylog.testing.completebackend.apis.GraylogApis; | ||
import org.graylog.testing.containermatrix.annotations.ContainerMatrixTest; | ||
import org.graylog.testing.containermatrix.annotations.ContainerMatrixTestsConfiguration; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@ContainerMatrixTestsConfiguration(serverLifecycle = Lifecycle.CLASS) | ||
public class IndexRangesCleanUpIT { | ||
public static final String RANGE_CLEANUP_PREFIX = "range-cleanup"; | ||
public static final String INDEX_TWO = RANGE_CLEANUP_PREFIX + "_1"; | ||
public static final String INDEX_ONE = RANGE_CLEANUP_PREFIX + "_0"; | ||
private final GraylogApis api; | ||
|
||
public IndexRangesCleanUpIT(GraylogApis api) { | ||
this.api = api; | ||
} | ||
|
||
@ContainerMatrixTest | ||
void testCleanUp() throws ExecutionException, RetryException { | ||
String indexSetId = api.indices().createIndexSet("Range clean up", "test index range clean up", RANGE_CLEANUP_PREFIX); | ||
|
||
//Rotate to create indices 0 & 1 | ||
api.indices().rotateIndexSet(indexSetId); | ||
api.indices().rotateIndexSet(indexSetId); | ||
|
||
assertThat(getIndexRangesList()).isNotEmpty().contains(INDEX_ONE, INDEX_TWO); | ||
|
||
//Deleting index should automatically remove the range | ||
api.indices().deleteIndex(INDEX_ONE); | ||
|
||
assertThat(getIndexRangesList()).isNotEmpty().doesNotContain(INDEX_ONE); | ||
|
||
//Deleting index set without deleting underlying indices | ||
api.indices().deleteIndexSet(indexSetId, false); | ||
assertThat(getIndexRangesList()).isNotEmpty().contains(INDEX_TWO); | ||
|
||
//Trigger clean up periodical over api | ||
api.indices().rebuildIndexRanges(); | ||
assertThat(getIndexRangesList()).isNotEmpty().doesNotContain(INDEX_TWO); | ||
} | ||
|
||
private List<String> getIndexRangesList() throws ExecutionException, RetryException { | ||
return RetryerBuilder.<List<String>>newBuilder() | ||
.withWaitStrategy(WaitStrategies.fixedWait(1, TimeUnit.SECONDS)) | ||
.withStopStrategy(StopStrategies.stopAfterAttempt(3)) | ||
.retryIfResult(List::isEmpty) | ||
.build() | ||
.call(() -> api.indices().listIndexRanges().properJSONPath().read("ranges.*.index_name")); | ||
} | ||
} |
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