Skip to content

Commit

Permalink
Improved server feature detection for integration tests
Browse files Browse the repository at this point in the history
Introduced BOOST_MYSQL_DISABLED_SERVER_FEATURES env var
Removed BOOST_MYSQL_NO_UNIX_SOCKET_TESTS env var
JSON tests in database_types are now actually run

close #29
  • Loading branch information
anarthal authored Jul 11, 2024
1 parent 3faf294 commit a918c6b
Show file tree
Hide file tree
Showing 45 changed files with 713 additions and 625 deletions.
23 changes: 10 additions & 13 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

_triggers = { "branch": [ "master", "develop" ] }
_container_tag = 'c3f5316cc19bf3c0f7a83e31dec58139581f5764'
_container_tag = 'b1f46a8305f62d0af54dda34231b199d76e945f1'
_win_container_tag = 'e7bd656c3515263f9b3c69a2d73d045f6a0fed72'


Expand Down Expand Up @@ -52,7 +52,6 @@ def _b2_command(
def _cmake_command(
source_dir,
server_host='127.0.0.1',
db='mysql8',
generator='Ninja',
cmake_build_type='Debug',
build_shared_libs=0,
Expand All @@ -63,7 +62,6 @@ def _cmake_command(
'--source-dir="{}" '.format(source_dir) + \
'cmake ' + \
'--server-host={} '.format(server_host) + \
'--db={} '.format(db) + \
'--generator="{}" '.format(generator) + \
'--cmake-build-type={} '.format(cmake_build_type) + \
'--build-shared-libs={} '.format(build_shared_libs) + \
Expand Down Expand Up @@ -100,7 +98,7 @@ def _pipeline(
"name": "Build and run",
"image": image,
"pull": "if-not-exists",
"privileged": arch == "arm64",
"privileged": arch == "arm64", # TSAN tests fail otherwise (personality syscall)
"volumes":[{
"name": "mysql-socket",
"path": "/var/run/mysqld"
Expand All @@ -124,7 +122,7 @@ def _pipeline(
"steps": steps,
"services": [{
"name": "mysql",
"image": _image(db),
"image": "ghcr.io/anarthal-containers/ci-db:{}-{}".format(db, _container_tag),
"volumes": [{
"name": "mysql-socket",
"path": "/var/run/mysqld"
Expand All @@ -151,7 +149,8 @@ def linux_b2(
undefined_sanitizer=0,
valgrind=0,
arch='amd64',
fail_if_no_openssl=1
fail_if_no_openssl=1,
db='mysql-8.4.1',
):
command = _b2_command(
source_dir='$(pwd)',
Expand All @@ -173,7 +172,7 @@ def linux_b2(
image=image,
os='linux',
command=command,
db='mysql8',
db=db,
arch=arch,
disable_aslr=True
)
Expand Down Expand Up @@ -203,18 +202,17 @@ def windows_b2(
def linux_cmake(
name,
image,
db='mysql-8.4.1',
build_shared_libs=0,
cmake_build_type='Debug',
cxxstd='20',
db='mysql8',
install_test=1
):
command = _cmake_command(
source_dir='$(pwd)',
build_shared_libs=build_shared_libs,
cmake_build_type=cmake_build_type,
cxxstd=cxxstd,
db=db,
server_host='mysql',
install_test=install_test
)
Expand Down Expand Up @@ -245,7 +243,6 @@ def windows_cmake(
source_dir='$Env:DRONE_WORKSPACE',
build_shared_libs=build_shared_libs,
generator='Visual Studio 17 2022',
db='mysql8',
server_host='127.0.0.1'
)
return _pipeline(
Expand Down Expand Up @@ -280,8 +277,8 @@ def docs(name):
def main(ctx):
return [
# CMake Linux
linux_cmake('Linux CMake MySQL 5.x', _image('build-gcc14'), db='mysql5', build_shared_libs=0),
linux_cmake('Linux CMake MariaDB', _image('build-gcc14'), db='mariadb', build_shared_libs=1),
linux_cmake('Linux CMake MySQL 5.x', _image('build-gcc14'), db='mysql-5.7.41', build_shared_libs=0),
linux_cmake('Linux CMake MariaDB', _image('build-gcc14'), db='mariadb-11.4.2', build_shared_libs=1),
linux_cmake('Linux CMake cmake 3.8', _image('build-cmake3_8'), cxxstd='11', install_test=0),
linux_cmake('Linux CMake gcc Release', _image('build-gcc14'), cmake_build_type='Release'),
linux_cmake('Linux CMake gcc MinSizeRel', _image('build-gcc14'), cmake_build_type='MinSizeRel'),
Expand All @@ -304,7 +301,7 @@ def main(ctx):
linux_b2('Linux B2 clang-14-libc++', _image('build-clang14'), toolset='clang-14', cxxstd='20', stdlib='libc++'),
linux_b2('Linux B2 clang-14-arm64', _image('build-clang14'), toolset='clang-14', cxxstd='20', arch='arm64'),
linux_b2('Linux B2 clang-16-sanit', _image('build-clang16'), toolset='clang-16', cxxstd='20', address_sanitizer=1, undefined_sanitizer=1),
linux_b2('Linux B2 clang-16-i386-sanit', _image('build-clang16-i386'), toolset='clang-16', cxxstd='20', address_model=32, address_sanitizer=1, undefined_sanitizer=1),
linux_b2('Linux B2 clang-16-i386-sanit', _image('build-clang16-i386'), toolset='clang-16', cxxstd='20', address_model='32', address_sanitizer=1, undefined_sanitizer=1),
linux_b2('Linux B2 clang-17', _image('build-clang17'), toolset='clang-17', cxxstd='20'),
linux_b2('Linux B2 clang-18', _image('build-clang18'), toolset='clang-18', cxxstd='23'),
linux_b2('Linux B2 gcc-5', _image('build-gcc5'), toolset='gcc-5', cxxstd='11'), # gcc-5 C++14 doesn't like my constexpr field_view
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
coverage:
runs-on: ubuntu-latest
container:
image: ghcr.io/anarthal-containers/build-gcc14:c3f5316cc19bf3c0f7a83e31dec58139581f5764
image: ghcr.io/anarthal-containers/build-gcc14:b1f46a8305f62d0af54dda34231b199d76e945f1
volumes:
- /var/run/mysqld:/var/run/mysqld
services:
mysql:
image: ghcr.io/anarthal-containers/mysql8:c3f5316cc19bf3c0f7a83e31dec58139581f5764
image: ghcr.io/anarthal-containers/ci-db:mysql-8.4.1-b1f46a8305f62d0af54dda34231b199d76e945f1
ports:
- 3306:3306
volumes:
Expand Down
49 changes: 41 additions & 8 deletions .github/workflows/docker-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ jobs:
- { image: build-cmake3_8, dockerfile: build-cmake3_8, platforms: "linux/amd64", }
- { image: build-noopenssl, dockerfile: build-noopenssl, platforms: "linux/amd64", }
- { image: build-docs, dockerfile: build-docs, platforms: "linux/amd64", }
- { image: mysql5, dockerfile: mysql5, platforms: "linux/amd64", }
- { image: mysql8, dockerfile: mysql8, platforms: "linux/amd64, linux/arm64/v8" }
- { image: mysql9, dockerfile: mysql9, platforms: "linux/amd64, linux/arm64/v8" }
- { image: mariadb, dockerfile: mariadb, platforms: "linux/amd64, linux/arm64/v8" }

permissions:
contents: read
packages: write

runs-on: ubuntu-latest

Expand Down Expand Up @@ -73,3 +65,44 @@ jobs:
build-args: ${{ matrix.build-args }}
platforms: ${{ matrix.platforms }}
tags: ghcr.io/anarthal-containers/${{ matrix.image }}:${{ github.sha }}, ghcr.io/anarthal-containers/${{ matrix.image }}:latest


dbs:
strategy:
matrix:
include:
- { flavor: mysql, version: 5.7.41, platforms: "linux/amd64" } # Unavailable for ARM
- { flavor: mysql, version: 8.4.1, platforms: "linux/amd64, linux/arm64/v8", entrypoint-args: "--mysql-native-password=ON" }
- { flavor: mysql, version: 9.0.0, platforms: "linux/amd64, linux/arm64/v8" }
- { flavor: mariadb, version: 11.4.2, platforms: "linux/amd64, linux/arm64/v8" }

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: anarthal-containers
password: ${{ secrets.ANARTHAL_CONTAINERS_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
file: tools/docker/${{ matrix.flavor }}.dockerfile
build-args: |
BASE_IMAGE_VERSION=${{ matrix.version }}
ENTRYPOINT_ARGS=${{ matrix.entrypoint-args }}
platforms: ${{ matrix.platforms }}
tags: ghcr.io/anarthal-containers/ci-db:${{ matrix.flavor }}-${{ matrix.version }}-${{ github.sha }}
4 changes: 2 additions & 2 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
fuzz:
runs-on: ubuntu-latest
container:
image: ghcr.io/anarthal-containers/build-clang18:c3f5316cc19bf3c0f7a83e31dec58139581f5764
image: ghcr.io/anarthal-containers/build-clang18:b1f46a8305f62d0af54dda34231b199d76e945f1
volumes:
- /var/run/mysqld:/var/run/mysqld
services:
mysql:
image: ghcr.io/anarthal-containers/mysql8:c3f5316cc19bf3c0f7a83e31dec58139581f5764
image: ghcr.io/anarthal-containers/ci-db:mysql-8.4.1-b1f46a8305f62d0af54dda34231b199d76e945f1
ports:
- 3306:3306
volumes:
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ target_compile_features(boost_mysql INTERFACE cxx_std_11)
option(BOOST_MYSQL_INTEGRATION_TESTS OFF "Whether to build and run integration tests or not")
mark_as_advanced(BOOST_MYSQL_INTEGRATION_TESTS)

# List of server features that the CI DB server does not support.
# Disables running some integration tests and examples
set(BOOST_MYSQL_DISABLED_SERVER_FEATURES "" CACHE STRING
"A CMake list of server features not supported by the CI server, for integration tests"
)
mark_as_advanced(BOOST_MYSQL_DISABLED_SERVER_FEATURES)

# Examples and tests
if(BUILD_TESTING)
# Contains some functions to share code between examples and tests
Expand Down
1 change: 0 additions & 1 deletion doc/qbk/00_main.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ END
[include 23_sql_formatting_advanced.qbk]
[include 24_pipeline.qbk]
[include 24_examples.qbk]
[include 25_tests.qbk]


[section:ref Reference]
Expand Down
19 changes: 7 additions & 12 deletions doc/qbk/24_examples.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,12 @@ Examples make use of a database named `boost_mysql_examples`.
The server hostname and credentials (username and password) are passed
to the examples via the command line.

If you're using docker, you can use the `ghcr.io/anarthal-containers/mysql8` container
to simplify the process:
You can spin up a server quickly by using Docker:

[!teletype]
```
# If you're on a system supporting UNIX sockets. Note that /var/run/mysqld
# should be empty for this to work; you can specify a different directory, if it's not
> docker run -p 3306:3306 -v /var/run/mysqld:/var/run/mysqld -d ghcr.io/anarthal-containers/mysql8

# If you're on a system that does not support UNIX sockets
> docker run -p 3306:3306 -d ghcr.io/anarthal-containers/mysql8
# Remove the "-v /var/run/mysqld:/var/run/mysqld" part if you don't need UNIX sockets
> docker run --name some-mysql -p 3306:3306 -v /var/run/mysqld:/var/run/mysqld -d -e MYSQL_ROOT_PASSWORD= -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -d mysql

# All the required data can be loaded by running example/db_setup.sql.
# If you're using the above container, the root user has a blank password
Expand Down Expand Up @@ -153,7 +148,7 @@ implement a minimal order management system for an online store.
The example employs synchronous functions with
exceptions as error handling. __see_error_handling__

This examples requires you to run [link_to_file example/order_management/db_setup.sql].
This example requires you to run [link_to_file example/order_management/db_setup.sql].
You can find table definitions there.

[import ../../example/order_management/prepared_statements_cpp11.cpp]
Expand All @@ -173,7 +168,7 @@ implement a minimal order management system for an online store.
The example employs synchronous functions with
exceptions as error handling. __see_error_handling__

This examples requires you to run [link_to_file example/order_management/db_setup.sql].
This example requires you to run [link_to_file example/order_management/db_setup.sql].
You can find table definitions there.

[import ../../example/order_management/prepared_statements_cpp14.cpp]
Expand All @@ -193,7 +188,7 @@ implement a minimal order management system for an online store.
The example employs synchronous functions with
exceptions as error handling. __see_error_handling__

This examples requires you to run [link_to_file example/order_management/db_setup.sql].
This example requires you to run [link_to_file example/order_management/db_setup.sql].
You can find table and procedure definitions there.

[import ../../example/order_management/stored_procedures_cpp11.cpp]
Expand All @@ -213,7 +208,7 @@ implement a minimal order management system for an online store.
The example employs synchronous functions with
exceptions as error handling. __see_error_handling__

This examples requires you to run [link_to_file example/order_management/db_setup.sql].
This example requires you to run [link_to_file example/order_management/db_setup.sql].
You can find table and procedure definitions there.

[import ../../example/order_management/stored_procedures_cpp14.cpp]
Expand Down
67 changes: 0 additions & 67 deletions doc/qbk/25_tests.qbk

This file was deleted.

4 changes: 2 additions & 2 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ endforeach()
add_example_coroutines(async_coroutines)
add_example_coroutines(any_connection)

# UNIX sockets
if("$ENV{BOOST_MYSQL_NO_UNIX_SOCKET_TESTS}" STREQUAL "")
# UNIX sockets. Don't run the example on Windows machines
if (NOT WIN32)
add_example(
boost_mysql_example_unix_socket
unix_socket.cpp
Expand Down
16 changes: 8 additions & 8 deletions example/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ run_python_example dynamic_filters : run_dynamic_filters.py : dynamic_filters.cp
run_python_example batch_inserts : run_batch_inserts.py : batch_inserts.cpp /boost/json//boost_json ;
run_python_example batch_inserts_generic : run_batch_inserts.py : batch_inserts_generic.cpp /boost/json//boost_json ;

# UNIX. Honor BOOST_MYSQL_NO_UNIX_SOCKET_TESTS for homogeneity with cmake
if [ os.environ BOOST_MYSQL_NO_UNIX_SOCKET_TESTS ] = "" {
run
unix_socket.cpp
/boost/mysql/test//boost_mysql_compiled
:
# UNIX. Don't run under Windows systems
run
unix_socket.cpp
/boost/mysql/test//boost_mysql_compiled
:
requirements
<target-os>windows:<build>no
<testing.arg>"example_user example_password"
;
}
;

# Source script
run
Expand Down
1 change: 0 additions & 1 deletion test/common/include/test_common/ci_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ constexpr const char* integ_user = "integ_user";
constexpr const char* integ_passwd = "integ_password";
constexpr const char* integ_db = "boost_mysql_integtests";
constexpr const char* default_unix_path = "/var/run/mysqld/mysqld.sock";
inline bool is_mariadb() { return safe_getenv("BOOST_MYSQL_TEST_DB", "mysql8") == "mariadb"; }

} // namespace test
} // namespace mysql
Expand Down
Loading

0 comments on commit a918c6b

Please sign in to comment.