Skip to content

Commit b36c87f

Browse files
authored
Merge pull request #136 from ClickHouse/better_tests
Better tests / CI
2 parents f0c2870 + f369b52 commit b36c87f

14 files changed

Lines changed: 254 additions & 204 deletions

File tree

.github/workflows/linux.yml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ master ]
8-
workflow_call:
9-
inputs:
10-
extra_cmake_flags:
11-
required: false
12-
type: string
13-
extra_install:
14-
required: false
15-
type: string
16-
gtest_filter:
17-
required: false
18-
type: string
19-
default: "*"
208

219
env:
2210
BUILD_TYPE: Release
@@ -26,37 +14,41 @@ jobs:
2614
runs-on: ubuntu-latest
2715
strategy:
2816
matrix:
29-
build: [clang-6, gcc-7, gcc-8, gcc-9]
17+
compiler: [clang-6, gcc-7, gcc-8, gcc-9]
18+
ssl: [ssl_ON, ssl_OFF]
3019
include:
31-
- build: clang-6
32-
os: ubuntu-latest
20+
- compiler: clang-6
3321
INSTALL: clang-6.0
3422
C_COMPILER: clang-6.0
3523
CXX_COMPILER: clang++-6.0
3624

37-
- build: gcc-7
38-
os: ubuntu-latest
25+
- compiler: gcc-7
3926
INSTALL: gcc-7 g++-7
4027
C_COMPILER: gcc-7
4128
CXX_COMPILER: g++-7
4229

43-
- build: gcc-8
44-
os: ubuntu-latest
30+
- compiler: gcc-8
4531
INSTALL: gcc-8 g++-8
4632
C_COMPILER: gcc-8
4733
CXX_COMPILER: g++-8
4834

49-
- build: gcc-9
50-
os: ubuntu-latest
35+
- compiler: gcc-9
5136
INSTALL: gcc-9 g++-9
5237
C_COMPILER: gcc-9
5338
CXX_COMPILER: g++-9
5439

40+
- ssl: ssl_ON
41+
INSTALL_SSL: libssl-dev
42+
EXTRA_CMAKE_FLAGS: -DWITH_OPENSSL=ON
43+
44+
- ssl: ssl_OFF
45+
EXTRA_CMAKE_FLAGS: -DWITH_OPENSSL=OFF
46+
5547
steps:
5648
- uses: actions/checkout@v2
5749

5850
- name: Install dependencies
59-
run: sudo apt-get install -y cmake ${{ matrix.INSTALL }} ${{ inputs.extra_install }}
51+
run: sudo apt-get install -y cmake ${{ matrix.INSTALL }} ${{ matrix.INSTALL_SSL }}
6052

6153
- name: Configure CMake
6254
run: |
@@ -65,7 +57,7 @@ jobs:
6557
-DCMAKE_CXX_COMPILER=${{ matrix.CXX_COMPILER}} \
6658
-B ${{github.workspace}}/build \
6759
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON \
68-
${{ inputs.extra_cmake_flags }}
60+
${{ matrix.EXTRA_CMAKE_FLAGS }}
6961
7062
- name: Build
7163
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all
@@ -84,4 +76,4 @@ jobs:
8476
8577
- name: Test
8678
working-directory: ${{github.workspace}}/build/ut
87-
run: ./clickhouse-cpp-ut --gtest_filter="${{inputs.gtest_filter}}"
79+
run: ./clickhouse-cpp-ut

.github/workflows/linux_ssl.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/macos.yml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,54 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ master ]
8-
workflow_call:
9-
inputs:
10-
extra_cmake_flags:
11-
required: false
12-
type: string
13-
extra_install:
14-
required: false
15-
type: string
16-
gtest_filter:
17-
required: false
18-
type: string
19-
default: "*"
208

219
env:
2210
BUILD_TYPE: Release
11+
CLICKHOUSE_USER: clickhouse_cpp_cicd
12+
CLICKHOUSE_PASSWORD: clickhouse_cpp_cicd
2313

2414
jobs:
2515
build:
2616
runs-on: macos-latest
2717

18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
build: [nossl, ssl]
22+
include:
23+
- build: nossl
24+
extra_cmake_flags: -DWITH_OPENSSL=OFF
25+
extra_install:
26+
27+
- build: ssl
28+
extra_cmake_flags: -DWITH_OPENSSL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/
29+
extra_install: openssl
30+
2831
steps:
2932
- uses: actions/checkout@v2
3033

3134
- name: Install dependencies
32-
run: brew install cmake ${{inputs.extra_install}}
35+
run: brew install cmake ${{matrix.extra_install}}
3336

3437
- name: Configure CMake
35-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON ${{inputs.extra_cmake_flags}}
38+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON ${{matrix.extra_cmake_flags}}
3639

3740
- name: Build
3841
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all
3942

43+
- name: Start tls offoader proxy
44+
# that mimics non-secure clickhouse running on localhost
45+
# by tunneling queries to remote tls server
46+
# (needed because we can't start real clickhouse instance on macOS)
47+
run: |
48+
wget https://github.com/filimonov/go-tlsoffloader/releases/download/v0.1.2/go-tlsoffloader_0.1.2_Darwin_x86_64.tar.gz
49+
tar -xvzf go-tlsoffloader_0.1.2_Darwin_x86_64.tar.gz
50+
./go-tlsoffloader -l localhost:9000 -b github.demo.trial.altinity.cloud:9440 &
51+
4052
- name: Test
4153
working-directory: ${{github.workspace}}/build/ut
4254
env:
4355
# It is impossible to start CH server in docker on macOS due to github actions limitations,
4456
# so limit tests to ones that do no require server interaction.
4557
GTEST_FILTER_ONLY_LOCAL: "-Client/*"
46-
run: ./clickhouse-cpp-ut --gtest_filter="${{inputs.gtest_filter}}:${{env.GTEST_FILTER_ONLY_LOCAL}}"
58+
run: ./clickhouse-cpp-ut

.github/workflows/macos_ssl.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

bench/bench.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
namespace clickhouse {
66

77
Client g_client(ClientOptions()
8-
.SetHost("localhost")
8+
.SetHost( getEnvOrDefault("CLICKHOUSE_HOST", "localhost"))
9+
.SetPort( std::stoi(getEnvOrDefault("CLICKHOUSE_PORT", "9000")))
10+
.SetUser( getEnvOrDefault("CLICKHOUSE_USER", "default"))
11+
.SetPassword( getEnvOrDefault("CLICKHOUSE_PASSWORD", ""))
12+
.SetDefaultDatabase(getEnvOrDefault("CLICKHOUSE_DB", "default"))
913
.SetPingBeforeQuery(false));
1014

1115
static void SelectNumber(benchmark::State& state) {

clickhouse/base/socket.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#endif
1919

2020
namespace clickhouse {
21+
2122
namespace {
2223

2324
class LocalNames : public std::unordered_set<std::string> {

tests/simple/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ TARGET_LINK_LIBRARIES (simple-test
66
clickhouse-cpp-lib
77
)
88

9+
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
10+
# there is a problem with __builtin_mul_overflow call at link time
11+
# the error looks like: ... undefined reference to `__muloti4' ...
12+
# caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404
13+
# explicit linking to compiler-rt allows to workaround the problem
14+
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --rtlib=compiler-rt")
15+
ENDIF ()

0 commit comments

Comments
 (0)