Skip to content

Commit 2002510

Browse files
Fix Existing System Index Migration Integration Tests (ES-10527) (#120663)
Re-enables system index migration tests in main. Previously, these tests were only running on the last minor version, leaving the system indices migration infrastructure largely untested for most of the time.
1 parent 928040e commit 2002510

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase
6868
static final String INTERNAL_MANAGED_INDEX_NAME = ".int-man-old";
6969
static final int INDEX_DOC_COUNT = 100; // arbitrarily chosen
7070
static final int INTERNAL_MANAGED_FLAG_VALUE = 1;
71-
public static final Version NEEDS_UPGRADE_VERSION = TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_VERSION.previousMajor();
72-
public static final IndexVersion NEEDS_UPGRADE_INDEX_VERSION = IndexVersionUtils.getPreviousMajorVersion(
71+
static final String FIELD_NAME = "some_field";
72+
protected static final IndexVersion NEEDS_UPGRADE_INDEX_VERSION = IndexVersionUtils.getPreviousMajorVersion(
7373
TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_INDEX_VERSION
7474
);
75+
protected static final int UPGRADED_TO_VERSION = TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_VERSION.major + 1;
7576

7677
static final SystemIndexDescriptor EXTERNAL_UNMANAGED = SystemIndexDescriptor.builder()
7778
.setIndexPattern(".ext-unman-*")
@@ -131,11 +132,6 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase
131132

132133
@Before
133134
public void setup() {
134-
assumeTrue(
135-
"We can only create the test indices we need if they're in the previous major version",
136-
NEEDS_UPGRADE_VERSION.onOrAfter(Version.CURRENT.previousMajor())
137-
);
138-
139135
internalCluster().setBootstrapMasterNodeIndex(0);
140136
masterName = internalCluster().startMasterOnlyNode();
141137
masterAndDataNode = internalCluster().startNode();

modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,31 +208,31 @@ public void testMigrateInternalManagedSystemIndex() throws Exception {
208208

209209
assertIndexHasCorrectProperties(
210210
finalMetadata,
211-
".int-man-old-reindexed-for-9",
211+
".int-man-old-reindexed-for-" + UPGRADED_TO_VERSION,
212212
INTERNAL_MANAGED_FLAG_VALUE,
213213
true,
214214
true,
215215
Arrays.asList(".int-man-old", ".internal-managed-alias")
216216
);
217217
assertIndexHasCorrectProperties(
218218
finalMetadata,
219-
".int-unman-old-reindexed-for-9",
219+
".int-unman-old-reindexed-for-" + UPGRADED_TO_VERSION,
220220
INTERNAL_UNMANAGED_FLAG_VALUE,
221221
false,
222222
true,
223223
Collections.singletonList(".int-unman-old")
224224
);
225225
assertIndexHasCorrectProperties(
226226
finalMetadata,
227-
".ext-man-old-reindexed-for-9",
227+
".ext-man-old-reindexed-for-" + UPGRADED_TO_VERSION,
228228
EXTERNAL_MANAGED_FLAG_VALUE,
229229
true,
230230
false,
231231
Arrays.asList(".ext-man-old", ".external-managed-alias")
232232
);
233233
assertIndexHasCorrectProperties(
234234
finalMetadata,
235-
".ext-unman-old-reindexed-for-9",
235+
".ext-unman-old-reindexed-for-" + UPGRADED_TO_VERSION,
236236
EXTERNAL_UNMANAGED_FLAG_VALUE,
237237
false,
238238
false,

modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,31 +218,31 @@ public void testMultipleFeatureMigration() throws Exception {
218218
// Finally, verify that all the indices exist and have the properties we expect.
219219
assertIndexHasCorrectProperties(
220220
finalMetadata,
221-
".int-man-old-reindexed-for-9",
221+
".int-man-old-reindexed-for-" + UPGRADED_TO_VERSION,
222222
INTERNAL_MANAGED_FLAG_VALUE,
223223
true,
224224
true,
225225
Arrays.asList(".int-man-old", ".internal-managed-alias")
226226
);
227227
assertIndexHasCorrectProperties(
228228
finalMetadata,
229-
".int-unman-old-reindexed-for-9",
229+
".int-unman-old-reindexed-for-" + UPGRADED_TO_VERSION,
230230
INTERNAL_UNMANAGED_FLAG_VALUE,
231231
false,
232232
true,
233233
Collections.singletonList(".int-unman-old")
234234
);
235235
assertIndexHasCorrectProperties(
236236
finalMetadata,
237-
".ext-man-old-reindexed-for-9",
237+
".ext-man-old-reindexed-for-" + UPGRADED_TO_VERSION,
238238
EXTERNAL_MANAGED_FLAG_VALUE,
239239
true,
240240
false,
241241
Arrays.asList(".ext-man-old", ".external-managed-alias")
242242
);
243243
assertIndexHasCorrectProperties(
244244
finalMetadata,
245-
".ext-unman-old-reindexed-for-9",
245+
".ext-unman-old-reindexed-for-" + UPGRADED_TO_VERSION,
246246
EXTERNAL_UNMANAGED_FLAG_VALUE,
247247
false,
248248
false,
@@ -251,7 +251,7 @@ public void testMultipleFeatureMigration() throws Exception {
251251

252252
assertIndexHasCorrectProperties(
253253
finalMetadata,
254-
".second-int-man-old-reindexed-for-9",
254+
".second-int-man-old-reindexed-for-" + UPGRADED_TO_VERSION,
255255
SECOND_FEATURE_IDX_FLAG_VALUE,
256256
true,
257257
true,

server/src/main/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusAction.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
2020
import org.elasticsearch.cluster.service.ClusterService;
2121
import org.elasticsearch.common.util.concurrent.EsExecutors;
22+
import org.elasticsearch.core.UpdateForV10;
2223
import org.elasticsearch.index.IndexVersion;
2324
import org.elasticsearch.index.IndexVersions;
2425
import org.elasticsearch.indices.SystemIndices;
2526
import org.elasticsearch.injection.guice.Inject;
2627
import org.elasticsearch.persistent.PersistentTasksCustomMetadata;
27-
import org.elasticsearch.persistent.PersistentTasksService;
2828
import org.elasticsearch.tasks.Task;
2929
import org.elasticsearch.threadpool.ThreadPool;
3030
import org.elasticsearch.transport.TransportService;
@@ -53,13 +53,13 @@ public class TransportGetFeatureUpgradeStatusAction extends TransportMasterNodeA
5353
GetFeatureUpgradeStatusResponse> {
5454

5555
/**
56-
* Once all feature migrations for 9.x -> 10.x have been tested, we can bump this to Version.V_9_0_0
56+
* These versions should be set to current major and current major's index version
5757
*/
58-
public static final Version NO_UPGRADE_REQUIRED_VERSION = Version.V_8_0_0;
59-
public static final IndexVersion NO_UPGRADE_REQUIRED_INDEX_VERSION = IndexVersions.V_8_0_0;
58+
@UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA)
59+
public static final Version NO_UPGRADE_REQUIRED_VERSION = Version.V_9_0_0;
60+
public static final IndexVersion NO_UPGRADE_REQUIRED_INDEX_VERSION = IndexVersions.UPGRADE_TO_LUCENE_10_0_0;
6061

6162
private final SystemIndices systemIndices;
62-
PersistentTasksService persistentTasksService;
6363

6464
@Inject
6565
public TransportGetFeatureUpgradeStatusAction(
@@ -68,7 +68,6 @@ public TransportGetFeatureUpgradeStatusAction(
6868
ActionFilters actionFilters,
6969
ClusterService clusterService,
7070
IndexNameExpressionResolver indexNameExpressionResolver,
71-
PersistentTasksService persistentTasksService,
7271
SystemIndices systemIndices
7372
) {
7473
super(
@@ -83,7 +82,6 @@ public TransportGetFeatureUpgradeStatusAction(
8382
);
8483

8584
this.systemIndices = systemIndices;
86-
this.persistentTasksService = persistentTasksService;
8785
}
8886

8987
@Override

server/src/main/java/org/elasticsearch/indices/SystemIndices.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
1717
import org.apache.lucene.util.automaton.Operations;
1818
import org.elasticsearch.action.ActionListener;
19+
import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction;
1920
import org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateResponse.ResetFeatureStateStatus;
2021
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
2122
import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction;
@@ -110,7 +111,8 @@
110111
public class SystemIndices {
111112
public static final String SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY = "_system_index_access_allowed";
112113
public static final String EXTERNAL_SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY = "_external_system_index_access_origin";
113-
public static final String UPGRADED_INDEX_SUFFIX = "-reindexed-for-9";
114+
private static final int UPGRADED_TO_VERSION = TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_VERSION.major + 1;
115+
public static final String UPGRADED_INDEX_SUFFIX = "-reindexed-for-" + UPGRADED_TO_VERSION;
114116

115117
private static final Automaton EMPTY = Automata.makeEmpty();
116118

0 commit comments

Comments
 (0)