-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Make DeleteStep retryable #52494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Make DeleteStep retryable #52494
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
72 changes: 72 additions & 0 deletions
72
x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/DeleteStepTests.java
This file contains hidden or 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,72 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
| package org.elasticsearch.xpack.ilm; | ||
|
|
||
| import org.elasticsearch.cluster.ClusterState; | ||
| import org.elasticsearch.cluster.ClusterStateObserver; | ||
| import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
| import org.elasticsearch.cluster.service.ClusterService; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.test.ESSingleNodeTestCase; | ||
| import org.elasticsearch.threadpool.ThreadPool; | ||
| import org.elasticsearch.xpack.core.ilm.AsyncActionStep; | ||
| import org.elasticsearch.xpack.core.ilm.DeleteStep; | ||
| import org.elasticsearch.xpack.core.ilm.Step.StepKey; | ||
|
|
||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
|
|
||
| import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY; | ||
| import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY_ALLOW_DELETE; | ||
| import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; | ||
| import static org.hamcrest.Matchers.is; | ||
|
|
||
| public class DeleteStepTests extends ESSingleNodeTestCase { | ||
|
|
||
| public void testDeleteStepRetriesOnError() throws Exception { | ||
| assertAcked(client().admin().indices().prepareCreate("test") | ||
| .setSettings(Settings.builder().put(SETTING_READ_ONLY_ALLOW_DELETE, false).put(SETTING_READ_ONLY, true)) | ||
| .get()); | ||
|
|
||
| ClusterService clusterService = getInstanceFromNode(ClusterService.class); | ||
| ClusterState state = clusterService.state(); | ||
| IndexMetaData indexMetaData = state.metaData().index("test"); | ||
| ThreadPool threadPool = getInstanceFromNode(ThreadPool.class); | ||
| ClusterStateObserver observer = new ClusterStateObserver(clusterService, null, logger, threadPool.getThreadContext()); | ||
|
|
||
| DeleteStep step = new DeleteStep(new StepKey("delete", "action", "delete"), null, client()); | ||
| AtomicBoolean done = new AtomicBoolean(); | ||
|
|
||
| step.performAction(indexMetaData, state, observer, new AsyncActionStep.Listener() { | ||
| @Override | ||
| public void onResponse(boolean complete) { | ||
| done.set(true); | ||
| fail("expected the test to fail when updating the setting to an invalid value"); | ||
| } | ||
|
|
||
| @Override | ||
| public void onFailure(Exception e) { | ||
| assertAcked(client().admin().indices().prepareUpdateSettings("test") | ||
| .setSettings(Settings.builder().put(SETTING_READ_ONLY, false)) | ||
| .get()); | ||
| step.performAction(indexMetaData, state, observer, new AsyncActionStep.Listener() { | ||
| @Override | ||
| public void onResponse(boolean complete) { | ||
| done.set(true); | ||
| assertThat(complete, is(true)); | ||
| } | ||
|
|
||
| @Override | ||
| public void onFailure(Exception e) { | ||
| done.set(true); | ||
| fail("unexpected failure when trying to update setting to a valid value"); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| assertBusy(() -> assertTrue(done.get())); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.