Skip to content

Commit

Permalink
random tests
Browse files Browse the repository at this point in the history
  • Loading branch information
original-brownbear committed Feb 23, 2022
1 parent 5c1985c commit 28cab49
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void testClusterActionStepThrowsException() throws Exception {
assertThat(lifecycleState.phaseTime(), nullValue());
assertThat(lifecycleState.actionTime(), nullValue());
assertThat(lifecycleState.stepInfo(), containsString("""
{"type":"runtime_exception","reason":"error","stack_trace":\""""));
{"type":"runtime_exception","reason":"error\""""));
}

public void testClusterWaitStepThrowsException() throws Exception {
Expand All @@ -322,7 +322,7 @@ public void testClusterWaitStepThrowsException() throws Exception {
assertThat(lifecycleState.phaseTime(), nullValue());
assertThat(lifecycleState.actionTime(), nullValue());
assertThat(lifecycleState.stepInfo(), containsString("""
{"type":"runtime_exception","reason":"error","stack_trace":\""""));
{"type":"runtime_exception","reason":"error\""""));
}

private void setStateToKey(StepKey stepKey) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public void testMoveClusterStateToErrorStep() throws IOException {
(idxMeta, stepKey) -> new MockStep(stepKey, nextStepKey)
);
assertClusterStateOnErrorStep(clusterState, index, currentStep, newClusterState, now, """
{"type":"illegal_argument_exception","reason":"non elasticsearch-exception","stack_trace":\"""");
{"type":"illegal_argument_exception","reason":"non elasticsearch-exception\"""");
}

public void testAddStepInfoToClusterState() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.LifecycleExecutionState;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.json.JsonXContent;
import org.elasticsearch.xpack.core.ilm.ErrorStep;
import org.elasticsearch.xpack.core.ilm.IndexLifecycleMetadata;
import org.elasticsearch.xpack.core.ilm.LifecyclePolicy;
Expand Down Expand Up @@ -98,13 +94,8 @@ public void testExecuteSuccessfullyMoved() throws IOException {
assertThat(lifecycleState.actionTime(), nullValue());
assertThat(lifecycleState.stepTime(), equalTo(now));

XContentBuilder causeXContentBuilder = JsonXContent.contentBuilder();
causeXContentBuilder.startObject();
ElasticsearchException.generateThrowableXContent(causeXContentBuilder, ToXContent.EMPTY_PARAMS, cause);
causeXContentBuilder.endObject();
String expectedCauseValue = BytesReference.bytes(causeXContentBuilder).utf8ToString();
assertThat(lifecycleState.stepInfo(), containsString("""
{"type":"exception","reason":"THIS IS AN EXPECTED CAUSE","stack_trace":\""""));
{"type":"exception","reason":"THIS IS AN EXPECTED CAUSE\""""));
}

public void testExecuteNoopDifferentStep() throws IOException {
Expand Down

0 comments on commit 28cab49

Please sign in to comment.