Skip to content

Commit

Permalink
Fix PersistentTaskInitializationFailureIT (#72000)
Browse files Browse the repository at this point in the history
Add the PersistentTaskPlugin created for the test to the transport
client in order to register the PersistentTaskParams into the
transport client NamedWriteableRegistry.

Closes #71995
  • Loading branch information
fcofdez authored Apr 21, 2021
1 parent d6038a3 commit d2b1dcd
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
Expand Down Expand Up @@ -41,7 +42,13 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singletonList(FailingInitializationPersistentTasksPlugin.class);
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/71995")
@Override
protected Collection<Class<? extends Plugin>> transportClientPlugins() {
// We need to pass the plugin to the transport client in order to get FailingInitializationTaskParams registered
// into the transport client NamedWriteableRegistry
return Collections.singletonList(FailingInitializationPersistentTasksPlugin.class);
}

public void testPersistentTasksThatFailDuringInitializationAreRemovedFromClusterState() throws Exception {
PersistentTasksService persistentTasksService = internalCluster().getInstance(PersistentTasksService.class);
PlainActionFuture<PersistentTasksCustomMetadata.PersistentTask<FailingInitializationTaskParams>> startPersistentTaskFuture =
Expand All @@ -54,9 +61,8 @@ public void testPersistentTasksThatFailDuringInitializationAreRemovedFromCluster
startPersistentTaskFuture.actionGet();

assertBusy(() -> {
final ClusterService clusterService = internalCluster().getMasterNodeInstance(ClusterService.class);
final PersistentTasksCustomMetadata persistentTasks =
clusterService.state().metadata().custom(PersistentTasksCustomMetadata.TYPE);
Metadata metadata = client().admin().cluster().prepareState().execute().actionGet().getState().getMetadata();
final PersistentTasksCustomMetadata persistentTasks = metadata.custom(PersistentTasksCustomMetadata.TYPE);
assertThat(persistentTasks.tasks().toString(), persistentTasks.tasks(), empty());
});
}
Expand Down

0 comments on commit d2b1dcd

Please sign in to comment.