Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import org.elasticsearch.reindex.ReindexPlugin;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.xpack.core.transform.action.DeleteTransformAction;
import org.elasticsearch.xpack.core.transform.action.GetTransformAction;
import org.elasticsearch.xpack.core.transform.action.PutTransformAction;
import org.elasticsearch.xpack.core.transform.action.StopTransformAction;
import org.elasticsearch.xpack.core.transform.action.UpdateTransformAction;
import org.elasticsearch.xpack.core.transform.transforms.DestConfig;
import org.elasticsearch.xpack.core.transform.transforms.QueryConfig;
Expand Down Expand Up @@ -137,6 +139,16 @@ protected TransformConfig getTransform(String transformId) {
return configs.getFirst();
}

protected void stopTransform(String transformId) {
var request = new StopTransformAction.Request(transformId, true, false, TimeValue.THIRTY_SECONDS, false, false);
assertTrue(client().execute(StopTransformAction.INSTANCE, request).actionGet(TimeValue.THIRTY_SECONDS).isAcknowledged());
}

protected void deleteTransform(String transformId) {
var request = new DeleteTransformAction.Request(transformId, true, false, TimeValue.THIRTY_SECONDS);
client().execute(DeleteTransformAction.INSTANCE, request).actionGet(TimeValue.THIRTY_SECONDS);
}

protected void updateTransform(String transformId, TransformConfigUpdate transformConfigUpdate) {
var request = new UpdateTransformAction.Request(transformConfigUpdate, transformId, false, TimeValue.THIRTY_SECONDS);
client().execute(UpdateTransformAction.INSTANCE, request).actionGet(TimeValue.THIRTY_SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public void testGetTransformWithProjectRouting() {

var transformConfig = getTransform(transformId);
assertThat(transformConfig.getSource().getProjectRouting(), equalTo(expectedProjectRouting));

deleteTransform(transformId);
}

public void testUpdateTransformWithProjectRouting() throws Exception {
Expand Down Expand Up @@ -112,6 +114,8 @@ public void testUpdateTransformWithProjectRouting() throws Exception {
)
)
);

deleteTransform(transformId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,7 @@ public void testUpdateDeletesOldTransformConfig() throws Exception {
GetResponse getResponse = client().get(getRequest).actionGet();
assertThat(getResponse.isExists(), is(true));
}

deleteTransform(transformId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public void testPutTransformWithRemoteIndex_DeferValidation() {
TransformConfig config = randomConfig(transformId, "remote_cluster:my-index");
PutTransformAction.Request request = new PutTransformAction.Request(config, true, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT);
client().execute(PutTransformAction.INSTANCE, request).actionGet();

deleteTransform(transformId);
}

public void testPutTransformWithRemoteIndex_NoDeferValidation() {
Expand Down Expand Up @@ -105,6 +107,8 @@ public void testUpdateTransformWithRemoteIndex_DeferValidation() {
AcknowledgedRequest.DEFAULT_ACK_TIMEOUT
);
client().execute(UpdateTransformAction.INSTANCE, request).actionGet();

deleteTransform(transformId);
}

public void testUpdateTransformWithRemoteIndex_NoDeferValidation() {
Expand Down Expand Up @@ -143,6 +147,8 @@ public void testUpdateTransformWithRemoteIndex_NoDeferValidation() {
containsString("transform requires a remote connection but the node does not have the remote_cluster_client role")
)
);

deleteTransform(transformId);
}

private static TransformConfig randomConfig(String transformId, String sourceIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public void testPutTransform_DeferValidation() {
assertThat(response.isAcknowledged(), is(true));

assertCriticalWarnings("Transform requires the transform node role for at least 1 node, found no transform nodes");

deleteTransform(transformId);
}

public void testPutTransform_NoDeferValidation() {
Expand Down Expand Up @@ -120,6 +122,8 @@ public void testUpdateTransform_DeferValidation() {
client().execute(UpdateTransformAction.INSTANCE, request).actionGet();

assertCriticalWarnings("Transform requires the transform node role for at least 1 node, found no transform nodes");

deleteTransform(transformId);
}

public void testUpdateTransform_NoDeferValidation() {
Expand Down Expand Up @@ -153,6 +157,8 @@ public void testUpdateTransform_NoDeferValidation() {
() -> client().execute(UpdateTransformAction.INSTANCE, request).actionGet()
);
assertThat(e.getMessage(), is(equalTo("Transform requires the transform node role for at least 1 node, found no transform nodes")));

deleteTransform(transformId);
}

private static TransformConfig randomConfig(String transformId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.elasticsearch.xpack.core.transform.action.GetTransformAction;
import org.elasticsearch.xpack.core.transform.action.PutTransformAction;
import org.elasticsearch.xpack.core.transform.action.StartTransformAction;
import org.elasticsearch.xpack.core.transform.action.StopTransformAction;
import org.elasticsearch.xpack.core.transform.action.UpdateTransformAction;
import org.elasticsearch.xpack.core.transform.transforms.DestConfig;
import org.elasticsearch.xpack.core.transform.transforms.SourceConfig;
Expand Down Expand Up @@ -141,11 +140,8 @@ public void testStopThrowsForDeprecatedTransformConfig() throws Exception {

assertTrue(startTransformActionResponse.isAcknowledged());

StopTransformAction.Response stopTransformActionResponse = client().execute(
StopTransformAction.INSTANCE,
new StopTransformAction.Request(transformId, true, false, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, false, false)
).actionGet();
assertTrue(stopTransformActionResponse.isAcknowledged());
stopTransform(transformId);
deleteTransform(transformId);
}

private void createTransformIndex() throws Exception {
Expand Down Expand Up @@ -179,6 +175,8 @@ public void testUpdateReplacesDeprecatedTransformSettings() throws Exception {
client().execute(UpdateTransformAction.INSTANCE, updateRequest).actionGet();

assertMaxPageSearchSizeInSettings(transformId, expectedMaxPageSearchSize);

deleteTransform(transformId);
}

private String createTransformWithDeprecatedMaxPageSearchSize(int maxPageSearchSize) throws Exception {
Expand Down Expand Up @@ -252,6 +250,9 @@ public void testStartReplacesDeprecatedTransformSettings() throws Exception {
assertTrue(startTransformActionResponse.isAcknowledged());

assertMaxPageSearchSizeInSettings(transformId, expectedMaxPageSearchSize);

stopTransform(transformId);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM.

Out of curiosity though - why does this test (and another one above) need both stop and delete, while all the others don't?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of them do not start the transform, for example testMigratedTransformIndex and testUpdateReplacesDeprecatedTransformSettings create the transform but do not start it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. Thanks!

deleteTransform(transformId);
}

public void testMigratedTransformIndex() {
Expand Down Expand Up @@ -313,6 +314,8 @@ public void testMigratedTransformIndex() {
var getTransformResponse = client().execute(GetTransformAction.INSTANCE, getTransformRequest).actionGet();
var transformConfig = getTransformResponse.getTransformConfigurations().get(0);
assertThat(transformConfig.getDestination().getIndex(), equalTo("some-new-dest-index"));

deleteTransform(transformId);
}

}