Skip to content

Commit 4bc6653

Browse files
committed
test: Implement REST Catalog Integration Tests with Docker in CI Pipeline
1 parent f1b0dba commit 4bc6653

File tree

13 files changed

+713
-83
lines changed

13 files changed

+713
-83
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,24 @@ jobs:
5656
shell: bash
5757
run: ci/scripts/build_example.sh $(pwd)/example
5858
macos:
59-
name: AArch64 macOS 26
60-
runs-on: macos-26
59+
name: AArch64 macOS 15
60+
runs-on: macos-15
6161
timeout-minutes: 30
6262
strategy:
6363
fail-fast: false
6464
steps:
6565
- name: Checkout iceberg-cpp
6666
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
67+
- name: Setup Docker on macOS
68+
id: setup-docker
69+
uses: douglascamata/setup-docker-macos-action@v1.0.1
70+
with:
71+
lima: v1.2.1
72+
colima: v0.9.1
73+
colima-network-address: false
6774
- name: Build Iceberg
6875
shell: bash
69-
run: ci/scripts/build_iceberg.sh $(pwd)
76+
run: ci/scripts/build_iceberg.sh $(pwd) ON
7077
- name: Build Example
7178
shell: bash
7279
run: ci/scripts/build_example.sh $(pwd)/example

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_TESTS=${build_rest_integration_test}"
3739
)
3840

3941
if is_windows; then

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})
@@ -178,15 +171,14 @@ if(ICEBERG_BUILD_REST)
178171
target_include_directories(${test_name} PRIVATE "${CMAKE_BINARY_DIR}/iceberg/test/")
179172
target_sources(${test_name} PRIVATE ${ARG_SOURCES})
180173
target_link_libraries(${test_name} PRIVATE GTest::gtest_main GTest::gmock
181-
iceberg_rest_static)
174+
iceberg_rest_static iceberg_test_util)
182175
add_test(NAME ${test_name} COMMAND ${test_name})
183176
endfunction()
184177

185-
add_rest_iceberg_test(rest_catalog_test
186-
SOURCES
187-
rest_catalog_test.cc
188-
rest_json_internal_test.cc
178+
add_rest_iceberg_test(rest_catalog_test SOURCES rest_json_internal_test.cc
189179
rest_util_test.cc)
190180

191-
target_include_directories(rest_catalog_test PRIVATE ${cpp-httplib_SOURCE_DIR})
181+
if(ICEBERG_BUILD_REST_INTEGRATION_TESTS)
182+
add_rest_iceberg_test(rest_catalog_integration_test SOURCES rest_catalog_test.cc)
183+
endif()
192184
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(
@@ -104,7 +107,7 @@ foreach test_name, values : iceberg_tests
104107
exc = executable(
105108
test_name,
106109
sources: values['sources'],
107-
dependencies: [iceberg_dep, gmock_main_dep] + values.get(
110+
dependencies: [iceberg_dep, gmock_main_dep, iceberg_test_util_dep] + values.get(
108111
'dependencies',
109112
[],
110113
),
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)