diff --git a/CMakeLists.txt b/CMakeLists.txt index 31b42d272652fc3405008585d32cea18e5a1403a..e0caaeb6cc52d914648f1c6f2acc48a196d447c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ project(libcaosdb_inttests set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # dependency management with conan diff --git a/README.md b/README.md index 551117a3b4eb123829e43fb3cefc15d04d8fc19c..9d2b880004b551f8e32eb0254e47377744584e69 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,17 @@ Integration tests for caosdb-cpplib and the caosdb-server # Run tests +## Prerequisite +Create a local conan package from the caosdb-cpplib repository + +## Build & Execution 1. `mkdir build && cd build/` 2. `conan install .. -s "compiler.libcxx=libstdc++11"` 3. `cmake -B . ..` 4. `cmake --build .` 5. Setup env vars + - CAOSDB_SERVER_GRPC_PORT_HTTP + - CAOSDB_SERVER_HOST + - CAOSDB_SERVER_GRPC_PORT_HTTPS + - CAOSDB_SERVER_CERT 6. Run with `ctest` in the build directory. - - diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 995f90a3043f8b33187c5623503867ee4c079bb3..2a1612d3106959c2e5534a60fef64816c070b764 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,6 +25,7 @@ set(test_cases test_connection test_transaction test_list_properties + test_file_transmission test_ccaosdb ) @@ -83,7 +84,7 @@ if(LINTING) "--warnings-as-errors=*" "--fix") set(_CMAKE_CXX_CLANG_TIDY_CHECKS - "--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes") + "--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay") endif() else() message(STATUS "LINTING is OFF") diff --git a/test/test_connection.cpp b/test/test_connection.cpp index ed1ca1faa5186105c87edb5068916f76ab850882..678035b50b4fee53cc246a7335ae5fb74bfb1eca 100644 --- a/test/test_connection.cpp +++ b/test/test_connection.cpp @@ -28,11 +28,11 @@ #include "caosdb/info.h" // for VersionInfo #include "caosdb/utility.h" // for get_env_var #include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE -#include <gtest/gtest-message.h> // for Message -#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPartR... -#include "gtest/gtest_pred_impl.h" // for Test, TestInfo, TEST, EXPEC... -#include <memory> // for allocator, unique_ptr, __sh... -#include <string> // for stoi, string +#include "gtest/gtest_pred_impl.h" // NOLINT TODO how to fix this? for Test, TestInfo, TEST, EXPEC... +#include <gtest/gtest-message.h> // for Message +#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPartR... +#include <memory> // for allocator, unique_ptr, __sh... +#include <string> // for stoi, string namespace caosdb::connection { using caosdb::authentication::PlainPasswordAuthenticator; diff --git a/test/test_file_transmission.cpp b/test/test_file_transmission.cpp index 7c6a72d0b4d52ecd76d01d253e377473ce7954cf..0f6eeb8f4f7bc0cd0e811e8a814f1c67812feba5 100644 --- a/test/test_file_transmission.cpp +++ b/test/test_file_transmission.cpp @@ -36,6 +36,11 @@ using caosdb::entity::v1alpha1::RegisterFileUploadResponse; using caosdb::entity::v1alpha1::RegistrationStatus; using caosdb::entity::v1alpha1::TransmissionStatus; +// TODO(tf) this file is currently not used (see CMakeLists.txt) +// Is it still necessary or is it obsolete due to test_transaction.cpp? +// RegisterFileDownloadResponse is currently not defined by proto or the h +// file. + class test_file_transmission : public ::testing::Test { protected: void SetUp() override {} diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp index 56e103c4ae247d533ee2cbdf9cec6d3372677605..74800a53c72366b73b222200ca6f9a904f0ee629 100644 --- a/test/test_transaction.cpp +++ b/test/test_transaction.cpp @@ -21,6 +21,7 @@ #include "caosdb/connection.h" // for Connection, ConnectionManager #include "caosdb/data_type.h" // for AtomicDataType #include "caosdb/entity.h" // for Entity, Messages, Message +#include "caosdb/file_transmission/file_reader.h" // for FileReader #include "caosdb/file_transmission/file_writer.h" // for FileWriter #include "caosdb/message_code.h" // for ENTITY_DOES_NOT_EXIST, Messag... #include "caosdb/status_code.h" // for SUCCESS, StatusCode @@ -670,9 +671,18 @@ TEST_F(test_transaction, test_file_upload) { const auto &inserted_file = insert_results.at(0); EXPECT_FALSE(inserted_file.GetId().empty()); EXPECT_FALSE(inserted_file.HasErrors()); + + // Check file once more + auto count_query(connection->CreateTransaction()); + count_query->Query("COUNT FILE WHICH IS STORED AT 'test.txt'"); + count_query->ExecuteAsynchronously(); + auto count_and_retrieve_status = count_query->WaitForIt(); + ASSERT_TRUE(count_and_retrieve_status.IsTerminated()); + ASSERT_FALSE(count_and_retrieve_status.IsError()); + EXPECT_EQ(count_query->GetCountResult(), 1); } -TEST_F(test_transaction, test_file_download) { +TEST_F(test_transaction, test_file_up_n_download) { const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection(); @@ -705,6 +715,14 @@ TEST_F(test_transaction, test_file_download) { ASSERT_FALSE(downloaded_file.HasErrors()); EXPECT_EQ(downloaded_file.GetLocalPath().string(), test_download_file_1.string()); + + FileReader reader_remote(test_upload_file_1); + std::string buffer_local(1024, 'c'); + std::string buffer_remote(1024, 'c'); + for (int i = 0; i < 8; i++) { + reader_remote.read(buffer_remote); + EXPECT_EQ(buffer_remote, buffer_local); + } } } // namespace caosdb::transaction