test(emr): shorten the Hive Docker case that shares its metastore (#8105)

hiveAndSparkStepsShareTheClustersMetastoreServiceAndHdfs ran six steps
one after another: 88s on a loaded machine, and past the suite's
2-minute limit on a busier one.

Its two cats are now one step, which runs beside the Spark step, and the
report step also reads the Spark step's table, which a Hive step of its
own read before. Every assertion stays, and the case took 73s on the
same machine.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-12 13:58:52 -04:00
1 parent 89a0c86797
commit ef5e1cf010
1 file changed
+21 -24
@@ -81,7 +81,8 @@ class EmrHiveStepsDockerIntegrationTest {
@Test
void hiveAndSparkStepsShareTheClustersMetastoreServiceAndHdfs() {
startCluster(HIVE_AND_SPARK, "[]", null);
// The two steps that read what the first one made, and need nothing from each other, run at once.
startCluster(HIVE_AND_SPARK, "[]", null, 2);
put("queries/load.q", """
create external table kv (k string, v int)
row format delimited fields terminated by ',' location '${INPUT}';
@@ -93,24 +94,8 @@ class EmrHiveStepsDockerIntegrationTest {
insert overwrite directory '${OUTPUT}' row format delimited fields terminated by ','
select k, v from scaled order by k;
select k, v from scaled order by k;
select k from from_spark order by k;
""");
assertEquals("COMPLETED", hiveStep("-f", s3Uri("queries/load.q"), "-d", "INPUT=" + s3Uri("data/rows/")));
// The table the first step made is in the cluster's metastore for the second.
String report = addStep("command-runner.jar", "hive-script", "--run-hive-script", "--args",
"-f", s3Uri("queries/report.q"), "-d", "OUTPUT=" + s3Uri("out/report/"));
assertEquals("COMPLETED", state(report));
assertEquals("a,10\nb,20\nc,30\n", objects("out/report/"));
assertTrue(stepLog(report, "stdout.gz").contains("a\t10\nb\t20\nc\t30\n"));
// Its data is in the cluster's HDFS, which a step in the Spark image reads as hdfs://.
String cat = addStep("command-runner.jar", "hadoop", "fs", "-cat", "hdfs:///user/hive/warehouse/scaled/*");
assertEquals("COMPLETED", state(cat));
assertEquals("a\u000110\nb\u000120\nc\u000130\n", stepLog(cat, "stdout.gz"));
// An hdfs:// location is the cluster's HDFS too, whose NameNode answers Hive's encryption zone lookups.
String pinned = addStep("command-runner.jar", "hadoop", "fs", "-cat", "hdfs:///floci/pinned/*");
assertEquals("COMPLETED", state(pinned));
assertEquals("a\nb\nc\n", stepLog(pinned, "stdout.gz"));
// A Spark step uses the cluster's metastore too: it reads Hive's table, and makes one a Hive step reads.
put("jobs/catalog.py", """
import sys
from pyspark.sql import SparkSession
@@ -119,13 +104,25 @@ class EmrHiveStepsDockerIntegrationTest {
spark.createDataFrame([(" ".join(rows),)], ["value"]).coalesce(1).write.text(sys.argv[1])
spark.sql("create table from_spark stored as textfile as select upper(k) as k from scaled")
""");
assertEquals("COMPLETED", state(addStep("command-runner.jar", "spark-submit", s3Uri("jobs/catalog.py"),
s3Uri("out/spark/"))));
assertEquals("COMPLETED", hiveStep("-f", s3Uri("queries/load.q"), "-d", "INPUT=" + s3Uri("data/rows/")));
// Its data is in the cluster's HDFS, which a step in the Spark image reads as hdfs://, and so is an hdfs://
// location's, whose NameNode answers Hive's encryption zone lookups.
String cat = addStep("command-runner.jar", "hadoop", "fs", "-cat", "hdfs:///user/hive/warehouse/scaled/*",
"hdfs:///floci/pinned/*");
// A Spark step uses the cluster's metastore too: it reads Hive's table, and makes one a Hive step reads.
String spark = addStep("command-runner.jar", "spark-submit", s3Uri("jobs/catalog.py"), s3Uri("out/spark/"));
assertEquals("COMPLETED", state(cat));
assertEquals("a\u000110\nb\u000120\nc\u000130\na\nb\nc\n", stepLog(cat, "stdout.gz"));
assertEquals("COMPLETED", state(spark));
assertEquals("a10 b20 c30\n", objects("out/spark/"));
String fromSpark = addStep("command-runner.jar", "hive-script", "--run-hive-script", "--args",
"-e", "select k from from_spark order by k;");
assertEquals("COMPLETED", state(fromSpark));
assertTrue(stepLog(fromSpark, "stdout.gz").contains("A\nB\nC\n"));
// The tables the first step and the Spark step made are in the cluster's metastore for a later Hive step.
String report = addStep("command-runner.jar", "hive-script", "--run-hive-script", "--args",
"-f", s3Uri("queries/report.q"), "-d", "OUTPUT=" + s3Uri("out/report/"));
assertEquals("COMPLETED", state(report));
assertEquals("a,10\nb,20\nc,30\n", objects("out/report/"));
String reported = stepLog(report, "stdout.gz");
assertTrue(reported.contains("a\t10\nb\t20\nc\t30\n") && reported.contains("A\nB\nC\n"), reported);
}
@Test