Repository navigation
Expand file tree
/
Copy pathwindows_test.bat
More file actions
186 lines (163 loc) · 7.31 KB
/
Copy pathwindows_test.bat
File metadata and controls
186 lines (163 loc) · 7.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
::
:: Copyright (c) 2024 Intel Corporation
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http:::www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
::
@echo off
setlocal EnableExtensions EnableDelayedExpansion
:: Delete stale test logs from previous runs before starting fresh
echo Cleaning up stale test logs...
del /f /q win_build_test.log 2>nul
del /f /q win_full_test.log 2>nul
del /f /q win_test_summary.log 2>nul
del /f /q win_test_log.zip 2>nul
del /f /q win_install_service_test.log 2>nul
:: Need to set shorter build paths for bazel cache for too long commands in mediapipe compilation
:: We expect a first script argument to be "PR-1234" number passed here from jenkins so that a tmp directory will be created
IF "%~1"=="" (
echo No argument provided. Using default opt path
set "BAZEL_SHORT_PATH=C:\opt"
) ELSE (
echo Argument provided: Using install path %1
set "BAZEL_SHORT_PATH=C:\%1"
)
set "bazelStartupCmd=--output_user_root=!BAZEL_SHORT_PATH!"
set "openvino_dir=!BAZEL_SHORT_PATH!/openvino/runtime/cmake"
set /p bazelVersion=<"%~dp0.bazelversion"
set "bazelPath=C:\opt\bazel-%bazelVersion%-windows-x86_64.exe"
set "OVMS_MEDIA_URL_ALLOW_REDIRECTS=1"
IF "%~3"=="" (
set "gtestFilter=*"
) ELSE (
set "gtestFilter=%3"
)
IF "%~2"=="--with_python" (
set "bazelBuildArgs=--config=win_mp_on_py_on --action_env OpenVINO_DIR=%openvino_dir%"
set "testTargets=//src:ovms_test //src:python_runtime_library_test"
set "runPythonRuntimeTest=%cd%\bazel-bin\src\python_runtime_library_test.exe --gtest_filter=!gtestFilter!"
) ELSE (
set "bazelBuildArgs=--config=win_mp_on_py_off --action_env OpenVINO_DIR=%openvino_dir%"
set "testTargets=//src:ovms_test"
set "runPythonRuntimeTest="
)
set "buildTestCommand=%bazelPath% %bazelStartupCmd% build %bazelBuildArgs% --jobs=%NUMBER_OF_PROCESSORS% --verbose_failures %testTargets%"
set "changeConfigsCmd=python windows_change_test_configs.py"
set "runTest=%cd%\bazel-bin\src\ovms_test.exe --gtest_filter=!gtestFilter! > win_full_test.log 2>&1"
:: Load chosen dependency versions from versions.mk
for /f "usebackq eol=# tokens=1,3" %%A in ("%cd%\versions.mk") do (
if "%%A"=="OPENCV_VERSION" if "!opencv_version!"=="" set "opencv_version=%%B"
if "%%A"=="CURL_VERSION" if "!curl_version!"=="" set "curl_version=%%B"
)
:: Setting PATH environment variable based on default windows node settings: Added ovms_windows specific python settings and c:/opt and removed unused Nvidia and OCL specific tools.
:: When changing the values here you can print the node default PATH value and base your changes on it.
set "setPath=C:\opt;C:\opt\Python312\;C:\opt\Python312\Scripts\;C:\opt\msys64\usr\bin\;C:\opt\curl-!curl_version!-win64-mingw\bin;c:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\;%PATH%;"
set "setPythonPath=%cd%\bazel-out\x64_windows-opt\bin\src\python\binding"
set "BAZEL_SH=C:\opt\msys64\usr\bin\bash.exe"
:: Bazel compilation settings
set VS_2022_BT="C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
IF /I EXIST %VS_2022_BT% goto :msvc_bt ELSE goto :msvc_error
:msvc_error
echo [ERROR] Required MSVC compiler not installed
echo [ERROR] windows_test.bat failed before test parsing stage.
exit /b 1
:msvc_bt
echo [INFO] Using MSVC %VS_2022_BT%
set BAZEL_VS=%VS_2022_BT%
:: Bazel compilation settings end
set "BAZEL_VC=%BAZEL_VS:"=%\VC"
set "BAZEL_VC_FULL_VERSION=14.44.35207"
:: Set proper PATH environment variable: Remove other python paths and add c:\opt with bazel to PATH
set "PATH=%setPath%"
set "BAZEL_SH=C:\opt\msys64\usr\bin\bash.exe"
:: Set paths with libs for execution - affects PATH
set "openvinoBatch=call !BAZEL_SHORT_PATH!\openvino\setupvars.bat"
set "opencvBatch=call C:\opt\opencv_!opencv_version!\setup_vars_opencv4.cmd"
set "PYTHONHOME=C:\opt\Python312"
:: Set required libraries paths
%openvinoBatch%
if !errorlevel! neq 0 (
echo [ERROR] OpenVINO setupvars.bat failed with error code !errorlevel! > win_full_test.log
exit /b !errorlevel!
)
%opencvBatch%
if !errorlevel! neq 0 (
echo [ERROR] OpenCV setup_vars_opencv4.cmd failed with error code !errorlevel! >> win_full_test.log
exit /b !errorlevel!
)
set "PYTHONPATH=%PYTHONPATH%;%setPythonPath%"
:: Start bazel build test
%buildTestCommand% 2>&1 | tee win_build_test.log
set "bazelExitCode=!errorlevel!"
:: Check the exit code and exit if it's not 0
if !bazelExitCode! neq 0 (
echo [ERROR] Bazel build failed with exit code !bazelExitCode! >> win_full_test.log
exit /b !bazelExitCode!
)
:: Change tests configs to windows paths
%changeConfigsCmd%
if !errorlevel! neq 0 (
echo [ERROR] windows_change_test_configs.py failed with error code !errorlevel! >> win_full_test.log
exit /b !errorlevel!
)
:: Download LLMs
call %cd%\windows_prepare_llm_models.bat %cd%\src\test\llm_testing
if !errorlevel! neq 0 (
echo [ERROR] windows_prepare_llm_models.bat failed with error code !errorlevel! >> win_full_test.log
exit /b !errorlevel!
)
:: Run install_ovms_service.bat unit tests
echo Running install_ovms_service.bat unit tests...
python -m pytest tests\python\test_install_ovms_service_windows.py -v > win_install_service_test.log 2>&1
set "pytestExitCode=!errorlevel!"
type win_install_service_test.log
if !pytestExitCode! neq 0 (
echo [ERROR] install_ovms_service.bat unit tests failed. See win_install_service_test.log.
exit /b !pytestExitCode!
)
echo [INFO] install_ovms_service.bat unit tests passed.
:: Start unit test
echo Running: %runTest%
%runTest%
set "testExitCode=!errorlevel!"
IF "%~2"=="--with_python" (
echo Running: %runPythonRuntimeTest%
%runPythonRuntimeTest% >> win_full_test.log 2>&1
set "pythonTestExitCode=!errorlevel!"
)
:: Cut tests log to results
set regex="\[ .* ms"
set sed_clean="s/ (.* ms)//g"
C:\Windows\System32\tar.exe -a -c -f win_test_log.zip win_full_test.log
:: Create summary log with filtered results, always create the file even if grep finds no matches
grep -a %regex% win_full_test.log > win_test_summary.tmp
if !errorlevel! equ 0 (
sed %sed_clean% win_test_summary.tmp > win_test_summary.log 2>&1
) else (
echo No matching test results found > win_test_summary.log
)
if exist win_test_summary.tmp del /f /q win_test_summary.tmp
:: Parse logs and decide final test status using dedicated parser script
:: Skip expensive parsing only if PASSED summary exists AND no FAILED markers
grep -a -q "\[ PASSED \] " win_full_test.log
set "hasPassed=!errorlevel!"
grep -a -q "\[ FAILED \] " win_full_test.log
set "hasFailed=!errorlevel!"
if !hasPassed! equ 0 if !hasFailed! neq 0 (
echo [INFO] Tests finished with no failures. Check the summary in win_test_summary.log.
exit /b 0
)
call %cd%\windows_parse_tests.bat win_full_test.log win_test_summary.log
set "parseExitCode=!errorlevel!"
if !parseExitCode! neq 0 exit /b !parseExitCode!
echo [INFO] Tests finished with no failures. Check the summary in win_test_summary.log.
exit /b 0