diff --git a/3d_party/mongo-c-driver/install.sh b/3d_party/mongo-c-driver/install.sh index 7d0f2b352617b65e2010bf0ed28a44da0a73206a..3280a302d059951ce0871c1bab12dc3d96afc450 100755 --- a/3d_party/mongo-c-driver/install.sh +++ b/3d_party/mongo-c-driver/install.sh @@ -14,6 +14,7 @@ wget https://github.com/mongodb/mongo-c-driver/releases/download/1.17.2/mongo-c- tar xzf mongo-c-driver-1.17.2.tar.gz cd mongo-c-driver-1.17.2 +#you can add -DENABLE_ZSTD=OFF to disable lzstd cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_SSL=OFF -DENABLE_SASL=OFF -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DMONGOC_ENABLE_STATIC=ON . make -j 4 #sudo make install diff --git a/README.md b/README.md index 61156b5081b1028eb2afbb27586284996c61ad40..c2c875b4b219b6fc0ba4e6367da3de206d74b155 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,13 @@ ## Prepare dependencies +depending on configuration, you might need need curllib, mongoc, google tests + - cd 3d_party/mongo-c-driver - ./install.sh $(pwd) - - sudo make -C mongo-c-driver-1.15.2 install + - sudo make -C mongo-c-driver-1.17.2 install - - back in the aspo-dir: + - back in the asapo-dir: - mkdir build - (cd build; cmake ..) @@ -49,4 +51,13 @@ Need googletest >= [1.8.0](https://github.com/google/googletest/releases/tag/rel - cmake -DBUILD_TESTS=ON .. The software is MIT licensed (see LICENSE.txt) and uses third party libraries that are distributed under their own terms -(see LICENSE-3RD-PARTY.txt) \ No newline at end of file +(see LICENSE-3RD-PARTY.txt) + +## with non-standard 3rd party libraries paths +- cmake -Dlibmongoc-static-1.0_DIR=... -Dlibbson-static-1.0_DIR=... -Dgtest_SOURCE_DIR=... -DLIBCURL_DIR=... ... + +## compile + - make -j 4 + +or compile specific target only, e.g. + - make -j 4 receiver \ No newline at end of file diff --git a/common/cpp/src/json_parser/rapid_json.cpp b/common/cpp/src/json_parser/rapid_json.cpp index 03d9b60721538a5d2ff94d68d2c9218da3aabb4b..c21fa0f27c4e89014f58185c97d5ebde7c8e47f0 100644 --- a/common/cpp/src/json_parser/rapid_json.cpp +++ b/common/cpp/src/json_parser/rapid_json.cpp @@ -62,6 +62,8 @@ asapo::Error RapidJson::CheckValueType(const std::string& name, ValueType type, case ValueType::kArray: res = val->IsArray(); break; + default: + res = false; } if (!res) { return TextError("wrong type for: " + name + " in: " + json_); diff --git a/consumer/tools/folder_to_db/src/main.cpp b/consumer/tools/folder_to_db/src/main.cpp index aa21af1f86b9113a4d09af1695ec1fbe346ef825..d8dcf2b773aaabc4664d04572bc38f6921c49c1e 100644 --- a/consumer/tools/folder_to_db/src/main.cpp +++ b/consumer/tools/folder_to_db/src/main.cpp @@ -85,7 +85,7 @@ int main(int argc, char* argv[]) { &statistics); if (err != nullptr) { std::cout << "Error import to database: " << err->Explain() << std::endl; - return 1; + return EXIT_FAILURE; } std::cout << statistics << std::endl; diff --git a/docs/site/versioned_examples/version-21.06.0/python/produce.py b/docs/site/versioned_examples/version-21.06.0/python/produce.py index 0742fe3afa29805ada23b983cf97bca7aaf418c2..2a645631e525d84246507b80c4cf2cefa71b2427 100644 --- a/docs/site/versioned_examples/version-21.06.0/python/produce.py +++ b/docs/site/versioned_examples/version-21.06.0/python/produce.py @@ -6,7 +6,7 @@ def callback(payload,err): print("could not send: ",payload,err) elif err is not None: # The data was sent, but there was some unexpected problem, e.g. the file was overwritten. - print("sent with warning":,payload,err) + print("sent with warning: ",payload,err) else: # all fine print("successfuly sent: ",payload) @@ -14,8 +14,7 @@ def callback(payload,err): endpoint = "localhost:8400" beamtime = "asapo_test" -producer = asapo_producer - .create_producer(endpoint, +producer = asapo_producer.create_producer(endpoint, 'processed', # should be 'processed' or 'raw', 'processed' writes to the core FS beamtime, # the folder should exist 'auto', # can be 'auto', if beamtime_id is given diff --git a/receiver/CMakeLists.txt b/receiver/CMakeLists.txt index 6d6ac3e8aa5d0fec8c24ef70b42f768fd14cc85f..af41e773a067d3b546a3c471cb2d4062f2fc6912 100644 --- a/receiver/CMakeLists.txt +++ b/receiver/CMakeLists.txt @@ -56,8 +56,6 @@ set(SOURCE_FILES ################################ # Library ################################ -#SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") - GET_PROPERTY(ASAPO_COMMON_FABRIC_LIBRARIES GLOBAL PROPERTY ASAPO_COMMON_FABRIC_LIBRARIES) add_library(${TARGET_NAME} STATIC ${SOURCE_FILES} $<TARGET_OBJECTS:system_io> $<TARGET_OBJECTS:curl_http_client> diff --git a/receiver/README.md b/receiver/README.md deleted file mode 100644 index 7f18fbae7ac7ad09cd0f4378320a37382cd9a716..0000000000000000000000000000000000000000 --- a/receiver/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# cpp-receiver - -This is the receiver implementation in c++ - -## Building this project - -### Requirements - - - TODO - -### How to build - - - TODO - diff --git a/receiver/src/connection.cpp b/receiver/src/connection.cpp index bd1a6d9c6395c9ba67a6c53dd419b97d057ef73d..b0fcdca7010056553a11f89041c459c94ab71f49 100644 --- a/receiver/src/connection.cpp +++ b/receiver/src/connection.cpp @@ -13,15 +13,13 @@ Connection::Connection(SocketDescriptor socket_fd, const std::string& address, io__{GenerateDefaultIO()}, statistics__{new ReceiverStatistics}, log__{GetDefaultReceiverLogger()}, -requests_dispatcher__{new RequestsDispatcher{socket_fd, address, statistics__.get(), cache}} { +requests_dispatcher__{new RequestsDispatcher{socket_fd, address, statistics__.get(), cache}} { socket_fd_ = socket_fd; address_ = address; statistics__->AddTag("connection_from", address); statistics__->AddTag("receiver_tag", std::move(receiver_tag)); } - - void Connection::ProcessStatisticsAfterRequest(const std::unique_ptr<Request>& request) const noexcept { statistics__->IncreaseRequestCounter(); statistics__->IncreaseRequestDataVolume(request->GetDataSize() + sizeof(GenericRequestHeader) + @@ -47,7 +45,6 @@ void Connection::Listen() const noexcept { log__->Info(LogMessageWithFields("disconnected from producer").Append("origin", HostFromUri(address_))); } - } diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 4ac76015f002c350473b9c765c6b234d5a1c0898..9f818218dcf240c04648775c1e83e2c5764645d8 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -2,7 +2,6 @@ #include <utility> #include "receiver.h" -#include "receiver_config_factory.h" #include "receiver_config.h" #include "receiver_data_server/receiver_data_server_logger.h" @@ -15,13 +14,17 @@ #include "metrics/receiver_prometheus_metrics.h" #include "metrics/receiver_mongoose_server.h" -asapo::Error ReadConfigFile(int argc, char* argv[]) { +void ReadConfigFile(int argc, char* argv[]) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " <config file>" << std::endl; exit(EXIT_FAILURE); } - asapo::ReceiverConfigFactory factory; - return factory.SetConfig(argv[1]); + asapo::ReceiverConfigManager config_manager; + auto err = config_manager.ReadConfigFromFile(argv[1]); + if (err) { + std::cerr << "cannot read config file:" << err->Explain() << std::endl; + exit(EXIT_FAILURE); + } } void AddDataServers(const asapo::ReceiverConfig* config, asapo::SharedCache, @@ -85,9 +88,9 @@ int StartReceiver(const asapo::ReceiverConfig* config, asapo::SharedCache cache, receiver->Listen(address, &err); if (err) { logger->Error("failed to start receiver: " + err->Explain()); - return 1; + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } std::unique_ptr<std::thread> StartMetricsServer(const asapo::ReceiverMetricsConfig& config, @@ -108,18 +111,13 @@ std::unique_ptr<std::thread> StartMetricsServer(const asapo::ReceiverMetricsConf }; } + + int main(int argc, char* argv[]) { asapo::ExitAfterPrintVersionIfNeeded("ASAPO Receiver", argc, argv); - - auto err = ReadConfigFile(argc, argv); + ReadConfigFile(argc, argv); const auto& logger = asapo::GetDefaultReceiverLogger(); - if (err) { - logger->Error("cannot read config file: " + err->Explain()); - return 1; - } - auto config = asapo::GetReceiverConfig(); - logger->SetLogLevel(config->log_level); asapo::SharedCache cache = nullptr; @@ -128,13 +126,15 @@ int main(int argc, char* argv[]) { (float) config->datacache_reserved_share / 100}); } + asapo::Error err; auto dataServerThreads = StartDataServers(config, cache, &err); if (err) { logger->Error("cannot start data server: " + err->Explain()); - return 1; + return EXIT_FAILURE; } - auto t = StartMetricsServer(config->metrics, logger); + auto metrics_thread = StartMetricsServer(config->metrics, logger); auto exit_code = StartReceiver(config, cache, logger); +// todo: implement graceful exit, currently it never reaches this point return exit_code; } diff --git a/receiver/src/receiver.cpp b/receiver/src/receiver.cpp index 7038deceb732617ce1a8090e0cd2a0b9d07a9ec8..e3ef529d402f141d51004104e3ab01bbbda5bfcd 100644 --- a/receiver/src/receiver.cpp +++ b/receiver/src/receiver.cpp @@ -44,7 +44,6 @@ void Receiver::ProcessConnections(Error* err) { //TODO: Use InetAcceptConnectionWithTimeout auto client_info_tuple = io__->InetAcceptConnection(listener_fd_, err); if(*err) { - //TODO: this can produce a lot of error messages log__->Error("accepting an incoming connection: " + (*err)->Explain()); return; } diff --git a/receiver/src/receiver_config.cpp b/receiver/src/receiver_config.cpp index e78004925d2f20dc1e1270b425d9868a20cfc2c5..c6cc7846083c669c072bbb9d6d9eacdf0f4d0b54 100644 --- a/receiver/src/receiver_config.cpp +++ b/receiver/src/receiver_config.cpp @@ -1,5 +1,4 @@ #include "receiver_config.h" -#include "receiver_config_factory.h" #include "asapo/io/io_factory.h" #include "asapo/json_parser/json_parser.h" @@ -9,11 +8,11 @@ namespace asapo { ReceiverConfig config; -ReceiverConfigFactory::ReceiverConfigFactory() : io__{GenerateDefaultIO()} { +ReceiverConfigManager::ReceiverConfigManager() : io__{GenerateDefaultIO()} { } -Error ReceiverConfigFactory::SetConfig(std::string file_name) { +Error ReceiverConfigManager::ReadConfigFromFile(std::string file_name) { JsonFileParser parser(file_name, &io__); std::string log_level; Error err; diff --git a/receiver/src/receiver_config.h b/receiver/src/receiver_config.h index 89c0d918fe0cd034a4afc141b204f01e4212c32e..0a054e2c1625cd7d41259b2e8d0f11007bd6f19a 100644 --- a/receiver/src/receiver_config.h +++ b/receiver/src/receiver_config.h @@ -29,6 +29,15 @@ struct ReceiverConfig { std::string discovery_server; }; +class ReceiverConfigManager { + public: + ReceiverConfigManager(); + Error ReadConfigFromFile(std::string file_name); + public: + std::unique_ptr<IO> io__; +}; + + const ReceiverConfig* GetReceiverConfig(); } diff --git a/receiver/src/receiver_config_factory.h b/receiver/src/receiver_config_factory.h deleted file mode 100644 index 6be2f933e0830a869dc6f7898f74ea6187a48289..0000000000000000000000000000000000000000 --- a/receiver/src/receiver_config_factory.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef ASAPO_RECEIVER_CONFIG_FACTORY__H -#define ASAPO_RECEIVER_CONFIG_FACTORY__H - -#include "asapo/io/io.h" -#include "asapo/common/error.h" - -namespace asapo { - -class ReceiverConfigFactory { - public: - ReceiverConfigFactory(); - Error SetConfig(std::string file_name); - public: - std::unique_ptr<IO> io__; -}; - -} - - -#endif //ASAPO_RECEIVER_CONFIG_FACTORY__H diff --git a/receiver/src/statistics/statistics.h b/receiver/src/statistics/statistics.h index e9fcbd3a25d1ff7ff9ce185ea9269ad6ed48e6e9..c6dff99969a4b9b37c165cd1f31bb8450d2d4b2e 100644 --- a/receiver/src/statistics/statistics.h +++ b/receiver/src/statistics/statistics.h @@ -26,8 +26,8 @@ struct StatisticsToSend { class Statistics { public: - VIRTUAL void SendIfNeeded(bool send_always = false) noexcept; explicit Statistics(unsigned int write_interval = kDefaultStatisticWriteIntervalMs); + VIRTUAL void SendIfNeeded(bool send_always = false) noexcept; VIRTUAL void IncreaseRequestCounter() noexcept; VIRTUAL void IncreaseRequestDataVolume(uint64_t transferred_data_volume) noexcept; VIRTUAL void AddTag(const std::string& name, const std::string& value) noexcept; diff --git a/receiver/src/statistics/statistics_sender_fluentd.cpp b/receiver/src/statistics/statistics_sender_fluentd.cpp index b1a3ba9e4213e2c8378c4d45ae94a997bc830a17..9631cd75b05c659c064031baf38967fff2da2c83 100644 --- a/receiver/src/statistics/statistics_sender_fluentd.cpp +++ b/receiver/src/statistics/statistics_sender_fluentd.cpp @@ -5,7 +5,6 @@ namespace asapo { StatisticsSenderFluentd::StatisticsSenderFluentd() : statistics_log__{asapo::CreateDefaultLoggerApi("receiver_stat", "localhost:8400/logs/")} { statistics_log__->SetLogLevel(LogLevel::Info); -// statistics_log__->EnableLocalLog(true); } void StatisticsSenderFluentd::SendStatistics(const asapo::StatisticsToSend& statistic) const noexcept { diff --git a/receiver/unittests/mock_receiver_config.cpp b/receiver/unittests/mock_receiver_config.cpp index 489fe8b96e10bbd72f2524a727c1c9ba74f1ff4f..2e02670b4a23553ecfa320112b924f05c20a4545 100644 --- a/receiver/unittests/mock_receiver_config.cpp +++ b/receiver/unittests/mock_receiver_config.cpp @@ -2,7 +2,7 @@ #include <gmock/gmock.h> #include "mock_receiver_config.h" -#include "../src/receiver_config_factory.h" +#include "../src/receiver_config.h" #include <asapo/unittests/MockIO.h> @@ -19,8 +19,8 @@ std::string Key(std::string value, std::string error_field) { Error SetReceiverConfig (const ReceiverConfig& config, std::string error_field) { MockIO mock_io; - ReceiverConfigFactory config_factory; - config_factory.io__ = std::unique_ptr<IO> {&mock_io}; + ReceiverConfigManager config_manager; + config_manager.io__ = std::unique_ptr<IO> {&mock_io}; std::string log_level; switch (config.log_level) { @@ -87,9 +87,9 @@ Error SetReceiverConfig (const ReceiverConfig& config, std::string error_field) testing::Return(config_string) ); - auto err = config_factory.SetConfig("fname"); + auto err = config_manager.ReadConfigFromFile("fname"); - config_factory.io__.release(); + config_manager.io__.release(); return err; } diff --git a/receiver/unittests/statistics/test_receiver_statistics.cpp b/receiver/unittests/statistics/test_receiver_statistics.cpp index d2bbe46e0fd812eb2e52af73b67beb87c0c523c1..318acac37c904b146c1efe89586074a4d83f24a4 100644 --- a/receiver/unittests/statistics/test_receiver_statistics.cpp +++ b/receiver/unittests/statistics/test_receiver_statistics.cpp @@ -8,25 +8,9 @@ #include "../../src/statistics/statistics_sender_fluentd.h" #include "../receiver_mocking.h" -using ::testing::Test; -using ::testing::Gt; -using ::testing::Ge; -using ::testing::Le; -using ::testing::Eq; -using ::testing::Ne; -using ::testing::Ref; -using ::testing::_; - -using asapo::ReceiverStatistics; -using asapo::Statistics; -using asapo::StatisticEntity; -using asapo::StatisticsSender; -using asapo::StatisticsSenderInfluxDb; -using asapo::StatisticsSenderFluentd; - -using asapo::StatisticsToSend; - -using asapo::MockStatisticsSender; + +using namespace testing; +using namespace asapo; namespace { diff --git a/receiver/unittests/statistics/test_statistics.cpp b/receiver/unittests/statistics/test_statistics.cpp index d31c2282f79c87b6c5d5ce4800888a0495443f69..74756dcd0a0cc6fbd4c2476106db8883a7e4ecd0 100644 --- a/receiver/unittests/statistics/test_statistics.cpp +++ b/receiver/unittests/statistics/test_statistics.cpp @@ -8,25 +8,11 @@ #include "../../src/statistics/statistics_sender_fluentd.h" #include "../receiver_mocking.h" #include "../../src/receiver_config.h" -#include "../../src/receiver_config_factory.h" #include "../mock_receiver_config.h" -using ::testing::Test; -using ::testing::Gt; -using ::testing::Ge; -using ::testing::Le; -using ::testing::Eq; -using ::testing::Ne; -using ::testing::Ref; -using ::testing::_; - -using asapo::Statistics; -using asapo::StatisticsSender; -using asapo::StatisticsSenderInfluxDb; -using asapo::StatisticsSenderFluentd; - -using asapo::StatisticsToSend; -using asapo::MockStatisticsSender; + +using namespace testing; +using namespace asapo; namespace { diff --git a/receiver/unittests/statistics/test_statistics_sender_fluentd.cpp b/receiver/unittests/statistics/test_statistics_sender_fluentd.cpp index 80247857ad84c5a89cfa668cc119a0e87aa6021c..5b749f55d5990e7688253b79481ef8ddb396cb0b 100644 --- a/receiver/unittests/statistics/test_statistics_sender_fluentd.cpp +++ b/receiver/unittests/statistics/test_statistics_sender_fluentd.cpp @@ -14,28 +14,9 @@ #include "../mock_receiver_config.h" #include "../../src/statistics/statistics_sender_fluentd.h" -using ::testing::Test; -using ::testing::Return; -using ::testing::_; -using ::testing::DoAll; -using ::testing::SetArgReferee; -using ::testing::Gt; -using ::testing::Eq; -using ::testing::Ne; -using ::testing::Mock; -using ::testing::NiceMock; -using ::testing::SaveArg; -using ::testing::HasSubstr; -using ::testing::AllOf; -using ::testing::SaveArgPointee; -using ::testing::InSequence; -using ::testing::SetArgPointee; - -using asapo::StatisticsSenderFluentd; -using asapo::MockHttpClient; -using asapo::StatisticsToSend; -using asapo::ReceiverConfig; -using asapo::SetReceiverConfig; + +using namespace testing; +using namespace asapo; namespace { diff --git a/receiver/unittests/statistics/test_statistics_sender_influx_db.cpp b/receiver/unittests/statistics/test_statistics_sender_influx_db.cpp index 222814629434ffea92aebdb9ee5fdd62bb48b22d..cb7116bf51dbc20e29aca7eb14c3441f75e32d38 100644 --- a/receiver/unittests/statistics/test_statistics_sender_influx_db.cpp +++ b/receiver/unittests/statistics/test_statistics_sender_influx_db.cpp @@ -14,28 +14,8 @@ #include "../mock_receiver_config.h" -using ::testing::Test; -using ::testing::Return; -using ::testing::_; -using ::testing::DoAll; -using ::testing::SetArgReferee; -using ::testing::Gt; -using ::testing::Eq; -using ::testing::Ne; -using ::testing::Mock; -using ::testing::NiceMock; -using ::testing::SaveArg; -using ::testing::HasSubstr; -using ::testing::AllOf; -using ::testing::SaveArgPointee; -using ::testing::InSequence; -using ::testing::SetArgPointee; - -using asapo::StatisticsSenderInfluxDb; -using asapo::MockHttpClient; -using asapo::StatisticsToSend; -using asapo::ReceiverConfig; -using asapo::SetReceiverConfig; +using namespace testing; +using namespace asapo; namespace { diff --git a/receiver/unittests/test_config.cpp b/receiver/unittests/test_config.cpp index 6e656529e62ce532b52c1777fe56f26251f01797..8ab74566ad81284e5bc37fd1f653784f9705cc5a 100644 --- a/receiver/unittests/test_config.cpp +++ b/receiver/unittests/test_config.cpp @@ -3,31 +3,10 @@ #include <asapo/unittests/MockIO.h> #include "../src/receiver_config.h" -#include "../src/receiver_config_factory.h" #include "mock_receiver_config.h" -using ::testing::Test; -using ::testing::Return; -using ::testing::_; -using ::testing::DoAll; -using ::testing::SetArgReferee; -using ::testing::Gt; -using ::testing::Eq; -using ::testing::Ne; -using ::testing::Mock; -using ::testing::NiceMock; -using ::testing::SaveArg; -using ::testing::SaveArgPointee; -using ::testing::InSequence; -using ::testing::SetArgPointee; -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockIO; - -using ::asapo::ReceiverConfigFactory; -using asapo::GetReceiverConfig; +using namespace testing; +using namespace asapo; namespace { @@ -35,7 +14,7 @@ namespace { class ConfigTests : public Test { public: MockIO mock_io; - ReceiverConfigFactory config_factory; + ReceiverConfigManager config_factory; asapo::ReceiverConfig test_config; void SetUp() override { config_factory.io__ = std::unique_ptr<asapo::IO> {&mock_io}; diff --git a/receiver/unittests/test_connection.cpp b/receiver/unittests/test_connection.cpp index fca987832b01204c8708a8bfe85840e9476d1c68..ee49f8c51d90e2ce9ef01a0b7a46ad994ded7485 100644 --- a/receiver/unittests/test_connection.cpp +++ b/receiver/unittests/test_connection.cpp @@ -4,55 +4,11 @@ #include "asapo/unittests/MockIO.h" #include "asapo/unittests/MockLogger.h" #include "../src/connection.h" -#include "../src/receiver_error.h" -#include "../src/request.h" -#include "../src/statistics/receiver_statistics.h" #include "receiver_mocking.h" #include "../src/receiver_config.h" -#include "../src/receiver_config_factory.h" -#include "../src/request_handler/requests_dispatcher.h" - -#include "mock_receiver_config.h" - - -using ::testing::Test; -using ::testing::Return; -using ::testing::_; -using ::testing::DoAll; -using ::testing::SetArgReferee; -using ::testing::Gt; -using ::testing::Eq; -using ::testing::Ne; -using ::testing::Mock; -using ::testing::NiceMock; -using ::testing::SaveArg; -using ::testing::SaveArgPointee; -using ::testing::InSequence; -using ::testing::HasSubstr; -using ::testing::StrEq; -using ::testing::SetArgPointee; -using ::testing::AllOf; -using testing::Sequence; - -using asapo::Error; -using asapo::ErrorInterface; -using asapo::FileDescriptor; -using asapo::SocketDescriptor; -using asapo::GenericRequestHeader; -using asapo::SendResponse; -using asapo::GenericRequestHeader; -using asapo::GenericNetworkResponse; -using asapo::Opcode; -using asapo::Connection; -using asapo::MockIO; -using asapo::MockLogger; -using asapo::Request; -using asapo::ReceiverStatistics; -using asapo::StatisticEntity; -using asapo::MockStatistics; - -using asapo::ReceiverConfig; -using asapo::SetReceiverConfig; + +using namespace testing; +using namespace asapo; namespace { diff --git a/receiver/unittests/test_datacache.cpp b/receiver/unittests/test_datacache.cpp index d17f292767cd819b8a77a72eb39372bb394b55a4..ead69885bdbad0ae6a4f880f6b45898eb403412c 100644 --- a/receiver/unittests/test_datacache.cpp +++ b/receiver/unittests/test_datacache.cpp @@ -4,15 +4,8 @@ #include "../src/data_cache.h" -using ::testing::Test; -using ::testing::Gt; -using ::testing::Ge; -using ::testing::Le; -using ::testing::Eq; -using ::testing::Ne; -using ::testing::Ref; -using ::testing::_; -using ::testing::ElementsAreArray; + +using namespace testing; using asapo::DataCache; using asapo::CacheMeta; diff --git a/receiver/unittests/test_receiver.cpp b/receiver/unittests/test_receiver.cpp index ff2f8c00f80e636beeb5fe041aafe8bc1d8f91d5..49e7859cd08227ff27e9baa7166d26fcab0e19c3 100644 --- a/receiver/unittests/test_receiver.cpp +++ b/receiver/unittests/test_receiver.cpp @@ -4,27 +4,11 @@ #include "asapo/unittests/MockIO.h" #include "asapo/unittests/MockLogger.h" #include "../src/receiver.h" -#include "../src/receiver_error.h" -#include "../src/connection.h" -#include "../src/data_cache.h" - -using ::testing::Return; -using ::testing::_; -using ::testing::DoAll; -using ::testing::SetArgReferee; -using ::testing::SetArgPointee; -using ::testing::Gt; -using ::testing::Eq; -using ::testing::Ne; -using ::testing::Mock; -using ::testing::InSequence; -using ::testing::HasSubstr; -using ::asapo::Error; -using ::asapo::FileDescriptor; -using ::asapo::ErrorInterface; -using ::asapo::Connection; -using ::asapo::SocketDescriptor; -using asapo::DataCache; + +using namespace testing; +using namespace asapo; + + namespace { TEST(Receiver, Constructor) { diff --git a/receiver/unittests/test_request.cpp b/receiver/unittests/test_request.cpp index 93d018c37b86b12dfca749f1b0f5f29ba639f444..096ebe8904ffbbbe2e534dae6d704269481ba9b5 100644 --- a/receiver/unittests/test_request.cpp +++ b/receiver/unittests/test_request.cpp @@ -2,47 +2,13 @@ #include <gmock/gmock.h> #include <asapo/unittests/MockIO.h> #include "../src/connection.h" -#include "../src/receiver_error.h" -#include "../src/request.h" -#include "../src/request_handler/request_handler.h" -#include "../src/request_handler/request_handler_file_process.h" -#include "../src/request_handler/request_handler_db_write.h" #include "asapo/database/database.h" #include "receiver_mocking.h" #include "mock_receiver_config.h" -using ::testing::Test; -using ::testing::Return; -using ::testing::_; -using ::testing::DoAll; -using ::testing::SetArgReferee; -using ::testing::Gt; -using ::testing::Eq; -using ::testing::Ne; -using ::testing::Mock; -using ::testing::NiceMock; -using ::testing::InSequence; -using ::testing::SetArgPointee; -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::GenericRequestHeader; -using ::asapo::SendResponse; -using ::asapo::GenericRequestHeader; -using ::asapo::GenericNetworkResponse; -using ::asapo::Opcode; -using ::asapo::Connection; -using ::asapo::MockIO; -using asapo::Request; -using asapo::MockStatistics; -using asapo::MockDataCache; -using asapo::StatisticEntity; - -using asapo::ReceiverConfig; -using asapo::SetReceiverConfig; -using asapo::RequestFactory; +using namespace testing; +using namespace asapo; namespace { diff --git a/tests/automatic/asapo_fabric/parallel_data_transfer.cpp b/tests/automatic/asapo_fabric/parallel_data_transfer.cpp index b7aed4413d05b50b3ca0073480e06aec0c648cea..41f2c82bb02b752c4dc89d90e0cb6859d12432ee 100644 --- a/tests/automatic/asapo_fabric/parallel_data_transfer.cpp +++ b/tests/automatic/asapo_fabric/parallel_data_transfer.cpp @@ -140,7 +140,7 @@ int main(int argc, char* argv[]) { if (argc > 3) { std::cout << "Usage: " << argv[0] << " [<host>] [<port>]" << std::endl; - return 1; + return EXIT_FAILURE; } if (argc == 2) { hostname = argv[1]; @@ -165,5 +165,5 @@ int main(int argc, char* argv[]) { std::cout << "Done testing. Joining server" << std::endl; serverMasterThread.join(); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/asapo_fabric/server_not_running.cpp b/tests/automatic/asapo_fabric/server_not_running.cpp index 698f8098062b25cca9e7efee0674f4229a4aac51..09db2139e17219b2959af6301af59587064faf79 100644 --- a/tests/automatic/asapo_fabric/server_not_running.cpp +++ b/tests/automatic/asapo_fabric/server_not_running.cpp @@ -12,7 +12,7 @@ int main(int argc, char* argv[]) { if (argc > 3) { std::cout << "Usage: " << argv[0] << " [<host>] [<port>]" << std::endl; - return 1; + return EXIT_FAILURE; } if (argc == 2) { hostname = argv[1]; diff --git a/tests/automatic/asapo_fabric/simple_data_transfer.cpp b/tests/automatic/asapo_fabric/simple_data_transfer.cpp index b2d15f2dc705cf39029f3471c77d99a929960e11..8999f6801f2d383f7154aed64955596a358478a7 100644 --- a/tests/automatic/asapo_fabric/simple_data_transfer.cpp +++ b/tests/automatic/asapo_fabric/simple_data_transfer.cpp @@ -114,7 +114,7 @@ int main(int argc, char* argv[]) { if (argc > 3) { std::cout << "Usage: " << argv[0] << " [<host>] [<port>]" << std::endl; - return 1; + return EXIT_FAILURE; } if (argc == 2) { hostname = argv[1]; diff --git a/tests/automatic/asapo_fabric/timeout_test.cpp b/tests/automatic/asapo_fabric/timeout_test.cpp index f752af6efa1af9f8021176f322530962cf65e729..d938faf642b4879ec2bec4157f5970b0ea2e25b9 100644 --- a/tests/automatic/asapo_fabric/timeout_test.cpp +++ b/tests/automatic/asapo_fabric/timeout_test.cpp @@ -93,7 +93,7 @@ int main(int argc, char* argv[]) { if (argc > 3) { std::cout << "Usage: " << argv[0] << " [<host>] [<port>]" << std::endl; - return 1; + return EXIT_FAILURE; } if (argc == 2) { hostname = argv[1]; @@ -110,5 +110,5 @@ int main(int argc, char* argv[]) { std::cout << "Done testing. Joining server" << std::endl; serverThread.join(); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/asapo_fabric/wrong_memory_info.cpp b/tests/automatic/asapo_fabric/wrong_memory_info.cpp index cb6c444a4db0c04457d8c6529ef134a10773b7ae..d3b9a5910fc29839c5ae7e1596b160a932a80ea8 100644 --- a/tests/automatic/asapo_fabric/wrong_memory_info.cpp +++ b/tests/automatic/asapo_fabric/wrong_memory_info.cpp @@ -133,7 +133,7 @@ int main(int argc, char* argv[]) { if (argc > 3) { std::cout << "Usage: " << argv[0] << " [<host>] [<port>]" << std::endl; - return 1; + return EXIT_FAILURE; } if (argc == 2) { hostname = argv[1]; @@ -150,5 +150,5 @@ int main(int argc, char* argv[]) { std::cout << "Done testing. Joining server" << std::endl; serverThread.join(); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/consumer/consumer_api/consumer_api.cpp b/tests/automatic/consumer/consumer_api/consumer_api.cpp index 64ce965b46a633c75ac9f407e202ec114738897a..f388fd945e8f9f7ce6fdcf3a735018788300c359 100644 --- a/tests/automatic/consumer/consumer_api/consumer_api.cpp +++ b/tests/automatic/consumer/consumer_api/consumer_api.cpp @@ -355,5 +355,5 @@ int main(int argc, char* argv[]) { auto args = GetArgs(argc, argv); TestAll(args); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/consumer/next_multithread_broker/next_multithread_broker.cpp b/tests/automatic/consumer/next_multithread_broker/next_multithread_broker.cpp index eb8c03c6f872c1c098d702e57f4dc071b5f1367f..a369f48964932c11c890137ba52c31b10380bf5d 100644 --- a/tests/automatic/consumer/next_multithread_broker/next_multithread_broker.cpp +++ b/tests/automatic/consumer/next_multithread_broker/next_multithread_broker.cpp @@ -94,5 +94,5 @@ int main(int argc, char* argv[]) { auto args = GetArgs(argc, argv); TestAll(args); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/curl_http_client/curl_http_client_command/curl_httpclient_command.cpp b/tests/automatic/curl_http_client/curl_http_client_command/curl_httpclient_command.cpp index 4bf11faac0d5971310434c889c5b627b69fe1b59..875c054d1ea92a648f49fd60a2c89213e4f19b55 100644 --- a/tests/automatic/curl_http_client/curl_http_client_command/curl_httpclient_command.cpp +++ b/tests/automatic/curl_http_client/curl_http_client_command/curl_httpclient_command.cpp @@ -95,5 +95,5 @@ int main(int argc, char* argv[]) { err = consumer_impl->httpclient__->Post(args.uri_fts + "/v0.1/transfer", cookie, transfer, "random", &code); M_AssertTrue(code == asapo::HttpCode::OK); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/full_chain/send_recv_streams/send_recv_streams.cpp b/tests/automatic/full_chain/send_recv_streams/send_recv_streams.cpp index cce8e600741ede934e6e7b1fa02d1d10aaa3be4c..a752a2ba27cd294f4f00112306e4ce075bf72d22 100644 --- a/tests/automatic/full_chain/send_recv_streams/send_recv_streams.cpp +++ b/tests/automatic/full_chain/send_recv_streams/send_recv_streams.cpp @@ -109,7 +109,7 @@ int main(int argc, char* argv[]) { err = consumer->GetNext(group_id, &fi, nullptr, "stream1"); if (err != asapo::ConsumerErrorTemplates::kStreamFinished) { - return 1; + return EXIT_FAILURE; } auto err_data = static_cast<const asapo::ConsumerErrorData*>(err->GetCustomData()); diff --git a/tests/automatic/mongo_db/auto_id/auto_id.cpp b/tests/automatic/mongo_db/auto_id/auto_id.cpp index ed966436e3412b9f4bbf5c88648ea195c893c614..337360aa8d5a365445ea6d8636d3c8ddb0f2baa9 100644 --- a/tests/automatic/mongo_db/auto_id/auto_id.cpp +++ b/tests/automatic/mongo_db/auto_id/auto_id.cpp @@ -118,5 +118,5 @@ int main(int argc, char* argv[]) { db.DeleteStream("stream"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/mongo_db/connect/connect_mongodb.cpp b/tests/automatic/mongo_db/connect/connect_mongodb.cpp index 1adfa650c1c0d9aee40e528b24b3411cae759357..07016691326582a6ebf93e31f0868fd7c1d193ee 100644 --- a/tests/automatic/mongo_db/connect/connect_mongodb.cpp +++ b/tests/automatic/mongo_db/connect/connect_mongodb.cpp @@ -45,7 +45,7 @@ int main(int argc, char* argv[]) { err = db.Connect(args.address, args.database_name); Assert(err, asapo::DBErrorTemplates::kAlreadyConnected.Generate()->Explain()); } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/mongo_db/insert_retrieve/insert_retrieve_mongodb.cpp b/tests/automatic/mongo_db/insert_retrieve/insert_retrieve_mongodb.cpp index 411148140ddf5eec54e694e1f86c85d0a78d1652..0beb953e44fc5d3473d9e83a017005727998e172 100644 --- a/tests/automatic/mongo_db/insert_retrieve/insert_retrieve_mongodb.cpp +++ b/tests/automatic/mongo_db/insert_retrieve/insert_retrieve_mongodb.cpp @@ -144,5 +144,5 @@ int main(int argc, char* argv[]) { M_AssertTrue(err == asapo::DBErrorTemplates::kWrongInput); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/mongo_db/insert_retrieve_dataset/insert_retrieve_dataset_mongodb.cpp b/tests/automatic/mongo_db/insert_retrieve_dataset/insert_retrieve_dataset_mongodb.cpp index 3c58541474849b1e004af2cc2d25301c3af23c92..ee9cea6c0b567e6d3dc1ee7f614c58cc4124c416 100644 --- a/tests/automatic/mongo_db/insert_retrieve_dataset/insert_retrieve_dataset_mongodb.cpp +++ b/tests/automatic/mongo_db/insert_retrieve_dataset/insert_retrieve_dataset_mongodb.cpp @@ -98,5 +98,5 @@ int main(int argc, char* argv[]) { } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/mongo_db/meta/meta_mongodb.cpp b/tests/automatic/mongo_db/meta/meta_mongodb.cpp index 8c61b4e178bfaf1329cb3cb5dcef3dcf7d135423..abae70c4e1d9d8d825005f9d2a61c65be5fbe3de 100644 --- a/tests/automatic/mongo_db/meta/meta_mongodb.cpp +++ b/tests/automatic/mongo_db/meta/meta_mongodb.cpp @@ -97,5 +97,5 @@ int main(int argc, char* argv[]) { db.DeleteStream(stream_name); } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/producer/c_api/producer_api.c b/tests/automatic/producer/c_api/producer_api.c index 317d647c81c0b3e9f18907bda98e56be9a65a635..2829064da3461e38e539065c1f391bebc88f124c 100644 --- a/tests/automatic/producer/c_api/producer_api.c +++ b/tests/automatic/producer/c_api/producer_api.c @@ -119,5 +119,5 @@ int main(int argc, char* argv[]) { asapo_free_handle(&err); asapo_free_handle(&cred); asapo_free_handle(&producer); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/producer/cpp_api/producer_api.cpp b/tests/automatic/producer/cpp_api/producer_api.cpp index aa573f0bd0f0032a6411072e6576bed684878d6a..699c3978d3c32851019bfae5b220d3a1eca0c2e7 100644 --- a/tests/automatic/producer/cpp_api/producer_api.cpp +++ b/tests/automatic/producer/cpp_api/producer_api.cpp @@ -94,5 +94,5 @@ int main(int argc, char* argv[]) { auto args = GetArgs(argc, argv); TestAll(args); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/spd_logger/console/spd_logger_console.cpp b/tests/automatic/spd_logger/console/spd_logger_console.cpp index bf6667457f0aea5d2f0b94a228d80b39613e323d..68150452e6a485d7653a92068b354a5dd6393e7d 100644 --- a/tests/automatic/spd_logger/console/spd_logger_console.cpp +++ b/tests/automatic/spd_logger/console/spd_logger_console.cpp @@ -60,5 +60,5 @@ int main() { logger->Debug("test debug_nonelev"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/spd_logger/fluentd/spd_logger_fluentd.cpp b/tests/automatic/spd_logger/fluentd/spd_logger_fluentd.cpp index c1e61fb1985c6b9adcbfa7cb5010e78e9d327fd9..fd0c8bcf4ee897e4f3c14d8091a20028a0d37491 100644 --- a/tests/automatic/spd_logger/fluentd/spd_logger_fluentd.cpp +++ b/tests/automatic/spd_logger/fluentd/spd_logger_fluentd.cpp @@ -13,5 +13,5 @@ int main() { logger->Warning("test warning"); logger->Debug("test debug"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/system_io/ip_tcp_network/client_serv/ip_tcp_network.cpp b/tests/automatic/system_io/ip_tcp_network/client_serv/ip_tcp_network.cpp index a7f1edfd2a4446d8ecb19b7bad6aa97c718fc6da..2e15db04eca4230d5e5c1b119266fa034eec879c 100644 --- a/tests/automatic/system_io/ip_tcp_network/client_serv/ip_tcp_network.cpp +++ b/tests/automatic/system_io/ip_tcp_network/client_serv/ip_tcp_network.cpp @@ -208,5 +208,5 @@ int main() { remove("sent"); remove("received"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/system_io/ip_tcp_network/client_serv_multicon/multicon.cpp b/tests/automatic/system_io/ip_tcp_network/client_serv_multicon/multicon.cpp index 4ee84fe88bfc82587cdbaf3e33f6114a5f0f8227..2022b66f492339b653dd7b98485175ca3003947a 100644 --- a/tests/automatic/system_io/ip_tcp_network/client_serv_multicon/multicon.cpp +++ b/tests/automatic/system_io/ip_tcp_network/client_serv_multicon/multicon.cpp @@ -130,5 +130,5 @@ int main() { std::cout << "server_thread->join()" << std::endl; server_thread->join(); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/system_io/read_file_content/read_file_content.cpp b/tests/automatic/system_io/read_file_content/read_file_content.cpp index 289a0aab39ae78a6c14b04ca1c5fd0066590c922..22a1a9a565e8f5cceba9a2c9ada0d98aeb736d24 100644 --- a/tests/automatic/system_io/read_file_content/read_file_content.cpp +++ b/tests/automatic/system_io/read_file_content/read_file_content.cpp @@ -7,7 +7,7 @@ int main(int argc, char* argv[]) { if (argc != 3) { std::cout << "Wrong number of arguments" << std::endl; - return 1; + return EXIT_FAILURE; } std::string expect{argv[2]}; @@ -33,5 +33,5 @@ int main(int argc, char* argv[]) { } M_AssertContains(result, expect); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/system_io/read_folder_content/read_folder_content.cpp b/tests/automatic/system_io/read_folder_content/read_folder_content.cpp index 8867f6d27b9568953fbd135fe379820ccdaa217d..edabc0053a52d6cea47ff12ba117c2f4e6f3b3f1 100644 --- a/tests/automatic/system_io/read_folder_content/read_folder_content.cpp +++ b/tests/automatic/system_io/read_folder_content/read_folder_content.cpp @@ -9,7 +9,7 @@ using asapo::Error; int main(int argc, char* argv[]) { if (argc != 3) { std::cout << "Wrong number of arguments" << std::endl; - return 1; + return EXIT_FAILURE; } std::string expect{argv[2]}; @@ -33,5 +33,5 @@ int main(int argc, char* argv[]) { M_AssertContains(result, expect); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/system_io/read_string_from_file/read_string_from_file.cpp b/tests/automatic/system_io/read_string_from_file/read_string_from_file.cpp index 789943a2945747050c90169d28292087fa1a0648..31d3ff532642069b8dbee98b1bfad74a005a32a7 100644 --- a/tests/automatic/system_io/read_string_from_file/read_string_from_file.cpp +++ b/tests/automatic/system_io/read_string_from_file/read_string_from_file.cpp @@ -6,7 +6,7 @@ int main(int argc, char* argv[]) { if (argc != 3) { std::cout << "Wrong number of arguments" << std::endl; - return 1; + return EXIT_FAILURE; } std::string expect{argv[2]}; @@ -23,5 +23,5 @@ int main(int argc, char* argv[]) { } M_AssertContains(result, expect); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/system_io/read_subdirectories/read_subdirectories.cpp b/tests/automatic/system_io/read_subdirectories/read_subdirectories.cpp index 1e134654e68477d382607768d1fc6a3067d79c81..d00d8761bbf8ede450f3dd05624087723ee326b2 100644 --- a/tests/automatic/system_io/read_subdirectories/read_subdirectories.cpp +++ b/tests/automatic/system_io/read_subdirectories/read_subdirectories.cpp @@ -9,7 +9,7 @@ using asapo::Error; int main(int argc, char* argv[]) { if (argc != 3) { std::cout << "Wrong number of arguments" << std::endl; - return 1; + return EXIT_FAILURE; } std::string expect{argv[2]}; @@ -28,5 +28,5 @@ int main(int argc, char* argv[]) { M_AssertContains(result, expect); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/system_io/resolve_hostname_to_ip/resolve_hostname_to_ip.cpp b/tests/automatic/system_io/resolve_hostname_to_ip/resolve_hostname_to_ip.cpp index 7e53dd64b053e5fe385677bf4c912d7a2b589df1..da90ded0b51558e77a303a12e9ebcaabdfa163ab 100644 --- a/tests/automatic/system_io/resolve_hostname_to_ip/resolve_hostname_to_ip.cpp +++ b/tests/automatic/system_io/resolve_hostname_to_ip/resolve_hostname_to_ip.cpp @@ -34,5 +34,5 @@ int main() { // Fallthrough tests Check("123.123.123.123", "123.123.123.123"); Check("8.8.8.8", "8.8.8.8"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/automatic/system_io/write_data_to_file/write_data_to_file.cpp b/tests/automatic/system_io/write_data_to_file/write_data_to_file.cpp index 4e0bbfc2c0b3f52303b1a80aedb6ed76a821e66e..0c5c494dbc26eca1218f4cd6fd5a378b1b6445ba 100644 --- a/tests/automatic/system_io/write_data_to_file/write_data_to_file.cpp +++ b/tests/automatic/system_io/write_data_to_file/write_data_to_file.cpp @@ -67,5 +67,5 @@ int main(int argc, char* argv[]) { AssertBadResult(err, params); } - return 0; + return EXIT_SUCCESS; }