docs: add shadow v3 field operations package
This commit is contained in:
86
scripts/shadow-v3-export.cmd
Normal file
86
scripts/shadow-v3-export.cmd
Normal file
@@ -0,0 +1,86 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions DisableDelayedExpansion
|
||||
|
||||
if "%~1"=="" goto :usage
|
||||
if "%~2"=="" goto :usage
|
||||
if "%~3"=="" goto :usage
|
||||
if "%~4"=="" goto :usage
|
||||
if "%~5"=="" goto :usage
|
||||
if "%~6"=="" goto :usage
|
||||
|
||||
set "REPO_ROOT=%~f1"
|
||||
set "SQL_SERVER=%~2"
|
||||
set "DATABASE=%~3"
|
||||
set "START_UTC=%~4"
|
||||
set "OUTPUT_DIR=%~f5"
|
||||
set "LOG_DIR=%~f6"
|
||||
set "SQL_FILE=%~dp0shadow-v3-export.sql"
|
||||
set "WAREHOUSE_ID=%FORTUCKY_ALGORITHM_WAREHOUSE_ID%"
|
||||
if not defined WAREHOUSE_ID set "WAREHOUSE_ID=01"
|
||||
if "%WAREHOUSE_ID%"=="1" set "WAREHOUSE_ID=01"
|
||||
rem FORTUCKY_SHADOW_ variables are collected by the FORTUCKY_ prefix scan below.
|
||||
|
||||
if not "%WAREHOUSE_ID%"=="01" (call :fail "FORTUCKY_ALGORITHM_WAREHOUSE_ID must be 01" & exit /b 1)
|
||||
if not exist "%REPO_ROOT%\.git" (call :fail "REPO_ROOT is not a Git repository" & exit /b 1)
|
||||
if not exist "%LOG_DIR%" (call :fail "LOG_DIR does not exist" & exit /b 1)
|
||||
if not exist "%SQL_FILE%" (call :fail "export SQL file is missing" & exit /b 1)
|
||||
where git >nul 2>nul
|
||||
if errorlevel 1 (call :fail "git is not available on PATH" & exit /b 1)
|
||||
where jps >nul 2>nul
|
||||
if errorlevel 1 (call :fail "jps is not available on PATH" & exit /b 1)
|
||||
where sqlcmd >nul 2>nul
|
||||
if errorlevel 1 (call :fail "sqlcmd is not available on PATH" & exit /b 1)
|
||||
|
||||
if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"
|
||||
if errorlevel 1 (call :fail "cannot create OUTPUT_DIR" & exit /b 1)
|
||||
|
||||
pushd "%REPO_ROOT%" >nul
|
||||
if errorlevel 1 (call :fail "cannot enter REPO_ROOT" & exit /b 1)
|
||||
(
|
||||
echo export_started_utc=%DATE% %TIME%
|
||||
echo expected_branch=test/ft546wms-shadow-v3-20260903
|
||||
git branch --show-current
|
||||
git rev-parse HEAD
|
||||
git status --porcelain
|
||||
) > "%OUTPUT_DIR%\deployment.txt" 2>&1
|
||||
if errorlevel 1 (call :fail "cannot collect Git deployment evidence" & exit /b 1)
|
||||
popd >nul
|
||||
|
||||
jps -lv > "%OUTPUT_DIR%\runtime-processes.txt" 2>&1
|
||||
if errorlevel 1 (call :fail "cannot collect JVM process evidence" & exit /b 1)
|
||||
|
||||
(
|
||||
for /f "tokens=1 delims==" %%E in ('set FORTUCKY_ 2^>nul') do echo %%E
|
||||
) > "%OUTPUT_DIR%\environment-variable-names.txt"
|
||||
|
||||
sqlcmd -S "%SQL_SERVER%" -d "%DATABASE%" -E -b -r1 -w 65535 -y 0 -Y 0 -v WarehouseId="%WAREHOUSE_ID%" StartUtc="%START_UTC%" OutputDir="%OUTPUT_DIR%" -i "%SQL_FILE%"
|
||||
if errorlevel 1 (call :fail "read-only SQL export failed" & exit /b 1)
|
||||
|
||||
findstr /S /I /N /C:"shadow_failure" "%LOG_DIR%\*.log" "%LOG_DIR%\*.txt" > "%OUTPUT_DIR%\shadow-warnings.txt" 2>nul
|
||||
|
||||
call :require_output "sql-diagnostics.txt"
|
||||
if errorlevel 1 exit /b 1
|
||||
call :require_output "comparison-detail.txt"
|
||||
if errorlevel 1 exit /b 1
|
||||
call :require_output "runtime-metrics.txt"
|
||||
if errorlevel 1 exit /b 1
|
||||
call :require_output "inventory-parity.txt"
|
||||
if errorlevel 1 exit /b 1
|
||||
call :require_output "shadow-warnings.txt"
|
||||
if errorlevel 1 exit /b 1
|
||||
|
||||
echo EXPORT_OK output=%OUTPUT_DIR%
|
||||
exit /b 0
|
||||
|
||||
:require_output
|
||||
if not exist "%OUTPUT_DIR%\%~1" (call :fail "expected export file is missing" & exit /b 1)
|
||||
exit /b 0
|
||||
|
||||
:usage
|
||||
echo Usage: %~nx0 REPO_ROOT SQL_SERVER DATABASE START_UTC OUTPUT_DIR LOG_DIR 1>&2
|
||||
exit /b 2
|
||||
|
||||
:fail
|
||||
echo EXPORT_FAILED %~1 1>&2
|
||||
popd >nul 2>nul
|
||||
exit /b 1
|
||||
Reference in New Issue
Block a user