From 5b36af129ec20c8172bbbef5bb35928c60e1238b Mon Sep 17 00:00:00 2001 From: Arun Sarin Date: Sun, 5 Apr 2026 23:42:43 +0530 Subject: [PATCH] HDDS-7373. Add Robot acceptance tests for ozone --validate classpath --- .../src/main/smoketest/cli/classpath.robot | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/hadoop-ozone/dist/src/main/smoketest/cli/classpath.robot b/hadoop-ozone/dist/src/main/smoketest/cli/classpath.robot index 6991d8bf8a22..31745281a234 100644 --- a/hadoop-ozone/dist/src/main/smoketest/cli/classpath.robot +++ b/hadoop-ozone/dist/src/main/smoketest/cli/classpath.robot @@ -14,12 +14,21 @@ # limitations under the License. *** Settings *** -Documentation Test ozone classpath command +Documentation Test ozone classpath command and --validate classpath checks (HDDS-7373) Library BuiltIn Resource ../lib/os.robot Resource ../ozone-lib/shell.robot Test Timeout 5 minutes +*** Variables *** +${TEMP_DIR} /tmp + +*** Keywords *** +Append missing jar path to classpath descriptor + [arguments] ${ozone_home} ${artifact} ${bogus_jar} + ${cp_file} = Set Variable ${ozone_home}/share/ozone/classpath/${artifact}.classpath + Execute sed -i 's_$_:${bogus_jar}_' '${cp_file}' + *** Test Cases *** Ignores HADOOP_CLASSPATH if OZONE_CLASSPATH is set [setup] Create File ${TEMP_DIR}/hadoop-classpath.jar @@ -48,3 +57,35 @@ Adds optional dir entries Should Contain ${output} ${jars_dir}/ozone-insight/optional.jar [teardown] Remove Directory ${OZONE_COPY} recursive=True + +Validate classpath succeeds when all jars are present + ${output} = Execute ozone --validate classpath ozone-insight + Should Contain ${output} Validating classpath file: + Should Contain ${output} Validation SUCCESSFUL + +Validate classpath fails when classpath descriptor is missing + ${output} = Execute and checkrc ozone --validate classpath hdds-nonexistent-artifact-7373 1 + Should Contain ${output} ERROR: Classpath file descriptor + +Validate classpath fails when a listed jar is missing + ${OZONE_COPY} = Set Variable ${TEMP_DIR}/ozone-validate-missing-jar + ${bogus_jar} = Set Variable ${TEMP_DIR}/ozone-robot-missing-7373.jar + Copy Directory ${OZONE_DIR} ${OZONE_COPY} + Append missing jar path to classpath descriptor ${OZONE_COPY} ozone-insight ${bogus_jar} + ${output} = Execute and checkrc ${OZONE_COPY}/bin/ozone --validate classpath ozone-insight 1 + Should Contain ${output} ERROR: Jar file ${bogus_jar} is missing + Should Contain ${output} Validation FAILED due to missing jar files! + [teardown] Remove Directory ${OZONE_COPY} recursive=True + +Validate with wrong subcommand prints usage + ${output} = Execute and checkrc ozone --validate version 1 + Should Contain ${output} Usage I: ozone --validate classpath + +Validate continue allows daemon command after failed classpath check + ${OZONE_COPY} = Set Variable ${TEMP_DIR}/ozone-validate-continue + ${bogus_jar} = Set Variable ${TEMP_DIR}/ozone-robot-missing-scm-7373.jar + Copy Directory ${OZONE_DIR} ${OZONE_COPY} + Append missing jar path to classpath descriptor ${OZONE_COPY} hdds-server-scm ${bogus_jar} + ${output} = Execute And Ignore Error ${OZONE_COPY}/bin/ozone --validate continue --daemon status scm + Should Contain ${output} Validation FAILED due to missing jar files! Continuing command execution + [teardown] Remove Directory ${OZONE_COPY} recursive=True