Skip to content

Commit ab43cd3

Browse files
Environment for integration tests (#270)
1 parent d455f01 commit ab43cd3

File tree

130 files changed

+1186
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1186
-33
lines changed

.github/workflows/pr_check.yaml renamed to .github/workflows/examples.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PR-check
1+
name: Examples
22

33
on:
44
push:
@@ -10,13 +10,17 @@ on:
1010
concurrency:
1111
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
1212
cancel-in-progress: true
13-
jobs:
13+
jobs:
1414
main:
15-
name: PR check for YDB C++ SDK
15+
name: Examples
1616
runs-on: ubuntu-22.04
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
ydb-version: [23.3, 24.1, trunk]
1721
services:
1822
ydb:
19-
image: ydbplatform/local-ydb:latest
23+
image: ydbplatform/local-ydb:${{ matrix.ydb-version }}
2024
ports:
2125
- 2135:2135
2226
- 2136:2136
@@ -57,10 +61,6 @@ jobs:
5761
ubuntu-22.04-ccache-
5862
- name: Build
5963
uses: ./.github/actions/build
60-
- name: Test
61-
shell: bash
62-
run: |
63-
ctest -j32 --preset release
6464
- name: Launch basic example
6565
shell: bash
6666
run: |

.github/workflows/tests.yaml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
12+
cancel-in-progress: true
13+
jobs:
14+
unit:
15+
concurrency:
16+
group: unit-${{ github.ref }}-${{ matrix.os }}
17+
cancel-in-progress: true
18+
strategy:
19+
fail-fast: false
20+
env:
21+
OS: ubuntu-22.04
22+
runs-on: ubuntu-22.04
23+
steps:
24+
- name: Checkout PR
25+
uses: actions/checkout@v3
26+
if: github.event.pull_request.head.sha != ''
27+
with:
28+
submodules: true
29+
ref: ${{ github.event.pull_request.head.sha }}
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
if: github.event.pull_request.head.sha == ''
33+
with:
34+
submodules: true
35+
- name: Install dependencies
36+
uses: ./.github/actions/prepare_vm
37+
- name: Prepare ccache timestamp
38+
id: ccache_cache_timestamp
39+
shell: cmake -P {0}
40+
run: |
41+
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
42+
message("::set-output name=timestamp::${current_date}")
43+
- name: Restore cache files
44+
uses: actions/cache/restore@v4
45+
with:
46+
path: ~/.ccache
47+
key: ubuntu-22.04-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
48+
restore-keys: |
49+
ubuntu-22.04-ccache-
50+
- name: Build
51+
uses: ./.github/actions/build
52+
- name: Test
53+
shell: bash
54+
run: |
55+
ctest -j32 --preset release-unit
56+
57+
integration:
58+
concurrency:
59+
group: integration-${{ github.ref }}-${{ matrix.ydb-version }}
60+
cancel-in-progress: true
61+
runs-on: ubuntu-22.04
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
ydb-version: [23.3, 24.1, trunk]
66+
services:
67+
ydb:
68+
image: ydbplatform/local-ydb:${{ matrix.ydb-version }}
69+
ports:
70+
- 2135:2135
71+
- 2136:2136
72+
- 8765:8765
73+
volumes:
74+
- /tmp/ydb_certs:/ydb_certs
75+
env:
76+
YDB_LOCAL_SURVIVE_RESTART: true
77+
YDB_USE_IN_MEMORY_PDISKS: true
78+
YDB_TABLE_ENABLE_PREPARED_DDL: true
79+
options: '-h localhost'
80+
steps:
81+
- name: Checkout PR
82+
uses: actions/checkout@v3
83+
if: github.event.pull_request.head.sha != ''
84+
with:
85+
submodules: true
86+
ref: ${{ github.event.pull_request.head.sha }}
87+
- name: Checkout
88+
uses: actions/checkout@v3
89+
if: github.event.pull_request.head.sha == ''
90+
with:
91+
submodules: true
92+
- name: Install dependencies
93+
uses: ./.github/actions/prepare_vm
94+
- name: Prepare ccache timestamp
95+
id: ccache_cache_timestamp
96+
shell: cmake -P {0}
97+
run: |
98+
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
99+
message("::set-output name=timestamp::${current_date}")
100+
- name: Restore cache files
101+
uses: actions/cache/restore@v4
102+
with:
103+
path: ~/.ccache
104+
key: ubuntu-22.04-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
105+
restore-keys: |
106+
ubuntu-22.04-ccache-
107+
- name: Build
108+
uses: ./.github/actions/build
109+
- name: Test
110+
shell: bash
111+
run: |
112+
ctest -j32 --preset release-integration

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ endif()
4747

4848
if (YDB_SDK_TESTS)
4949
enable_testing()
50-
add_subdirectory(tests)
50+
add_subdirectory(tests/unit)
51+
add_subdirectory(tests/integration)
5152
endif()
5253

5354
if (YDB_SDK_INSTALL)

CMakePresets.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,46 @@
5959
},
6060
"execution": {
6161
"timeout": 1200
62+
},
63+
"environment": {
64+
"YDB_ENDPOINT": "localhost:2136",
65+
"YDB_DATABASE": "/local"
66+
}
67+
},
68+
{
69+
"name": "release-unit",
70+
"configurePreset": "release",
71+
"displayName": "Default Unit Release Tests",
72+
"filter" : {
73+
"include": {
74+
"label": "unit"
75+
}
76+
},
77+
"output": {
78+
"outputOnFailure": true
79+
},
80+
"execution": {
81+
"timeout": 1200
82+
}
83+
},
84+
{
85+
"name": "release-integration",
86+
"configurePreset": "release",
87+
"displayName": "Default Integration Release Tests",
88+
"output": {
89+
"outputOnFailure": true
90+
},
91+
"filter" : {
92+
"include": {
93+
"label": "integration"
94+
}
95+
},
96+
"execution": {
97+
"timeout": 1200
98+
},
99+
"environment": {
100+
"YDB_ENDPOINT": "localhost:2136",
101+
"YDB_DATABASE": "/local"
62102
}
63103
}
64104
]

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ cmake --build --preset release
122122

