@@ -30,6 +30,32 @@ MUST_GATHER_SCRIPT_URL="${MUST_GATHER_SCRIPT_URL:-https://raw.githubusercontent.
3030ENABLE_GCP_SOS_COLLECTION=" ${ENABLE_GCP_SOS_COLLECTION:- false} "
3131ENABLE_AWS_SOS_COLLECTION=" ${ENABLE_AWS_SOS_COLLECTION:- false} "
3232
33+ # Mock mode for testing
34+ MOCK_MODE=" ${MOCK_MODE:- false} "
35+ MOCK_EXIT_CODE=" ${MOCK_EXIT_CODE:- 0} "
36+ MOCK_SLEEP_DURATION=" ${MOCK_SLEEP_DURATION:- 5} "
37+
38+ # If mock mode is enabled, set up mock tools directory and prepend to PATH
39+ # This approach allows the real production flow to run while using fake tools
40+ if [ " ${MOCK_MODE} " = " true" ]; then
41+ echo " [INFO] Mock mode enabled - setting up mock tools"
42+
43+ MOCK_TOOLS_DIR=" /tmp/mock-tools"
44+ mkdir -p " ${MOCK_TOOLS_DIR} "
45+
46+ # Symlink mock nvidia-bug-report.sh
47+ if [ -f " /mock-nvidia-bug-report.sh" ]; then
48+ ln -sf /mock-nvidia-bug-report.sh " ${MOCK_TOOLS_DIR} /nvidia-bug-report.sh"
49+ chmod +x " ${MOCK_TOOLS_DIR} /nvidia-bug-report.sh"
50+ fi
51+
52+ # Prepend mock tools directory to PATH so our mocks are used first
53+ export PATH=" ${MOCK_TOOLS_DIR} :${PATH} "
54+
55+ echo " [INFO] Mock tools setup complete. PATH: ${PATH} "
56+ echo " [INFO] Mock exit code will be: ${MOCK_EXIT_CODE} "
57+ fi
58+
3359mkdir -p " ${ARTIFACTS_DIR} "
3460echo " [INFO] Target node: ${NODE_NAME} | GPU Operator namespace: ${GPU_OPERATOR_NAMESPACE} | Driver container: ${DRIVER_CONTAINER_NAME} "
3561
197223GPU_MG_DIR=" ${ARTIFACTS_DIR} /gpu-operator-must-gather"
198224mkdir -p " ${GPU_MG_DIR} "
199225echo " [INFO] Running GPU Operator must-gather..."
200- curl -fsSL " ${MUST_GATHER_SCRIPT_URL} " -o " ${GPU_MG_DIR} /must-gather.sh"
201- chmod +x " ${GPU_MG_DIR} /must-gather.sh"
226+
227+ # In mock mode, use the mock script directly; otherwise download from URL
228+ if [ " ${MOCK_MODE} " = " true" ] && [ -f " /mock-must-gather.sh" ]; then
229+ cp /mock-must-gather.sh " ${GPU_MG_DIR} /must-gather.sh"
230+ chmod +x " ${GPU_MG_DIR} /must-gather.sh"
231+ echo " [INFO] Using mock must-gather script"
232+ else
233+ curl -fsSL " ${MUST_GATHER_SCRIPT_URL} " -o " ${GPU_MG_DIR} /must-gather.sh"
234+ chmod +x " ${GPU_MG_DIR} /must-gather.sh"
235+ fi
236+
202237bash " ${GPU_MG_DIR} /must-gather.sh"
203238
204239GPU_MG_TARBALL=" ${ARTIFACTS_DIR} /gpu-operator-must-gather-${NODE_NAME} -${TIMESTAMP} .tar.gz"
@@ -250,4 +285,10 @@ if [ -n "${UPLOAD_URL_BASE:-}" ]; then
250285 fi
251286fi
252287
253- echo " [INFO] Done. Artifacts under ${ARTIFACTS_DIR} "
288+ echo " [INFO] Done. Artifacts under ${ARTIFACTS_DIR} "
289+
290+ # If mock mode is enabled, exit with the configured mock exit code
291+ if [ " ${MOCK_MODE} " = " true" ]; then
292+ echo " [INFO] Mock mode: Exiting with code ${MOCK_EXIT_CODE} "
293+ exit " ${MOCK_EXIT_CODE} "
294+ fi
0 commit comments