diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java index a4f63635d2649..ec0a4a522c9a4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java @@ -9,7 +9,6 @@ package org.opensearch.indices.replication; import com.carrotsearch.randomizedtesting.RandomizedTest; -import org.apache.lucene.codecs.Codec; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.SortedDocValuesField; @@ -43,7 +42,6 @@ import org.opensearch.cluster.routing.ShardRouting; import org.opensearch.cluster.routing.ShardRoutingState; import org.opensearch.cluster.routing.allocation.command.CancelAllocationCommand; -import org.opensearch.common.io.PathUtils; import org.opensearch.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.lease.Releasable; import org.opensearch.common.lucene.index.OpenSearchDirectoryReader; @@ -72,24 +70,14 @@ import org.opensearch.test.transport.MockTransportService; import org.opensearch.transport.TransportService; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.TreeSet; import java.util.concurrent.CountDownLatch; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; import static java.util.Arrays.asList; import static org.opensearch.action.search.PitTestsUtil.assertSegments; @@ -1314,71 +1302,4 @@ public void testWithDifferentCompressionModes() throws Exception { verifyStoreContent(); } } - - /** - * This test validates that segment replications works for older codec implementations - * @throws Exception - */ - public void testWithOlderCodecs() throws Exception { - final String nodeA = internalCluster().startNode(); - final String nodeB = internalCluster().startNode(); - final Settings settings = Settings.builder() - .put(indexSettings()) - .put(EngineConfig.INDEX_CODEC_SETTING.getKey(), getOlderLuceneCodec()) - .build(); - createIndex(INDEX_NAME, settings); - final int initialDocCount = scaledRandomIntBetween(100, 200); - try ( - BackgroundIndexer indexer = new BackgroundIndexer( - INDEX_NAME, - "_doc", - client(), - -1, - RandomizedTest.scaledRandomIntBetween(2, 5), - false, - random() - ) - ) { - indexer.start(initialDocCount); - waitForDocs(initialDocCount, indexer); - refresh(INDEX_NAME); - waitForSearchableDocs(initialDocCount, nodeA, nodeB); - - final int additionalDocCount = scaledRandomIntBetween(0, 200); - final int expectedHitCount = initialDocCount + additionalDocCount; - indexer.start(additionalDocCount); - waitForDocs(expectedHitCount, indexer); - - flushAndRefresh(INDEX_NAME); - waitForSearchableDocs(expectedHitCount, nodeA, nodeB); - - ensureGreen(INDEX_NAME); - verifyStoreContent(); - } - } - - // Return oldest lucene codec name. It does this by iterating throw all directories under lucene library and filter - // ones matching lucene codec name regex - private String getOlderLuceneCodec() throws IOException, URISyntaxException { - final TreeSet codecNames = new TreeSet<>(); - final String separator = PathUtils.getDefaultFileSystem().getSeparator(); - Pattern pattern = Pattern.compile("lucene[0-9]+"); - Path luceneJarPath = PathUtils.get(Codec.class.getProtectionDomain().getCodeSource().getLocation().toURI()); - try (var fileIn = Files.newInputStream(luceneJarPath)) { - ZipInputStream zip = new ZipInputStream(fileIn); - for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) { - final String dirPath = entry.getName(); - // Fetch name i.e. '../lucene94/' -> 'lucene94' - final String dirName = dirPath.substring(dirPath.lastIndexOf(separator, dirPath.length() - 2) + 1, dirPath.length() - 1); - Matcher matcher = pattern.matcher(dirName); - if (matcher.matches()) { - codecNames.add(dirName); - } - } - } - logger.debug("--> Older lucene codecs {}", codecNames); - String oldestSupportedCodec = codecNames.pollFirst(); - // Get actual lucene codec class name i.e. lucene90 -> Lucene90 - return oldestSupportedCodec.substring(0, 1).toUpperCase(Locale.getDefault()) + oldestSupportedCodec.substring(1); - } }