diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8958d3b4158fd0c882a96c9aa3b5d4f5ec24afd0..99a78db863f3258efeb6830a9159c5c7d723ee0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,6 +14,7 @@ stages: variables: XROOTD_VERSION: 4 SCHED_TYPE: "objectstore" + ORACLE_SUPPORT: "ON" CTA_VERSION: "${XROOTD_VERSION}" CMAKE_OPTIONS: "" @@ -43,6 +44,12 @@ variables: CMAKE_OPTIONS="-DSKIP_UNIT_TESTS:STRING=1 ${sched_opt}"; fi +.prepare-no-oracle: &prepare-no-oracle + - if [[ ${ORACLE_SUPPORT} != "ON" ]]; then + echo "Disabling Oracle Support"; + CMAKE_OPTIONS="-DDISABLE_ORACLE_SUPPORT:BOOL=ON"; + fi + before_script: - export CTA_BUILD_ID=${CI_PIPELINE_ID}git${CI_COMMIT_SHA:0:8} - echo "Exporting CTA_BUILD_ID=${CTA_BUILD_ID}" @@ -55,6 +62,7 @@ before_script: fi - *prepare-xrootd5 - *prepare-scheduler-type + - *prepare-no-oracle include: - local: .gitlab/ci/*.gitlab-ci.yml diff --git a/.gitlab/ci/build.gitlab-ci.yml b/.gitlab/ci/build.gitlab-ci.yml index f58f31143b71cd8a4bb1b4a06f9dc16042063db3..86eb6d980415225729bbc1fc52fe56139b377647 100644 --- a/.gitlab/ci/build.gitlab-ci.yml +++ b/.gitlab/ci/build.gitlab-ci.yml @@ -50,7 +50,7 @@ cta_srpm_xrootd4: - .cta_srpm rules: - !reference [.cta_build, rules] - - if: $XROOTD_VERSION == "4" && $SCHED_TYPE == "objectstore" + - if: $XROOTD_VERSION == "4" && $SCHED_TYPE == "objectstore" && $ORACLE_SUPPORT == "ON" cta_rpm_xrootd4: stage: build:rpm @@ -58,7 +58,7 @@ cta_rpm_xrootd4: - .cta_rpm rules: - !reference [.cta_build, rules] - - if: $XROOTD_VERSION == "4" && $SCHED_TYPE == "objectstore" + - if: $XROOTD_VERSION == "4" && $SCHED_TYPE == "objectstore" && $ORACLE_SUPPORT == "ON" - if: $CI_COMMIT_TAG when: never @@ -68,7 +68,7 @@ cta_srpm_xrootd4_pgsched: - .cta_srpm rules: - !reference [.cta_build, rules] - - if: $XROOTD_VERSION == "4" && $SCHED_TYPE == "pgsched" + - if: $XROOTD_VERSION == "4" && $SCHED_TYPE == "pgsched" && $ORACLE_SUPPORT == "OFF" cta_rpm_xrootd4_pgsched: stage: build:rpm @@ -76,7 +76,7 @@ cta_rpm_xrootd4_pgsched: - .cta_rpm rules: - !reference [.cta_build, rules] - - if: $XROOTD_VERSION == "4" && $SCHED_TYPE == "pgsched" + - if: $XROOTD_VERSION == "4" && $SCHED_TYPE == "pgsched" && $ORACLE_SUPPORT == "OFF" - if: $CI_COMMIT_TAG when: never @@ -86,7 +86,7 @@ cta_srpm_xrootd5: - .cta_srpm rules: - !reference [.cta_build, rules] - - if: $XROOTD_VERSION == "5" && $SCHED_TYPE == "objectstore" + - if: $XROOTD_VERSION == "5" && $SCHED_TYPE == "objectstore" && $ORACLE_SUPPORT == "ON" cta_rpm_xrootd5: stage: build:rpm @@ -94,7 +94,42 @@ cta_rpm_xrootd5: - .cta_rpm rules: - !reference [.cta_build, rules] - - if: $XROOTD_VERSION == "5" && $SCHED_TYPE == "objectstore" + - if: $XROOTD_VERSION == "5" && $SCHED_TYPE == "objectstore" && $ORACLE_SUPPORT == "ON" - if: $CI_COMMIT_TAG when: never +cta_srpm_xrootd5: + stage: build:srpm + extends: + - .cta_srpm + rules: + - !reference [.cta_build, rules] + - if: $XROOTD_VERSION == "5" && $SCHED_TYPE == "objectstore" && $ORACLE_SUPPORT == "ON" + +cta_rpm_xrootd5: + stage: build:rpm + extends: + - .cta_rpm + rules: + - !reference [.cta_build, rules] + - if: $XROOTD_VERSION == "5" && $SCHED_TYPE == "objectstore" && $ORACLE_SUPPORT == "ON" + - if: $CI_COMMIT_TAG + when: never + +cta_srpm_no_oracle: + stage: build:srpm + extends: + - .cta_srpm + rules: + - !reference [.cta_build, rules] + - if: $XROOTD_VERSION == "4" && $SCHED_TYPE == "objectstore" && $ORACLE_SUPPORT == "OFF" + +cta_rpm_no_oracle: + stage: build:rpm + extends: + - .cta_rpm + rules: + - !reference [.cta_build, rules] + - if: $XROOTD_VERSION == "4" && $SCHED_TYPE == "objectstore" && $ORACLE_SUPPORT == "OFF" + - if: $CI_COMMIT_TAG + when: never \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 2526b929f87e7400b11eaa0dc46d976ba3100cfa..cd0172120fa266ce06e0c6d439bf5c50e08d9e19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,15 @@ if (ENABLE_STDOUT_LOGGING) add_definitions (-DSTDOUT_LOGGING) endif () +set (OCCI_SUPPORT ON) +if (DISABLE_ORACLE_SUPPORT) + message(STATUS "NO ORACLE") + unset (OCCI_SUPPORT) + set(RPM_ORACLE "-DDISABLE_ORACLE_SUPPORT:BOOL=ON" CACHE STRING "" FORCE) +else () + set(RPM_ORACLE "%{nil}" CACHE STRING "" FORCE) +endif () + if (CTA_USE_PGSCHED) add_definitions (-DCTA_PGSCHED) set(RPM_USINGOBJECTSTORE "0" CACHE STRING "" FORCE) @@ -120,8 +129,6 @@ ELSE(DEFINED PackageOnly) include_directories(${CMAKE_BINARY_DIR}) # OCCI support is on by default - set (OCCI_SUPPORT ON) - if (OCCI_SUPPORT) find_package (oracle-instantclient REQUIRED) endif (OCCI_SUPPORT) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index a8c09f8d92488b62a6faf533a738385b22c73f45..3161caa3709d656169197f3af120502a2e9113a0 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -4,7 +4,10 @@ ### Features - cta/CTA#89 - Create stubs for Enstore tape label format ### Continuous Integration +- cta/CTA#7 - Use same versionlock.list file for xrootd4 and 5 - cta/CTA#49 - Clean up orchestration test scripts +### Building and Packaging +- cta/CTA#92 - Refactor CTA code so that it can be build without Oracle dependencies # v4.7.9-2 diff --git a/catalogue/CMakeLists.txt b/catalogue/CMakeLists.txt index b56ecdb1ef8406ad97003d22818011a5848d86e4..b088783d95ddd60f5fe25bb572e6ba801ec5ad49 100644 --- a/catalogue/CMakeLists.txt +++ b/catalogue/CMakeLists.txt @@ -18,7 +18,13 @@ cmake_minimum_required (VERSION 3.17) find_package(Protobuf3 REQUIRED) find_package(postgres REQUIRED) -include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS} ${POSTGRES_INCLUDE_DIRS}) +include_directories (${POSTGRES_INCLUDE_DIRS}) + +if (OCCI_SUPPORT) + find_package (oracle-instantclient REQUIRED) + include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS}) + add_definitions( -DSUPPORT_OCCI ) +endif () # # Compiled protocol buffers (for ChecksumBlob) @@ -39,8 +45,6 @@ set (CATALOGUE_LIB_SRC_FILES DriveConfig.cpp InMemoryCatalogue.cpp InMemoryCatalogueFactory.cpp - OracleCatalogue.cpp - OracleCatalogueFactory.cpp PostgresCatalogue.cpp PostgresqlCatalogueFactory.cpp SqliteCatalogueSchema.cpp @@ -59,6 +63,13 @@ set (CATALOGUE_LIB_SRC_FILES TapeForWriting.cpp ) +if (OCCI_SUPPORT) + set (CATALOGUE_LIB_SRC_FILES + ${CATALOGUE_LIB_SRC_FILES} + OracleCatalogue.cpp + OracleCatalogueFactory.cpp) +endif() + add_library (ctacatalogue SHARED ${CATALOGUE_LIB_SRC_FILES}) @@ -83,7 +94,7 @@ add_custom_target(create_catalogue_schema_directory ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${catalogue_schema_directory} DEPENDS ${CMAKE_SOURCE_DIR}/cmake/CTAVersions.cmake) -add_custom_command (OUTPUT sqlite_catalogue_schema.sql oracle_catalogue_schema.sql postgres_catalogue_schema.sql +add_custom_command (OUTPUT sqlite_catalogue_schema.sql postgres_catalogue_schema.sql COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/CreateAllSchemasSQL.sh ${CMAKE_CURRENT_SOURCE_DIR} ${catalogue_schema_directory} >/dev/null COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/CreateAllSchemasCppFile.sh ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS @@ -93,14 +104,28 @@ add_custom_command (OUTPUT sqlite_catalogue_schema.sql oracle_catalogue_schema.s ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_trailer.sql ${CMAKE_CURRENT_SOURCE_DIR}/postgres_catalogue_schema_header.sql ${CMAKE_CURRENT_SOURCE_DIR}/postgres_catalogue_schema_trailer.sql - ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_header.sql - ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_trailer.sql ${CMAKE_CURRENT_SOURCE_DIR}/CreateAllSchemasCppFile.sh ${CMAKE_CURRENT_SOURCE_DIR}/AllCatalogueSchema.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/insert_cta_catalogue_version.sql.in create_catalogue_schema_directory ) +if (OCCI_SUPPORT) + add_custom_command (OUTPUT oracle_catalogue_schema.sql + COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/CreateAllSchemasSQL.sh ${CMAKE_CURRENT_SOURCE_DIR} ${catalogue_schema_directory} >/dev/null + COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/CreateAllSchemasCppFile.sh ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/common_catalogue_schema.sql + ${CMAKE_SOURCE_DIR}/cmake/CTAVersions.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_header.sql + ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_trailer.sql + ${CMAKE_CURRENT_SOURCE_DIR}/CreateAllSchemasCppFile.sh + ${CMAKE_CURRENT_SOURCE_DIR}/AllCatalogueSchema.hpp.in + ${CMAKE_CURRENT_SOURCE_DIR}/insert_cta_catalogue_version.sql.in + create_catalogue_schema_directory + ) +endif () + add_custom_command(OUTPUT sqlite_catalogue_schema.cpp COMMAND sed 's/^/\ \ \"/' sqlite_catalogue_schema.sql | sed 's/$$/\"/' > sqlite_catalogue_schema.cpp DEPENDS sqlite_catalogue_schema.sql) @@ -158,23 +183,32 @@ install (FILES cta-catalogue.conf.example DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) -add_custom_command(OUTPUT oracle_catalogue_schema.cpp - COMMAND sed 's/^/\ \ \"/' oracle_catalogue_schema.sql | sed 's/$$/\"/' > oracle_catalogue_schema.cpp - DEPENDS oracle_catalogue_schema.sql) +if (OCCI_SUPPORT) + add_custom_command(OUTPUT oracle_catalogue_schema.cpp + COMMAND sed 's/^/\ \ \"/' oracle_catalogue_schema.sql | sed 's/$$/\"/' > oracle_catalogue_schema.cpp + DEPENDS oracle_catalogue_schema.sql) -add_custom_command(OUTPUT OracleCatalogueSchema.cpp - COMMAND sed '/CTA_SQL_SCHEMA/r oracle_catalogue_schema.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/OracleCatalogueSchema.before_SQL.cpp > OracleCatalogueSchema.cpp - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/OracleCatalogueSchema.before_SQL.cpp oracle_catalogue_schema.cpp) + add_custom_command(OUTPUT OracleCatalogueSchema.cpp + COMMAND sed '/CTA_SQL_SCHEMA/r oracle_catalogue_schema.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/OracleCatalogueSchema.before_SQL.cpp > OracleCatalogueSchema.cpp + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/OracleCatalogueSchema.before_SQL.cpp oracle_catalogue_schema.cpp) +endif () -add_executable(cta-catalogue-schema-create +set (SCHEMA_CREATE_SRC_FILES CreateSchemaCmd.cpp CreateSchemaCmdLineArgs.cpp CreateSchemaCmdMain.cpp - OracleCatalogueSchema.cpp VersionedCatalogueSchemas.cpp SqliteCatalogueSchema.cpp PostgresCatalogueSchema.cpp - ) +) + +if (OCCI_SUPPORT) + set (SCHEMA_CREATE_SRC_FILES + ${SCHEMA_CREATE_SRC_FILES} + OracleCatalogueSchema.cpp) +endif() + +add_executable(cta-catalogue-schema-create ${SCHEMA_CREATE_SRC_FILES}) set (SCHEMA_CHECKER_LIB_SRC_FILES SQLiteSchemaInserter.cpp @@ -186,11 +220,16 @@ set (SCHEMA_CHECKER_LIB_SRC_FILES SchemaChecker.cpp DatabaseMetadataGetter.cpp CatalogueSchema.cpp - OracleCatalogueSchema.cpp SqliteCatalogueSchema.cpp PostgresCatalogueSchema.cpp ) +if (OCCI_SUPPORT) + set (SCHEMA_CHECKER_LIB_SRC_FILES + ${SCHEMA_CHECKER_LIB_SRC_FILES} + OracleCatalogueSchema.cpp) +endif() + add_library (ctaschemachecker SHARED ${SCHEMA_CHECKER_LIB_SRC_FILES}) @@ -198,7 +237,9 @@ install (TARGETS ctaschemachecker DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) target_link_libraries (cta-catalogue-schema-create ctacatalogue) set_property(TARGET cta-catalogue-schema-create APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH}) -set_property(TARGET cta-catalogue-schema-create APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +if (OCCI_SUPPORT) + set_property(TARGET cta-catalogue-schema-create APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +endif() install (TARGETS cta-catalogue-schema-create DESTINATION /usr/bin) install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-schema-create.1cta DESTINATION /usr/share/man/man1) @@ -217,7 +258,9 @@ add_executable(cta-catalogue-schema-drop DropSchemaCmdMain.cpp) target_link_libraries (cta-catalogue-schema-drop ctacatalogue ctadropschemacmd) set_property(TARGET cta-catalogue-schema-drop APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH}) -set_property(TARGET cta-catalogue-schema-drop APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +if (OCCI_SUPPORT) + set_property(TARGET cta-catalogue-schema-drop APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +endif () install (TARGETS cta-catalogue-schema-drop DESTINATION /usr/bin) install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-schema-drop.1cta DESTINATION /usr/share/man/man1) @@ -230,7 +273,9 @@ add_executable(cta-catalogue-schema-set-production target_link_libraries (cta-catalogue-schema-set-production ctacatalogue ctaschemachecker) set_property(TARGET cta-catalogue-schema-set-production APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH}) -set_property(TARGET cta-catalogue-schema-set-production APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +if (OCCI_SUPPORT) + set_property(TARGET cta-catalogue-schema-set-production APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +endif () install (TARGETS cta-catalogue-schema-set-production DESTINATION /usr/bin) install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-schema-set-production.1cta DESTINATION /usr/share/man/man1) @@ -242,7 +287,9 @@ add_executable(cta-database-poll target_link_libraries (cta-database-poll ctacatalogue) set_property(TARGET cta-database-poll APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH}) -set_property(TARGET cta-database-poll APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +if (OCCI_SUPPORT) + set_property(TARGET cta-database-poll APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +endif () install (TARGETS cta-database-poll DESTINATION /usr/bin) install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-database-poll.1cta DESTINATION /usr/share/man/man1) @@ -254,7 +301,9 @@ add_executable(cta-catalogue-admin-user-create target_link_libraries(cta-catalogue-admin-user-create ctacatalogue) set_property(TARGET cta-catalogue-admin-user-create APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH}) -set_property(TARGET cta-catalogue-admin-user-create APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +if (OCCI_SUPPORT) + set_property(TARGET cta-catalogue-admin-user-create APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +endif () install(TARGETS cta-catalogue-admin-user-create DESTINATION /usr/bin) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-admin-user-create.1cta DESTINATION /usr/share/man/man1) @@ -266,7 +315,9 @@ add_executable(cta-catalogue-schema-verify target_link_libraries(cta-catalogue-schema-verify ctacatalogue ctaschemachecker) set_property(TARGET cta-catalogue-schema-verify APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH}) -set_property(TARGET cta-catalogue-schema-verify APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +if (OCCI_SUPPORT) + set_property(TARGET cta-catalogue-schema-verify APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH}) +endif () install (TARGETS cta-catalogue-schema-verify DESTINATION /usr/bin) install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-schema-verify.1cta DESTINATION /usr/share/man/man1) diff --git a/catalogue/CatalogueFactoryFactory.cpp b/catalogue/CatalogueFactoryFactory.cpp index 0bbed578cd8cc885c4513fe6a66c8946beae5ab6..8e44be05717fa805df7cafa958f1e2df208ee00f 100644 --- a/catalogue/CatalogueFactoryFactory.cpp +++ b/catalogue/CatalogueFactoryFactory.cpp @@ -19,9 +19,13 @@ #include "catalogue/CatalogueFactoryFactory.hpp" #include "catalogue/InMemoryCatalogueFactory.hpp" -#include "catalogue/OracleCatalogueFactory.hpp" #include "catalogue/PostgresqlCatalogueFactory.hpp" +#ifdef SUPPORT_OCCI + #include "catalogue/OracleCatalogueFactory.hpp" +#endif + + namespace cta { namespace catalogue { @@ -38,9 +42,11 @@ std::unique_ptr<CatalogueFactory> CatalogueFactoryFactory::create( switch (login.dbType) { case rdbms::Login::DBTYPE_IN_MEMORY: return std::make_unique<InMemoryCatalogueFactory>(log, nbConns, nbArchiveFileListingConns, maxTriesToConnect); +#ifdef SUPPORT_OCCI case rdbms::Login::DBTYPE_ORACLE: return std::make_unique<OracleCatalogueFactory>(log, login, nbConns, nbArchiveFileListingConns, maxTriesToConnect); +#endif case rdbms::Login::DBTYPE_POSTGRESQL: return std::make_unique<PostgresqlCatalogueFactory>(log, login, nbConns, nbArchiveFileListingConns, maxTriesToConnect); case rdbms::Login::DBTYPE_SQLITE: diff --git a/catalogue/CreateSchemaCmd.cpp b/catalogue/CreateSchemaCmd.cpp index f994f3672133e3d44833d444f6b1783d3bb62c5c..65c0dbd497b4324f29774ff0822b820fa828af4e 100644 --- a/catalogue/CreateSchemaCmd.cpp +++ b/catalogue/CreateSchemaCmd.cpp @@ -17,7 +17,9 @@ #include "catalogue/CreateSchemaCmd.hpp" #include "catalogue/CreateSchemaCmdLineArgs.hpp" +#ifdef SUPPORT_OCCI #include "catalogue/OracleCatalogueSchema.hpp" +#endif #include "catalogue/PostgresCatalogueSchema.hpp" #include "catalogue/SqliteCatalogueSchema.hpp" #include "catalogue/VersionedCatalogueSchemas.hpp" @@ -84,6 +86,7 @@ int CreateSchemaCmd::exceptionThrowingMain(const int argc, char *const *const ar } } break; +#ifdef SUPPORT_OCCI case rdbms::Login::DBTYPE_ORACLE: { if (cmdLineArgs.catalogueVersion) { @@ -95,6 +98,7 @@ int CreateSchemaCmd::exceptionThrowingMain(const int argc, char *const *const ar } } break; +#endif case rdbms::Login::DBTYPE_NONE: throw exception::Exception("Cannot create a catalogue without a database type"); default: diff --git a/catalogue/SchemaSqlStatementsReader.cpp b/catalogue/SchemaSqlStatementsReader.cpp index 5d8b0c060bd77f41623f39faacd371a695a3792f..91e79130bdd190655fbdfab56b101d8b08434a0b 100644 --- a/catalogue/SchemaSqlStatementsReader.cpp +++ b/catalogue/SchemaSqlStatementsReader.cpp @@ -24,7 +24,9 @@ #include "SchemaSqlStatementsReader.hpp" #include "SqliteCatalogueSchema.hpp" #include "PostgresCatalogueSchema.hpp" +#ifdef SUPPORT_OCCI #include "OracleCatalogueSchema.hpp" +#endif #include "common/exception/Exception.hpp" #include "common/utils/utils.hpp" @@ -59,7 +61,11 @@ std::list<std::string> SchemaSqlStatementsReader::getStatements() { schema.reset(new PostgresCatalogueSchema); break; case rdbms::Login::DBTYPE_ORACLE: +#ifdef SUPPORT_OCCI schema.reset(new OracleCatalogueSchema); +#else + throw exception::Exception("Oracle Catalogue Schema is not supported. Compile CTA with Oracle support."); +#endif break; case rdbms::Login::DBTYPE_NONE: throw exception::Exception("Cannot get statements without a database type"); @@ -95,8 +101,10 @@ std::string SchemaSqlStatementsReader::getDatabaseType() { return "sqlite"; case rdbms::Login::DBTYPE_POSTGRESQL: return "postgres"; +#ifdef SUPPORT_OCCI case rdbms::Login::DBTYPE_ORACLE: return "oracle"; +#endif case rdbms::Login::DBTYPE_NONE: throw exception::Exception("The database type should not be DBTYPE_NONE"); default: diff --git a/continuousintegration/orchestration/run_systemtest.sh b/continuousintegration/orchestration/run_systemtest.sh index 8d15bbc3added20088156d115942cfe5a94136fc..d9562cc554baf3ddfdfe877030f0220d295c6b0a 100755 --- a/continuousintegration/orchestration/run_systemtest.sh +++ b/continuousintegration/orchestration/run_systemtest.sh @@ -145,6 +145,13 @@ if [ ! -z "${error}" ]; then exit 1 fi +# ORACLE_SUPPORT is an external variable of the gitlab-ci to use postgres when CTA is compiled without Oracle +if [ $ORACLE_SUPPORT == "OFF" ] ; then + database_configmap="internal_postgres.yaml" + CREATE_OPTS="${CREATE_OPTS} -d ${database_configmap}" + useoracle=0 +fi + if [ $useoracle == 1 ] ; then database_configmap=$(find /opt/kubernetes/CTA/ | grep yaml$ | grep database | head -1) if [ "-${database_configmap}-" == "--" ]; then diff --git a/cta.spec.in b/cta.spec.in index 725986f4e84fa744741b14bde6d3c5f11feffebf..26a5786fef3341186f91d24f0f2021bdd9898a1b 100644 --- a/cta.spec.in +++ b/cta.spec.in @@ -9,6 +9,7 @@ %define usingObjectstore @RPM_USINGOBJECTSTORE@ %define schedOpt @RPM_SCHEDOPT@ +%define oracleOpt @RPM_ORACLE@ # Neutral packaging (for srpm) #----------------------------- @@ -80,7 +81,7 @@ The CTA project is the CERN Tape Archive system. mkdir -p build cd build # The cmake step does the selection between client/server compilation or just client -CTA_VERSION=%{ctaVersion} cmake3 .. -DCOMPILE_PACKAGING:STRING=0 -DVCS_VERSION=%{ctaRelease} %{schedOpt} +CTA_VERSION=%{ctaVersion} cmake3 .. -DCOMPILE_PACKAGING:STRING=0 -DVCS_VERSION=%{ctaRelease} %{schedOpt} %{oracleOpt} # Workaround for the inability of cmake to handle properly the dependencies to generated code. %{__make} -s %{_smp_mflags} -k || true %{__make} -s %{_smp_mflags} diff --git a/frontend-grpc/CMakeLists.txt b/frontend-grpc/CMakeLists.txt index 33f62c0d4da224f5d1d00e424403245bb525e90e..ea786df425886763766a2ec2ed30a0346042e22a 100644 --- a/frontend-grpc/CMakeLists.txt +++ b/frontend-grpc/CMakeLists.txt @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.17) find_package(Protobuf3 REQUIRED) find_package(GRPC REQUIRED) diff --git a/rdbms/wrapper/CMakeLists.txt b/rdbms/wrapper/CMakeLists.txt index 48c155eabfda4a30dabb5e59e2bc567365040b22..d9fdb0f7b58f5eb2d45cd39d758ce142beae4b0c 100644 --- a/rdbms/wrapper/CMakeLists.txt +++ b/rdbms/wrapper/CMakeLists.txt @@ -18,23 +18,29 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") find_package (sqlite REQUIRED) find_package (postgres REQUIRED) -find_package (oracle-instantclient REQUIRED) include_directories (${POSTGRES_INCLUDE_DIRS}) -include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS}) + +if (OCCI_SUPPORT) + find_package (oracle-instantclient REQUIRED) + include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS}) + add_definitions( -DSUPPORT_OCCI ) +endif() set (RDBMS_WRAPPER_LIB_SRC_FILES ColumnNameToIdx.cpp ColumnNameToIdxAndType.cpp - ConnWrapper.cpp ConnFactory.cpp - RsetWrapper.cpp - StmtWrapper.cpp + ConnFactoryFactory.cpp + ConnWrapper.cpp ParamNameToIdx.cpp + RsetWrapper.cpp Sqlite.cpp SqliteConn.cpp SqliteConnFactory.cpp SqliteRset.cpp - SqliteStmt.cpp) + SqliteStmt.cpp + StmtWrapper.cpp +) set (RDBMS_WRAPPER_LIB_SRC_FILES ${RDBMS_WRAPPER_LIB_SRC_FILES} @@ -44,16 +50,17 @@ set (RDBMS_WRAPPER_LIB_SRC_FILES PostgresStmt.cpp PostgresColumn.cpp) -set (RDBMS_WRAPPER_LIB_SRC_FILES - ${RDBMS_WRAPPER_LIB_SRC_FILES} - ConnFactoryFactory.cpp - OcciColumn.cpp - OcciConn.cpp - OcciConnFactory.cpp - OcciEnv.cpp - OcciEnvSingleton.cpp - OcciRset.cpp - OcciStmt.cpp) +if (OCCI_SUPPORT) + set (RDBMS_WRAPPER_LIB_SRC_FILES + ${RDBMS_WRAPPER_LIB_SRC_FILES} + OcciColumn.cpp + OcciConn.cpp + OcciConnFactory.cpp + OcciEnv.cpp + OcciEnvSingleton.cpp + OcciRset.cpp + OcciStmt.cpp) +endif() add_library (ctardbmswrapper SHARED ${RDBMS_WRAPPER_LIB_SRC_FILES}) @@ -63,18 +70,27 @@ set_property(TARGET ctardbmswrapper PROPERTY VERSION "${CTA_LIBVERSION}") target_link_libraries (ctardbmswrapper ctacommon ${SQLITE_LIBRARIES} - ${POSTGRES_LIBRARIES} - ${ORACLE-INSTANTCLIENT_LIBRARIES}) + ${POSTGRES_LIBRARIES}) + +if (OCCI_SUPPORT) + target_link_libraries (ctardbmswrapper ${ORACLE-INSTANTCLIENT_LIBRARIES}) +endif() install (TARGETS ctardbmswrapper DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) set(RDBMS_WRAPPER_UNIT_TESTS_LIB_SRC_FILES ConnTest.cpp - OcciColumnTest.cpp ParamNameToIdxTest.cpp PostgresStmtTest.cpp SqliteStmtTest.cpp) +if (OCCI_SUPPORT) + set(RDBMS_WRAPPER_UNIT_TESTS_LIB_SRC_FILES + ${RDBMS_WRAPPER_UNIT_TESTS_LIB_SRC_FILES} + OcciColumnTest.cpp + ) +endif() + add_library (ctardbmswrapperunittests SHARED ${RDBMS_WRAPPER_UNIT_TESTS_LIB_SRC_FILES}) set_property(TARGET ctardbmswrapperunittests PROPERTY SOVERSION "${CTA_SOVERSION}") diff --git a/rdbms/wrapper/ConnFactoryFactory.cpp b/rdbms/wrapper/ConnFactoryFactory.cpp index 9810adf6c2022abcdb8c932cbc6ccd269985ba3b..ec8c4026e85b45db74596e9e0258bef9da32d018 100644 --- a/rdbms/wrapper/ConnFactoryFactory.cpp +++ b/rdbms/wrapper/ConnFactoryFactory.cpp @@ -19,10 +19,13 @@ #include "common/exception/Exception.hpp" #include "rdbms/wrapper/ConnFactoryFactory.hpp" -#include "rdbms/wrapper/OcciConnFactory.hpp" #include "rdbms/wrapper/SqliteConnFactory.hpp" #include "rdbms/wrapper/PostgresConnFactory.hpp" +#ifdef SUPPORT_OCCI + #include "rdbms/wrapper/OcciConnFactory.hpp" +#endif + namespace cta { namespace rdbms { namespace wrapper { @@ -35,8 +38,10 @@ std::unique_ptr<ConnFactory> ConnFactoryFactory::create(const Login &login) { switch (login.dbType) { case Login::DBTYPE_IN_MEMORY: return std::make_unique<SqliteConnFactory>("file::memory:?cache=shared"); +#ifdef SUPPORT_OCCI case Login::DBTYPE_ORACLE: return std::make_unique<OcciConnFactory>(login.username, login.password, login.database); +#endif case Login::DBTYPE_SQLITE: return std::make_unique<SqliteConnFactory>(login.database); case Login::DBTYPE_POSTGRESQL: