From 46190f056f145c8ed1e250cd687d8afaffb7ea7e Mon Sep 17 00:00:00 2001 From: "Jain, Nihal" Date: Fri, 30 Aug 2024 12:19:10 +0530 Subject: [PATCH 1/5] HBASE-28433 Modify the assembly to not include test jars and their transitive dependencies --- bin/hbase | 8 +-- hbase-assembly/pom.xml | 40 ----------- .../src/main/assembly/client-components.xml | 55 --------------- hbase-assembly/src/main/assembly/client.xml | 12 +--- .../src/main/assembly/components.xml | 70 ------------------- .../src/main/assembly/hadoop-three-compat.xml | 16 +---- hbase-endpoint/pom.xml | 1 + hbase-examples/pom.xml | 1 + hbase-it/pom.xml | 2 + hbase-shell/pom.xml | 2 + hbase-thrift/pom.xml | 1 + pom.xml | 11 --- 12 files changed, 14 insertions(+), 205 deletions(-) diff --git a/bin/hbase b/bin/hbase index 937f7c22f2dd..d35a1ae4e72c 100755 --- a/bin/hbase +++ b/bin/hbase @@ -340,6 +340,7 @@ fi #If configured and available, add Hadoop to the CLASSPATH and to the JAVA_LIBRARY_PATH if [ -n "${HADOOP_IN_PATH}" ] && [ -f "${HADOOP_IN_PATH}" ]; then + # TODO: Drop/Modify this logic # If built hbase, temporarily add hbase-server*.jar to classpath for GetJavaProperty # Exclude hbase-server*-tests.jar temporary_cp= @@ -766,13 +767,6 @@ elif [ "$COMMAND" = "copyreppeers" ] ; then CLASS='org.apache.hadoop.hbase.replication.CopyReplicationPeers' else CLASS=$COMMAND -if [[ "$CLASS" =~ .*IntegrationTest.* ]] ; then - for f in ${HBASE_HOME}/lib/test/*.jar; do - if [ -f "${f}" ]; then - CLASSPATH="${CLASSPATH}:${f}" - fi - done - fi fi add_jdk17_jvm_flags diff --git a/hbase-assembly/pom.xml b/hbase-assembly/pom.xml index 5b51b88f9313..254ffe350931 100644 --- a/hbase-assembly/pom.xml +++ b/hbase-assembly/pom.xml @@ -47,20 +47,6 @@ org.apache.hbase hbase-shaded-mapreduce - - - org.apache.hbase - hbase-it - test-jar - - - - org.hamcrest - hamcrest-core - - compile - org.apache.hbase hbase-openssl @@ -73,22 +59,11 @@ org.apache.hbase hbase-mapreduce - - org.apache.hbase - hbase-mapreduce - test-jar - org.apache.hbase hbase-procedure - - org.apache.hbase - hbase-procedure - test-jar - test - org.apache.hbase hbase-hadoop-compat @@ -115,10 +90,6 @@ org.apache.hbase hbase-external-blockcache - - org.apache.hbase - hbase-testing-util - org.apache.hbase hbase-metrics-api @@ -235,17 +206,6 @@ io.opentelemetry.javaagent opentelemetry-javaagent - - junit - junit - - - org.mockito - mockito-core - - - compile - diff --git a/hbase-assembly/src/main/assembly/client-components.xml b/hbase-assembly/src/main/assembly/client-components.xml index 7cb97dd6822d..b0e359485a37 100644 --- a/hbase-assembly/src/main/assembly/client-components.xml +++ b/hbase-assembly/src/main/assembly/client-components.xml @@ -87,60 +87,5 @@ *.dylib - - - - ${project.basedir}/../hbase-server/target/ - lib - - ${server.test.jar} - - 0644 - - - ${project.basedir}/../hbase-mapreduce/target/ - lib - - ${mapreduce.test.jar} - - 0644 - - - ${project.basedir}/../hbase-common/target/ - lib - - ${common.test.jar} - - 0644 - - - ${project.basedir}/../hbase-asyncfs/target/ - lib - - ${asyncfs.test.jar} - - 0644 - - - ${project.basedir}/../hbase-zookeeper/target/ - lib - - ${zookeeper.test.jar} - - 0644 - - - ${project.basedir}/../hbase-procedure/target/ - lib - - ${procedure.test.jar} - - 0644 - diff --git a/hbase-assembly/src/main/assembly/client.xml b/hbase-assembly/src/main/assembly/client.xml index cd627ae9589b..70a335c1a07a 100644 --- a/hbase-assembly/src/main/assembly/client.xml +++ b/hbase-assembly/src/main/assembly/client.xml @@ -44,7 +44,10 @@ lib + false + org.apache.hadoop:*:test-jar + org.apache.hbase:*:test-jar com.sun.xml.ws:jaxws-ri @@ -167,15 +170,6 @@ io.opentelemetry.javaagent:* - - - lib/test - - junit:junit - org.hamcrest:hamcrest-core - org.mockito:mockito-core - - diff --git a/hbase-assembly/src/main/assembly/components.xml b/hbase-assembly/src/main/assembly/components.xml index 3e1394e7d5b1..f79b2e754caf 100644 --- a/hbase-assembly/src/main/assembly/components.xml +++ b/hbase-assembly/src/main/assembly/components.xml @@ -109,75 +109,5 @@ **/*.h - - - ${project.basedir}/../hbase-server/target/ - lib - - ${server.test.jar} - - 0644 - - - ${project.basedir}/../hbase-it/target/ - lib - - ${it.test.jar} - - 0644 - - - ${project.basedir}/../hbase-annotations/target/ - lib - - ${annotations.test.jar} - - 0644 - - - ${project.basedir}/../hbase-common/target/ - lib - - ${common.test.jar} - - 0644 - - - ${project.basedir}/../hbase-mapreduce/target/ - lib - - ${mapreduce.test.jar} - - 0644 - - - ${project.basedir}/../hbase-asyncfs/target/ - lib - - ${asyncfs.test.jar} - - 0644 - - - ${project.basedir}/../hbase-zookeeper/target/ - lib - - ${zookeeper.test.jar} - - 0644 - - - ${project.basedir}/../hbase-procedure/target/ - lib - - ${procedure.test.jar} - - 0644 - diff --git a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml index 4ba995409f08..65354e0534e2 100644 --- a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml +++ b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml @@ -33,7 +33,6 @@ true - org.apache.hbase:hbase-annotations org.apache.hbase:hbase-asyncfs org.apache.hbase:hbase-backup org.apache.hbase:hbase-balancer @@ -43,7 +42,6 @@ org.apache.hbase:hbase-external-blockcache org.apache.hbase:hbase-hadoop-compat org.apache.hbase:hbase-http - org.apache.hbase:hbase-it org.apache.hbase:hbase-logging org.apache.hbase:hbase-mapreduce org.apache.hbase:hbase-diagnostics @@ -55,7 +53,6 @@ org.apache.hbase:hbase-rest org.apache.hbase:hbase-server org.apache.hbase:hbase-shell - org.apache.hbase:hbase-testing-util org.apache.hbase:hbase-thrift org.apache.hbase:hbase-zookeeper @@ -65,7 +62,10 @@ false + false + org.apache.hadoop:*:test-jar + org.apache.hbase:*:test-jar com.sun.xml.ws:jaxws-ri:pom @@ -206,16 +206,6 @@ io.opentelemetry.javaagent:* - - - - lib/test - - junit:junit - org.hamcrest:hamcrest-core - org.mockito:mockito-core - - diff --git a/hbase-endpoint/pom.xml b/hbase-endpoint/pom.xml index ed17e8e48f1f..18ef94fd8df3 100644 --- a/hbase-endpoint/pom.xml +++ b/hbase-endpoint/pom.xml @@ -261,6 +261,7 @@ org.apache.hadoop hadoop-minicluster + test com.google.guava diff --git a/hbase-examples/pom.xml b/hbase-examples/pom.xml index 6d3727e8425f..526e3c7e417b 100644 --- a/hbase-examples/pom.xml +++ b/hbase-examples/pom.xml @@ -315,6 +315,7 @@ org.apache.hadoop hadoop-minicluster + test javax.xml.bind. diff --git a/hbase-it/pom.xml b/hbase-it/pom.xml index d36f753b283b..00dbe2d2d8cd 100644 --- a/hbase-it/pom.xml +++ b/hbase-it/pom.xml @@ -375,6 +375,7 @@ org.apache.hadoop hadoop-minicluster + test javax.xml.bind @@ -389,6 +390,7 @@ org.apache.hadoop hadoop-minikdc + test diff --git a/hbase-shell/pom.xml b/hbase-shell/pom.xml index 7e6278c37a40..ed8670a29489 100644 --- a/hbase-shell/pom.xml +++ b/hbase-shell/pom.xml @@ -195,6 +195,7 @@ org.apache.hadoop hadoop-minicluster + test com.google.guava @@ -209,6 +210,7 @@ org.apache.hadoop hadoop-minikdc + test diff --git a/hbase-thrift/pom.xml b/hbase-thrift/pom.xml index b75b288c8789..885db7466e0d 100644 --- a/hbase-thrift/pom.xml +++ b/hbase-thrift/pom.xml @@ -437,6 +437,7 @@ org.apache.hadoop hadoop-minicluster + test com.google.guava diff --git a/pom.xml b/pom.xml index c692e26993c9..6749e63d5496 100644 --- a/pom.xml +++ b/pom.xml @@ -937,17 +937,6 @@ 0.8.8 3.9.1.2184 - - - hbase-server-${project.version}-tests.jar - hbase-common-${project.version}-tests.jar - hbase-procedure-${project.version}-tests.jar - hbase-it-${project.version}-tests.jar - hbase-annotations-${project.version}-tests.jar - hbase-mapreduce-${project.version}-tests.jar - hbase-zookeeper-${project.version}-tests.jar - hbase-asyncfs-${project.version}-tests.jar bash surefire-junit47 From bc7c28fb5497c6bf3c6a012b394f85b2246b86f6 Mon Sep 17 00:00:00 2001 From: Nihal Jain Date: Wed, 16 Oct 2024 01:56:34 +0530 Subject: [PATCH 2/5] - Make sure we are able to run IT/Chaos from compiled source directory - Revert change of removing lib/test jars --- bin/hbase | 23 ++++++++++++++++++- hbase-assembly/pom.xml | 19 +++++++++++++++ hbase-assembly/src/main/assembly/client.xml | 9 ++++++++ .../src/main/assembly/hadoop-three-compat.xml | 9 ++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/bin/hbase b/bin/hbase index d35a1ae4e72c..fd528d864cc6 100755 --- a/bin/hbase +++ b/bin/hbase @@ -340,7 +340,6 @@ fi #If configured and available, add Hadoop to the CLASSPATH and to the JAVA_LIBRARY_PATH if [ -n "${HADOOP_IN_PATH}" ] && [ -f "${HADOOP_IN_PATH}" ]; then - # TODO: Drop/Modify this logic # If built hbase, temporarily add hbase-server*.jar to classpath for GetJavaProperty # Exclude hbase-server*-tests.jar temporary_cp= @@ -480,6 +479,17 @@ add_maven_deps_to_classpath() { CLASSPATH=${CLASSPATH}:$(cat "${f}") } +add_test_jars_from_compiled_source() { + # if in dev env, add test jars so that ITs/Chaos etc. can be run from compiled source directory + if $in_dev_env; then + for f in */target/*.jar; do + if [ -f "${f}" ]; then + CLASSPATH="${CLASSPATH}:${f}" + fi + done + fi +} + add_jdk17_jvm_flags() { # Keep in sync with hbase-surefire.jdk17.flags in the root pom.xml HBASE_OPTS="$HBASE_OPTS -Dorg.apache.hbase.thirdparty.io.netty.tryReflectionSetAccessible=true" @@ -767,6 +777,17 @@ elif [ "$COMMAND" = "copyreppeers" ] ; then CLASS='org.apache.hadoop.hbase.replication.CopyReplicationPeers' else CLASS=$COMMAND + + if [[ "$CLASS" =~ .*IntegrationTest.* ]] || [[ "$CLASS" =~ .*Chaos.* ]]; then + for f in ${HBASE_HOME}/lib/test/*.jar; do + if [ -f "${f}" ]; then + CLASSPATH="${CLASSPATH}:${f}" + fi + done + + add_test_jars_from_compiled_source + fi + fi add_jdk17_jvm_flags diff --git a/hbase-assembly/pom.xml b/hbase-assembly/pom.xml index 254ffe350931..1e0381f04703 100644 --- a/hbase-assembly/pom.xml +++ b/hbase-assembly/pom.xml @@ -47,6 +47,14 @@ org.apache.hbase hbase-shaded-mapreduce + + + org.hamcrest + hamcrest-core + + compile + org.apache.hbase hbase-openssl @@ -206,6 +214,17 @@ io.opentelemetry.javaagent opentelemetry-javaagent + + junit + junit + + + org.mockito + mockito-core + + + compile + diff --git a/hbase-assembly/src/main/assembly/client.xml b/hbase-assembly/src/main/assembly/client.xml index 70a335c1a07a..1a341b016438 100644 --- a/hbase-assembly/src/main/assembly/client.xml +++ b/hbase-assembly/src/main/assembly/client.xml @@ -170,6 +170,15 @@ io.opentelemetry.javaagent:* + + + lib/test + + junit:junit + org.hamcrest:hamcrest-core + org.mockito:mockito-core + + diff --git a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml index 65354e0534e2..09c1ea04fe9a 100644 --- a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml +++ b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml @@ -206,6 +206,15 @@ io.opentelemetry.javaagent:* + + + lib/test + + junit:junit + org.hamcrest:hamcrest-core + org.mockito:mockito-core + + From 35bec8bb23384cea5202ae6d6c3d23baf46aad00 Mon Sep 17 00:00:00 2001 From: Nihal Jain Date: Wed, 16 Oct 2024 15:12:49 +0530 Subject: [PATCH 3/5] - Fix self review comments --- bin/hbase | 6 +++--- hbase-assembly/pom.xml | 2 +- hbase-assembly/src/main/assembly/client.xml | 1 - hbase-assembly/src/main/assembly/hadoop-three-compat.xml | 1 - 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/bin/hbase b/bin/hbase index fd528d864cc6..105661d3a004 100755 --- a/bin/hbase +++ b/bin/hbase @@ -479,8 +479,8 @@ add_maven_deps_to_classpath() { CLASSPATH=${CLASSPATH}:$(cat "${f}") } -add_test_jars_from_compiled_source() { - # if in dev env, add test jars so that ITs/Chaos etc. can be run from compiled source directory +add_jars_from_compiled_source() { + # if in dev env, add jars so that ITs/Chaos etc. can be run from compiled source directory if $in_dev_env; then for f in */target/*.jar; do if [ -f "${f}" ]; then @@ -785,7 +785,7 @@ else fi done - add_test_jars_from_compiled_source + add_jars_from_compiled_source fi fi diff --git a/hbase-assembly/pom.xml b/hbase-assembly/pom.xml index 1e0381f04703..dbad3e86d8e9 100644 --- a/hbase-assembly/pom.xml +++ b/hbase-assembly/pom.xml @@ -48,7 +48,7 @@ hbase-shaded-mapreduce + maven dependency resolution won't pick it up for us. --> org.hamcrest hamcrest-core diff --git a/hbase-assembly/src/main/assembly/client.xml b/hbase-assembly/src/main/assembly/client.xml index 1a341b016438..f2aac27d175f 100644 --- a/hbase-assembly/src/main/assembly/client.xml +++ b/hbase-assembly/src/main/assembly/client.xml @@ -44,7 +44,6 @@ lib - false org.apache.hadoop:*:test-jar org.apache.hbase:*:test-jar diff --git a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml index 09c1ea04fe9a..beec966638bb 100644 --- a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml +++ b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml @@ -62,7 +62,6 @@ false - false org.apache.hadoop:*:test-jar org.apache.hbase:*:test-jar From 555573c8f48895acd527b11df4782327162cd964 Mon Sep 17 00:00:00 2001 From: Nihal Jain Date: Mon, 21 Oct 2024 23:38:41 +0530 Subject: [PATCH 4/5] - Improve the handling of how we run IT, other tools in dev environment, now we revert back to directly using cached_classpath.txt to load jars required during runtime (as before). NOTE: To ensure cached_classpath is same as before this change, we retain some jars (including test jars) in assembly pom.xml which we actually remove during tarball creation. --- bin/hbase | 25 ++----------- hbase-assembly/pom.xml | 35 +++++++++++++++++++ hbase-assembly/src/main/assembly/client.xml | 9 ----- .../src/main/assembly/hadoop-three-compat.xml | 9 ----- 4 files changed, 37 insertions(+), 41 deletions(-) diff --git a/bin/hbase b/bin/hbase index 105661d3a004..68d85d6805fd 100755 --- a/bin/hbase +++ b/bin/hbase @@ -479,17 +479,6 @@ add_maven_deps_to_classpath() { CLASSPATH=${CLASSPATH}:$(cat "${f}") } -add_jars_from_compiled_source() { - # if in dev env, add jars so that ITs/Chaos etc. can be run from compiled source directory - if $in_dev_env; then - for f in */target/*.jar; do - if [ -f "${f}" ]; then - CLASSPATH="${CLASSPATH}:${f}" - fi - done - fi -} - add_jdk17_jvm_flags() { # Keep in sync with hbase-surefire.jdk17.flags in the root pom.xml HBASE_OPTS="$HBASE_OPTS -Dorg.apache.hbase.thirdparty.io.netty.tryReflectionSetAccessible=true" @@ -525,8 +514,9 @@ add_opentelemetry_agent() { #Add the development env class path stuff if $in_dev_env; then + # The below line makes available all the jars required in dev_env, even if we may not add them + # to assembly. See HBASE-28433 for more info. add_maven_deps_to_classpath "cached_classpath.txt" - if [[ $jline_needed ]]; then add_maven_deps_to_classpath "cached_classpath_jline.txt" elif [[ $jruby_needed ]]; then @@ -777,17 +767,6 @@ elif [ "$COMMAND" = "copyreppeers" ] ; then CLASS='org.apache.hadoop.hbase.replication.CopyReplicationPeers' else CLASS=$COMMAND - - if [[ "$CLASS" =~ .*IntegrationTest.* ]] || [[ "$CLASS" =~ .*Chaos.* ]]; then - for f in ${HBASE_HOME}/lib/test/*.jar; do - if [ -f "${f}" ]; then - CLASSPATH="${CLASSPATH}:${f}" - fi - done - - add_jars_from_compiled_source - fi - fi add_jdk17_jvm_flags diff --git a/hbase-assembly/pom.xml b/hbase-assembly/pom.xml index dbad3e86d8e9..7f343f0ee555 100644 --- a/hbase-assembly/pom.xml +++ b/hbase-assembly/pom.xml @@ -47,8 +47,18 @@ org.apache.hbase hbase-shaded-mapreduce + + + + org.apache.hbase + hbase-it + test-jar + + org.hamcrest hamcrest-core @@ -67,11 +77,26 @@ org.apache.hbase hbase-mapreduce + + + org.apache.hbase + hbase-mapreduce + test-jar + org.apache.hbase hbase-procedure + + + org.apache.hbase + hbase-procedure + test-jar + test + org.apache.hbase hbase-hadoop-compat @@ -98,6 +123,12 @@ org.apache.hbase hbase-external-blockcache + + + org.apache.hbase + hbase-testing-util + org.apache.hbase hbase-metrics-api @@ -214,10 +245,14 @@ io.opentelemetry.javaagent opentelemetry-javaagent + junit junit + org.mockito mockito-core diff --git a/hbase-assembly/src/main/assembly/client.xml b/hbase-assembly/src/main/assembly/client.xml index f2aac27d175f..9f95e139332d 100644 --- a/hbase-assembly/src/main/assembly/client.xml +++ b/hbase-assembly/src/main/assembly/client.xml @@ -169,15 +169,6 @@ io.opentelemetry.javaagent:* - - - lib/test - - junit:junit - org.hamcrest:hamcrest-core - org.mockito:mockito-core - - diff --git a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml index beec966638bb..f5da20b21317 100644 --- a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml +++ b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml @@ -205,15 +205,6 @@ io.opentelemetry.javaagent:* - - - lib/test - - junit:junit - org.hamcrest:hamcrest-core - org.mockito:mockito-core - - From c1cc762fe06ac2c325beab9135f77c8572ed7d67 Mon Sep 17 00:00:00 2001 From: Nihal Jain Date: Tue, 22 Oct 2024 21:10:29 +0530 Subject: [PATCH 5/5] Fix typo --- hbase-assembly/pom.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hbase-assembly/pom.xml b/hbase-assembly/pom.xml index 7f343f0ee555..90be45e9cbfe 100644 --- a/hbase-assembly/pom.xml +++ b/hbase-assembly/pom.xml @@ -48,7 +48,7 @@ hbase-shaded-mapreduce - org.apache.hbase @@ -57,7 +57,7 @@ - org.hamcrest @@ -77,7 +77,7 @@ org.apache.hbase hbase-mapreduce - org.apache.hbase @@ -89,7 +89,7 @@ org.apache.hbase hbase-procedure - org.apache.hbase @@ -123,7 +123,7 @@ org.apache.hbase hbase-external-blockcache - org.apache.hbase @@ -245,13 +245,13 @@ io.opentelemetry.javaagent opentelemetry-javaagent - junit junit - org.mockito