Skip to content

Commit 444d3af

Browse files
committed
Remove an integration test from unit tests
1 parent dd32a09 commit 444d3af

File tree

3 files changed

+0
-512
lines changed

3 files changed

+0
-512
lines changed

dumper/app/src/test/java/com/google/edwmigration/dumper/application/dumper/connector/hive/HiveMetadataConnectorTest.java

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,22 @@
2020
import static org.junit.Assert.assertTrue;
2121

2222
import com.google.common.collect.ImmutableList;
23-
import com.google.common.collect.Lists;
2423
import com.google.edwmigration.dumper.application.dumper.ConnectorArguments;
25-
import com.google.edwmigration.dumper.application.dumper.Main;
2624
import com.google.edwmigration.dumper.application.dumper.connector.AbstractConnectorTest;
27-
import com.google.edwmigration.dumper.application.dumper.connector.hive.support.HiveServerSupport;
28-
import com.google.edwmigration.dumper.application.dumper.connector.hive.support.HiveTestSchemaBuilder;
2925
import com.google.edwmigration.dumper.application.dumper.task.Task;
30-
import com.google.edwmigration.dumper.plugin.ext.jdk.progress.ConcurrentProgressMonitor;
31-
import com.google.edwmigration.dumper.plugin.ext.jdk.progress.ConcurrentRecordProgressMonitor;
32-
import java.io.File;
3326
import java.io.IOException;
34-
import java.nio.charset.StandardCharsets;
35-
import java.nio.file.Files;
36-
import java.nio.file.Path;
3727
import java.util.ArrayList;
38-
import java.util.Collection;
39-
import java.util.Collections;
4028
import java.util.List;
41-
import java.util.concurrent.Callable;
42-
import java.util.concurrent.ExecutorService;
43-
import java.util.concurrent.Executors;
44-
import java.util.concurrent.Future;
45-
import java.util.stream.Collectors;
46-
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
47-
import org.apache.commons.compress.archivers.zip.ZipFile;
48-
import org.apache.commons.io.FileUtils;
49-
import org.apache.commons.io.IOUtils;
50-
import org.apache.commons.lang3.SystemUtils;
51-
import org.junit.Assert;
52-
import org.junit.Assume;
5329
import org.junit.Test;
5430
import org.junit.experimental.theories.DataPoints;
5531
import org.junit.experimental.theories.FromDataPoints;
5632
import org.junit.experimental.theories.Theories;
5733
import org.junit.experimental.theories.Theory;
5834
import org.junit.runner.RunWith;
59-
import org.slf4j.Logger;
60-
import org.slf4j.LoggerFactory;
6135

6236
@RunWith(Theories.class)
6337
public class HiveMetadataConnectorTest extends AbstractConnectorTest {
6438

65-
private static final Logger logger = LoggerFactory.getLogger(HiveMetadataConnectorTest.class);
66-
private static final boolean debug = false;
67-
6839
private final HiveMetadataConnector connector = new HiveMetadataConnector();
6940

7041
@Test
@@ -141,109 +112,4 @@ public void addTasksTo_migrationMetadataTaskExists_success(
141112
"Task names must contain '" + taskName + "'. Actual tasks: " + taskNames,
142113
taskNames.contains(taskName));
143114
}
144-
145-
/**
146-
* Run this with:
147-
*
148-
* <pre>
149-
* ./gradlew :dumper:app:{cleanTest,test} --tests HiveMetadataConnectorTest
150-
* -Dtest.verbose=true -Dorg.gradle.java.home=/usr/lib/jvm/java-1.8.0-openjdk-amd64
151-
* </pre>
152-
*/
153-
@Test
154-
public void testLoadedHive312() throws Exception {
155-
156-
// Hive 3.1.2 requires java 1.8
157-
Assume.assumeTrue(SystemUtils.IS_JAVA_1_8);
158-
159-
// with 5/5/10/1000 -> ~2 minutes
160-
int NUM_SCHEMAS = 5;
161-
int NUM_TABLES = 5;
162-
int NUM_COLUMNS = 10;
163-
int NUM_PARTITIONS = 1000;
164-
165-
int NUM_DUMPER_RUNS = 5; // 5 -> ~4 minutes
166-
int BATCH_SIZE = 25;
167-
168-
List<List<String>> setupStatements =
169-
HiveTestSchemaBuilder.getStatements(NUM_SCHEMAS, NUM_TABLES, NUM_COLUMNS, NUM_PARTITIONS);
170-
171-
try (HiveServerSupport instanceSupport = new HiveServerSupport().start()) {
172-
173-
// Populate Hive Metastore
174-
long total = setupStatements.stream().mapToLong(Collection::size).sum();
175-
try (ConcurrentProgressMonitor monitor =
176-
new ConcurrentRecordProgressMonitor("Populating Hive instance.", total)) {
177-
ExecutorService executor = Executors.newFixedThreadPool(HiveServerSupport.CONCURRENCY);
178-
179-
for (List<String> statementList : setupStatements) {
180-
executor
181-
.invokeAll(
182-
Lists.partition(statementList, BATCH_SIZE).stream()
183-
.map(l -> getCallable(instanceSupport, l, monitor))
184-
.collect(Collectors.toList()))
185-
.forEach(this::assertNoException);
186-
}
187-
}
188-
189-
// Run dumper many times and assert all tables are there (1 table = 1 line, JSONL)
190-
for (int i = 0; i < NUM_DUMPER_RUNS; i++) {
191-
String tmpPrefix = String.format("dumper-test-iteration-%d-", i);
192-
Path tmpPath = Files.createTempFile(tmpPrefix, ".zip");
193-
File tmpFile = tmpPath.toFile();
194-
195-
try {
196-
Main.main(
197-
"--connector",
198-
"hiveql",
199-
"--port",
200-
"" + instanceSupport.getMetastoreThriftPort(),
201-
"--output",
202-
tmpFile.getAbsolutePath());
203-
204-
assertTrue(tmpFile.exists());
205-
206-
try (ZipFile zipFile = new ZipFile(tmpFile)) {
207-
List<ZipArchiveEntry> entries = Collections.list(zipFile.getEntries());
208-
209-
entries.forEach(e -> Assert.assertFalse(e.getName().contains("exception.txt")));
210-
211-
List<String> tables =
212-
IOUtils.readLines(
213-
zipFile.getInputStream(zipFile.getEntry("tables.jsonl")),
214-
StandardCharsets.UTF_8);
215-
216-
Assert.assertEquals(
217-
"All tables should be present.", NUM_SCHEMAS * NUM_TABLES, tables.size());
218-
219-
logger.info("Dump verified.");
220-
}
221-
222-
} catch (Exception e) {
223-
throw new AssertionError(e);
224-
} finally {
225-
if (!debug) {
226-
FileUtils.forceDelete(tmpFile);
227-
}
228-
}
229-
}
230-
}
231-
}
232-
233-
private void assertNoException(Future<Void> f) {
234-
try {
235-
f.get();
236-
} catch (Exception e) {
237-
Assert.fail("Exception during setup");
238-
}
239-
}
240-
241-
private Callable<Void> getCallable(
242-
HiveServerSupport support, List<String> batch, ConcurrentProgressMonitor monitor) {
243-
return () -> {
244-
support.execute(batch.toArray(new String[] {}));
245-
monitor.count(batch.size());
246-
return null;
247-
};
248-
}
249115
}

0 commit comments

Comments
 (0)