Skip to content
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 @@ -37,6 +37,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import java.util.function.Function;
Expand Down Expand Up @@ -91,6 +93,8 @@ public void testMultipleFeatureMigration() throws Exception {

ensureGreen();

CountDownLatch hooksCalled = new CountDownLatch(4);

SetOnce<Boolean> preMigrationHookCalled = new SetOnce<>();
SetOnce<Boolean> postMigrationHookCalled = new SetOnce<>();
SetOnce<Boolean> secondPluginPreMigrationHookCalled = new SetOnce<>();
Expand All @@ -109,6 +113,7 @@ public void testMultipleFeatureMigration() throws Exception {
assertThat(currentResults, nullValue());

preMigrationHookCalled.set(true);
hooksCalled.countDown();
return metadata;
});

Expand All @@ -125,6 +130,7 @@ public void testMultipleFeatureMigration() throws Exception {
assertThat(currentResults, nullValue());

postMigrationHookCalled.set(true);
hooksCalled.countDown();
});

SecondPlugin.preMigrationHook.set(clusterState -> {
Expand All @@ -145,6 +151,7 @@ public void testMultipleFeatureMigration() throws Exception {
assertThat(currentResults.getFeatureStatuses().get(FEATURE_NAME).getException(), nullValue());

secondPluginPreMigrationHookCalled.set(true);
hooksCalled.countDown();
return metadata;
});

Expand All @@ -165,6 +172,7 @@ public void testMultipleFeatureMigration() throws Exception {
assertThat(currentResults.getFeatureStatuses().get(FEATURE_NAME).getException(), nullValue());

secondPluginPostMigrationHookCalled.set(true);
hooksCalled.countDown();
});

PostFeatureUpgradeRequest migrationRequest = new PostFeatureUpgradeRequest();
Expand All @@ -177,6 +185,9 @@ public void testMultipleFeatureMigration() throws Exception {
.collect(Collectors.toSet());
assertThat(migratingFeatures, hasItems(FEATURE_NAME, SECOND_FEATURE_NAME));

// wait for all the plugin methods to have been called before assertBusy since that will exponentially backoff
assertThat(hooksCalled.await(30, TimeUnit.SECONDS), is(true));

GetFeatureUpgradeStatusRequest getStatusRequest = new GetFeatureUpgradeStatusRequest();
assertBusy(() -> {
GetFeatureUpgradeStatusResponse statusResponse = client().execute(GetFeatureUpgradeStatusAction.INSTANCE, getStatusRequest)
Expand Down