From d2b1dcd64856e43ad1f4f87e245096a63c638a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20Casta=C3=B1o?= Date: Wed, 21 Apr 2021 13:31:41 +0200 Subject: [PATCH] Fix PersistentTaskInitializationFailureIT (#72000) Add the PersistentTaskPlugin created for the test to the transport client in order to register the PersistentTaskParams into the transport client NamedWriteableRegistry. Closes #71995 --- .../PersistentTaskInitializationFailureIT.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/persistent/PersistentTaskInitializationFailureIT.java b/server/src/internalClusterTest/java/org/elasticsearch/persistent/PersistentTaskInitializationFailureIT.java index 672a3bc0bfdf2..a757254660f97 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/persistent/PersistentTaskInitializationFailureIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/persistent/PersistentTaskInitializationFailureIT.java @@ -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; @@ -41,7 +42,13 @@ protected Collection> nodePlugins() { return Collections.singletonList(FailingInitializationPersistentTasksPlugin.class); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/71995") + @Override + protected Collection> 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> startPersistentTaskFuture = @@ -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()); }); }