@@ -160,18 +160,14 @@ private MetaDataIndexUpgradeService getMetaDataIndexUpgradeService() {
160160 Collections .emptyList ());
161161 }
162162
163- public IndexMetaData newIndexMeta (String name , Settings indexSettings ) {
164- final Version createdVersion = VersionUtils .randomVersionBetween (random (),
165- Version .CURRENT .minimumIndexCompatibilityVersion (), VersionUtils .getPreviousVersion ());
166- final Version upgradedVersion = VersionUtils .randomVersionBetween (random (), createdVersion , VersionUtils .getPreviousVersion ());
167-
163+ public static IndexMetaData newIndexMeta (String name , Settings indexSettings ) {
168164 final Settings settings = Settings .builder ()
169- .put (IndexMetaData .SETTING_VERSION_CREATED , createdVersion )
165+ .put (IndexMetaData .SETTING_VERSION_CREATED , randomEarlierCompatibleVersion () )
170166 .put (IndexMetaData .SETTING_NUMBER_OF_REPLICAS , between (0 , 5 ))
171167 .put (IndexMetaData .SETTING_NUMBER_OF_SHARDS , between (1 , 5 ))
172168 .put (IndexMetaData .SETTING_CREATION_DATE , randomNonNegativeLong ())
173169 .put (IndexMetaData .SETTING_INDEX_UUID , UUIDs .randomBase64UUID (random ()))
174- .put (IndexMetaData .SETTING_VERSION_UPGRADED , upgradedVersion )
170+ .put (IndexMetaData .SETTING_VERSION_UPGRADED , randomEarlierCompatibleVersion () )
175171 .put (indexSettings )
176172 .build ();
177173 final IndexMetaData .Builder indexMetaDataBuilder = IndexMetaData .builder (name ).settings (settings );
@@ -181,4 +177,9 @@ public IndexMetaData newIndexMeta(String name, Settings indexSettings) {
181177 return indexMetaDataBuilder .build ();
182178 }
183179
180+ private static Version randomEarlierCompatibleVersion () {
181+ return VersionUtils .randomVersionBetween (random (),
182+ Version .CURRENT .minimumIndexCompatibilityVersion (), VersionUtils .getPreviousVersion ());
183+ }
184+
184185}
0 commit comments