Skip to content

Commit d92cafe

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

File tree

13 files changed

+686
-83
lines changed

13 files changed

+686
-83
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 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:

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: 4 additions & 2 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+
"-ICEBERG_BUILD_REST_INTEGRATION_TESTS=${build_rest_integration_test}"
3739
)
3840

3941
if is_windows; then
@@ -45,10 +47,10 @@ fi
4547

4648
cmake "${CMAKE_ARGS[@]}" ${source_dir}
4749
if is_windows; then
48-
cmake --build . --config Release --target install
50+
cmake --build . --config Release --target install -j
4951
ctest --output-on-failure -C Release
5052
else
51-
cmake --build . --target install
53+
cmake --build . --target install -j
5254
ctest --output-on-failure
5355
fi
5456

src/iceberg/test/CMakeLists.txt

Lines changed: 10 additions & 18 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)
@@ -54,10 +47,10 @@ function(add_iceberg_test test_name)
5447

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

6356
add_test(NAME ${test_name} COMMAND ${test_name})
@@ -179,15 +172,14 @@ if(ICEBERG_BUILD_REST)
179172
target_include_directories(${test_name} PRIVATE "${CMAKE_BINARY_DIR}/iceberg/test/")
180173
target_sources(${test_name} PRIVATE ${ARG_SOURCES})
181174
target_link_libraries(${test_name} PRIVATE GTest::gtest_main GTest::gmock
182-
iceberg_rest_static)
175+
iceberg_rest_static iceberg_test_util)
183176
add_test(NAME ${test_name} COMMAND ${test_name})
184177
endfunction()
185178

186-
add_rest_iceberg_test(rest_catalog_test
187-
SOURCES
188-
rest_catalog_test.cc
189-
rest_json_internal_test.cc
179+
add_rest_iceberg_test(rest_catalog_test SOURCES rest_json_internal_test.cc
190180
rest_util_test.cc)
191181

192-
target_include_directories(rest_catalog_test PRIVATE ${cpp-httplib_SOURCE_DIR})
182+
if(ICEBERG_BUILD_REST_INTEGRATION_TESTS)
183+
add_rest_iceberg_test(rest_catalog_integration_test SOURCES rest_catalog_test.cc)
184+
endif()
193185
endif()

src/iceberg/test/meson.build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ configure_file(
2727
install_dir: get_option('includedir') / 'iceberg/test',
2828
)
2929

30+
# Add test utilities subdirectory
31+
subdir('util')
32+
3033
iceberg_tests = {
3134
'schema_test': {
3235
'sources': files(
@@ -105,7 +108,7 @@ 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
),
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
networks:
19+
rest_bridge:
20+
21+
services:
22+
rest:
23+
image: apache/iceberg-rest-fixture:1.10.0
24+
environment:
25+
- AWS_ACCESS_KEY_ID=admin
26+
- AWS_SECRET_ACCESS_KEY=password
27+
- AWS_REGION=us-east-1
28+
- CATALOG_CATALOG__IMPL=org.apache.iceberg.jdbc.JdbcCatalog
29+
- CATALOG_URI=jdbc:sqlite:file:/tmp/iceberg_rest_mode=memory
30+
- CATALOG_WAREHOUSE=file:///tmp/iceberg_warehouse
31+
networks:
32+
rest_bridge:
33+
ports:
34+
- "8181:8181"

0 commit comments

Comments
 (0)