diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 320a6e21ee770a360d0f71ccb8a1cc7cf74e7ca0..9695b6f80950698ca7a587ed2c649c8f10b43549 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,25 +1,33 @@ -FROM debian:bullseye +FROM debian:bookworm RUN apt-get update RUN apt-get install -y cmake -RUN apt-get install -y lcov +# iwyu is not a strict dependency here, but in the cppinttests. +RUN apt-get install -y lcov iwyu RUN apt-get install -y doxygen graphviz -RUN apt-get install -y clang-format-11 clang-tidy-11 -RUN apt-get install -y python3-pip -RUN apt-get install -y git +RUN apt-get install -y clang-format-16 clang-tidy-16 +RUN apt-get install -y python3-pip python3-venv +RUN apt-get install -y git RUN apt-get install -y curl zip unzip tar - - -RUN apt-get install -y openjdk-11-jdk-headless - +RUN apt-get install -y perl pkg-config +RUN apt-get install -y openjdk-17-jdk-headless WORKDIR / +RUN python3 -m venv ./venv +RUN . ./venv/bin/activate COPY doc/requirements.txt doc-requirements.txt -RUN pip3 install -r doc-requirements.txt +RUN ./venv/bin/pip install -r doc-requirements.txt COPY requirements.txt build-requirements.txt -RUN pip3 install -r build-requirements.txt +RUN ./venv/bin/pip install -r build-requirements.txt +RUN ./venv/bin/conan profile detect + +ENV PATH=/venv/bin:$PATH COPY . /libcaosdb/ WORKDIR /libcaosdb RUN git rev-parse HEAD > libcaosdb_commit RUN rm -rf .git + +# build dependencies +RUN /venv/bin/conan install /libcaosdb --build=missing -s build_type=Debug +RUN /venv/bin/conan install /libcaosdb --build=missing -s build_type=Release diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 244fc7e7c5a84a02a0ad897bbb8d19f222f53dc3..f200853328d4da817249e4fbebd9540e53256c31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,7 +78,7 @@ code_style: tags: [ docker ] stage: test script: - - clang-format-11 --dry-run --verbose --Werror $(find test/ src/ include/ -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.h.in") + - clang-format-16 --dry-run --verbose --Werror $(find test/ src/ include/ -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.h.in") allow_failure: true @@ -86,29 +86,23 @@ code_style: build_vcpkg: tags: [ docker ] stage: test - script: - - apt update && apt install -y pkg-config + script: - cd vcpkg && git fetch origin 5d3798ac7388ca66c169773e46103b14077b76a4 && cd .. - make vcpkg-build-release allow_failure: true # unit tests with gtest -test: +test-debug: + tags: [ docker ] + stage: test + script: + - make test-debug + +test-release: tags: [ docker ] stage: test script: - - conan profile detect - - make test - # - mkdir build - # - cd build - # - VERSION="$(conan inspect --raw version ..)" - # - conan install -s "compiler.libcxx=libstdc++11" --build=missing -o build_acm=True . #.. "caosdb/$VERSION@_/_" - # - conan build -s "compiler.libcxx=libstdc++11" . --s build_type=Debug - # - cd build/Debug - # - cmake --build . -j - # - cmake --build . -j --target unit_test_coverage - # - cmake --build . -j --target cxxcaosdbcli - # - cmake --build . -j --target ccaosdbcli # Disabled until it compiles again. + - make test-release trigger_prepare: # Calculate the branch name @@ -237,7 +231,6 @@ trigger_inttest: tags: [ cached-dind ] stage: deploy script: - - conan profile detect - make doc - cp -r build/Release/doc/sphinx_out ./public diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ed4a7df88aa517e5ca84e6b852dfdca8c6007e4..c8f7292bd2afd194d532a198f73e3c6d2c36c92a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ project(liblinkahead set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) - +set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) @@ -145,11 +145,22 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) ############################################################################### find_package(gRPC CONFIG REQUIRED) -find_package(Boost COMPONENTS json REQUIRED) -find_package(Boost COMPONENTS filesystem REQUIRED) -find_package(Boost COMPONENTS log REQUIRED) -find_package(Boost COMPONENTS thread REQUIRED) -find_package(Boost COMPONENTS system REQUIRED) + +# boost +find_package(Boost REQUIRED COMPONENTS json filesystem log thread system log_setup) +# find_package(Boost REQUIRED COMPONENTS filesystem ) +# find_package(Boost REQUIRED COMPONENTS log ) +# find_package(Boost REQUIRED COMPONENTS thread ) +# find_package(Boost REQUIRED COMPONENTS system ) + +# Boost settings +set(Boost_USE_STATIC_LIBS ON) # only find static libs +set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and +set(Boost_USE_RELEASE_LIBS ON) # only find release libs +set(Boost_USE_MULTITHREADED ON) +set(Boost_USE_STATIC_RUNTIME ON) # link Boost Static libraries + + find_package(GTest REQUIRED) # print include directories for debugging @@ -271,7 +282,7 @@ if(_LINTING) add_compiler_flag("-Wall") add_compiler_flag("-Wextra") add_compiler_flag("-pedantic") - # add_compiler_flag("-Werror") # removed until issue #71 is resolved + add_compiler_flag("-Werror") message(STATUS "PEDANTIC_CMAKE_CXX_FLAGS: [${PEDANTIC_CMAKE_CXX_FLAGS}]") set(TARGET_LINKAHEAD_COMPILE_FLAGS "${TARGET_LINKAHEAD_COMPILE_FLAGS} ${PEDANTIC_CMAKE_CXX_FLAGS}") @@ -309,7 +320,7 @@ if(_LINTING) ) endif() - find_program(clang_tidy NAMES clang-tidy clang-tidy-11) + find_program(clang_tidy NAMES clang-tidy clang-tidy-16) if(NOT clang_tidy) message(WARNING "clang-tidy: Not found") else() @@ -428,7 +439,7 @@ install(FILES ${PROJECT_SOURCE_DIR}/linkaheadConfigVersion.cmake ####################################################### option(AUTOFORMATTING "call clang-format at configure time" ON) if(AUTOFORMATTING AND NOT SKIP_LINTING) - find_program(clang_format NAMES clang-format-11 clang-format) + find_program(clang_format NAMES clang-format-16 clang-format) file(GLOB format_test_sources test/*.cpp test/*.h test/*.h.in) execute_process(COMMAND ${clang_format} -i --verbose ${liblinkahead_INCL} ${liblinkahead_SRC} ${liblinkahead_TEST_SRC} diff --git a/Makefile b/Makefile index 49609d5bf07586b762dd75e6dce856f77622ff91..707209ca54adf20506752c74eb8cfa57f9bfefce 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ # This Makefile is a wrapper for several other scripts. -CLANG_FORMAT ?= clang-format-11 +CLANG_FORMAT ?= clang-format-16 CONAN_SETTINGS = "compiler.libcxx=libstdc++11" # OS specific handling, with code by Ken Jackson and oHo, @@ -49,6 +49,15 @@ help: @echo -e " conan-create - Create Conan binary package in the local conan\n"\ " repostory." @echo " conan - Install dependencies, then build and install package." + @echo " doc - Generate documentation." + @echo " conan-debug - Install dependencies and create Conan binary package in Debug mode." + @echo " conan-build - Build the Conan package." + @echo " conan-build-debug - Build the Conan package in Debug mode." + @echo " vcpkg-install - Install dependencies with Vcpkg." + @echo " vcpkg-build-release - Build the project with Vcpkg in Release mode." + @echo " test-debug - Install dependencies, build the project in Debug mode, and run the tests." + @echo " test-release - Install dependencies, build the project in Release mode, and run the tests." + @echo " clean - Remove build directory." style: $(CLANG_FORMAT) -i --verbose \ @@ -92,27 +101,42 @@ conan-debug: conan-install-debug conan-create-debug conan-build: conan build . -s $(CONAN_SETTINGS) -s build_type=Release +.PHONY: conan-build conan-build-debug: + @command -v lcov || (echo "Could not find 'lcov', exiting."; exit 1) + @command -v clang-tidy || command -v clang-tidy-16 || \ + (echo "Could not find 'clang-tidy'(-16), exiting."; exit 1) conan build . -s $(CONAN_SETTINGS) -s build_type=Debug - +.PHONY: conan-build-debug vcpkg-install: ./vcpkg/bootstrap-vcpkg.sh -disableMetrics\ &&vcpkg/vcpkg install +.PHONY: vcpkg-install vcpkg-build-release: vcpkg-install mkdir -p build/build_tools\ && cp vcpkg_installed/x64-linux/tools/grpc/grpc_cpp_plugin build/build_tools\ && cd build\ - && cmake -S .. -B . -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux -DCMAKE_BUILD_TYPE=Release\ + && cmake -S .. -B . -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux-release -DCMAKE_BUILD_TYPE=Release\ && cmake --build . +.PHONY: vcpkg-build-release -ctest: +ctest-debug: cd build/Debug && ctest +.PHONY: ctest-debug + +ctest-release: + cd build/Release && ctest +.PHONY: ctest-release + +test-debug: conan-install-debug conan-build-debug ctest-debug +.PHONY: test-debug -test: conan-install-debug conan-build-debug ctest - +test-release: conan-install-deps conan-build ctest-release +.PHONY: test-release clean: - rm -rf build \ No newline at end of file + rm -rf build +.PHONY: clean diff --git a/doc/DEPENDENCIES.md b/doc/DEPENDENCIES.md index dbbd559904ce9314891a8d5dcf1d332929136474..543d02c00d535589103d9d7c39dea708b8846914 100644 --- a/doc/DEPENDENCIES.md +++ b/doc/DEPENDENCIES.md @@ -32,7 +32,7 @@ python packages from the `doc/requirements.txt` file ## Build and run tests ## ``` ->=clang-tidy-11 +clang-tidy-16 >=gtest-1.10.0 ``` @@ -40,11 +40,11 @@ python packages from the `doc/requirements.txt` file ``` >=gcc-10.2.0 ->=lcov-1.15 +>=lcov-1.16 ``` ## Formatting ## ``` ->=clang-formatting-11 +>=clang-format-16 ``` diff --git a/include/linkahead/authentication.h b/include/linkahead/authentication.h index d4596ae54c994435ea66d5d7204ed6ee2632e48c..2770bcfdda5fbef96e8005f9e723a3f84358e333 100644 --- a/include/linkahead/authentication.h +++ b/include/linkahead/authentication.h @@ -27,15 +27,15 @@ * @date 2021-06-28 * @brief Configuration and setup of the client authentication. */ -#include "linkahead/utility.h" // for base64_encode #include <grpcpp/security/auth_context.h> // for AuthContext -#include <grpcpp/security/credentials.h> // for CallCredentials +#include <grpcpp/security/credentials.h> // for CallCredentials, MetadataC... +#include <grpcpp/support/config.h> // for string #include <grpcpp/support/interceptor.h> // for Status -#include <grpcpp/support/status.h> // for Status #include <grpcpp/support/string_ref.h> // for string_ref #include <map> // for multimap #include <memory> // for shared_ptr -#include <string> // for string +#include <string> // for string, basic_string +#include "linkahead/utility.h" // for base64_encode namespace linkahead { namespace authentication { diff --git a/include/linkahead/configuration.h b/include/linkahead/configuration.h index a25727db4713fca91e3468d66244bebfb8da4c8d..bdb87fd3f8133485649af3561fb065455f7a993f 100644 --- a/include/linkahead/configuration.h +++ b/include/linkahead/configuration.h @@ -104,7 +104,6 @@ public: class ConfigurationManager { public: static ConfigurationManager &GetInstance(); - ; /** * See mReset. @@ -156,7 +155,7 @@ private: JsonValue json_configuration; static ConfigurationManager mInstance; - inline ConfigurationManager() + inline ConfigurationManager() noexcept : json_configuration(nullptr){ // InitializeDefaults(); }; diff --git a/include/linkahead/connection.h b/include/linkahead/connection.h index 97fdcd97f28d5a5e0ab3fa8347afcede425d153d..1f47a421cc123688051a45514fcffaf94179d9c7 100644 --- a/include/linkahead/connection.h +++ b/include/linkahead/connection.h @@ -173,7 +173,7 @@ private: static ConnectionManager mInstance; - inline ConnectionManager(){}; + ConnectionManager() = default; auto mHasConnection(const std::string &name) const -> bool; diff --git a/include/linkahead/entity.h b/include/linkahead/entity.h index 1c75813c3ab4af95f4deb30cd6c4c60eaf135cb7..fd08014634a1a650b6fd3c4cac3e64a6e39e8890 100644 --- a/include/linkahead/entity.h +++ b/include/linkahead/entity.h @@ -29,24 +29,24 @@ #ifndef LINKAHEAD_ENTITY_H #define LINKAHEAD_ENTITY_H -#include "linkahead/data_type.h" // for DataType -#include "caosdb/entity/v1/main.pb.h" // for RepeatedPtrField -#include "linkahead/file_descriptor.h" // for FileDescriptor -#include "linkahead/logging.h" // for LINKAHEAD_LOG_WARN -#include "linkahead/message_code.h" // for get_message_code -#include "linkahead/protobuf_helper.h" // for get_arena -#include "linkahead/status_code.h" // for StatusCode -#include "linkahead/value.h" // for Value -#include <cstdint> // for int64_t -#include <filesystem> // for path -#include <google/protobuf/arena.h> // for Arena #include <google/protobuf/message.h> // for RepeatedPtrField -#include <iterator> // for iterator, output_iterato... +#include <cstdint> // for int64_t +#include <filesystem> // for path, exists, is_directory +#include <iosfwd> // for ptrdiff_t +#include <iterator> // for output_iterator_tag #include <map> // for map #include <stdexcept> // for out_of_range -#include <string> // for string, basic... -#include <utility> // for move +#include <string> // for string, basic_string, operator== +#include <utility> // for move, pair #include <vector> // for vector +#include "caosdb/entity/v1/main.pb.h" // for Entity, EntityRole, Property +#include "linkahead/data_type.h" // for DataType, AtomicDataType +#include "linkahead/file_descriptor.h" // for FileDescriptor +#include "linkahead/logging.h" // for LoggerOutputStream, LINKAHEAD... +#include "linkahead/message_code.h" // for get_message_code, MessageCode +#include "linkahead/protobuf_helper.h" // for ScalarProtoMessageWrapper +#include "linkahead/status_code.h" // for StatusCode +#include "linkahead/value.h" // for Value, AbstractValue, Arena // IWYU pragma: no_include "net/proto2/public/repeated_field.h" namespace linkahead::entity { @@ -242,8 +242,14 @@ protected: mutable std::map<int, T> cache; private: - class iterator : public std::iterator<std::output_iterator_tag, T> { + class iterator { public: + using iterator_category = std::output_iterator_tag; + using value_type = T; + using difference_type = std::ptrdiff_t; + using pointer = T *; + using reference = T &; + explicit iterator(const RepeatedPtrFieldWrapper<T, P> *instance, int index = 0); // TODO(henrik) add unit tests auto operator*() const -> T &; diff --git a/include/linkahead/file_transmission/download_request_handler.h b/include/linkahead/file_transmission/download_request_handler.h index deec6c23eefe8b2b29dd689eb91c805dd3d9b593..8419a0e3ab110a8fd0da272d3dbda16dc58cb52b 100644 --- a/include/linkahead/file_transmission/download_request_handler.h +++ b/include/linkahead/file_transmission/download_request_handler.h @@ -49,17 +49,18 @@ #ifndef LINKAHEAD_FILE_TRANSMISSION_DOWNLOAD_REQUEST_HANDLER_H #define LINKAHEAD_FILE_TRANSMISSION_DOWNLOAD_REQUEST_HANDLER_H -#include "linkahead/file_descriptor.h" // for FileDescriptor -#include "caosdb/entity/v1/main.pb.h" // for FileTransmissionS... -#include "caosdb/entity/v1/main.grpc.pb.h" // for FileDownloadResponse -#include "linkahead/file_transmission/file_writer.h" // for FileWriter -#include "linkahead/handler_interface.h" // for HandlerTag, Handl... -#include <cstdint> // for uint64_t #include <grpcpp/client_context.h> // for ClientContext #include <grpcpp/completion_queue.h> // for CompletionQueue #include <grpcpp/support/async_stream.h> // for ClientAsyncReader +#include <grpcpp/support/interceptor.h> // for InterceptionHoo... #include <grpcpp/support/status.h> // for Status +#include <cstdint> // for uint64_t #include <memory> // for unique_ptr +#include "caosdb/entity/v1/main.grpc.pb.h" // for FileTransmissio... +#include "caosdb/entity/v1/main.pb.h" // for FileDownloadRes... +#include "linkahead/file_descriptor.h" // for FileDescriptor +#include "linkahead/file_transmission/file_writer.h" // for FileWriter +#include "linkahead/handler_interface.h" // for HandlerTag, Han... namespace linkahead::transaction { using caosdb::entity::v1::FileDownloadRequest; diff --git a/include/linkahead/result_set.h b/include/linkahead/result_set.h index d12d417635f38478d2262cf8dceb2dcedfeb820e..0ada000f0faaec395ace73f725d504f44a473dc4 100644 --- a/include/linkahead/result_set.h +++ b/include/linkahead/result_set.h @@ -21,12 +21,12 @@ #ifndef LINKAHEAD_RESULT_SET_H #define LINKAHEAD_RESULT_SET_H -#include "linkahead/entity.h" // for Entity, FileDe... -#include <algorithm> // for max -#include <iterator> // for iterator, next -#include <memory> // for unique_ptr +#include <iosfwd> // for ptrdiff_t +#include <iterator> // for output_iterator_tag +#include <memory> // for unique_ptr, make_unique #include <utility> // for move #include <vector> // for vector +#include "linkahead/entity.h" // for Entity // IWYU pragma: no_include <ext/alloc_traits.h> namespace linkahead::transaction { @@ -56,8 +56,14 @@ public: auto end() const -> iterator; private: - class iterator : public std::iterator<std::output_iterator_tag, Entity> { + class iterator { public: + using iterator_category = std::output_iterator_tag; + using value_type = Entity; + using difference_type = std::ptrdiff_t; + using pointer = Entity *; + using reference = Entity &; + explicit iterator(const ResultSet *result_set, int index = 0); auto operator*() const -> const Entity &; auto operator++() -> iterator &; diff --git a/include/linkahead/result_table.h b/include/linkahead/result_table.h index bbdbf363e0932b9fcea5df2c1db18390f99fd5c6..c6a122973391f491b121bf75bb179c63d955407c 100644 --- a/include/linkahead/result_table.h +++ b/include/linkahead/result_table.h @@ -21,10 +21,11 @@ #ifndef LINKAHEAD_RESULT_TABLE_H #define LINKAHEAD_RESULT_TABLE_H -#include "linkahead/value.h" // for Value -#include <iterator> // for iterator, next +#include <iosfwd> // for ptrdiff_t +#include <iterator> // for output_iterator_tag #include <memory> // for unique_ptr #include <string> // for string +#include "linkahead/value.h" // for Value namespace linkahead::transaction { using linkahead::entity::Value; @@ -82,8 +83,14 @@ public: friend class ResultTableImpl; private: - class HeaderIterator : std::iterator<std::output_iterator_tag, ResultTableColumn> { + class HeaderIterator { public: + using iterator_category = std::output_iterator_tag; + using value_type = ResultTableColumn; + using difference_type = std::ptrdiff_t; + using pointer = ResultTableColumn *; + using reference = ResultTableColumn &; + explicit HeaderIterator(const ResultTable *result_table, int index = 0); HeaderIterator(const HeaderIterator &other); auto operator*() const -> const ResultTableColumn &; @@ -99,8 +106,14 @@ private: const ResultTable *result_table; }; - class RowIterator : std::iterator<std::output_iterator_tag, ResultTableRow> { + class RowIterator { public: + using iterator_category = std::output_iterator_tag; + using value_type = linkahead::transaction::ResultTableRow; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + explicit RowIterator(const ResultTable *result_table, int index = 0); RowIterator(const RowIterator &other); auto operator*() const -> const ResultTableRow &; diff --git a/include/linkahead/transaction.h b/include/linkahead/transaction.h index efe2ae0ff69b244ffb09245d1ff3b31a92e9b5bf..84e7829edf61a071328e7e7824367a00c2cee9c8 100644 --- a/include/linkahead/transaction.h +++ b/include/linkahead/transaction.h @@ -21,29 +21,27 @@ #ifndef LINKAHEAD_TRANSACTION_H #define LINKAHEAD_TRANSACTION_H -#include "linkahead/entity.h" // for Entity, FileDe... -#include "caosdb/entity/v1/main.pb.h" // for EntityTransact... -#include "caosdb/entity/v1/main.grpc.pb.h" // for MultiTransacti... -#include "linkahead/file_descriptor.h" // for FileDescriptor -#include "linkahead/handler_interface.h" // for HandlerInterface -#include "linkahead/transaction_handler.h" // for EntityTransactionHandler -#include "linkahead/logging.h" // for LINKAHEAD_LOG_ERR... -#include "linkahead/protobuf_helper.h" // for get_arena -#include "linkahead/status_code.h" // for StatusCode -#include "linkahead/result_set.h" // for ResultSet -#include "linkahead/result_table.h" // for ResultTable -#include "linkahead/transaction_status.h" // for StatusCode -#include "linkahead/value.h" // for Value -#include <future> // for async, future -#include <google/protobuf/arena.h> // for Arena -#include <google/protobuf/util/json_util.h> // for MessageToJsonS... +#include <google/protobuf/util/json_util.h> // for JsonPrintOptions, Messag... #include <grpcpp/completion_queue.h> // for CompletionQueue -#include <iterator> // for iterator, next +#include <future> // for future +#include <iterator> // for next #include <map> // for map -#include <memory> // for unique_ptr +#include <memory> // for unique_ptr, shared_ptr #include <mutex> // for mutex -#include <string> // for string +#include <string> // for string, basic_string #include <vector> // for vector +#include "caosdb/entity/v1/main.grpc.pb.h" // for EntityTransactionService +#include "caosdb/entity/v1/main.pb.h" // for MultiTransactionRequest +#include "linkahead/entity.h" // for Entity +#include "linkahead/file_descriptor.h" // for FileDescriptor +#include "linkahead/handler_interface.h" // for logger_name, HandlerInte... +#include "linkahead/logging.h" // for LINKAHEAD_LOG_ERROR_AND_... +#include "linkahead/protobuf_helper.h" // for get_arena +#include "linkahead/result_set.h" // for MultiResultSet, ResultSet +#include "linkahead/result_table.h" // for ResultTable +#include "linkahead/status_code.h" // for StatusCode +#include "linkahead/transaction_status.h" // for StatusCode, TransactionS... +#include "linkahead/value.h" // for Value /** * Do all necessary checks and assure that another retrieval (by id or by diff --git a/include/linkahead/transaction_status.h b/include/linkahead/transaction_status.h index 4653b2a6d5ddc8b88b85b6de8e8641ca44b3a4ed..6ef62a95c8484d02d60ca08636bead78d3c96544 100644 --- a/include/linkahead/transaction_status.h +++ b/include/linkahead/transaction_status.h @@ -40,7 +40,7 @@ using linkahead::exceptions::TransactionTypeError; * Define static factory method in the TransactionStatus class. */ #define LINKAHEAD_TRANSACTION_STATUS_DEFAULT_FACTORY(_StatusName, _StatusCode) \ - inline static auto _StatusName() -> const TransactionStatus & { \ + inline static auto _StatusName()->const TransactionStatus & { \ static const TransactionStatus instance(_StatusCode, \ linkahead::get_status_description(_StatusCode)); \ return instance; \ diff --git a/src/linkahead/acm/user.cpp b/src/linkahead/acm/user.cpp index 392c7e60fcc9ed1d1ca5833367e600d5f2f5c775..39c88f1501a13f55d2f3a81e0a6f37f7ef679c1b 100644 --- a/src/linkahead/acm/user.cpp +++ b/src/linkahead/acm/user.cpp @@ -19,9 +19,9 @@ * */ #include "linkahead/acm/user.h" -#include "linkahead/acm/user_impl.h" // for UserImpl +#include "linkahead/acm/user_impl.h" // for UserImpl #include "caosdb/acm/v1alpha1/main.pb.h" // for ProtoUser -#include "linkahead/protobuf_helper.h" // for ProtoMessageWrapper +#include "linkahead/protobuf_helper.h" // for ProtoMessageWrapper #include <utility> // for move namespace linkahead::acm { diff --git a/src/linkahead/acm/user_impl.h b/src/linkahead/acm/user_impl.h index 5cbe1ab8796970b8bd5eb830b31f5ce5e9cf0359..3ba072f0f4fa6052c3d8028fe68327a2eafefda0 100644 --- a/src/linkahead/acm/user_impl.h +++ b/src/linkahead/acm/user_impl.h @@ -20,7 +20,7 @@ */ #include "linkahead/acm/user.h" #include "caosdb/acm/v1alpha1/main.pb.h" // for ProtoUser -#include "linkahead/protobuf_helper.h" // for ProtoMessageWrapper +#include "linkahead/protobuf_helper.h" // for ProtoMessageWrapper #include <memory> // for unique_ptr #include <utility> // for move diff --git a/src/linkahead/authentication.cpp b/src/linkahead/authentication.cpp index 2d3cd96f2e4fa2360ebfe7c9b06dae82fb70e483..bebe747e32018e99a63b68337852016b38292e1c 100644 --- a/src/linkahead/authentication.cpp +++ b/src/linkahead/authentication.cpp @@ -19,13 +19,14 @@ * */ #include "linkahead/authentication.h" -#include "linkahead/utility.h" // for base64_encode -#include <grpcpp/security/credentials.h> // for MetadataCredentialsPlugin #include <grpcpp/security/auth_context.h> // for AuthContext +#include <grpcpp/security/credentials.h> // for MetadataCredentialsPlugin +#include <grpcpp/support/status.h> // for Status #include <map> // for multimap -#include <memory> // for allocator, shared_ptr +#include <memory> // for allocator, shared_ptr, uni... #include <string> // for basic_string, operator+ #include <utility> // for pair, move, make_pair +#include "linkahead/utility.h" // for base64_encode namespace linkahead::authentication { using grpc::AuthContext; diff --git a/src/linkahead/configuration.cpp b/src/linkahead/configuration.cpp index 1c60cfe4c9154a8e2077bd9f08bfdd348483f647..377c8241e7b72619e3898994dabdb013dc47fca0 100644 --- a/src/linkahead/configuration.cpp +++ b/src/linkahead/configuration.cpp @@ -19,31 +19,30 @@ * */ #include "linkahead/configuration.h" -#include "linkahead/authentication.h" // for Authenticator -#include "linkahead/connection.h" // for ConnectionManager -#include "linkahead/constants.h" // for LIBLINKAHEAD_CONF... -#include "linkahead/exceptions.h" // for ConfigurationE... -#include "linkahead/log_level.h" // for LINKAHEAD_DEFAULT... -#include "linkahead/logging.h" // for SinkConfiguration, Loggin... -#include "linkahead/status_code.h" // for StatusCode -#include "linkahead/utility.h" // for get_home_direc... -#include <boost/json/impl/object.hpp> // for object::at -#include <boost/json/object.hpp> // for object, objec... -#include <boost/json/string.hpp> // for string -#include <boost/json/string_view.hpp> // for string_view -#include <boost/json/value.hpp> // for value, key_va... -#include <boost/json/value_ref.hpp> // for object -#include <cassert> // for assert -#include <cstdlib> // for getenv -#include <cstring> // for strcmp -#include <exception> // IWYU pragma: keep -// IWYU pragma: no_include <bits/exception.h> -#include <grpcpp/security/credentials.h> // for SslCredentials +#include <grpcpp/security/credentials.h> // for SslCredentialsOptions, SslC... +#include <boost/json/impl/object.hpp> // for object::at, object::empty +#include <boost/json/object.hpp> // for object +#include <boost/json/string.hpp> // for string +#include <boost/json/value.hpp> // for value +#include <boost/json/value_ref.hpp> // for object +#include <cassert> // for assert +#include <cstdlib> // for getenv +#include <cstring> // for strcmp +#include <exception> // for exception #include <iterator> // for next #include <map> // for map +#include <ostream> // for basic_ios, basic_ostream #include <stdexcept> // for out_of_range -#include <string> // for string, operator+ -#include <utility> // for move +#include <string> // for basic_string, operator+ +#include <utility> // for pair, move +#include "linkahead/authentication.h" // for Authenticator, PlainPasswor... +#include "linkahead/connection.h" // for ConnectionManager +#include "linkahead/constants.h" // for LIBLINKAHEAD_CONFIGURATION_... +#include "linkahead/exceptions.h" // for ConfigurationError, Exception +#include "linkahead/log_level.h" // for LINKAHEAD_LOG_LEVEL_OFF +#include "linkahead/logging.h" // for FileSinkConfiguration, Cons... +#include "linkahead/status_code.h" // for StatusCode +#include "linkahead/utility.h" // for JsonValue, get_home_directory // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define WRAPPED_JSON_CONFIGURATION(obj) \ @@ -55,7 +54,7 @@ throw ConfigurationError("This LinkAhead client has not been configured."); \ } \ assert(WRAPPED_JSON_CONFIGURATION(this)->is_object()); \ - const auto &configuration = WRAPPED_JSON_CONFIGURATION(this) -> as_object(); \ + const auto &configuration = WRAPPED_JSON_CONFIGURATION(this)->as_object(); \ if (!configuration.contains("connections")) { \ throw ConfigurationError("This LinkAhead client hasn't any configured connections."); \ } \ diff --git a/src/linkahead/connection.cpp b/src/linkahead/connection.cpp index bff799b093741b81b90417446b3dc8ccf37916d4..717f7d96b5bffdb3e9b96d23d1ff731b920ad3b2 100644 --- a/src/linkahead/connection.cpp +++ b/src/linkahead/connection.cpp @@ -66,12 +66,9 @@ using linkahead::info::VersionInfo; using linkahead::transaction::Transaction; using linkahead::transaction::TransactionStatus; - ConnectionManager ConnectionManager::mInstance; -ConnectionManager &ConnectionManager::GetInstance() { - return mInstance; -} +ConnectionManager &ConnectionManager::GetInstance() { return mInstance; } Connection::Connection(const ConnectionConfiguration &configuration) { const std::string target = diff --git a/src/linkahead/file_transmission/download_request_handler.cpp b/src/linkahead/file_transmission/download_request_handler.cpp index 1d8d03b56cec5abeb2fbe40e38cc9d6c8f817102..ae1e9cb88199ccdf366c28b69622865e8b640c46 100644 --- a/src/linkahead/file_transmission/download_request_handler.cpp +++ b/src/linkahead/file_transmission/download_request_handler.cpp @@ -47,20 +47,19 @@ * > DEALINGS IN THE SOFTWARE. */ #include "linkahead/file_transmission/download_request_handler.h" -#include "linkahead/logging.h" // for LINKAHEAD_LOG_TRACE -#include "linkahead/protobuf_helper.h" // for get_arena -#include "linkahead/status_code.h" // for GENERIC_RPC_E... -#include "linkahead/transaction_status.h" // for TransactionStatus -#include <exception> // IWYU pragma: keep -#include <filesystem> // for operator<<, path #include <google/protobuf/arena.h> // for Arena #include <grpcpp/client_context.h> // for ClientContext #include <grpcpp/completion_queue.h> // for CompletionQueue #include <grpcpp/support/async_stream.h> // for ClientAsyncReader -#include <grpcpp/support/status.h> // for Status +#include <grpcpp/support/status.h> // for Status, StatusCode +#include <exception> // for exception #include <stdexcept> // for runtime_error -#include <string> // for string, opera... +#include <string> // for basic_string, operator+ #include <utility> // for move +#include "linkahead/logging.h" // for LoggerOutputStream, LINKAH... +#include "linkahead/protobuf_helper.h" // for get_arena +#include "linkahead/status_code.h" // for get_status_description +#include "linkahead/transaction_status.h" // for TransactionStatus // IWYU pragma: no_include <bits/exception.h> // namespace linkahead::transaction { diff --git a/src/linkahead/logging.cpp b/src/linkahead/logging.cpp index 642f2ae75c26c901704818ac633e419817c58cc7..a3060697b521fc35169a8b8ec19acbb08f249540 100644 --- a/src/linkahead/logging.cpp +++ b/src/linkahead/logging.cpp @@ -19,7 +19,8 @@ * */ #include "linkahead/logging.h" -#include "linkahead/log_level.h" +#include <boost/core/swap.hpp> // for swap +#include <boost/iterator/iterator_facade.hpp> #include <boost/log/attributes/clock.hpp> #include <boost/log/core/core.hpp> // for core #include <boost/log/core/record.hpp> @@ -27,13 +28,21 @@ #include <boost/log/sources/severity_channel_logger.hpp> #include <boost/log/utility/setup/from_settings.hpp> #include <boost/log/utility/setup/settings.hpp> +#include <boost/multi_index/detail/bidir_node_iterator.hpp> +#include <boost/operators.hpp> +#include <boost/preprocessor/seq/limits/enum_256.hpp> +#include <boost/preprocessor/seq/limits/size_256.hpp> +#include <boost/property_tree/detail/exception_implementation.hpp> +#include <boost/property_tree/detail/ptree_implementation.hpp> +#include <boost/smart_ptr/intrusive_ref_counter.hpp> #include <boost/smart_ptr/shared_ptr.hpp> -#include <cstdint> // for uint64_t -#include <filesystem> +#include <cstdint> +#include <filesystem> // for path #include <memory> #include <string> #include <utility> // for move #include <vector> +#include "linkahead/log_level.h" namespace linkahead::logging { using boost_logger_class = boost::log::sources::severity_channel_logger_mt<int, std::string>; diff --git a/src/linkahead/result_table.cpp b/src/linkahead/result_table.cpp index c08cc4db516f9b4c238cc3c5a7f18a90ea557cde..65283e3bd51d3614db6216146bea317ab96501ff 100644 --- a/src/linkahead/result_table.cpp +++ b/src/linkahead/result_table.cpp @@ -18,17 +18,15 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ -#include "linkahead/result_table.h" // for ResultTable, ResultTab... -#include "caosdb/entity/v1/main.pb.h" // for SelectQueryResult, Sel... -#include "linkahead/protobuf_helper.h" // for ScalarProtoMessageWrapper -#include "linkahead/result_table_impl.h" // for ResultTableImpl, Resul... -#include "linkahead/value.h" // for Value -#include <algorithm> // for max -#include <google/protobuf/repeated_field.h> // IWYU pragma: keep for RepeatedPtrField -#include <memory> // for unique_ptr -#include <string> // for string, operator== -#include <utility> // for move -#include <vector> // for vector +#include "linkahead/result_table.h" +#include <memory> // for unique_ptr +#include <string> // for string, operator==, basic_s... +#include <utility> // for move +#include <vector> // for vector +#include "caosdb/entity/v1/main.pb.h" // for SelectQueryResult, SelectQu... +#include "linkahead/protobuf_helper.h" // for ScalarProtoMessageWrapper +#include "linkahead/result_table_impl.h" // for ResultTableImpl, ResultTabl... +#include "linkahead/value.h" // for Value // IWYU pragma: no_include "net/proto2/public/repeated_field.h" namespace linkahead::transaction { @@ -106,8 +104,7 @@ auto ResultTable::GetRows() const noexcept -> RowIterator { return RowIterator(t ResultTable::RowIterator::RowIterator(const ResultTable *result_table_param, int index) : current_index(index), result_table(result_table_param) {} -ResultTable::RowIterator::RowIterator(const RowIterator &other) - : current_index(other.current_index), result_table(other.result_table) {} +ResultTable::RowIterator::RowIterator(const RowIterator &other) = default; auto ResultTable::RowIterator::size() const noexcept -> int { return this->result_table->delegate->wrapped->data_rows_size(); @@ -145,8 +142,7 @@ auto ResultTable::GetHeader() const noexcept -> HeaderIterator { return HeaderIt ResultTable::HeaderIterator::HeaderIterator(const ResultTable *result_table_param, int index) : current_index(index), result_table(result_table_param) {} -ResultTable::HeaderIterator::HeaderIterator(const HeaderIterator &other) - : current_index(other.current_index), result_table(other.result_table) {} +ResultTable::HeaderIterator::HeaderIterator(const HeaderIterator &other) = default; auto ResultTable::HeaderIterator::size() const noexcept -> int { return this->result_table->delegate->wrapped->header().columns_size(); diff --git a/src/linkahead/status_code_description.cpp b/src/linkahead/status_code_description.cpp index 59517c4763a2450d5c01675b54fe23a4a8b6955d..7183c38a362566347e52361a909825696fcbd1ea 100644 --- a/src/linkahead/status_code_description.cpp +++ b/src/linkahead/status_code_description.cpp @@ -18,10 +18,11 @@ * */ -#include "linkahead/status_code.h" // for StatusCode, ABORTED, ALREADY_EXISTS -#include <map> // for allocator, map +#include <map> // for map #include <stdexcept> // for out_of_range -#include <string> // for string, basic_string +#include <string> // for basic_string, string +#include <utility> // for pair +#include "linkahead/status_code.h" // for StatusCode, get_status_description namespace linkahead { diff --git a/src/linkahead/transaction.cpp b/src/linkahead/transaction.cpp index 2af4cadfef5a33cc33ae1648c19ffe73a6d99d7b..5fafb34b67cbb4324cd178e83184948d19a77cee 100644 --- a/src/linkahead/transaction.cpp +++ b/src/linkahead/transaction.cpp @@ -18,31 +18,27 @@ * */ #include "linkahead/transaction.h" -#include "caosdb/entity/v1/main.pb.h" // for EntityTransac... -#include "caosdb/entity/v1/main.grpc.pb.h" // for TransactionRe... -#include "linkahead/file_transmission/download_request_handler.h" // Download... -#include "linkahead/file_transmission/file_reader.h" // for path -#include "linkahead/file_transmission/register_file_upload_handler.h" // for RegisterFileUploadHandler -#include "linkahead/file_transmission/upload_request_handler.h" // Upload... -#include "linkahead/logging.h" // for LINKAHEAD_LOG_FATAL -#include "linkahead/protobuf_helper.h" // for ProtoMessageWrapper -#include "linkahead/result_set.h" // for ResultSet -#include "linkahead/result_table.h" // for ResultTable -#include "linkahead/result_table_impl.h" // for ResultTableImpl -#include "linkahead/status_code.h" // for StatusCode -#include "linkahead/transaction_handler.h" // for EntityTransactionHandler -#include <algorithm> // for max -#include <exception> // IWYU pragma: keep -#include <filesystem> // for operator<<, path -#include <future> // for async, future -#include <google/protobuf/arena.h> // for Arena -#include <grpc/grpc.h> // for gpr_timespec -#include <map> // for map, operator!= -#include <memory> // for unique_ptr -#include <random> // for mt19937, rand... -#include <string> // for string -#include <system_error> // for std::system_error -#include <utility> // for move, pair +#include <google/protobuf/arena.h> +#include <grpc/grpc.h> +#include <filesystem> +#include <future> +#include <map> +#include <memory> +#include <random> +#include <string> +#include <utility> +#include "caosdb/entity/v1/main.grpc.pb.h" +#include "caosdb/entity/v1/main.pb.h" +#include "linkahead/file_transmission/download_request_handler.h" +#include "linkahead/file_transmission/register_file_upload_handler.h" +#include "linkahead/file_transmission/upload_request_handler.h" +#include "linkahead/logging.h" +#include "linkahead/protobuf_helper.h" +#include "linkahead/result_set.h" +#include "linkahead/result_table.h" +#include "linkahead/result_table_impl.h" +#include "linkahead/status_code.h" +#include "linkahead/transaction_handler.h" // IWYU pragma: no_include <cxxabi.h> // IWYU pragma: no_include "net/proto2/public/repeated_field.h" diff --git a/src/linkahead/transaction_handler.cpp b/src/linkahead/transaction_handler.cpp index a1214a70321952d18bc52547dacbd5c3189dcc48..57bebd963ba114df1376931739cfcfe3be149041 100644 --- a/src/linkahead/transaction_handler.cpp +++ b/src/linkahead/transaction_handler.cpp @@ -1,6 +1,6 @@ #include "linkahead/transaction_handler.h" -#include "linkahead/logging.h" // for LINKAHEAD_LOG_TRACE -#include <exception> // IWYU pragma: keep +#include <string> // for basic_string +#include "linkahead/logging.h" // for LINKAHEAD_LOG_TRACE_ENTER_AND_LEAVE // IWYU pragma: no_include <bits/exception.h> namespace linkahead::transaction { diff --git a/src/linkahead/utility.cpp b/src/linkahead/utility.cpp index 4fabfbcfd39e6aa83fd0f33f64b4bcc525c7a4c7..fe229d16976c5abd9b9090bb06de7c67917248b1 100644 --- a/src/linkahead/utility.cpp +++ b/src/linkahead/utility.cpp @@ -19,20 +19,21 @@ * */ #include "linkahead/utility.h" -#include "linkahead/data_type.h" // for AtomicDataType, atomicdatatype_names -#include "linkahead/entity.h" // for Importance, Role, importance_names #include <boost/beast/core/detail/base64.hpp> // for encoded_size #include <boost/beast/core/detail/base64.ipp> // for encode -#include <boost/filesystem/string_file.hpp> // for load_string_file #include <boost/json/stream_parser.hpp> // for stream_parser #include <boost/json/value.hpp> // for value #include <cassert> // for assert -#include <map> // for map, operator!=, _Rb_tree_const_iterator -#include <memory> // for allocator, unique_ptr -#include <stdexcept> // for logic_error +#include <cstdint> // for uintmax_t +#include <limits> // for numeric_limits +#include <map> // for map, _Rb_tree_const_it... +#include <memory> // for shared_ptr, allocator +#include <stdexcept> // for out_of_range, length_e... #include <type_traits> // for underlying_type_t #include <typeinfo> // for type_info -#include <utility> // for pair +#include <utility> // for pair, move +#include "linkahead/data_type.h" // for AtomicDataType, atomic... +#include "linkahead/entity.h" // for Importance, Role, impo... namespace linkahead::utility { @@ -106,7 +107,20 @@ template <> auto getEnumValueFromName<Role>(const std::string &name) -> Role { auto load_string_file(const path &file_path) -> std::string { std::string result; - boost::filesystem::load_string_file(file_path.string(), result); + + // adapted from boost::filesystem::load_string_file, which was removed in 1.84 + std::ifstream file; + file.exceptions(std::ios_base::failbit | std::ios_base::badbit); + file.open(file_path, std::ios_base::binary); + const std::uintmax_t sz = std::filesystem::file_size(file_path); + if ((sz > static_cast<std::uintmax_t>((std::numeric_limits<std::streamsize>::max)()))) { + throw(std::length_error("File size exceeds max read size")); + } + result.resize(static_cast<std::size_t>(sz), '\0'); + if (sz > 0U) { + file.read(result.data(), static_cast<std::streamsize>(sz)); + } + return result; } @@ -128,9 +142,8 @@ auto _load_json_file(const path &json_file) -> value { stream.exceptions(std::ios_base::badbit); stream_parser parser; - auto result = std::string(); auto buffer = std::string(buffer_size, '\0'); - while (stream.read(&buffer[0], buffer_size)) { + while (stream.read(buffer.data(), buffer_size)) { parser.write(buffer.c_str(), stream.gcount()); } parser.write(buffer.c_str(), stream.gcount()); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6497de6bd54eb4de357202116d9dd472163d5b1d..7b70f9f14fcb0594f166713bee5821a96ae2f029 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -51,7 +51,7 @@ set(_CMAKE_CXX_CLANG_TIDY_TEST_CHECKS ) # add special cmake functions for gtest -find_package(GTest REQUIRED) +find_package(GTest CONFIG REQUIRED) include(GoogleTest) message(DEBUG "CMAKE_INCLUDE_PATH: ${CMAKE_INCLUDE_PATH}") @@ -65,7 +65,7 @@ foreach (i RANGE "${len_test_cases}") set(liblinkahead_TEST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${test_case_name}.cpp ${liblinkahead_TEST_SRC}") target_link_libraries(${test_case_name} - PRIVATE GTest::gtest_main linkahead clinkahead gtest::gtest caosdb_grpc) + PRIVATE GTest::gtest_main linkahead clinkahead GTest::gtest caosdb_grpc ${Boost_LIBRARIES}) target_include_directories(${test_case_name} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}) set_target_properties(${test_case_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") diff --git a/test/test_clinkahead.cpp b/test/test_clinkahead.cpp index 25e83fe9da32a440ea2c675ee6b5c9bd08e9894a..a46f41e0dec8bfe20eb80c3ac72b9605192f4ccd 100644 --- a/test/test_clinkahead.cpp +++ b/test/test_clinkahead.cpp @@ -20,17 +20,15 @@ * */ -#include "linkahead/configuration.h" -#include "linkahead/status_code.h" // for StatusCode -#include "linkahead_test_utility.h" // for EXPECT_THROW_MESSAGE, TEST_DATA_DIR -#include "clinkahead.h" // for linkahead_utility_get_env_fallback -#include <cstdint> // for int64_t -#include <cstring> // for strcmp #include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl -#include <gtest/gtest_pred_impl.h> // for Test, TestInfo, EXPECT_EQ, TEST -#include <string> // for allocator, operator+, string,... +#include <cstdint> // for int64_t +#include <cstring> // for strcmp +#include <filesystem> // for path +#include <string> // for allocator, basic_string, operator+ +#include "clinkahead.h" // for linkahead_entity_delete_value +#include "linkahead/configuration.h" // for ConfigurationManager +#include "linkahead/status_code.h" // for StatusCode +#include "linkahead_test_utility.h" // for TEST_DATA_DIR class test_clinkahead : public ::testing::Test { protected: diff --git a/test/test_configuration.cpp b/test/test_configuration.cpp index 2d95bd3a9d5eceed102de593a77b56f387bacc27..b2cc95f3e410ec72ced509a7d608dedc929c1592 100644 --- a/test/test_configuration.cpp +++ b/test/test_configuration.cpp @@ -19,17 +19,18 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ -#include "linkahead/configuration.h" // for ConfigurationError, Configuration... +#include <gtest/gtest.h> // for Test, TestPartResult, TestPartR... +#include <gtest/gtest-message.h> // for Message +#include <gtest/gtest-test-part.h> // for TestPartResult +#include <gtest/gtest_pred_impl.h> // for TestInfo, TEST_F, Test +#include <filesystem> // for path +#include <memory> // for make_shared, shared_ptr +#include <string> // for basic_string, operator+ +#include "linkahead/configuration.h" // for ConfigurationError, Configurati... #include "linkahead/exceptions.h" // for ConfigurationError -#include "linkahead/log_level.h" // for LINKAHEAD_DEFAULT_LOG_LEVEL, LINKAHEAD_... -#include "linkahead/logging.h" // for ConsoleSinkConfiguration, Logging... -#include "linkahead_test_utility.h" // for EXPECT_THROW_MESSAGE, TEST_DATA_DIR -#include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiResolver -#include <gtest/gtest_pred_impl.h> // for TestInfo, TEST_F, Test -#include <memory> // for make_shared -#include <string> // for operator+, allocator, string +#include "linkahead/log_level.h" // for LINKAHEAD_DEFAULT_LOG_LEVEL +#include "linkahead/logging.h" // for ConsoleSinkConfiguration, Loggi... +#include "linkahead_test_utility.h" // for EXPECT_THROW_MESSAGE, TEST_DATA... namespace linkahead::configuration { diff --git a/test/test_connection.cpp b/test/test_connection.cpp index aa805ad09d202f19d59828f3712255c52008fbb4..2b92e94a4d098137f7879469a83dac5a3131406e 100644 --- a/test/test_connection.cpp +++ b/test/test_connection.cpp @@ -22,17 +22,18 @@ #ifdef BUILD_ACM #include "linkahead/acm/user.h" // for User #endif +#include <gtest/gtest.h> // for Test, TestPartResult, Test +#include <gtest/gtest-message.h> // for Message +#include <gtest/gtest-test-part.h> // for TestPartResult +#include <gtest/gtest_pred_impl.h> // for AssertionResult, TestInfo +#include <filesystem> // for path +#include <memory> // for operator!=, shared_ptr +#include <string> // for basic_string, operator+ #include "linkahead/certificate_provider.h" // for PemCertificateProvider -#include "linkahead/configuration.h" // for InsecureConnectionConfigura... +#include "linkahead/configuration.h" // for InsecureConnectionConfig... #include "linkahead/connection.h" // for ConnectionManager -#include "linkahead/exceptions.h" // for ConnectionConfigurationError -#include "linkahead_test_utility.h" // for EXPECT_THROW_MESSAGE, TEST_... -#include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPartR... -#include <gtest/gtest_pred_impl.h> // for AssertionResult, TestInfo -#include <memory> // for allocator, operator!=, shar... -#include <string> // for operator+, string +#include "linkahead/exceptions.h" // for ConnectionConfigurationE... +#include "linkahead_test_utility.h" // for EXPECT_THROW_MESSAGE namespace linkahead::connection { #ifdef BUILD_ACM diff --git a/test/test_data_type.cpp b/test/test_data_type.cpp index aa90cb32e9eb03f6be6e4d22ebf337ab3270432d..272f373e07277fd2808c65727c5e4b20aa96b98f 100644 --- a/test/test_data_type.cpp +++ b/test/test_data_type.cpp @@ -19,19 +19,18 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ - -#include "linkahead/data_type.h" // for DataType, AtomicDataType -#include "linkahead/entity.h" // for Entity -#include "caosdb/entity/v1/main.pb.h" // for DataType, Ato... +#include <gtest/gtest.h> // for TEST, EXPECT_EQ, EXPECT_FALSE, ... +#include <gtest/gtest-message.h> // for Message +#include <gtest/gtest-test-part.h> // for TestPartResult +#include <gtest/gtest_pred_impl.h> // for AssertionResult, Test, EXPECT_EQ +#include <map> // for _Rb_tree_const_iterator, map +#include <string> // for allocator, basic_string, char... +#include <utility> // for pair, move +#include "caosdb/entity/v1/main.pb.h" // for AtomicDataType, DataType, Entity +#include "linkahead/data_type.h" // for DataType, ListDataType, Refer... +#include "linkahead/entity.h" // for Entity, Role #include "linkahead/logging.h" // for LINKAHEAD_LOG_DEBUG -#include "linkahead/protobuf_helper.h" // for LINKAHEAD_DEBUG_... -#include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApi... -#include <gtest/gtest_pred_impl.h> // for AssertionResult, Test -#include <map> // for map, operator!= -#include <string> // for allocator -#include <utility> // for pair +#include "linkahead/protobuf_helper.h" // for reset_arena, LINKAHEAD_DEBUG_... namespace linkahead::entity { using ProtoEntity = caosdb::entity::v1::Entity; diff --git a/test/test_entity.cpp b/test/test_entity.cpp index 61e53c13ec41b9f0fda2ea14ea931bc7c053eaf4..6c5c4a7b8315404f73d04d3e76102f8d6733ed37 100644 --- a/test/test_entity.cpp +++ b/test/test_entity.cpp @@ -20,26 +20,27 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ -#include "linkahead/data_type.h" // for DataType, AtomicDat... -#include "linkahead/entity.h" // for Entity, Property -#include "caosdb/entity/v1/main.pb.h" // for EntityTransactionSe... -#include "caosdb/entity/v1/main.grpc.pb.h" // for IdResponse, Message -#include "linkahead/message_code.h" // for MessageCode, ENTITY... +#include <google/protobuf/arena.h> // for Arena +#include <gtest/gtest.h> // for Test, TestPartResult, Test +#include <gtest/gtest-message.h> // for Message +#include <gtest/gtest-test-part.h> // for TestPartResult +#include <gtest/gtest_pred_impl.h> // for Test, EXPECT_EQ, Assertio... +#include <filesystem> // for path +#include <iostream> // for basic_ostream, operator<< +#include <memory> // for shared_ptr +#include <stdexcept> // for out_of_range +#include <string> // for basic_string, operator+ +#include <utility> // for move +#include "caosdb/entity/v1/main.grpc.pb.h" // for EntityTransactionService +#include "caosdb/entity/v1/main.pb.h" // for EntityResponse, Entity +#include "linkahead/data_type.h" // for AtomicDataType, DataType +#include "linkahead/entity.h" // for Entity, Property, Parent +#include "linkahead/message_code.h" // for MessageCode #include "linkahead/protobuf_helper.h" // for get_arena -#include "linkahead/status_code.h" // for StatusCode, FILE_DO... -#include "linkahead/transaction.h" // for Transaction -#include "linkahead/value.h" // for Value +#include "linkahead/status_code.h" // for StatusCode +#include "linkahead/transaction.h" // for Transaction, EntityTransa... +#include "linkahead/value.h" // for Value, Arena #include "linkahead_test_utility.h" // for TEST_DATA_DIR -#include <google/protobuf/arena.h> // for Arena -#include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for TestPartResult, Sui... -#include <gtest/gtest_pred_impl.h> // for Test, EXPECT_EQ -#include <iostream> // for operator<<, basic_o... -#include <memory> // for allocator, shared_ptr -#include <stdexcept> // for out_of_range -#include <string> // for operator+, to_string -#include <utility> // for move // IWYU pragma: no_include "net/proto2/public/repeated_field.h" namespace linkahead::entity { @@ -737,11 +738,13 @@ TEST(test_entity, test_remove_property) { entity.AppendProperty(property10); ASSERT_EQ(entity.GetProperties().size(), 9); - std::cout << "[" << std::endl; + std::cout << "[" + << "\n"; for (int i = 0; i < 9; i++) { std::cout << " " << entity.GetProperties().at(i).GetName() << ",\n"; } - std::cout << "]" << std::endl; + std::cout << "]" + << "\n"; for (int i = 0; i < 3; i++) { auto name = "PROPERTY-" + std::to_string(i); diff --git a/test/test_file_transmission.cpp b/test/test_file_transmission.cpp index b337a2450f49460a89092b66ad8d2ed9e8ff97b8..12917317e5f47b2af0746b47ec94d7e208ce4a15 100644 --- a/test/test_file_transmission.cpp +++ b/test/test_file_transmission.cpp @@ -17,16 +17,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "linkahead/file_transmission/file_writer.h" -#include "linkahead/file_transmission/file_reader.h" -#include <chrono> // for filesystem -#include <filesystem> // for path #include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiResolver -#include <gtest/gtest_pred_impl.h> // for Test, EXPECT_EQ, AssertionResult -#include <string> // for string - +#include <filesystem> // for path, exists +#include <string> // for basic_string +#include "linkahead/file_transmission/file_reader.h" // for FileReader +#include "linkahead/file_transmission/file_writer.h" // for FileWriter namespace fs = std::filesystem; namespace linkahead::transaction { @@ -47,11 +42,11 @@ TEST_F(test_file_transmission, test_file_writer_reader) { FileWriter writer(test_file_name); std::string buffer_out(1024, 'c'); for (int i = 0; i < 8; i++) { - writer.write(buffer_out); + writer.write(buffer_out); } } EXPECT_EQ(fs::file_size(test_file_name), 1024 * 8); - + { FileReader reader(test_file_name); std::string buffer_in(1024, '\0'); diff --git a/test/test_info.cpp b/test/test_info.cpp index 20be8fb5ff43d7b5481ab4e01d95728ed80ab606..fc6fd3a694d9e867d08fd335704323a15e27be87 100644 --- a/test/test_info.cpp +++ b/test/test_info.cpp @@ -20,13 +20,10 @@ * */ -#include "linkahead/info.h" // for VersionInfo -#include "caosdb/info/v1/main.pb.h" // for VersionInfo #include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiRe... -#include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ, TEST -#include <memory> // for allocator +#include "caosdb/info/v1/main.pb.h" // for VersionInfo +#include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ, TestInfo, TEST +#include "linkahead/info.h" // for VersionInfo namespace linkahead::info { using ProtoVersionInfo = caosdb::info::v1::VersionInfo; diff --git a/test/test_issues.cpp b/test/test_issues.cpp index 41a004689a33b338dd50468cd94f5be6e6178f98..25b1a87fa539e0624b978f489ca1c251f0a528f2 100644 --- a/test/test_issues.cpp +++ b/test/test_issues.cpp @@ -17,17 +17,15 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "linkahead/configuration.h" // for InsecureConnectionConfig... +#include <gtest/gtest.h> +#include <memory> // for unique_ptr +#include <string> // for basic_string +#include "linkahead/configuration.h" // for InsecureConnectionConfigur... #include "linkahead/connection.h" // for Connection #include "linkahead/result_set.h" // for ResultSet -#include "linkahead/status_code.h" // for StatusCode, EXECUTING +#include "linkahead/status_code.h" // for StatusCode #include "linkahead/transaction.h" // for Transaction #include "linkahead/transaction_status.h" // for StatusCode -#include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPa... -#include <gtest/gtest_pred_impl.h> // for Test, TestInfo, TEST -#include <memory> // for allocator, unique_ptr namespace linkahead::transaction { using linkahead::configuration::InsecureConnectionConfiguration; diff --git a/test/test_list_properties.cpp b/test/test_list_properties.cpp index 63d4aa65d3d4296484248133bd6a1ff5357153ca..8c8dfe287dd1e73a527e098aee4e75404f3b91f4 100644 --- a/test/test_list_properties.cpp +++ b/test/test_list_properties.cpp @@ -20,18 +20,14 @@ * */ -#include "linkahead/data_type.h" // for DataType, AtomicDataType -#include "linkahead/entity.h" // for Entity -#include "caosdb/entity/v1/main.pb.h" // for AtomicDataType, DataType -#include "linkahead/value.h" // for Value -#include <cstdint> // for int64_t #include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApi... -#include <gtest/gtest_pred_impl.h> // for AssertionResult, Test -#include <memory> // for allocator_traits<>::valu... -#include <string> // for string -#include <vector> // for vector +#include <cstdint> // for int64_t +#include <string> // for basic_string, string +#include <vector> // for vector +#include "caosdb/entity/v1/main.pb.h" // for AtomicDataType, DataType, Entity +#include "linkahead/data_type.h" // for AtomicDataType, DataType, List... +#include "linkahead/entity.h" // for Property, Entity, Properties +#include "linkahead/value.h" // for ScalarValue, Value namespace linkahead::entity { using ProtoEntity = caosdb::entity::v1::Entity; diff --git a/test/test_protobuf.cpp b/test/test_protobuf.cpp index 21f67787ecc303545972616a71affbe4a13f085c..a49c205dd2f9ac03860d30ff6a315692751e0efe 100644 --- a/test/test_protobuf.cpp +++ b/test/test_protobuf.cpp @@ -19,15 +19,11 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ +#include <google/protobuf/arena.h> // for Arena +#include <gtest/gtest.h> +#include "caosdb/entity/v1/main.pb.h" // for Entity, Message, Version, Data... #include "linkahead/data_type.h" // for DataType, ReferenceDataType #include "linkahead/entity.h" // for Entity -#include "caosdb/entity/v1/main.pb.h" // for RepeatedPtrField, Message -#include <google/protobuf/arena.h> // for Arena -#include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPa... -#include <gtest/gtest_pred_impl.h> // for Test, TestInfo, TEST -#include <memory> // for allocator namespace linkahead { using ProtoEntity = caosdb::entity::v1::Entity; diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp index 6f8705680a80c41be3cddfee7f1cdabf9fe0c338..cb936c0dab7193178c9eaec132d429e7be2a5515 100644 --- a/test/test_transaction.cpp +++ b/test/test_transaction.cpp @@ -17,28 +17,25 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "linkahead/configuration.h" // for InsecureConnectionConfig... -#include "linkahead/connection.h" // for Connection -#include "linkahead/entity.h" // for Entity -#include "caosdb/entity/v1/main.pb.h" // for Entity -#include "linkahead/exceptions.h" // for ConnectionError -#include "linkahead/result_set.h" // for MultiResultSet, Entity, Resu... -#include "linkahead/status_code.h" // for StatusCode -#include "linkahead/transaction.h" // for Transaction -#include "linkahead/transaction_handler.h" // for MultiTransactionResponse -#include "linkahead/transaction_status.h" // for ConnectionError -#include "linkahead_test_utility.h" // for EXPECT_THROW_MESSAGE -#include <algorithm> // for max -#include <google/protobuf/arena.h> // for Arena +#include <google/protobuf/arena.h> // for Arena #include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPa... -#include <gtest/gtest_pred_impl.h> // for Test, TestInfo, TEST -#include <memory> // for allocator, unique_ptr -#include <stdexcept> // for out_of_range -#include <string> // for string, basic_string -#include <utility> // for move -#include <vector> // for vector +#include <filesystem> // for path +#include <memory> // for unique_ptr, make_unique +#include <stdexcept> // for out_of_range +#include <string> // for basic_string, operator+ +#include <utility> // for move +#include <vector> // for vector +#include "caosdb/entity/v1/main.pb.h" // for RetrieveResponse, MultiTra... +#include "linkahead/configuration.h" // for InsecureConnectionConfigur... +#include "linkahead/connection.h" // for Connection +#include "linkahead/entity.h" // for Entity, Role +#include "linkahead/exceptions.h" // for ConnectionError +#include "linkahead/file_descriptor.h" // for FileDescriptor +#include "linkahead/result_set.h" // for MultiResultSet +#include "linkahead/status_code.h" // for StatusCode +#include "linkahead/transaction.h" // for Transaction, Arena, Retrie... +#include "linkahead/transaction_status.h" // for StatusCode, TransactionStatus +#include "linkahead_test_utility.h" // for EXPECT_THROW_STARTS_WITH // IWYU pragma: no_include "net/proto2/public/repeated_field.h" namespace linkahead::transaction { diff --git a/test/test_utility.cpp b/test/test_utility.cpp index 8abe42e6bc77221863d20386a8e5f3b1c7c1312c..9880d1e830019091ca42cc25d1cf53f4cd89bb07 100644 --- a/test/test_utility.cpp +++ b/test/test_utility.cpp @@ -20,20 +20,17 @@ * */ -#include "boost/beast/core/detail/base64.hpp" // for encoded_size -#include "linkahead/data_type.h" // for atomicdatatype_names -#include "linkahead/entity.h" // for importance_names, role... -#include "linkahead/status_code.h" // for get_status_description -#include "linkahead/utility.h" // for base64_encode, load_js... -#include "linkahead_test_utility.h" // for TEST_DATA_DIR #include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteA... -#include <gtest/gtest_pred_impl.h> // for Test, EXPECT_EQ, TestInfo -#include <map> // for map, operator!=, _Rb_t... -#include <stdexcept> // for out_of_range -#include <string> // for allocator, string, ope... -#include <utility> // for pair +#include <map> // for _Rb_tree_const_iterator +#include <stdexcept> // for out_of_range +#include <string> // for basic_string, string +#include <utility> // for pair +#include <boost/beast/core/detail/base64.hpp> // for encoded_size +#include "linkahead/data_type.h" // for AtomicDataType, atomic... +#include "linkahead/entity.h" // for Importance, Role, impo... +#include "linkahead/status_code.h" // for get_status_description +#include "linkahead/utility.h" // for getEnumValueFromName +#include "linkahead_test_utility.h" // for EXPECT_THROW_MESSAGE namespace linkahead::utility { diff --git a/test/test_value.cpp b/test/test_value.cpp index f39181272adddcb28c009d055fa5943e465d656e..0dab4d657d6112961b3d5d7eb40e17effab04604 100644 --- a/test/test_value.cpp +++ b/test/test_value.cpp @@ -20,18 +20,14 @@ * */ -#include "linkahead/value.h" // for Value -#include "caosdb/entity/v1/main.pb.h" // for AtomicDataType, DataType -#include "linkahead/protobuf_helper.h" // for ProtoMessageWrapper -#include <algorithm> // for max -#include <cmath> // for isnan #include <gtest/gtest.h> -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApi... -#include <gtest/gtest_pred_impl.h> // for AssertionResult, Test -#include <initializer_list> // for initializer_list -#include <string> // for string, basic_string -#include <vector> // for vector +#include <cmath> // for sqrt, isnan +#include <initializer_list> // for initializer_list +#include <string> // for basic_string, string, operator+ +#include <vector> // for vector +#include "caosdb/entity/v1/main.pb.h" // for AtomicDataType, DataType, Entity +#include "linkahead/protobuf_helper.h" // for ProtoMessageWrapper +#include "linkahead/value.h" // for Value, ScalarValue, AbstractV... namespace linkahead::entity { using ProtoValue = caosdb::entity::v1::Value;