Skip to content

Commit 19b9859

Browse files
committed
test: add REST Catalog Integration Tests with Docker
1 parent dbcbdf2 commit 19b9859

21 files changed

+733
-117
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
env:
5555
CC: gcc-14
5656
CXX: g++-14
57-
run: ci/scripts/build_iceberg.sh $(pwd)
57+
run: ci/scripts/build_iceberg.sh $(pwd) ON
5858
- name: Build Example
5959
shell: bash
6060
env:
@@ -110,6 +110,7 @@ jobs:
110110
runs-on: ubuntu-24.04
111111
CC: gcc-14
112112
CXX: g++-14
113+
meson-setup-args: -Drest_integration_test=enabled
113114
- title: AMD64 Windows 2025
114115
runs-on: windows-2025
115116
meson-setup-args: --vsenv

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ option(ICEBERG_BUILD_SHARED "Build shared library" OFF)
4242
option(ICEBERG_BUILD_TESTS "Build tests" ON)
4343
option(ICEBERG_BUILD_BUNDLE "Build the battery included library" ON)
4444
option(ICEBERG_BUILD_REST "Build rest catalog client" ON)
45+
option(ICEBERG_BUILD_REST_INTEGRATION_TESTS "Build rest catalog integration tests" OFF)
4546
option(ICEBERG_ENABLE_ASAN "Enable Address Sanitizer" OFF)
4647
option(ICEBERG_ENABLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF)
4748

ci/scripts/build_iceberg.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ set -eux
2121

2222
source_dir=${1}
2323
build_dir=${1}/build
24+
build_rest_integration_test=${2:-OFF}
2425

2526
mkdir ${build_dir}
2627
pushd ${build_dir}
@@ -34,6 +35,7 @@ CMAKE_ARGS=(
3435
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-${ICEBERG_HOME}}"
3536
"-DICEBERG_BUILD_STATIC=ON"
3637
"-DICEBERG_BUILD_SHARED=ON"
38+
"-DICEBERG_BUILD_REST_INTEGRATION_TESTS=${build_rest_integration_test}"
3739
)
3840

3941
if is_windows; then

meson.options

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,12 @@ option(
3636
description: 'Build rest catalog client',
3737
value: 'enabled',
3838
)
39+
40+
option(
41+
'rest_integration_test',
42+
type: 'feature',
43+
description: 'Build integration test for rest catalog',
44+
value: 'disabled',
45+
)
46+
3947
option('tests', type: 'feature', description: 'Build tests', value: 'enabled')

src/iceberg/test/CMakeLists.txt

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,21 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
fetchcontent_declare(cpp-httplib
19-
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
20-
GIT_TAG 89c932f313c6437c38f2982869beacc89c2f2246 #release-0.26.0
21-
)
22-
2318
fetchcontent_declare(googletest
2419
GIT_REPOSITORY https://github.com/google/googletest.git
2520
GIT_TAG b514bdc898e2951020cbdca1304b75f5950d1f59 # release-1.15.2
2621
FIND_PACKAGE_ARGS
2722
NAMES
2823
GTest)
2924

30-
if(ICEBERG_BUILD_REST)
31-
fetchcontent_makeavailable(cpp-httplib googletest)
32-
else()
33-
fetchcontent_makeavailable(googletest)
34-
endif()
25+
fetchcontent_makeavailable(googletest)
3526

3627
set(ICEBERG_TEST_RESOURCES "${CMAKE_SOURCE_DIR}/src/iceberg/test/resources")
3728

3829
configure_file("test_config.h.in" "test_config.h")
3930

31+
add_subdirectory(util)
32+
4033
function(add_iceberg_test test_name)
4134
set(options USE_BUNDLE)
4235
set(oneValueArgs)
@@ -53,11 +46,11 @@ function(add_iceberg_test test_name)
5346
target_sources(${test_name} PRIVATE ${ARG_SOURCES})
5447

5548
if(ARG_USE_BUNDLE)
56-
target_link_libraries(${test_name} PRIVATE iceberg_bundle_static GTest::gtest_main
57-
GTest::gmock)
49+
target_link_libraries(${test_name} PRIVATE iceberg_bundle_static GTest::gmock_main
50+
iceberg_test_util)
5851
else()
59-
target_link_libraries(${test_name} PRIVATE iceberg_static GTest::gtest_main
60-
GTest::gmock)
52+
target_link_libraries(${test_name} PRIVATE iceberg_static GTest::gmock_main
53+
iceberg_test_util)
6154
endif()
6255

6356
add_test(NAME ${test_name} COMMAND ${test_name})
@@ -85,8 +78,7 @@ add_iceberg_test(table_test
8578
table_test.cc
8679
table_metadata_builder_test.cc
8780
table_requirement_test.cc
88-
table_update_test.cc
89-
test_common.cc)
81+
table_update_test.cc)
9082

9183
add_iceberg_test(expression_test
9284
SOURCES
@@ -98,7 +90,6 @@ add_iceberg_test(expression_test
9890

9991
add_iceberg_test(json_serde_test
10092
SOURCES
101-
test_common.cc
10293
json_internal_test.cc
10394
metadata_serde_test.cc
10495
schema_json_test.cc)
@@ -128,8 +119,7 @@ if(ICEBERG_BUILD_BUNDLE)
128119
manifest_list_reader_writer_test.cc
129120
manifest_list_versions_test.cc
130121
manifest_reader_writer_test.cc
131-
manifest_writer_versions_test.cc
132-
test_common.cc)
122+
manifest_writer_versions_test.cc)
133123

134124
add_iceberg_test(arrow_test
135125
USE_BUNDLE
@@ -140,18 +130,13 @@ if(ICEBERG_BUILD_BUNDLE)
140130
metadata_io_test.cc
141131
struct_like_test.cc)
142132

