mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
test(emr): right-size tiny word-count fixtures (#8525)
* test(emr): right-size tiny word-count fixtures * test(emr): share single-task streaming fixture arguments
This commit is contained in:
1 parent
dc7948013d
commit
6fa18cc99e
1 file changed
+15
-4
@@ -35,6 +35,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@@ -122,7 +123,7 @@ class EmrDockerRunnerDockerIntegrationTest {
|
||||
void aStreamingWordCountStepReadsItsInputAndWritesItsCountsInFlocisS3() {
|
||||
startCluster("[]");
|
||||
|
||||
assertEquals("COMPLETED", runStep("command-runner.jar", "hadoop-streaming",
|
||||
assertEquals("COMPLETED", runSingleTaskStreamingStep("command-runner.jar",
|
||||
"-files", side("mapper.py", "reducer.py"), "-mapper", "python3 mapper.py",
|
||||
"-reducer", "python3 reducer.py", "-input", s3Uri("in/"), "-output", s3Uri("out/")));
|
||||
assertEquals(WORD_COUNTS, counts("out/"));
|
||||
@@ -146,8 +147,7 @@ class EmrDockerRunnerDockerIntegrationTest {
|
||||
|
||||
// The mapper and the reducer, from the files -files sends, with a shuffle between them, run on the core and
|
||||
// task nodes, not in the step's container.
|
||||
assertEquals("COMPLETED", runStep("command-runner.jar", "hadoop-streaming",
|
||||
"-D", "mapreduce.job.maps=1", "-D", "mapreduce.job.reduces=1",
|
||||
assertEquals("COMPLETED", runSingleTaskStreamingStep("command-runner.jar",
|
||||
"-files", side("where-mapper.py", "where-reducer.py"), "-mapper", "python3 where-mapper.py mapper",
|
||||
"-reducer", "python3 where-reducer.py reducer", "-input", s3Uri("in/"), "-output", s3Uri("where/")));
|
||||
Map<String, Integer> counts = counts("where/");
|
||||
@@ -165,7 +165,7 @@ class EmrDockerRunnerDockerIntegrationTest {
|
||||
void aCustomJarAtEmrsStreamingJarPathRunsItsWordCountInTheDriver() {
|
||||
startCluster("[]");
|
||||
|
||||
assertEquals("COMPLETED", runStep("/usr/lib/hadoop-mapreduce/hadoop-streaming.jar",
|
||||
assertEquals("COMPLETED", runSingleTaskStreamingStep("/usr/lib/hadoop-mapreduce/hadoop-streaming.jar",
|
||||
"-files", side("mapper.py", "reducer.py"), "-mapper", "python3 mapper.py",
|
||||
"-reducer", "python3 reducer.py", "-input", s3Uri("in/"), "-output", s3Uri("jar-out/")));
|
||||
assertEquals(WORD_COUNTS, counts("jar-out/"));
|
||||
@@ -474,6 +474,17 @@ class EmrDockerRunnerDockerIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
/** Runs a tiny streaming fixture with one mapper and one reducer. */
|
||||
private String runSingleTaskStreamingStep(String jar, String... args) {
|
||||
List<String> streamingArgs = new ArrayList<>();
|
||||
if ("command-runner.jar".equals(jar)) {
|
||||
streamingArgs.add("hadoop-streaming");
|
||||
}
|
||||
streamingArgs.addAll(List.of("-D", "mapreduce.job.maps=1", "-D", "mapreduce.job.reduces=1"));
|
||||
streamingArgs.addAll(List.of(args));
|
||||
return runStep(jar, streamingArgs.toArray(String[]::new));
|
||||
}
|
||||
|
||||
/** Adds one step to the cluster and returns the state it ended in. */
|
||||
private String runStep(String jar, String... args) {
|
||||
ObjectNode request = JSON.createObjectNode().put("JobFlowId", clusterId);
|
||||
|
||||
Reference in new issue
Block a user