diff --git a/core/docker/Dockerfile b/core/docker/Dockerfile index 4a9bce50f..e0714d2c7 100644 --- a/core/docker/Dockerfile +++ b/core/docker/Dockerfile @@ -65,7 +65,7 @@ RUN ${DATAFED_DEPENDENCIES_ROOT}/scripts/generate_dependencies_config.sh && \ -DBUILD_PYTHON_CLIENT=False \ -DBUILD_FOXX=False \ -DENABLE_UNIT_TESTS=True \ - -DENABLE_INTEGRATION_TESTS=False + -DENABLE_INTEGRATION_TESTS=True RUN ${DATAFED_DEPENDENCIES_INSTALL_PATH}/bin/cmake --build build -j 8 RUN ${DATAFED_DEPENDENCIES_INSTALL_PATH}/bin/cmake --build build --target install diff --git a/core/server/tests/integration/CMakeLists.txt b/core/server/tests/integration/CMakeLists.txt index e26556b19..f46bc9315 100644 --- a/core/server/tests/integration/CMakeLists.txt +++ b/core/server/tests/integration/CMakeLists.txt @@ -11,11 +11,20 @@ set(MOCK_SCHEMA_PORT "4010" set(MOCK_SCHEMA_PULL "true" CACHE STRING "Pull the mock image before starting (set to 'false' for offline/local builds)") +set(ARANGO_IMAGE "savannah.ornl.gov/datafed/arango-foxx:latest" + CACHE STRING "Docker image for the ArangoDB test instance (with Foxx services)") +set(ARANGO_PORT "8529" + CACHE STRING "Host port for the ArangoDB test container") +set(ARANGO_ROOT_PASS "test" + CACHE STRING "Root password for the ArangoDB test instance") +set(ARANGO_PULL "true" + CACHE STRING "Pull the ArangoDB image before starting (set to 'false' for offline/local builds)") + # ── Check for Docker (needed by SchemaAPIClient tests) ─────────────────────── find_program(DOCKER_EXECUTABLE docker) if(NOT DOCKER_EXECUTABLE) - message(STATUS "Docker not found — SchemaAPIClient integration tests will be skipped") + message(STATUS "Docker not found — integration tests requiring containers will be skipped") endif() # ── Compile and register all integration tests ────────────────────────────── @@ -23,6 +32,7 @@ endif() foreach(PROG test_SchemaServiceFactory test_SchemaAPIClient + test_SchemaHandler ) file(GLOB ${PROG}_SOURCES ${PROG}*.cpp) add_executable(integration_${PROG} ${${PROG}_SOURCES}) @@ -52,6 +62,10 @@ endforeach(PROG) if(DOCKER_EXECUTABLE) + # ======================================================================== + # Mock Schema API (Prism) fixture — used by SchemaAPIClient + # ======================================================================== + set(_mock_schema_env "MOCK_SCHEMA_IMAGE=${MOCK_SCHEMA_IMAGE}" "MOCK_SCHEMA_PORT=${MOCK_SCHEMA_PORT}" @@ -59,7 +73,7 @@ if(DOCKER_EXECUTABLE) "CONTAINER_NAME=datafed-mock-schema" ) - set(_test_env + set(_mock_schema_test_env "SCHEMA_API_TEST_URL=http://localhost:${MOCK_SCHEMA_PORT}" ) @@ -91,14 +105,72 @@ if(DOCKER_EXECUTABLE) set_tests_properties(integration_test_SchemaAPIClient PROPERTIES FIXTURES_REQUIRED MockSchemaAPI - ENVIRONMENT "${_test_env}" + ENVIRONMENT "${_mock_schema_test_env}" LABELS "integration" ) if(ENABLE_MEMORY_TESTS) set_tests_properties(memory_test_SchemaAPIClient PROPERTIES FIXTURES_REQUIRED MockSchemaAPI - ENVIRONMENT "${_test_env}" + ENVIRONMENT "${_mock_schema_test_env}" + LABELS "integration;memory" + ) + endif() + + # ======================================================================== + # ArangoDB fixture — used by SchemaHandler + # ======================================================================== + + set(_arango_env + "ARANGO_IMAGE=${ARANGO_IMAGE}" + "ARANGO_PORT=${ARANGO_PORT}" + "ARANGO_ROOT_PASS=${ARANGO_ROOT_PASS}" + "ARANGO_PULL=${ARANGO_PULL}" + "ARANGO_CONTAINER=datafed-test-arango" + ) + + set(_arango_test_env + "DATAFED_TEST_ARANGO_URL=http://localhost:${ARANGO_PORT}" + "DATAFED_TEST_ARANGO_USER=root" + "DATAFED_TEST_ARANGO_PASS=${ARANGO_ROOT_PASS}" + ) + + # ── Fixture setup: start ArangoDB container ────────────────────────── + + add_test( + NAME arango_start + COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/start_test_arango.sh + ) + set_tests_properties(arango_start PROPERTIES + FIXTURES_SETUP TestArangoDB + ENVIRONMENT "${_arango_env}" + LABELS "fixture;integration" + ) + + # ── Fixture cleanup: stop and remove container ─────────────────────── + + add_test( + NAME arango_stop + COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/stop_test_arango.sh + ) + set_tests_properties(arango_stop PROPERTIES + FIXTURES_CLEANUP TestArangoDB + ENVIRONMENT "${_arango_env}" + LABELS "fixture;integration" + ) + + # ── Attach fixture to SchemaHandler tests ──────────────────────────── + + set_tests_properties(integration_test_SchemaHandler PROPERTIES + FIXTURES_REQUIRED TestArangoDB + ENVIRONMENT "${_arango_test_env}" + LABELS "integration" + ) + + if(ENABLE_MEMORY_TESTS) + set_tests_properties(memory_test_SchemaHandler PROPERTIES + FIXTURES_REQUIRED TestArangoDB + ENVIRONMENT "${_arango_test_env}" LABELS "integration;memory" ) endif() diff --git a/scripts/compose_build_images.sh b/scripts/compose_build_images.sh index 1536367b7..ee771de5f 100755 --- a/scripts/compose_build_images.sh +++ b/scripts/compose_build_images.sh @@ -73,6 +73,13 @@ if [[ "$BUILD_METADATA" == "TRUE" ]]; then --build-arg BASE_IMAGE=$BASE_IMAGE \ -t datafed-runtime:latest fi + docker build -f \ + "${PROJECT_ROOT}/core/docker/Dockerfile" \ + --build-arg DEPENDENCIES="datafed-dependencies:latest" \ + --build-arg RUNTIME="datafed-runtime:latest" \ + --target core-build \ + "${PROJECT_ROOT}" \ + -t datafed-core-build:latest docker build -f \ "${PROJECT_ROOT}/core/docker/Dockerfile" \ --build-arg DEPENDENCIES="datafed-dependencies:latest" \ diff --git a/tests/mock/CMakeLists.txt b/tests/mock/CMakeLists.txt index 038f16943..23dd87b3a 100644 --- a/tests/mock/CMakeLists.txt +++ b/tests/mock/CMakeLists.txt @@ -8,7 +8,7 @@ foreach(PROG file(GLOB ${PROG}_SOURCES ${PROG}*.cpp) add_executable(mock_liveness_${PROG} ${${PROG}_SOURCES}) - target_link_libraries(mock_liveness_${PROG} PUBLIC ${DATAFED_BOOST_LIBRARIES} ${DATAFED_GSSAPI_LIBRARIES} ${DATAFED_GLOBUS_COMMON_LIBRARIES} common ) + target_link_libraries(mock_liveness_${PROG} PUBLIC ${DATAFED_BOOST_LIBRARIES} common ) if(BUILD_SHARED_LIBS) target_compile_definitions(mock_liveness_${PROG} PRIVATE BOOST_TEST_DYN_LINK) endif()