mikemccand commented on code in PR #13046:
URL: https://github.com/apache/lucene/pull/13046#discussion_r1469886161


##########
lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestIndexUpgradeBackwardsCompatibility.java:
##########
@@ -0,0 +1,260 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.backward_index;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexUpgrader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.MergePolicy;
+import org.apache.lucene.index.SegmentCommitInfo;
+import org.apache.lucene.index.SegmentInfos;
+import org.apache.lucene.store.ByteBuffersDirectory;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.NIOFSDirectory;
+import org.apache.lucene.tests.analysis.MockAnalyzer;
+import org.apache.lucene.tests.util.TestUtil;
+import org.apache.lucene.util.InfoStream;
+import org.apache.lucene.util.Version;
+
+public class TestIndexUpgradeBackwardsCompatibility extends 
BackwardsCompatibilityTestBase {
+
+  public TestIndexUpgradeBackwardsCompatibility(Version version, String 
pattern) {
+    super(version, pattern);
+  }
+
+  @ParametersFactory(argumentFormatting = "Lucene-Version:%1$s; Pattern: %2$s")
+  public static Iterable<Object[]> testVersionsFactory() throws 
IllegalAccessException {
+    Iterable<Object[]> allSupportedVersions =
+        allVersion(
+            TestBasicBackwardsCompatibility.INDEX_NAME,
+            TestBasicBackwardsCompatibility.SUFFIX_CFS,
+            TestBasicBackwardsCompatibility.SUFFIX_NO_CFS);
+    return allSupportedVersions;
+  }
+
+  /** Randomizes the use of some of hte constructor variations */
+  static IndexUpgrader newIndexUpgrader(Directory dir) {
+    final boolean streamType = random().nextBoolean();
+    final int choice = TestUtil.nextInt(random(), 0, 2);
+    switch (choice) {
+      case 0:
+        return new IndexUpgrader(dir);
+      case 1:
+        return new IndexUpgrader(dir, streamType ? null : 
InfoStream.NO_OUTPUT, false);
+      case 2:
+        return new IndexUpgrader(dir, newIndexWriterConfig(null), false);
+      default:
+        fail("case statement didn't get updated when random bounds changed");
+    }
+    return null; // never get here
+  }
+
+  public void testUpgradeOldIndex() throws Exception {
+    Directory dir = newDirectory(directory);
+    int indexCreatedVersion = 
SegmentInfos.readLatestCommit(dir).getIndexCreatedVersionMajor();
+    newIndexUpgrader(dir).upgrade();
+
+    checkAllSegmentsUpgraded(dir, indexCreatedVersion);
+    dir.close();
+  }
+
+  @Override
+  protected void createIndex(Directory directory) throws IOException {
+    if (indexPattern.equals(
+        createPattern(
+            TestBasicBackwardsCompatibility.INDEX_NAME,
+            TestBasicBackwardsCompatibility.SUFFIX_CFS))) {
+      TestBasicBackwardsCompatibility.createIndex(directory, true, false);
+    } else {
+      TestBasicBackwardsCompatibility.createIndex(directory, false, false);
+    }
+  }
+
+  public void testUpgradeOldSingleSegmentIndexWithAdditions() throws Exception 
{
+    // NOCOMMIT we use to have single segment indices but we stopped creating 
them at some point

Review Comment:
   I don't know why we stopped!  We should start again?  But maybe as followon?



##########
lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestIndexUpgradeBackwardsCompatibility.java:
##########
@@ -0,0 +1,260 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.backward_index;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexUpgrader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.MergePolicy;
+import org.apache.lucene.index.SegmentCommitInfo;
+import org.apache.lucene.index.SegmentInfos;
+import org.apache.lucene.store.ByteBuffersDirectory;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.NIOFSDirectory;
+import org.apache.lucene.tests.analysis.MockAnalyzer;
+import org.apache.lucene.tests.util.TestUtil;
+import org.apache.lucene.util.InfoStream;
+import org.apache.lucene.util.Version;
+
+public class TestIndexUpgradeBackwardsCompatibility extends 
BackwardsCompatibilityTestBase {
+
+  public TestIndexUpgradeBackwardsCompatibility(Version version, String 
pattern) {
+    super(version, pattern);
+  }
+
+  @ParametersFactory(argumentFormatting = "Lucene-Version:%1$s; Pattern: %2$s")
+  public static Iterable<Object[]> testVersionsFactory() throws 
IllegalAccessException {
+    Iterable<Object[]> allSupportedVersions =
+        allVersion(
+            TestBasicBackwardsCompatibility.INDEX_NAME,
+            TestBasicBackwardsCompatibility.SUFFIX_CFS,
+            TestBasicBackwardsCompatibility.SUFFIX_NO_CFS);
+    return allSupportedVersions;
+  }
+
+  /** Randomizes the use of some of hte constructor variations */

Review Comment:
   `hte` -> `the`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to