jpountz commented on code in PR #13046: URL: https://github.com/apache/lucene/pull/13046#discussion_r1469520708
########## lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBinaryBackwardsCompatibility.java: ########## @@ -0,0 +1,87 @@ +/* + * 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 com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.apache.lucene.index.DirectoryReader; +import org.apache.lucene.index.IndexCommit; +import org.apache.lucene.index.IndexFormatTooOldException; +import org.apache.lucene.index.SegmentInfos; +import org.apache.lucene.index.StandardDirectoryReader; +import org.apache.lucene.store.Directory; +import org.apache.lucene.tests.store.BaseDirectoryWrapper; +import org.apache.lucene.util.Version; + +public class TestBinaryBackwardsCompatibility extends BackwardsCompatibilityTestBase { + + static final int MIN_BINARY_SUPPORTED_MAJOR = Version.MIN_SUPPORTED_MAJOR - 1; + static final String INDEX_NAME = "unsupported"; + static final String SUFFIX_CFS = "-cfs"; + static final String SUFFIX_NO_CFS = "-nocfs"; + + public TestBinaryBackwardsCompatibility(Version version, String pattern) { + super(version, pattern); + } + + @ParametersFactory(argumentFormatting = "Lucene-Version:%1$s; Pattern: %2$s") + public static Iterable<Object[]> testVersionsFactory() { + List<Object[]> params = new ArrayList<>(); + for (Version version : BINARY_SUPPORTED_VERSIONS) { + params.add(new Object[] {version, createPattern(INDEX_NAME, SUFFIX_CFS)}); + params.add(new Object[] {version, createPattern(INDEX_NAME, SUFFIX_NO_CFS)}); + } + return params; + } + + @Override + void verifyUsesDefaultCodec(Directory dir, String name) throws IOException { + // don't this will fail since the indices are not supportd Review Comment: ```suggestion // don't this will fail since the indices are not supported ``` ########## lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestEmptyIndexBackwardsCompatibility.java: ########## @@ -0,0 +1,65 @@ +/* + * 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 com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.index.IndexWriterConfig; +import org.apache.lucene.index.NoMergePolicy; +import org.apache.lucene.store.Directory; +import org.apache.lucene.tests.analysis.MockAnalyzer; +import org.apache.lucene.tests.util.TestUtil; +import org.apache.lucene.util.Version; + +public class TestEmptyIndexBackwardsCompatibility extends BackwardsCompatibilityTestBase { + static final String INDEX_NAME = "empty"; + static final String SUFFIX = ""; + + public TestEmptyIndexBackwardsCompatibility(Version version, String pattern) { + super(version, pattern); + } + + @Override + protected void createIndex(Directory directory) throws IOException { + IndexWriterConfig conf = + new IndexWriterConfig(new MockAnalyzer(random())) + .setUseCompoundFile(false) + .setCodec(TestUtil.getDefaultCodec()) + .setMergePolicy(NoMergePolicy.INSTANCE); + try (IndexWriter writer = new IndexWriter(directory, conf)) { + writer.flush(); + } + } + + @ParametersFactory(argumentFormatting = "Lucene-Version:%1$s; Pattern: %2$s") + public static Iterable<Object[]> testVersionsFactory() { + List<Object[]> params = new ArrayList<>(); + // NOCOMMIT: why are we only testing one version here? Review Comment: I would guess it's because it's more about testing the upgrade logic on empty indexes than about testing the format of old empty indexes. -- 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