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 committed by GitHub
parent 24fcd80a37
commit f80d816ce7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

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