Skip to content

[ML] Fix license feature test cleanup #84020

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
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 @@ -31,6 +31,7 @@
import org.elasticsearch.xpack.core.ml.job.config.JobState;
import org.elasticsearch.xpack.ml.MachineLearning;
import org.elasticsearch.xpack.ml.MlSingleNodeTestCase;
import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase;
import org.junit.After;

import java.time.ZonedDateTime;
Expand All @@ -57,14 +58,17 @@ public class TestFeatureLicenseTrackingIT extends MlSingleNodeTestCase {
private final Set<String> createdPipelines = new HashSet<>();

@After
public void cleanup() {
public void cleanup() throws Exception {
for (String pipeline : createdPipelines) {
try {
client().execute(DeletePipelineAction.INSTANCE, new DeletePipelineRequest(pipeline)).actionGet();
} catch (Exception ex) {
logger.warn(() -> new ParameterizedMessage("error cleaning up pipeline [{}]", pipeline), ex);
}
}
// Some of the tests have async side effects. We need to wait for these to complete before continuing
// the cleanup, otherwise unexpected indices may get created during the cleanup process.
BaseMlIntegTestCase.waitForPendingTasks(client());
}

public void testFeatureTrackingAnomalyJob() throws Exception {
Expand Down Expand Up @@ -125,7 +129,7 @@ public void testFeatureTrackingInferenceModelPipeline() throws Exception {
.setInferenceConfig(new ClassificationConfig(3))
.setParsedDefinition(
new TrainedModelDefinition.Builder().setPreProcessors(
Arrays.asList(new OneHotEncoding("other.categorical", oneHotEncoding, false))
List.of(new OneHotEncoding("other.categorical", oneHotEncoding, false))
).setTrainedModel(buildClassification(true))
)
.build();
Expand Down