123123
Specify a level of parallelism by passing the `-j<level>` option into the command below (e.g. `-j$(nproc)`)
124124

125+
Running all tests:
126+
125127
```bash
126128
ctest -j$(nproc) --preset release
127129
```
130+
131+
Running unit tests only:
132+
133+
```bash
134+
ctest -j$(nproc) --preset release-unit
135+
```
136+
137+
Running integration tests only:
138+
139+
```bash
140+
ctest -j$(nproc) --preset release-integration
141+
```

cmake/testing.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ endfunction()
6060
function(add_ydb_test)
6161
set(opts "")
6262
set(oneval_args NAME)
63-
set(multival_args INCLUDE_DIRS SOURCES LINK_LIBRARIES)
63+
set(multival_args INCLUDE_DIRS SOURCES LINK_LIBRARIES LABELS)
6464
cmake_parse_arguments(YDB_TEST
6565
"${opts}"
6666
"${oneval_args}"
@@ -121,6 +121,7 @@ function(add_ydb_test)
121121
PROPERTY
122122
LABELS
123123
MEDIUM
124+
${YDB_TEST_LABELS}
124125
)
125126

126127
set_yunittest_property(

examples/basic_example/basic_example.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
#include <ydb-cpp-sdk/util/string/cast.h>
44

5-
#include <src/util/folder/pathsplit.h>
6-
75
#include <filesystem>
86
#include <format>
97

tests/integration/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(basic_example_it)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
add_ydb_test(NAME basic-example_it
2+
SOURCES
3+
main.cpp
4+
basic_example_data.cpp
5+
basic_example.cpp
6+
basic_example.h
7+
LINK_LIBRARIES
8+
yutil
9+
YDB-CPP-SDK::Table
10+
GTest::gtest_main
11+
public-lib-json_value
12+
LABELS
13+
integration
14+
)

0 commit comments

Comments
 (0)