Add Bazel unit test target and Windows (MSVC) support#510
Open
BYVoid wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #501, in two parts:
cc_testtarget covering the server-independent subset of the existing googletest suite inut/, wired into the Bazel CI workflow.windows-latestis added to the CI matrix. MSVC is the toolchain here because it is what Bazel supports on Windows — Bazel has no MinGW support (unlike the CMake build, which has a separate MinGW CI workflow), so the existingWindows mingwcoverage remains CMake-only.Part 1: Unit tests
ut/BUILD.bazel//ut:unit_testscc_test targetMODULE.bazelgoogletest 1.17.0.bcr.2from BCR, markeddev_dependency = Trueso library consumers never pull it in.github/workflows/bazel.ymlbazel test //ut:unit_testsstep on the matrixTest selection — only tests that run hermetically, i.e. no running ClickHouse server required:
types_ut,type_parser_ut,columns_ut,column_array_ut,block_ut,itemview_ut,stream_ut,utils_ut,CreateColumnByType_ut, plussocket_ut(spins up its ownLocalTcpServeron localhost, which works inside the Bazel test sandbox), together with the shared support code (utils.cpp,value_generators.cpp,tcp_server.cpp) and the gtestmain.cpp.$CLICKHOUSE_HOST—client_ut,roundtrip_tests,Column_ut,low_cardinality_nullable_tests,array_of_low_cardinality_tests,abnormal_column_names_test,readonly_client_test,connection_failed_client_test,performance_tests,ssl_ut. These keep running in the CMake CI, which provides a server via docker-compose. Running them under Bazel (e.g. with a dockerized server fixture) could be a future follow-up.The split is documented in a comment at the top of
ut/BUILD.bazel.googletestis adev_dependency, so it does not participate in version resolution for downstream consumers — it only exists when this module is the root.Part 2: Windows support
Adding
windows-latestto the matrix surfaced that the Bazel build didn't link on Windows except by luck:tls=noandtls=opensslfailed withLNK2019: unresolved external symbol __imp_ntohl / __imp_socket / ...— the Winsock library was never declared.tls=boringsslonly worked because BoringSSL's own BUILD file propagatesws2_32to its dependents.Fixes, mirroring what the CMake build already does:
BUILD.bazellinkopts:-DEFAULTLIB:ws2_32.libon WindowsIF (WIN32 OR MINGW) TARGET_LINK_LIBRARIES(... wsock32 ws2_32)ut/BUILD.bazel/bigobjon WindowsIF (MSVC) TARGET_COMPILE_OPTIONS(... /bigobj)MODULE.bazelplatforms 1.1.0(for@platforms//os:windowsinselect())Notably, the BCR
opensslmodule itself compiled cleanly under MSVC — the failure was purely the missing Winsock declaration in this repo's BUILD file.CI
The Bazel workflow matrix is now 3 OS × 3 TLS modes = 9 combinations (Linux, macOS, Windows ×
boringssl,openssl,no), each running build + unit tests. All 9 are green on this branch.Test plan
bazel test //ut:unit_testspasses locally on darwin-arm64 for all three TLS modes: 192 tests, 191 passed, 1 skipped by design (Socketcase.connecttimeout), 1 pre-existingDISABLEDtest.