-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Make feature reset API response more informative #71240
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
williamrandolph
merged 23 commits into
elastic:master
from
williamrandolph:reset-api-fail-fast
Apr 27, 2021
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
7855587
Reset API should fail fast when there is an error
williamrandolph 9a8f090
Use admin credentials with reset API
williamrandolph 99b863a
Merge branch 'master' into reset-api-fail-fast
williamrandolph 21fd604
Improve feature reset status reporting
williamrandolph 282a38b
Merging changes from master
williamrandolph db18cc7
Merge branch 'master' into reset-api-fail-fast
williamrandolph 3123225
Return a 207 if some but not all reset actions fail
williamrandolph bad2600
Merge branch 'master' into reset-api-fail-fast
williamrandolph 6e30065
Serialize stack trace in usable format
williamrandolph 5a3bdc8
Merge branch 'master' into reset-api-fail-fast
williamrandolph b039ca9
Reduce number of iterations over response set
williamrandolph d4eacc2
Merge branch 'master' into reset-api-fail-fast
williamrandolph e6113a3
Add optional exception to HLRC reset feature state response
williamrandolph deffae3
Add tests for xcontent serialization
williamrandolph f3f29f0
Make method name more specific
williamrandolph d2c1b45
Add a line to the docs about response codes
williamrandolph cd047f2
Use constructing object parser to handle exception
williamrandolph 83f2019
Improve naming in ResetFeaturesResponse and add javadoc
williamrandolph 19e4842
Use concurrency-safe accessors for static variable
williamrandolph d277a24
Respond to PR feedback
williamrandolph 9e2ab6f
Pity me and my XContent woes
williamrandolph e5f0332
Merge branch 'master' into reset-api-fail-fast
williamrandolph ff5a9d8
Improve javadoc
williamrandolph 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
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
65 changes: 65 additions & 0 deletions
65
...gh-level/src/test/java/org/elasticsearch/client/snapshots/ResetFeaturesResponseTests.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,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.client.snapshots; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateResponse; | ||
import org.elasticsearch.client.AbstractResponseTestCase; | ||
import org.elasticsearch.client.feature.ResetFeaturesResponse; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
import org.elasticsearch.common.xcontent.XContentType; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.hamcrest.Matchers.everyItem; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hamcrest.Matchers.in; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
public class ResetFeaturesResponseTests extends AbstractResponseTestCase<ResetFeatureStateResponse, ResetFeaturesResponse> { | ||
|
||
@Override | ||
protected ResetFeatureStateResponse createServerTestInstance( | ||
XContentType xContentType) { | ||
return new org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateResponse( | ||
randomList( | ||
10, | ||
() -> randomBoolean() | ||
? ResetFeatureStateResponse.ResetFeatureStateStatus.success(randomAlphaOfLengthBetween(6, 10)) | ||
: ResetFeatureStateResponse.ResetFeatureStateStatus.failure( | ||
randomAlphaOfLengthBetween(6, 10), new ElasticsearchException("something went wrong")) | ||
) | ||
); | ||
} | ||
|
||
@Override | ||
protected ResetFeaturesResponse doParseToClientInstance(XContentParser parser) throws IOException { | ||
return ResetFeaturesResponse.parse(parser); | ||
} | ||
|
||
@Override | ||
protected void assertInstances(ResetFeatureStateResponse serverTestInstance, ResetFeaturesResponse clientInstance) { | ||
|
||
assertNotNull(serverTestInstance.getFeatureStateResetStatuses()); | ||
assertNotNull(clientInstance.getFeatureResetStatuses()); | ||
|
||
assertThat(clientInstance.getFeatureResetStatuses(), hasSize(serverTestInstance.getFeatureStateResetStatuses().size())); | ||
|
||
Map<String, String> clientFeatures = clientInstance.getFeatureResetStatuses() | ||
.stream() | ||
.collect(Collectors.toMap(f -> f.getFeatureName(), f -> f.getStatus())); | ||
Map<String, String> serverFeatures = serverTestInstance.getFeatureStateResetStatuses() | ||
.stream() | ||
.collect(Collectors.toMap(f -> f.getFeatureName(), f -> f.getStatus().toString())); | ||
|
||
assertThat(clientFeatures.entrySet(), everyItem(is(in(serverFeatures.entrySet())))); | ||
} | ||
} |
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
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
Oops, something went wrong.
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.