Speed up TestBackwardsCompatibility#testCommandLineArgs. (#467)

This test unzip files that we already unzipped. This commit copies the already
uncompressed files instead.
This commit is contained in:
Adrien Grand 2021-11-24 08:25:22 +01:00
parent 3f634e2ab9
commit b3a36166a5

View File

@ -106,6 +106,7 @@ import org.apache.lucene.store.BaseDirectoryWrapper;
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.util.Bits;
import org.apache.lucene.util.BytesRef;
@ -1664,17 +1665,22 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
}
}
public void testCommandLineArgs() throws Exception {
public void testIndexUpgraderCommandLineArgs() throws Exception {
PrintStream savedSystemOut = System.out;
System.setOut(new PrintStream(new ByteArrayOutputStream(), false, "UTF-8"));
try {
for (Map.Entry<String, Directory> entry : oldIndexDirs.entrySet()) {
String name = entry.getKey();
Directory origDir = entry.getValue();
int indexCreatedVersion =
SegmentInfos.readLatestCommit(entry.getValue()).getIndexCreatedVersionMajor();
SegmentInfos.readLatestCommit(origDir).getIndexCreatedVersionMajor();
Path dir = createTempDir(name);
TestUtil.unzip(getDataInputStream("index." + name + ".zip"), dir);
try (FSDirectory fsDir = FSDirectory.open(dir)) {
for (String file : origDir.listAll()) {
fsDir.copyFrom(origDir, file, file, IOContext.DEFAULT);
}
}
String path = dir.toAbsolutePath().toString();