143-
add_iceberg_test(catalog_test
144-
USE_BUNDLE
145-
SOURCES
146-
test_common.cc
147-
in_memory_catalog_test.cc)
133+
add_iceberg_test(catalog_test USE_BUNDLE SOURCES in_memory_catalog_test.cc)
148134

149135
add_iceberg_test(eval_expr_test
150136
USE_BUNDLE
151137
SOURCES
152138
eval_expr_test.cc
153-
evaluator_test.cc
154-
test_common.cc)
139+
evaluator_test.cc)
155140

156141
add_iceberg_test(parquet_test
157142
USE_BUNDLE
@@ -178,16 +163,15 @@ if(ICEBERG_BUILD_REST)
178163
add_executable(${test_name})
179164
target_include_directories(${test_name} PRIVATE "${CMAKE_BINARY_DIR}/iceberg/test/")
180165
target_sources(${test_name} PRIVATE ${ARG_SOURCES})
181-
target_link_libraries(${test_name} PRIVATE GTest::gtest_main GTest::gmock
182-
iceberg_rest_static)
166+
target_link_libraries(${test_name} PRIVATE GTest::gmock_main iceberg_rest_static
167+
iceberg_test_util)
183168
add_test(NAME ${test_name} COMMAND ${test_name})
184169
endfunction()
185170

186-
add_rest_iceberg_test(rest_catalog_test
187-
SOURCES
188-
rest_catalog_test.cc
189-
rest_json_internal_test.cc
171+
add_rest_iceberg_test(rest_catalog_test SOURCES rest_json_internal_test.cc
190172
rest_util_test.cc)
191173

192-
target_include_directories(rest_catalog_test PRIVATE ${cpp-httplib_SOURCE_DIR})
174+
if(ICEBERG_BUILD_REST_INTEGRATION_TESTS)
175+
add_rest_iceberg_test(rest_catalog_integration_test SOURCES rest_catalog_test.cc)
176+
endif()
193177
endif()

src/iceberg/test/in_memory_catalog_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "iceberg/table_metadata.h"
3232
#include "iceberg/test/matchers.h"
3333
#include "iceberg/test/mock_catalog.h"
34-
#include "iceberg/test/test_common.h"
34+
#include "iceberg/test/util/common_util.h"
3535

3636
namespace iceberg {
3737

src/iceberg/test/manifest_list_reader_writer_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "iceberg/manifest_writer.h"
2929
#include "iceberg/test/matchers.h"
3030
#include "iceberg/test/temp_file_test_base.h"
31-
#include "iceberg/test/test_common.h"
31+
#include "iceberg/test/util/common_util.h"
3232

3333
namespace iceberg {
3434

src/iceberg/test/manifest_reader_writer_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "iceberg/schema.h"
3333
#include "iceberg/test/matchers.h"
3434
#include "iceberg/test/temp_file_test_base.h"
35-
#include "iceberg/test/test_common.h"
35+
#include "iceberg/test/util/common_util.h"
3636
#include "iceberg/transform.h"
3737
#include "iceberg/type.h"
3838

src/iceberg/test/meson.build

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ configure_file(
2727
install_dir: get_option('includedir') / 'iceberg/test',
2828
)
2929

30+
subdir('util')
31+
3032
iceberg_tests = {
3133
'schema_test': {
3234
'sources': files(
@@ -51,7 +53,6 @@ iceberg_tests = {
5153
'table_requirement_test.cc',
5254
'table_test.cc',
5355
'table_update_test.cc',
54-
'test_common.cc',
5556
),
5657
},
5758
'expression_test': {
@@ -68,7 +69,6 @@ iceberg_tests = {
6869
'json_internal_test.cc',
6970
'metadata_serde_test.cc',
7071
'schema_json_test.cc',
71-
'test_common.cc',
7272
),
7373
},
7474
'util_test': {
@@ -88,24 +88,27 @@ iceberg_tests = {
8888
}
8989

9090
if get_option('rest').enabled()
91-
cpp_httplib_dep = dependency('cpp-httplib')
9291
iceberg_tests += {
9392
'rest_catalog_test': {
94-
'sources': files(
95-
'rest_catalog_test.cc',
96-
'rest_json_internal_test.cc',
97-
'rest_util_test.cc',
98-
),
99-
'dependencies': [iceberg_rest_dep, cpp_httplib_dep],
93+
'sources': files('rest_json_internal_test.cc', 'rest_util_test.cc'),
94+
'dependencies': [iceberg_rest_dep],
10095
},
10196
}
97+
if get_option('rest_integration_test').enabled()
98+
iceberg_tests += {
99+
'rest_integration_test': {
100+
'sources': files('rest_catalog_test.cc'),
101+
'dependencies': [iceberg_rest_dep],
102+
},
103+
}
104+
endif
102105
endif
103106

104107
foreach test_name, values : iceberg_tests
105108
exc = executable(
106109
test_name,
107110
sources: values['sources'],
108-
dependencies: [iceberg_dep, gmock_main_dep] + values.get(
111+
dependencies: [iceberg_dep, gmock_main_dep, iceberg_test_util_dep] + values.get(
109112
'dependencies',
110113
[],
111114
),

src/iceberg/test/metadata_serde_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "iceberg/statistics_file.h"
3333
#include "iceberg/table_metadata.h"
3434
#include "iceberg/test/matchers.h"
35-
#include "iceberg/test/test_common.h"
35+
#include "iceberg/test/util/common_util.h"
3636
#include "iceberg/transform.h"
3737
#include "iceberg/type.h"
3838

0 commit comments

Comments
 (0)