HIVE-29483: Implement an integration testing mechanism with real Tez on Yarn including resource localization - #6640
Conversation
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
|
|
||
| /** |
There was a problem hiding this comment.
I think we don't need this comment entirely naming itself quite self explainatory
| * | ||
| * Run with: mvn -Pitests,tez-yarn -pl itests/tez-yarn-it -Dtest=TezYarnClusterContainerTest test | ||
| */ | ||
| public class TezYarnClusterContainerTest { |
There was a problem hiding this comment.
please use TestTezYarnClusterContainer
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| /** |
There was a problem hiding this comment.
please get rid of these large chunk of explainatory comments
try to keep them coincise to convey the purpose wherever the methods and classes are complex enough and need some explicit explanation
please avoid these * Run with: kind of comments
| import java.util.Set; | ||
| import java.util.stream.Stream; | ||
|
|
||
| /** |
There was a problem hiding this comment.
same https://github.com/apache/hive/pull/6640/changes#r3681063334
and here comments are explaining the same redundant thing over and over so please remove those
There was a problem hiding this comment.
Hey @ramitg254 Thanks for pointing it out..I'll get rid of these unwanted comments
There was a problem hiding this comment.
Pull request overview
Adds a new opt-in integration-test module that runs Hive-on-Tez against a real (containerized) HDFS + YARN cluster, specifically to validate YARN resource localization behavior (e.g., ensuring hive-exec.jar is localized for Tez AM/task containers).
Changes:
- Introduces
itests/tez-yarn-itMaven module (profile-gated execution) with Testcontainers-based HDFS/YARN cluster orchestration. - Adds end-to-end HS2 + Tez query test intended to catch regressions in Tez-on-YARN jar localization.
- Adds Docker build assets and minimal Hadoop/YARN/Hive config used by the integration tests.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| itests/pom.xml | Adds the new tez-yarn-it module to the itests reactor. |
| itests/tez-yarn-it/pom.xml | Defines the module, test dependencies, surefire args, and generation of a custom hosts file for stable container hostname resolution. |
| itests/tez-yarn-it/src/test/java/org/apache/hive/tez/yarn/TezYarnClusterContainer.java | Testcontainers orchestration for NameNode/DataNode/RM/NM plus helper methods for staging jars to HDFS. |
| itests/tez-yarn-it/src/test/java/org/apache/hive/tez/yarn/TestTezYarnLocalization.java | End-to-end HS2 + Tez test and diagnostics collection. |
| itests/tez-yarn-it/src/test/java/org/apache/hive/tez/yarn/TestTezYarnClusterContainer.java | Container “smoke test” coverage for HDFS/YARN basics and jar upload helper. |
| itests/tez-yarn-it/src/test/java/org/apache/hive/tez/yarn/TestHiveServer2Connectivity.java | HS2 connectivity smoke test against the containerized cluster. |
| itests/tez-yarn-it/src/test/resources/hive-site-yarn-it.xml | Hive configuration overrides for the Tez-on-YARN integration tests. |
| itests/tez-yarn-it/src/test/resources/yarn-site.xml | YARN configuration overrides (notably disabling container memory checks for Docker). |
| itests/tez-yarn-it/src/test/resources/custom_hosts_file | Static host mappings used via -Djdk.net.hosts.file to make container hostnames resolvable from the test JVM. |
| itests/tez-yarn-it/src/test/docker/hadoop-yarn/Dockerfile | Custom Hadoop image that adds a Java 21 runtime for Tez AM/task container launch. |
| itests/tez-yarn-it/src/test/docker/hadoop-yarn/config | Environment-driven Hadoop/YARN configuration used by the Dockerized cluster. |
Suppressed comments (1)
itests/tez-yarn-it/src/test/java/org/apache/hive/tez/yarn/TestTezYarnLocalization.java:66
- These additional HDFS setup commands also ignore exit codes, which can hide early failures (e.g., namenode not ready, permissions issues) and make the failing signal less direct.
nn.execInContainer("hdfs", "dfs", "-mkdir", "-p", HDFS_ROOT + "/warehouse");
nn.execInContainer("hdfs", "dfs", "-mkdir", "-p", HDFS_ROOT + "/scratch");
nn.execInContainer("hdfs", "dfs", "-mkdir", "-p", HDFS_ROOT + "/user-install");
nn.execInContainer("hdfs", "dfs", "-chmod", "-R", "777", HDFS_ROOT);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| public void start() { | ||
| namenode.start(); | ||
| datanode.start(); | ||
| resourcemanager.start(); | ||
| nodemanager.start(); |
| private static String buildHadoopImage() { | ||
| String basedir = System.getProperty("basedir", "."); | ||
| Path dockerfile = Paths.get(basedir, "src/test/docker/hadoop-yarn/Dockerfile"); | ||
| return new ImageFromDockerfile("hive-it-hadoop-jdk21", false) | ||
| .withDockerfile(dockerfile) | ||
| .get(); | ||
| } |
| private static boolean isTezFrameworkJar(String name) { | ||
| if (name.endsWith("-tests.jar")) { | ||
| return false; | ||
| } | ||
| return name.contains("tez") | ||
| || name.startsWith("hadoop-shim") | ||
| || name.startsWith("hadoop-mapreduce-client-core") | ||
| || name.startsWith("hadoop-mapreduce-client-common"); | ||
| } |
| nn.execInContainer("hdfs", "dfs", "-mkdir", "-p", "/tmp"); | ||
| nn.execInContainer("hdfs", "dfs", "-chmod", "-R", "777", "/tmp"); |
| Path localScratch = Files.createDirectories( | ||
| Path.of("/tmp", "hive-tez-loc-" + System.currentTimeMillis())); |
| cluster.namenodeContainer().execInContainer("hdfs", "dfs", "-mkdir", "-p", "/tmp/hive-29483/warehouse"); | ||
| cluster.namenodeContainer().execInContainer("hdfs", "dfs", "-mkdir", "-p", "/tmp/hive-29483/scratch"); | ||
| cluster.namenodeContainer().execInContainer("hdfs", "dfs", "-chmod", "-R", "777", "/tmp/hive-29483"); |
c45e9a5 to
362e95b
Compare
abstractdog
left a comment
There was a problem hiding this comment.
thanks @hemanthumashankar0511 , tried it locally, seems to work, I left some comments regarding the design
once you address those and/or we discussed them, I'm ready to test it again
| if (hiveSite != null) conf.addResource(hiveSite); | ||
| if (yarnSite != null) conf.addResource(yarnSite); |
There was a problem hiding this comment.
use proper {} blocks for single line blocks as well
| cluster.namenodeContainer().execInContainer("hdfs", "dfs", "-mkdir", "-p", "/tmp/hive-29483/scratch"); | ||
| cluster.namenodeContainer().execInContainer("hdfs", "dfs", "-chmod", "-R", "777", "/tmp/hive-29483"); | ||
|
|
||
| Path localScratch = Files.createTempDirectory("hive-29483-local-"); |
There was a problem hiding this comment.
using "29483" explicitly looks strange, it should be handled by the test code under the hood
| private static final String HDFS_BASE = "hdfs://namenode:8020"; | ||
| private static final String HDFS_WAREHOUSE = HDFS_BASE + "/tmp/hive-tez-loc/warehouse"; | ||
| private static final String HDFS_SCRATCH = HDFS_BASE + "/tmp/hive-tez-loc/scratch"; | ||
| private static final String HDFS_ROOT = "/tmp/hive-tez-loc"; |
There was a problem hiding this comment.
no need for extra indendation for aligning values
| <!-- Resolve docker-network hostnames (namenode, resourcemanager, …) to 127.0.0.1 | ||
| so HDFS URIs embedded in Tez LocalResources are reachable from both the host JVM | ||
| and inside YARN containers (via the shared docker network alias). --> | ||
| <argLine>${maven.test.jvm.args} -Xshare:off -Djdk.net.hosts.file=${test.conf.dir}/custom_hosts_file</argLine> |
There was a problem hiding this comment.
is there a specific reason to disable class data sharing via Xshare? if the base java image supports class metadata sharing for the base JDK classes, it can reduce container startup time a bit
| return nodemanager; | ||
| } | ||
|
|
||
| private void waitForNodeManagerRegistration() { |
There was a problem hiding this comment.
consider using Awaitility for this purpose, which is already used in the hive project
| conf.set("tez.lib.uris", tezLibUris); | ||
| conf.setBoolean("tez.use.cluster.hadoop-libs", true); | ||
| conf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_TEZ_INITIALIZE_DEFAULT_SESSIONS, false); | ||
| conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_TEZ_SESSIONS_PER_DEFAULT_QUEUE, 0); | ||
|
|
||
| conf.set("tez.am.client.am.port-range", | ||
| TezYarnClusterContainer.AM_CLIENT_PORT + "-" + TezYarnClusterContainer.AM_CLIENT_PORT); | ||
|
|
||
| String containerEnv = "JAVA_HOME=" + TezYarnClusterContainer.CONTAINER_JAVA_21_HOME | ||
| + ",HADOOP_HOME=/opt/hadoop" | ||
| + ",HADOOP_MAPRED_HOME=/opt/hadoop"; | ||
| conf.set("tez.am.launch.env", containerEnv); | ||
| conf.set("tez.task.launch.env", containerEnv); | ||
|
|
||
| hs2Port = findFreePort(); | ||
| conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_PORT, hs2Port); | ||
| conf.setVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST, "localhost"); | ||
| conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_WEBUI_PORT, findFreePort()); | ||
| conf.setVar(HiveConf.ConfVars.HIVE_SERVER2_TRANSPORT_MODE, "binary"); | ||
| conf.setVar(HiveConf.ConfVars.HIVE_SERVER2_AUTHENTICATION, "NOSASL"); | ||
| conf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS, false); |
There was a problem hiding this comment.
is it possible to move whatever is constant to hive-site-yarn-it.xml?
| dumpNmCommand("NodeManager daemon log (tail 200)", | ||
| "find /var/log/hadoop -maxdepth 1 -name '*.log' 2>/dev/null | head -3 " | ||
| + "| xargs -I{} sh -c 'echo \"--- {} ---\"; tail -200 {}' 2>/dev/null || true"); |
There was a problem hiding this comment.
after a successful run of TestTezYarnLocalization I saw empty nodemanager logs, is this expected?
===== NM: NodeManager daemon log (tail 200) =====
(no output found)
########## END NodeManager diagnostics ##########
| } | ||
|
|
||
| @Test | ||
| public void testQuerySucceedsWithAppJar() throws Exception { |
There was a problem hiding this comment.
this unit test might want to become even smarter by asserting 2 more things:
- hive-exec.jar is present on HDFS somewhere (result of localization step 1)
- hive-exec.jar is present in the yarn container's local folder (result of localization step 2)
| <name>Hive Integration - Tez on YARN localization tests</name> | ||
| <properties> | ||
| <hive.path.to.root>../..</hive.path.to.root> | ||
| <skip.tez.yarn.tests>true</skip.tez.yarn.tests> |
There was a problem hiding this comment.
instead of skip.tez.yarn.tests I would use run.tez.yarn.tests, because skip + false is always a strange form of double-negative
| import java.util.Set; | ||
| import java.util.stream.Stream; | ||
|
|
||
| public class TezYarnClusterContainer { |
There was a problem hiding this comment.
design consideration: would you consider moving all this stuff to a docker-compose file for users' convenience (see my other comment regarding readme: https://github.com/apache/hive/pull/6640/changes#r3842926313)
I think this PR now handles a lot of the Java code when it comes to docker setup, which otherwise would be a simple docker-compose
and then TezYarnClusterContainer can leverage ComposeContainers like:
File composeFile = ...
"src/test/docker/hadoop-yarn/docker-compose.yml");
ComposeContainer c = new ComposeContainer(composeFile)
given that "docker compose" is not available on precommit pods, and we don't want to make it a hard dependency for devs, withLocalCompose(false) will work
I'm hoping that a docker-compose will save us from using workarounds/hacks like the "custom_hosts_file"
for docker compose and the surrounding templates and stuff, feel free to take a look at whatever we already have in the packaging module:
https://github.com/apache/hive/blob/master/packaging/src/docker/docker-compose.yml
|
|
Hey @abstractdog thanks for the review!! I'll go through all the suggestions and keep you updated |



What changes were proposed in this pull request?
Adds an opt-in itests/tez-yarn-it module with a Docker/Testcontainers-based HDFS+YARN cluster and an end-to-end test that verifies hive-exec.jar is localized when Tez runs on YARN.
Why are the changes needed?
MiniTezCluster / TestMiniTezCliDriver do not exercise real YARN resource localization, so regressions like skipping hive-exec.jar from commonLocalResources are not caught today.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Ran locally with mvn test -Pitests,tez-yarn -pl itests/tez-yarn-it -Dtest=TestTezYarnLocalization#testQuerySucceedsWithAppJar, and also validated on GitHub Actions (ubuntu-latest, native Linux amd64) using the same Maven command after mvn clean install -DskipTests -Pitests -pl itests/tez-yarn-it -am; the full end-to-end test is reliable on native Linux and macOS