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..aca0823cab84c3ebc6a784e3b7abc0db62334e9d 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,45 @@ -# asapo +# ASAP::O - High performance distributed streaming platform -# C++ Projects +## Folder structure - - /common/cpp - - **Library:** Common library which get shared between the producer and receiver - - - /producer/asapo-producer - - **Library:** Producer library which can send data to the receiver - - - /receiver - - **Executable:** The receiver which can receive data from the producer - - - /producer/inotify-event-detector-cpp - - **Executable:** Implementation of the producer api with inotify +### Microservices + - **authorizer** - authorization _(Go)_ + - **broker** - server for consumer clients _(Go)_ + - **discovery** - discovery service _(Go)_ + - **file_transfer** - file transfer service to deliver files to clients that have no access to storage _(Go)_ + - **receiver** - server for producer clients to send data to, also contains data server that is contacted by consumer clients to get data from cache _(C++)_ + +### Client libraries + - **producer** - producer libraries _(C++, C, Python)_ + - **consumer** - consumer libraries _(C++, C, Python)_ +### Docs & Tests +- **docs** - doxygen,sphinx and site documentation +- **tests** - automatic integration/e2e tests +- **docs/site/examples** - examples used for site +- **examples** - some outdated examples, also used for automated tests, (todo: move it somewhere) -# Building +### Auxiliary folders +- **common** - stuff to be shared between microservices +- **CMakeIncludes**, **CMakeModules**, **install** - CMake stuff +- **config** - to store various config files, also nomad jobs for tests +- **deploy** - Docker files for various images, Helm files, Nomad&Consul files -## Prepare dependencies +## Building + +### 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 ..) -## With documentation +### With documentation Need Doxygen >= [1.8.10](https://github.com/doxygen/doxygen/releases/tag/Release_1_8_11) and sphinx @@ -40,7 +48,7 @@ and sphinx - cd build - cmake -DBUILD_CPP_DOCS=ON _DBUILD_PYTHON_DOCS .. -## With tests +### With tests Need googletest >= [1.8.0](https://github.com/google/googletest/releases/tag/release-1.8.0) @@ -49,4 +57,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/include/asapo/asapo_fabric/fabric_error.h b/common/cpp/include/asapo/asapo_fabric/fabric_error.h index 1a8ca01061397a9d59384fe11e92505692d0c1d8..95b4e3b1436369421df1c9760feab07ee66f0003 100644 --- a/common/cpp/include/asapo/asapo_fabric/fabric_error.h +++ b/common/cpp/include/asapo/asapo_fabric/fabric_error.h @@ -17,8 +17,8 @@ enum class FabricErrorType { }; -using FabricError = ServiceError<FabricErrorType, ErrorType::kFabricError>; -using FabricErrorTemplate = ServiceErrorTemplate<FabricErrorType, ErrorType::kFabricError>; +using FabricError = ServiceError<FabricErrorType>; +using FabricErrorTemplate = ServiceErrorTemplate<FabricErrorType>; namespace FabricErrorTemplates { auto const kNotSupportedOnBuildError = FabricErrorTemplate { diff --git a/common/cpp/include/asapo/common/common_c.h b/common/cpp/include/asapo/common/common_c.h index 08cff2ad6c14c333959fc469e512871086e47a9e..d851b87efd4ded60178c8fb605d1587c4f03d583 100644 --- a/common/cpp/include/asapo/common/common_c.h +++ b/common/cpp/include/asapo/common/common_c.h @@ -33,7 +33,7 @@ enum AsapoSourceType { kRaw }; -#define asapo_free_handle(handle) asapo_free_handle__((void**)handle); +#define asapo_free_handle(handle) asapo_free_handle__((void**)handle) void asapo_free_handle__(void** handle); void* asapo_new_handle(); diff --git a/common/cpp/include/asapo/common/data_structs.h b/common/cpp/include/asapo/common/data_structs.h index b864e310da8a0180d8bb5eab9543a7941a8703f6..1460af10bd07e7bf4abe0343988311e3cef53a95 100644 --- a/common/cpp/include/asapo/common/data_structs.h +++ b/common/cpp/include/asapo/common/data_structs.h @@ -22,6 +22,9 @@ std::chrono::system_clock::time_point TimePointfromNanosec(uint64_t nanoseconds_ std::string IsoDateFromEpochNanosecs(uint64_t time_from_epoch_nanosec); uint64_t NanosecsEpochFromISODate(std::string date_time); +std::string HostFromUri(const std::string& uri); + + bool TimeFromJson(const JsonStringParser& parser, const std::string& name, std::chrono::system_clock::time_point* val); class MessageMeta { diff --git a/common/cpp/include/asapo/common/error.h b/common/cpp/include/asapo/common/error.h index 3366ee7e80dcf175d15c86a4f6319255d991580d..510ea0866dc7c3e1659e3b3eb9680d487fe8fee1 100644 --- a/common/cpp/include/asapo/common/error.h +++ b/common/cpp/include/asapo/common/error.h @@ -5,73 +5,32 @@ #include <memory> #include <utility> #include <ostream> -namespace asapo { +#include <map> -enum class ErrorType { - kUnknownError = 0, - kAsapoError, - kHttpError, - kIOError, - kDBError, - kReceiverError, - kProducerError, - kConsumerError, - kMemoryAllocationError, - kEndOfFile, - kFabricError, -}; +namespace asapo { class ErrorInterface; class ErrorTemplateInterface; class CustomErrorData; -// nullptr == noError -// Example check: -// void TestError(Error* err) { -// if(*err) { -// [...] //An error occurred -// } -// } + using Error = std::unique_ptr<ErrorInterface>; class ErrorInterface { public: virtual std::string Explain() const noexcept = 0; - virtual void Append(const std::string& value) noexcept = 0; - virtual void Prepend(const std::string& value) noexcept = 0; - virtual ErrorType GetErrorType() const noexcept = 0; - virtual CustomErrorData* GetCustomData() = 0; - virtual void SetCustomData(std::unique_ptr<CustomErrorData> data) = 0; + virtual std::string ExplainPretty(uint8_t shift = 0) const noexcept = 0; + virtual std::string ExplainInJSON() const noexcept = 0; + virtual ErrorInterface* AddContext(std::string key, std::string value) noexcept = 0; + virtual ErrorInterface* SetCause(Error cause_err) noexcept = 0; + virtual const Error& GetCause() const noexcept = 0; + virtual CustomErrorData* GetCustomData() noexcept = 0; + virtual void SetCustomData(std::unique_ptr<CustomErrorData> data) noexcept = 0; virtual ~ErrorInterface() = default; // needed for unique_ptr to delete itself }; - -class ErrorTemplateInterface { - public: - virtual ErrorType GetErrorType() const noexcept = 0; - virtual Error Generate() const noexcept = 0; - virtual Error Generate(const std::string& suffix) const noexcept = 0; - virtual std::string Text() const noexcept = 0; - virtual inline bool operator == (const Error& rhs) const { - return rhs != nullptr && - GetErrorType() == rhs->GetErrorType(); - } - - virtual inline bool operator != (const Error& rhs) const { - return !(operator==(rhs)); - } -}; - -static inline bool operator == (const Error& lhs, const ErrorTemplateInterface& rhs) { - return rhs.operator == (lhs); -} - -static inline bool operator != (const Error& lhs, const ErrorTemplateInterface& rhs) { - return rhs.operator != (lhs); -} - static inline std::ostream& operator<<(std::ostream& os, const Error& err) { - if(err) { + if (err) { os << err->Explain(); } else { static std::string no_error = "No error"; @@ -85,148 +44,121 @@ class CustomErrorData { virtual ~CustomErrorData() = default; }; -class SimpleError: public ErrorInterface { +template<typename ServiceErrorType> +class ServiceError : public ErrorInterface { private: - std::string error_; + ServiceErrorType error_type_; + std::string error_name_; + std::string error_message_; + std::map<std::string, std::string> context_; + Error cause_err_; std::unique_ptr<CustomErrorData> custom_data_; - ErrorType error_type_ = ErrorType::kAsapoError; public: - explicit SimpleError(std::string error): error_{std::move(error)} { - - } - SimpleError(std::string error, ErrorType error_type ): error_{std::move(error)}, error_type_{error_type} { - } - - CustomErrorData* GetCustomData() override { - if (custom_data_) { - return custom_data_.get(); - } else { - return nullptr; - } - }; - - void SetCustomData(std::unique_ptr<CustomErrorData> data) override { - custom_data_ = std::move(data); - } - - void Append(const std::string& value) noexcept override { - error_ += ": " + value; - } - - void Prepend(const std::string& value) noexcept override { - error_ = value + ": " + error_; - } + ServiceError(std::string error_name, std::string error_message, ServiceErrorType error_type); + ServiceErrorType GetServiceErrorType() const noexcept; + CustomErrorData* GetCustomData() noexcept override; + void SetCustomData(std::unique_ptr<CustomErrorData> data) noexcept override; + ErrorInterface* AddContext(std::string key, std::string value) noexcept override; + ErrorInterface* SetCause(Error cause_err) noexcept override; + const Error& GetCause() const noexcept override; + std::string Explain() const noexcept override; + virtual std::string ExplainPretty(uint8_t shift) const noexcept override; + std::string ExplainInJSON() const noexcept override; +}; - std::string Explain() const noexcept override { - return error_; - } +class ErrorTemplateInterface { + public: + virtual Error Generate() const noexcept = 0; + virtual Error Generate(std::string error_message) const noexcept = 0; + virtual Error Generate(std::string error_message, Error cause) const noexcept = 0; + virtual Error Generate(Error cause) const noexcept = 0; + virtual bool operator==(const Error& rhs) const = 0; + virtual bool operator!=(const Error& rhs) const = 0; - ErrorType GetErrorType() const noexcept override { - return error_type_; - } }; +static inline bool operator==(const Error& lhs, const ErrorTemplateInterface& rhs) { + return rhs == lhs; +} -/* - * IMPORTANT: - * Never use the same ErrorType for two different errors, - * otherwise the == operator might not work as expected! - */ -class SimpleErrorTemplate : public ErrorTemplateInterface { - protected: - std::string error_; - ErrorType error_type_ = ErrorType::kAsapoError; - public: - explicit SimpleErrorTemplate(std::string error): error_{std::move(error)} { - - } +static inline bool operator!=(const Error& lhs, const ErrorTemplateInterface& rhs) { + return rhs != lhs; +} - virtual std::string Text() const noexcept override { - return error_; +template<typename ServiceErrorType> +class ServiceErrorTemplate : public ErrorTemplateInterface { + private: + std::string error_name_; + ServiceErrorType error_type_; + public: + ServiceErrorTemplate(const std::string& error_name, ServiceErrorType error_type) { + error_name_ = error_name; + error_type_ = error_type; } - - SimpleErrorTemplate(std::string error, ErrorType error_type ): error_{std::move(error)}, error_type_{error_type} { + const std::string& Text() const noexcept { + return error_name_; } - inline ErrorType GetErrorType() const noexcept override { + ServiceErrorType GetServiceErrorType() const noexcept { return error_type_; } - inline Error Generate() const noexcept override { - return Error(new SimpleError{error_, error_type_}); + Error Generate() const noexcept override; + + Error Generate(std::string error_message) const noexcept override; + Error Generate(std::string error_message, Error cause) const noexcept override; + Error Generate(Error cause) const noexcept override; + inline bool operator==(const Error& rhs) const override { + return rhs != nullptr + && GetServiceErrorType() == ((ServiceError<ServiceErrorType>*) rhs.get())->GetServiceErrorType(); } - inline Error Generate(const std::string& suffix) const noexcept override { - return Error(new SimpleError{error_ + " :" + suffix, error_type_}); + inline bool operator!=(const Error& rhs) const override { + return rhs != nullptr + && GetServiceErrorType() != ((ServiceError<ServiceErrorType>*) rhs.get())->GetServiceErrorType(); } }; -static inline std::ostream& operator<<(std::ostream& os, const SimpleErrorTemplate& err) { - return os << err.Text(); +template<typename ServiceErrorType> +static inline bool operator==(const Error& lhs, const ServiceErrorTemplate<ServiceErrorType>& rhs) { + return rhs == lhs; } - -inline Error TextError(const std::string& error) { - return Error{new SimpleError{error}}; +template<typename ServiceErrorType> +static inline bool operator!=(const Error& lhs, const ServiceErrorTemplate<ServiceErrorType>& rhs) { + return rhs != lhs; } -inline Error TextErrorWithType(const std::string& error, ErrorType error_type) { - return Error{new SimpleError{error, error_type}}; -} +namespace GeneralErrorTemplates { -namespace ErrorTemplates { -auto const kMemoryAllocationError = SimpleErrorTemplate { - "kMemoryAllocationError", ErrorType::kMemoryAllocationError -}; -auto const kEndOfFile = SimpleErrorTemplate { - "End of file", ErrorType::kEndOfFile +enum class GeneralErrorType { + kMemoryAllocationError, + kEndOfFile, + kSimpleError, }; -} +using GeneralError = ServiceError<GeneralErrorType>; +using GeneralErrorTemplate = ServiceErrorTemplate<GeneralErrorType>; -template <typename ServiceErrorType, ErrorType MainErrorType> -class ServiceError : public SimpleError { - private: - ServiceErrorType error_type_; - public: - ServiceError(const std::string& error, ServiceErrorType error_type) : SimpleError(error, MainErrorType) { - error_type_ = error_type; - } - ServiceErrorType GetServiceErrorType() const noexcept { - return error_type_; - } +auto const kMemoryAllocationError = GeneralErrorTemplate { + "memory allocation", GeneralErrorType::kMemoryAllocationError }; -template <typename ServiceErrorType, ErrorType MainErrorType> -class ServiceErrorTemplate : public SimpleErrorTemplate { - protected: - ServiceErrorType error_type_; - public: - ServiceErrorTemplate(const std::string& error, ServiceErrorType error_type) : SimpleErrorTemplate(error, - MainErrorType) { - error_type_ = error_type; - } +auto const kEndOfFile = GeneralErrorTemplate { + "end of file", GeneralErrorType::kEndOfFile +}; - inline ServiceErrorType GetServiceErrorType() const noexcept { - return error_type_; - } +auto const kSimpleError = GeneralErrorTemplate { + "unnamed error", GeneralErrorType::kSimpleError +}; - inline Error Generate() const noexcept override { - auto err = new ServiceError<ServiceErrorType, MainErrorType>(error_, error_type_); - return Error(err); - } +} - inline Error Generate(const std::string& suffix) const noexcept override { - return Error(new ServiceError<ServiceErrorType, MainErrorType>(error_ + ": " + suffix, error_type_)); - } +} + +#include "error.tpp" - inline bool operator==(const Error& rhs) const override { - return SimpleErrorTemplate::operator==(rhs) - && GetServiceErrorType() == ((ServiceError<ServiceErrorType, MainErrorType>*) rhs.get())->GetServiceErrorType(); - } -}; -} #endif //ASAPO_ERROR_H diff --git a/common/cpp/include/asapo/common/error.tpp b/common/cpp/include/asapo/common/error.tpp new file mode 100644 index 0000000000000000000000000000000000000000..95f6eed6606794d1596731640ce58b58614841c2 --- /dev/null +++ b/common/cpp/include/asapo/common/error.tpp @@ -0,0 +1,137 @@ + +#include "error.h" + +namespace asapo { + +template<typename ServiceErrorType> +ServiceError<ServiceErrorType>::ServiceError(std::string error_name, + std::string error_message, + ServiceErrorType error_type) : error_type_{ + error_type}, error_name_{std::move(error_name)}, error_message_{std::move(error_message)} { +} + +template<typename ServiceErrorType> +ServiceErrorType ServiceError<ServiceErrorType>::GetServiceErrorType() const noexcept { + return error_type_; +} + +template<typename ServiceErrorType> +CustomErrorData *ServiceError<ServiceErrorType>::GetCustomData() noexcept { + if (custom_data_) { + return custom_data_.get(); + } else { + return nullptr; + } +} + +template<typename ServiceErrorType> +void ServiceError<ServiceErrorType>::SetCustomData(std::unique_ptr<CustomErrorData> data) noexcept { + custom_data_ = std::move(data); +} + +template<typename ServiceErrorType> +std::string ServiceError<ServiceErrorType>::ExplainPretty(uint8_t shift) const noexcept { + std::string base_shift(static_cast<size_t>(shift), ' '); + std::string shift_s(static_cast<size_t>(2), ' '); + std::string err = base_shift + "error: " + error_name_; + if (!error_message_.empty()) { + err += "\n" + base_shift + shift_s + "message: " + error_message_; + } + if (!context_.empty()) { + err += "\n" + base_shift + shift_s + "context: "; + auto i = 0; + for (const auto &kv : context_) { + err += (i > 0 ? ", " : "") + kv.first + ":" + kv.second; + i++; + } + } + if (cause_err_ != nullptr) { + err += "\n" + base_shift + shift_s + "caused by: "; + err += "\n" + base_shift + shift_s + cause_err_->ExplainPretty(shift + 2); + } + return err; +} + +template<typename ServiceErrorType> +std::string ServiceError<ServiceErrorType>::Explain() const noexcept { + std::string err = "error: " + error_name_; + if (!error_message_.empty()) { + err += ", message: " + error_message_; + } + if (!context_.empty()) { + err += ", context: "; + auto i = 0; + for (const auto &kv : context_) { + err += (i > 0 ? ", " : "") + kv.first + ":" + kv.second; + i++; + } + } + if (cause_err_ != nullptr) { + err += ", caused by: " + cause_err_->Explain() ; + } + return err; +} + +template<typename ServiceErrorType> +ErrorInterface *ServiceError<ServiceErrorType>::AddContext(std::string key, std::string value) noexcept { + context_[std::move(key)] = std::move(value); + return this; +} +template<typename ServiceErrorType> +ErrorInterface *ServiceError<ServiceErrorType>::SetCause(Error cause_err) noexcept { + cause_err_ = std::move(cause_err); + return this; +} + +inline std::string WrapInQuotes(const std::string &origin) { + return "\"" + origin + "\""; +} + +template<typename ServiceErrorType> +std::string ServiceError<ServiceErrorType>::ExplainInJSON() const noexcept { + std::string err = WrapInQuotes("error") + ":" + WrapInQuotes(error_name_); + if (!error_message_.empty()) { + err += "," + WrapInQuotes("message") + ":" + WrapInQuotes(error_message_); + } + if (!context_.empty()) { + err += "," + WrapInQuotes("context") + ":{"; + auto i = 0; + for (const auto &kv : context_) { + err += (i > 0 ? ", " : "") + WrapInQuotes(kv.first) + ":" + WrapInQuotes(kv.second); + i++; + } + err += "}"; + } + if (cause_err_ != nullptr) { + err += ","+ WrapInQuotes("cause")+":{"+cause_err_->ExplainInJSON()+"}"; + } + return err; +} +template<typename ServiceErrorType> +const Error &ServiceError<ServiceErrorType>::GetCause() const noexcept { + return cause_err_; +} + +template<typename ServiceErrorType> +Error ServiceErrorTemplate<ServiceErrorType>::Generate() const noexcept { + return Generate(""); +} + +template<typename ServiceErrorType> +Error ServiceErrorTemplate<ServiceErrorType>::Generate(std::string error_message) const noexcept { + return Error(new ServiceError<ServiceErrorType>(error_name_, std::move(error_message), error_type_)); +} + +template<typename ServiceErrorType> +Error ServiceErrorTemplate<ServiceErrorType>::Generate(std::string error_message, Error cause) const noexcept { + auto err = Generate(std::move(error_message)); + err->SetCause(std::move(cause)); + return err; +} + +template<typename ServiceErrorType> +Error ServiceErrorTemplate<ServiceErrorType>::Generate(Error cause) const noexcept { + return Generate("",std::move(cause)); +} + +} diff --git a/common/cpp/include/asapo/common/io_error.h b/common/cpp/include/asapo/common/io_error.h index e11399e00bcbe73554358d49a26f4da301457910..ef15e630836fe854ea5f51f069f800413e52c5e6 100644 --- a/common/cpp/include/asapo/common/io_error.h +++ b/common/cpp/include/asapo/common/io_error.h @@ -31,8 +31,8 @@ enum class IOErrorType { kNotConnected }; -using IOError = ServiceError<IOErrorType, ErrorType::kIOError>; -using IOErrorTemplate = ServiceErrorTemplate<IOErrorType, ErrorType::kIOError>; +using IOError = ServiceError<IOErrorType>; +using IOErrorTemplate = ServiceErrorTemplate<IOErrorType>; namespace IOErrorTemplates { auto const kUnknownIOError = IOErrorTemplate { diff --git a/common/cpp/include/asapo/common/networking.h b/common/cpp/include/asapo/common/networking.h index ca2c2f8e81fb6b788581e1d1cfe13cdbc816ca39..d814a88df4db17d0f9181f46ae5cb0ec6f133da3 100644 --- a/common/cpp/include/asapo/common/networking.h +++ b/common/cpp/include/asapo/common/networking.h @@ -13,39 +13,67 @@ namespace asapo { typedef uint64_t NetworkRequestId; enum class NetworkConnectionType : uint32_t { - kUndefined, - kAsapoTcp, // ASAPOs TCP (Multiple connections for parallel data transfers) - kFabric, // Fabric connection (Primarily used for InfiniBand verbs) + kUndefined, + kAsapoTcp, // ASAPOs TCP (Multiple connections for parallel data transfers) + kFabric, // Fabric connection (Primarily used for InfiniBand verbs) }; - // do not forget to add new codes to the end! enum Opcode : uint8_t { - kOpcodeUnknownOp = 1, - kOpcodeTransferData, - kOpcodeTransferDatasetData, - kOpcodeStreamInfo, - kOpcodeLastStream, - kOpcodeGetBufferData, - kOpcodeAuthorize, - kOpcodeTransferMetaData, - kOpcodeDeleteStream, - kOpcodeGetMeta, - kOpcodeCount, + kOpcodeUnknownOp = 1, + kOpcodeTransferData, + kOpcodeTransferDatasetData, + kOpcodeStreamInfo, + kOpcodeLastStream, + kOpcodeGetBufferData, + kOpcodeAuthorize, + kOpcodeTransferMetaData, + kOpcodeDeleteStream, + kOpcodeGetMeta, + kOpcodeCount, }; +inline std::string OpcodeToString(uint8_t code) { + switch (code) { + case kOpcodeTransferData:return "transfer data"; + case kOpcodeTransferDatasetData:return "transfer dataset data"; + case kOpcodeStreamInfo:return "stream info"; + case kOpcodeLastStream:return "last stream"; + case kOpcodeGetBufferData:return "get buffer data"; + case kOpcodeAuthorize:return "authorize"; + case kOpcodeTransferMetaData:return "transfer metadata"; + case kOpcodeDeleteStream:return "delete stream"; + case kOpcodeGetMeta:return "get meta"; + default:return "unknown op"; + } +} enum NetworkErrorCode : uint16_t { - kNetErrorNoError, - kNetErrorReauthorize, - kNetErrorWarning, - kNetErrorWrongRequest, - kNetErrorNotSupported, - kNetErrorNoData, - kNetAuthorizationError, - kNetErrorInternalServerError = 65535, + kNetErrorNoError, + kNetErrorReauthorize, + kNetErrorWarning, + kNetErrorWrongRequest, + kNetErrorNotSupported, + kNetErrorNoData, + kNetAuthorizationError, + kNetErrorInternalServerError = 65535, }; +inline std::string NetworkErrorCodeToString(uint16_t code) { + switch (code) { + case kNetErrorNoError:return "success"; + case kNetErrorReauthorize:return "reauthorize"; + case kNetErrorWarning:return "warning"; + case kNetErrorWrongRequest:return "wrong request"; + case kNetErrorNotSupported:return "not suported"; + case kNetErrorNoData:return "no data"; + case kNetAuthorizationError:return "authorization error"; + case kNetErrorInternalServerError:return "internal server error"; + default:return "unknown code"; + } +} + + //TODO need to use an serialization framework to ensure struct consistency on different computers const std::size_t kMaxMessageSize = 1024; @@ -58,51 +86,52 @@ const std::size_t kPosMetaIngestMode = 1; const std::size_t kPosDataSetSize = 2; struct GenericRequestHeader { - GenericRequestHeader(const GenericRequestHeader& header) { - op_code = header.op_code, data_id = header.data_id, data_size = header.data_size, meta_size = header.meta_size, - memcpy(custom_data, header.custom_data, kNCustomParams * sizeof(uint64_t)), - memcpy(message, header.message, kMaxMessageSize); - strncpy(stream, header.stream, kMaxMessageSize); - strncpy(api_version, header.api_version, kMaxVersionSize); - } - - /* Keep in mind that the message here is just strncpy'ed, you can change the message later */ - GenericRequestHeader(Opcode i_op_code = kOpcodeUnknownOp, uint64_t i_data_id = 0, - uint64_t i_data_size = 0, uint64_t i_meta_size = 0, const std::string& i_message = "", - const std::string& i_stream = ""): - op_code{i_op_code}, data_id{i_data_id}, data_size{i_data_size}, meta_size{i_meta_size} { - strncpy(message, i_message.c_str(), kMaxMessageSize); - strncpy(stream, i_stream.c_str(), kMaxMessageSize); - strncpy(api_version, "v0.0", kMaxVersionSize); - } - - Opcode op_code; - uint64_t data_id; - uint64_t data_size; - uint64_t meta_size; - CustomRequestData custom_data; - char message[kMaxMessageSize]; /* Can also be a binary message (e.g. MemoryRegionDetails) */ - char stream[kMaxMessageSize]; /* Must be a string (strcpy is used) */ - char api_version[kMaxVersionSize]; /* Must be a string (strcpy is used) */ - std::string Json() { - std::string s = "{\"id\":" + std::to_string(data_id) + "," - "\"buffer\":\"" + std::string(message) + "\"" + "," - "\"stream\":\"" + std::string(stream) + "\"" - + "}"; - return s; - }; + GenericRequestHeader(const GenericRequestHeader &header) { + operator=(header); + } + GenericRequestHeader &operator=(const GenericRequestHeader &header) { + op_code = header.op_code, data_id = header.data_id, data_size = header.data_size, meta_size = header.meta_size, + memcpy(custom_data, header.custom_data, kNCustomParams * sizeof(uint64_t)), + memcpy(message, header.message, kMaxMessageSize); + strncpy(stream, header.stream, kMaxMessageSize); + strncpy(api_version, header.api_version, kMaxVersionSize); + return *this; + }; + /* Keep in mind that the message here is just strncpy'ed, you can change the message later */ + GenericRequestHeader(Opcode i_op_code = kOpcodeUnknownOp, uint64_t i_data_id = 0, + uint64_t i_data_size = 0, uint64_t i_meta_size = 0, const std::string &i_message = "", + const std::string &i_stream = "") : + op_code{i_op_code}, data_id{i_data_id}, data_size{i_data_size}, meta_size{i_meta_size} { + strncpy(message, i_message.c_str(), kMaxMessageSize); + strncpy(stream, i_stream.c_str(), kMaxMessageSize); + strncpy(api_version, "v0.0", kMaxVersionSize); + } + + Opcode op_code; + uint64_t data_id; + uint64_t data_size; + uint64_t meta_size; + CustomRequestData custom_data; + char message[kMaxMessageSize]; /* Can also be a binary message (e.g. MemoryRegionDetails) */ + char stream[kMaxMessageSize]; /* Must be a string (strcpy is used) */ + char api_version[kMaxVersionSize]; /* Must be a string (strcpy is used) */ + std::string Json() { + std::string s = "{\"id\":" + std::to_string(data_id) + "," + "\"buffer\":\"" + std::string(message) + "\"" + "," + "\"stream\":\"" + + std::string(stream) + "\"" + + "}"; + return s; + }; }; - - struct GenericNetworkResponse { - Opcode op_code; - NetworkErrorCode error_code; - char message[kMaxMessageSize]; + Opcode op_code; + NetworkErrorCode error_code; + char message[kMaxMessageSize]; }; - -struct SendResponse : GenericNetworkResponse { +struct SendResponse : GenericNetworkResponse { }; } diff --git a/common/cpp/include/asapo/database/db_error.h b/common/cpp/include/asapo/database/db_error.h index 6128dcbbd76c50f28a7d8c1c5430bb35345b6734..aa16a143fc511c2532cfc056b9c5f4ed36f06a41 100644 --- a/common/cpp/include/asapo/database/db_error.h +++ b/common/cpp/include/asapo/database/db_error.h @@ -20,8 +20,8 @@ enum class DBErrorType { kWrongInput }; -using DBError = ServiceError<DBErrorType, ErrorType::kDBError>; -using DBErrorTemplate = ServiceErrorTemplate<DBErrorType, ErrorType::kDBError>; +using DBError = ServiceError<DBErrorType>; +using DBErrorTemplate = ServiceErrorTemplate<DBErrorType>; namespace DBErrorTemplates { diff --git a/common/cpp/include/asapo/http_client/http_error.h b/common/cpp/include/asapo/http_client/http_error.h index b701cb31d7eeb214be0f6a5e7c07fbcf258a294a..a52af7bfbabab201f8151f599d38600203ecded9 100644 --- a/common/cpp/include/asapo/http_client/http_error.h +++ b/common/cpp/include/asapo/http_client/http_error.h @@ -11,7 +11,7 @@ enum class HttpErrorType { kConnectionError }; -using HttpErrorTemplate = ServiceErrorTemplate<HttpErrorType, ErrorType::kHttpError>; +using HttpErrorTemplate = ServiceErrorTemplate<HttpErrorType>; namespace HttpErrorTemplates { diff --git a/common/cpp/include/asapo/logger/logger.h b/common/cpp/include/asapo/logger/logger.h index 030c39184b4e43d8dbfa364ad3b6f3798fbb2495..e4dc868959f8b5347b95a7a51b19623f166a6e73 100644 --- a/common/cpp/include/asapo/logger/logger.h +++ b/common/cpp/include/asapo/logger/logger.h @@ -6,6 +6,7 @@ #include "asapo/common/error.h" #include <ostream> + namespace asapo { enum class LogLevel { @@ -20,12 +21,16 @@ class LogMessageWithFields { public: LogMessageWithFields(std::string key, uint64_t val); LogMessageWithFields(std::string key, double val, int precision); + LogMessageWithFields(std::string val); + LogMessageWithFields(const Error& error); LogMessageWithFields(std::string key, std::string val); LogMessageWithFields& Append(std::string key, uint64_t val); LogMessageWithFields& Append(std::string key, double val, int precision); + LogMessageWithFields& Append(const LogMessageWithFields& log_msg); LogMessageWithFields& Append(std::string key, std::string val); std::string LogString() const; private: + inline std::string QuoteIFNeeded(); std::string log_string_; }; @@ -37,6 +42,10 @@ class AbstractLogger { virtual void Error(const std::string& text) const = 0; virtual void Debug(const std::string& text) const = 0; virtual void Warning(const std::string& text) const = 0; + virtual void Info(const asapo::Error& error) const = 0; + virtual void Error(const asapo::Error& error) const = 0; + virtual void Debug(const asapo::Error& error) const = 0; + virtual void Warning(const asapo::Error& error) const = 0; virtual void Info(const LogMessageWithFields& msg) const = 0; virtual void Error(const LogMessageWithFields& msg) const = 0; virtual void Debug(const LogMessageWithFields& msg) const = 0; diff --git a/common/cpp/include/asapo/request/request_pool.h b/common/cpp/include/asapo/request/request_pool.h index 2af119d68a24cbdc89791a22d7ea549f0658536c..32be614b0f7aaa0a3168778255f916d928ea6ad2 100644 --- a/common/cpp/include/asapo/request/request_pool.h +++ b/common/cpp/include/asapo/request/request_pool.h @@ -34,7 +34,7 @@ class RequestPool { VIRTUAL uint64_t NRequestsInPool(); VIRTUAL uint64_t UsedMemoryInPool(); VIRTUAL Error WaitRequestsFinished(uint64_t timeout_ms); - VIRTUAL void StopThreads(); + void StopThreads(); private: const AbstractLogger* log__; RequestHandlerFactory* request_handler_factory__; diff --git a/common/cpp/include/asapo/unittests/MockDatabase.h b/common/cpp/include/asapo/unittests/MockDatabase.h index b8f94b260fb13f4554ea86e71f59166a9b32b4bd..887653507910802a51fe56d66037dd4ec99db07e 100644 --- a/common/cpp/include/asapo/unittests/MockDatabase.h +++ b/common/cpp/include/asapo/unittests/MockDatabase.h @@ -25,25 +25,23 @@ class MockDatabase : public Database { return Error{InsertAsDatasetMessage_t(collection, file, dataset_size, ignore_duplicates)}; } - MOCK_METHOD2(Connect_t, ErrorInterface * (const std::string&, const std::string&)); - MOCK_CONST_METHOD4(Insert_t, ErrorInterface * (const std::string&, const MessageMeta&, bool, uint64_t*)); + MOCK_METHOD(ErrorInterface *, Connect_t, (const std::string&, const std::string&), ()); + MOCK_METHOD(ErrorInterface *, Insert_t, (const std::string&, const MessageMeta&, bool, uint64_t*), (const)); - MOCK_CONST_METHOD4(InsertAsDatasetMessage_t, - ErrorInterface * (const std::string&, const MessageMeta&, uint64_t, bool)); + MOCK_METHOD(ErrorInterface *, InsertAsDatasetMessage_t, (const std::string&, const MessageMeta&, uint64_t, bool), (const)); Error InsertMeta(const std::string& collection, const std::string& id, const uint8_t* data, uint64_t size, MetaIngestMode mode) const override { return Error{InsertMeta_t(collection, id, data, size, mode)}; } - MOCK_CONST_METHOD5(InsertMeta_t, ErrorInterface * (const std::string&, const std::string& id, const uint8_t* data, - uint64_t size, MetaIngestMode mode)); + MOCK_METHOD(ErrorInterface *, InsertMeta_t, (const std::string&, const std::string& id, const uint8_t* data, uint64_t size, MetaIngestMode mode), (const)); Error GetById(const std::string& collection, uint64_t id, MessageMeta* file) const override { return Error{GetById_t(collection, id, file)}; } - MOCK_CONST_METHOD3(GetById_t, ErrorInterface * (const std::string&, uint64_t id, MessageMeta*)); + MOCK_METHOD(ErrorInterface *, GetById_t, (const std::string&, uint64_t id, MessageMeta*), (const)); Error GetDataSetById(const std::string& collection, uint64_t set_id, uint64_t id, MessageMeta* file) const override { return Error{GetSetById_t(collection, set_id, id, file)}; @@ -52,31 +50,31 @@ class MockDatabase : public Database { Error GetMetaFromDb(const std::string& collection, const std::string& id, std::string* res) const override { return Error{GetMetaFromDb_t(collection, id, res)}; } - MOCK_CONST_METHOD3(GetMetaFromDb_t, ErrorInterface * (const std::string&, const std::string&, std::string* res)); + MOCK_METHOD(ErrorInterface *, GetMetaFromDb_t, (const std::string&, const std::string&, std::string* res), (const)); - MOCK_CONST_METHOD4(GetSetById_t, ErrorInterface * (const std::string&, uint64_t set_id, uint64_t id, MessageMeta*)); + MOCK_METHOD(ErrorInterface *, GetSetById_t, (const std::string&, uint64_t set_id, uint64_t id, MessageMeta*), (const)); Error GetStreamInfo(const std::string& collection, StreamInfo* info) const override { return Error{GetStreamInfo_t(collection, info)}; } - MOCK_CONST_METHOD2(GetStreamInfo_t, ErrorInterface * (const std::string&, StreamInfo*)); + MOCK_METHOD(ErrorInterface *, GetStreamInfo_t, (const std::string&, StreamInfo*), (const)); Error GetLastStream(StreamInfo* info) const override { return Error{GetLastStream_t(info)}; } - MOCK_CONST_METHOD1(DeleteStream_t, ErrorInterface * (const std::string&)); + MOCK_METHOD(ErrorInterface *, DeleteStream_t, (const std::string&), (const)); Error DeleteStream(const std::string& stream) const override { return Error{DeleteStream_t(stream)}; } - MOCK_CONST_METHOD1(GetLastStream_t, ErrorInterface * (StreamInfo*)); + MOCK_METHOD(ErrorInterface *, GetLastStream_t, (StreamInfo*), (const)); // stuff to test db destructor is called and avoid "uninteresting call" messages - MOCK_METHOD0(Die, void()); + MOCK_METHOD(void, Die, (), ()); virtual ~MockDatabase() override { if (check_destructor) Die(); diff --git a/common/cpp/include/asapo/unittests/MockFabric.h b/common/cpp/include/asapo/unittests/MockFabric.h index 2ce3823c0dcde6cac675053eb0369a66ed615aa0..c08596b908d5bd7537796a352f5050b2c66b132b 100644 --- a/common/cpp/include/asapo/unittests/MockFabric.h +++ b/common/cpp/include/asapo/unittests/MockFabric.h @@ -13,13 +13,13 @@ class MockFabricMemoryRegion : public FabricMemoryRegion { ~MockFabricMemoryRegion() override { Destructor(); } - MOCK_METHOD0(Destructor, void()); - MOCK_CONST_METHOD0(GetDetails, const MemoryRegionDetails * ()); + MOCK_METHOD(void, Destructor, (), ()); + MOCK_METHOD(const MemoryRegionDetails *, GetDetails, (), (const, override)); }; class MockFabricContext : public FabricContext { public: - MOCK_CONST_METHOD0(GetAddress, std::string()); + MOCK_METHOD(std::string, GetAddress, (), (const, override)); std::unique_ptr<FabricMemoryRegion> ShareMemoryRegion(void* src, size_t size, Error* error) override { ErrorInterface* err = nullptr; @@ -27,7 +27,7 @@ class MockFabricContext : public FabricContext { error->reset(err); return std::unique_ptr<FabricMemoryRegion> {data}; } - MOCK_METHOD3(ShareMemoryRegion_t, FabricMemoryRegion * (void* src, size_t size, ErrorInterface** err)); + MOCK_METHOD(FabricMemoryRegion *, ShareMemoryRegion_t, (void* src, size_t size, ErrorInterface** err), ()); void Send(FabricAddress dstAddress, FabricMessageId messageId, const void* src, size_t size, Error* error) override { @@ -35,8 +35,7 @@ class MockFabricContext : public FabricContext { Send_t(dstAddress, messageId, src, size, &err); error->reset(err); } - MOCK_METHOD5(Send_t, void(FabricAddress dstAddress, FabricMessageId messageId, - const void* src, size_t size, ErrorInterface** err)); + MOCK_METHOD(void, Send_t, (FabricAddress dstAddress, FabricMessageId messageId, const void* src, size_t size, ErrorInterface** err), ()); void Recv(FabricAddress srcAddress, FabricMessageId messageId, void* dst, size_t size, Error* error) override { @@ -44,8 +43,7 @@ class MockFabricContext : public FabricContext { Recv_t(srcAddress, messageId, dst, size, &err); error->reset(err); } - MOCK_METHOD5(Recv_t, void(FabricAddress dstAddress, FabricMessageId messageId, - const void* src, size_t size, ErrorInterface** err)); + MOCK_METHOD(void, Recv_t, (FabricAddress dstAddress, FabricMessageId messageId, const void* src, size_t size, ErrorInterface** err), ()); void RdmaWrite(FabricAddress dstAddress, const MemoryRegionDetails* details, const void* buffer, size_t size, @@ -54,8 +52,7 @@ class MockFabricContext : public FabricContext { RdmaWrite_t(dstAddress, details, buffer, size, &err); error->reset(err); } - MOCK_METHOD5(RdmaWrite_t, void(FabricAddress dstAddress, const MemoryRegionDetails* details, const void* buffer, - size_t size, ErrorInterface** error)); + MOCK_METHOD(void, RdmaWrite_t, (FabricAddress dstAddress, const MemoryRegionDetails* details, const void* buffer, size_t size, ErrorInterface** error), ()); }; class MockFabricClient : public MockFabricContext, public FabricClient { @@ -66,7 +63,7 @@ class MockFabricClient : public MockFabricContext, public FabricClient { error->reset(err); return data; } - MOCK_METHOD2(AddServerAddress_t, FabricAddress (const std::string& serverAddress, ErrorInterface** err)); + MOCK_METHOD(FabricAddress, AddServerAddress_t, (const std::string& serverAddress, ErrorInterface** err), ()); public: // Link to FabricContext std::string GetAddress() const override { return MockFabricContext::GetAddress(); @@ -100,8 +97,7 @@ class MockFabricServer : public MockFabricContext, public FabricServer { RecvAny_t(srcAddress, messageId, dst, size, &err); error->reset(err); } - MOCK_METHOD5(RecvAny_t, void(FabricAddress* srcAddress, FabricMessageId* messageId, - void* dst, size_t size, ErrorInterface** err)); + MOCK_METHOD(void, RecvAny_t, (FabricAddress* srcAddress, FabricMessageId* messageId, void* dst, size_t size, ErrorInterface** err), ()); public: // Link to FabricContext std::string GetAddress() const override { return MockFabricContext::GetAddress(); @@ -138,9 +134,7 @@ class MockFabricFactory : public FabricFactory { error->reset(err); return std::unique_ptr<FabricServer> {data}; } - MOCK_CONST_METHOD4(CreateAndBindServer_t, - FabricServer * (const AbstractLogger* logger, const std::string& host, - uint16_t port, ErrorInterface** err)); + MOCK_METHOD(FabricServer *, CreateAndBindServer_t, (const AbstractLogger* logger, const std::string& host, uint16_t port, ErrorInterface** err), (const)); std::unique_ptr<FabricClient> CreateClient(Error* error) const override { ErrorInterface* err = nullptr; @@ -148,8 +142,7 @@ class MockFabricFactory : public FabricFactory { error->reset(err); return std::unique_ptr<FabricClient> {data}; } - MOCK_CONST_METHOD1(CreateClient_t, - FabricClient * (ErrorInterface** err)); + MOCK_METHOD(FabricClient *, CreateClient_t, (ErrorInterface** err), (const)); }; } } diff --git a/common/cpp/include/asapo/unittests/MockHttpClient.h b/common/cpp/include/asapo/unittests/MockHttpClient.h index d5d318ed8890ecc2d245a9d8e76e934788337dc0..92d31d9c007698627154208f167d6324f4738e67 100644 --- a/common/cpp/include/asapo/unittests/MockHttpClient.h +++ b/common/cpp/include/asapo/unittests/MockHttpClient.h @@ -41,17 +41,12 @@ class MockHttpClient : public HttpClient { return UrlEscape_t(uri); } - MOCK_CONST_METHOD1(UrlEscape_t, std::string(const std::string& uri)); + MOCK_METHOD(std::string, UrlEscape_t, (const std::string& uri), (const)); - MOCK_CONST_METHOD3(Get_t, - std::string(const std::string& uri, HttpCode* code, ErrorInterface** err)); - MOCK_CONST_METHOD5(Post_t, - std::string(const std::string& uri, const std::string& cookie, const std::string& data, HttpCode* code, - ErrorInterface** err)); - MOCK_CONST_METHOD6(PostReturnArray_t, - ErrorInterface * (const std::string& uri, const std::string& cookie, const std::string& input_data, - MessageData* ouput_data, uint64_t output_data_size, HttpCode* code)); + MOCK_METHOD(std::string, Get_t, (const std::string& uri, HttpCode* code, ErrorInterface** err), (const)); + MOCK_METHOD(std::string, Post_t, (const std::string& uri, const std::string& cookie, const std::string& data, HttpCode* code, ErrorInterface** err), (const)); + MOCK_METHOD(ErrorInterface *, PostReturnArray_t, (const std::string& uri, const std::string& cookie, const std::string& input_data, MessageData* ouput_data, uint64_t output_data_size, HttpCode* code), (const)); }; diff --git a/common/cpp/include/asapo/unittests/MockIO.h b/common/cpp/include/asapo/unittests/MockIO.h index 9f32eadc4679299ba6d1771265cd84127dffd9f4..7e3c29fd534338a3baff0170da934327d6354331 100644 --- a/common/cpp/include/asapo/unittests/MockIO.h +++ b/common/cpp/include/asapo/unittests/MockIO.h @@ -16,25 +16,25 @@ class MockIO : public IO { return res; } - MOCK_CONST_METHOD1(GetHostName_t, std::string(ErrorInterface** err)); + MOCK_METHOD(std::string, GetHostName_t, (ErrorInterface** err), (const)); std::string AddressFromSocket(SocketDescriptor socket) const noexcept override { return AddressFromSocket_t(socket); } - MOCK_CONST_METHOD1(AddressFromSocket_t, std::string (SocketDescriptor socket)); + MOCK_METHOD(std::string, AddressFromSocket_t, (SocketDescriptor socket), (const)); std::unique_ptr<std::thread> NewThread(const std::string&, std::function<void()> function) const override { return std::unique_ptr<std::thread>(NewThread_t(function)); } - MOCK_CONST_METHOD1(NewThread_t, std::thread * (std::function<void()> function)); + MOCK_METHOD(std::thread *, NewThread_t, (std::function<void()> function), (const)); std::unique_ptr<std::thread> NewThread(const std::string&, std::function<void(uint64_t index)> function, uint64_t index) const override { return std::unique_ptr<std::thread>(NewThread_t(function, index)); } - MOCK_CONST_METHOD2(NewThread_t, std::thread * (std::function<void(uint64_t)> function, uint64_t index)); + MOCK_METHOD(std::thread *, NewThread_t, (std::function<void(uint64_t)> function, uint64_t index), (const)); ListSocketDescriptors WaitSocketsActivity(SocketDescriptor master_socket, ListSocketDescriptors* sockets_to_listen, @@ -45,9 +45,7 @@ class MockIO : public IO { return data; } - MOCK_CONST_METHOD4(WaitSocketsActivity_t, ListSocketDescriptors(SocketDescriptor master_socket, - ListSocketDescriptors* sockets_to_listen, - std::vector<std::string>* connections, ErrorInterface** err)); + MOCK_METHOD(ListSocketDescriptors, WaitSocketsActivity_t, (SocketDescriptor master_socket, ListSocketDescriptors* sockets_to_listen, std::vector<std::string>* connections, ErrorInterface** err), (const)); SocketDescriptor CreateSocket(AddressFamilies address_family, SocketTypes socket_type, SocketProtocols socket_protocol, @@ -57,15 +55,14 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD4(CreateSocket_t, SocketDescriptor(AddressFamilies address_family, SocketTypes socket_type, - SocketProtocols socket_protocol, ErrorInterface** err)); + MOCK_METHOD(SocketDescriptor, CreateSocket_t, (AddressFamilies address_family, SocketTypes socket_type, SocketProtocols socket_protocol, ErrorInterface** err), (const)); void Listen(SocketDescriptor socket_fd, int backlog, Error* err) const override { ErrorInterface* error = nullptr; Listen_t(socket_fd, backlog, &error); err->reset(error); } - MOCK_CONST_METHOD3(Listen_t, void(SocketDescriptor socket_fd, int backlog, ErrorInterface** err)); + MOCK_METHOD(void, Listen_t, (SocketDescriptor socket_fd, int backlog, ErrorInterface** err), (const)); void InetBind(SocketDescriptor socket_fd, const std::string& address, Error* err) const override { @@ -73,7 +70,7 @@ class MockIO : public IO { InetBind_t(socket_fd, address, &error); err->reset(error); } - MOCK_CONST_METHOD3(InetBind_t, void(SocketDescriptor socket_fd, const std::string& address, ErrorInterface** err)); + MOCK_METHOD(void, InetBind_t, (SocketDescriptor socket_fd, const std::string& address, ErrorInterface** err), (const)); SocketDescriptor CreateAndBindIPTCPSocketListener(const std::string& address, int backlog, Error* err) const override { ErrorInterface* error = nullptr; @@ -81,8 +78,7 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD3(CreateAndBindIPTCPSocketListener_t, SocketDescriptor(const std::string& address, int backlog, - ErrorInterface** err)); + MOCK_METHOD(SocketDescriptor, CreateAndBindIPTCPSocketListener_t, (const std::string& address, int backlog, ErrorInterface** err), (const)); std::unique_ptr<std::tuple<std::string, SocketDescriptor>> InetAcceptConnection(SocketDescriptor socket_fd, @@ -92,8 +88,7 @@ class MockIO : public IO { err->reset(error); return std::unique_ptr<std::tuple<std::string, SocketDescriptor>>(data); } - MOCK_CONST_METHOD2(InetAcceptConnection_t, std::tuple<std::string, SocketDescriptor>* (SocketDescriptor socket_fd, - ErrorInterface** err)); + MOCK_METHOD((std::tuple<std::string, SocketDescriptor>*), InetAcceptConnection_t, (SocketDescriptor socket_fd, ErrorInterface** err), (const)); std::string ResolveHostnameToIp(const std::string& hostname, Error* err) const override { ErrorInterface* error = nullptr; @@ -101,14 +96,14 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD2(ResolveHostnameToIp_t, std::string(const std::string& hostname, ErrorInterface** err)); + MOCK_METHOD(std::string, ResolveHostnameToIp_t, (const std::string& hostname, ErrorInterface** err), (const)); void InetConnect(SocketDescriptor socket_fd, const std::string& address, Error* err) const override { ErrorInterface* error = nullptr; InetConnect_t(socket_fd, address, &error); err->reset(error); } - MOCK_CONST_METHOD3(InetConnect_t, void(SocketDescriptor socket_fd, const std::string& address, ErrorInterface** err)); + MOCK_METHOD(void, InetConnect_t, (SocketDescriptor socket_fd, const std::string& address, ErrorInterface** err), (const)); SocketDescriptor CreateAndConnectIPTCPSocket(const std::string& address, Error* err) const override { ErrorInterface* error = nullptr; @@ -116,7 +111,7 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD2(CreateAndConnectIPTCPSocket_t, SocketDescriptor(const std::string& address, ErrorInterface** err)); + MOCK_METHOD(SocketDescriptor, CreateAndConnectIPTCPSocket_t, (const std::string& address, ErrorInterface** err), (const)); size_t Receive(SocketDescriptor socket_fd, void* buf, size_t length, Error* err) const override { ErrorInterface* error = nullptr; @@ -124,7 +119,7 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD4(Receive_t, size_t(SocketDescriptor socket_fd, void* buf, size_t length, ErrorInterface** err)); + MOCK_METHOD(size_t, Receive_t, (SocketDescriptor socket_fd, void* buf, size_t length, ErrorInterface** err), (const)); size_t ReceiveWithTimeout(SocketDescriptor socket_fd, void* buf, size_t length, long timeout_in_usec, Error* err) const override { @@ -133,9 +128,7 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD5(ReceiveWithTimeout_t, size_t(SocketDescriptor socket_fd, void* buf, size_t length, - long timeout_in_usec, - ErrorInterface** err)); + MOCK_METHOD(size_t, ReceiveWithTimeout_t, (SocketDescriptor socket_fd, void* buf, size_t length, long timeout_in_usec, ErrorInterface** err), (const)); size_t Send(SocketDescriptor socket_fd, const void* buf, size_t length, Error* err) const override { ErrorInterface* error = nullptr; @@ -143,20 +136,20 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD4(Send_t, size_t(SocketDescriptor socket_fd, const void* buf, size_t length, ErrorInterface** err)); + MOCK_METHOD(size_t, Send_t, (SocketDescriptor socket_fd, const void* buf, size_t length, ErrorInterface** err), (const)); std::unique_ptr<std::tuple<std::string, uint16_t>> SplitAddressToHostnameAndPort(const std::string& address) const override { return std::unique_ptr<std::tuple<std::string, uint16_t>>(SplitAddressToHostnameAndPort_t(address)); } - MOCK_CONST_METHOD1(SplitAddressToHostnameAndPort_t, std::tuple<std::string, uint16_t>* (const std::string& address)); + MOCK_METHOD((std::tuple<std::string, uint16_t>*), SplitAddressToHostnameAndPort_t, (const std::string& address), (const)); void Skip(SocketDescriptor socket_fd, size_t length, Error* err) const override { ErrorInterface* error = nullptr; Skip_t(socket_fd, length, &error); err->reset(error); } - MOCK_CONST_METHOD3(Skip_t, void(SocketDescriptor socket_fd, size_t length, ErrorInterface** err)); + MOCK_METHOD(void, Skip_t, (SocketDescriptor socket_fd, size_t length, ErrorInterface** err), (const)); void CloseSocket(SocketDescriptor socket_fd, Error* err) const override { ErrorInterface* error = nullptr; @@ -165,7 +158,7 @@ class MockIO : public IO { err->reset(error); } } - MOCK_CONST_METHOD2(CloseSocket_t, void(SocketDescriptor socket_fd, ErrorInterface** err)); + MOCK_METHOD(void, CloseSocket_t, (SocketDescriptor socket_fd, ErrorInterface** err), (const)); FileDescriptor Open(const std::string& filename, int open_flags, Error* err) const override { ErrorInterface* error = nullptr; @@ -173,16 +166,16 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD3(Open_t, FileDescriptor(const std::string& filename, int open_flags, ErrorInterface** err)); + MOCK_METHOD(FileDescriptor, Open_t, (const std::string& filename, int open_flags, ErrorInterface** err), (const)); void Close(FileDescriptor fd, Error* err) const override { ErrorInterface* error = nullptr; Close_t(fd, &error); if(err) { err->reset(error); - }; + } } - MOCK_CONST_METHOD2(Close_t, void(FileDescriptor fd, ErrorInterface** err)); + MOCK_METHOD(void, Close_t, (FileDescriptor fd, ErrorInterface** err), (const)); size_t Read(FileDescriptor fd, void* buf, size_t length, Error* err) const override { ErrorInterface* error = nullptr; @@ -190,7 +183,7 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD4(Read_t, size_t(FileDescriptor fd, void* buf, size_t length, ErrorInterface** err)); + MOCK_METHOD(size_t, Read_t, (FileDescriptor fd, void* buf, size_t length, ErrorInterface** err), (const)); size_t Write(FileDescriptor fd, const void* buf, size_t length, Error* err) const override { ErrorInterface* error = nullptr; @@ -198,14 +191,14 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD4(Write_t, size_t(FileDescriptor fd, const void* buf, size_t length, ErrorInterface** err)); + MOCK_METHOD(size_t, Write_t, (FileDescriptor fd, const void* buf, size_t length, ErrorInterface** err), (const)); void CreateNewDirectory(const std::string& directory_name, asapo::Error* err) const override { ErrorInterface* error = nullptr; CreateNewDirectory_t(directory_name, &error); err->reset(error); } - MOCK_CONST_METHOD2(CreateNewDirectory_t, void(const std::string& directory_name, ErrorInterface** err)); + MOCK_METHOD(void, CreateNewDirectory_t, (const std::string& directory_name, ErrorInterface** err), (const)); MessageData GetDataFromFile(const std::string& fname, uint64_t* fsize, Error* err) const override { std::function<ErrorInterface*()> error; @@ -218,20 +211,19 @@ class MockIO : public IO { return MessageData(data); } - MOCK_CONST_METHOD3(GetDataFromFile_t, uint8_t* (const std::string& fname, uint64_t* fsize, - std::function<ErrorInterface*()>* err_gen)); + MOCK_METHOD(uint8_t*, GetDataFromFile_t, (const std::string& fname, uint64_t* fsize, std::function<ErrorInterface*()>* err_gen), (const)); Error GetLastError() const override { return Error{GetLastError_t()}; } - MOCK_CONST_METHOD0(GetLastError_t, ErrorInterface * ()); + MOCK_METHOD(ErrorInterface *, GetLastError_t, (), (const)); Error SendFile(SocketDescriptor socket_fd, const std::string& fname, size_t length) const override { return Error{SendFile_t(socket_fd, fname, length)}; } - MOCK_CONST_METHOD3(SendFile_t, ErrorInterface * (SocketDescriptor socket_fd, const std::string& fname, size_t length)); + MOCK_METHOD(ErrorInterface *, SendFile_t, (SocketDescriptor socket_fd, const std::string& fname, size_t length), (const)); Error WriteDataToFile(const std::string& root_folder, const std::string& fname, const MessageData& data, size_t length, bool create_directories, bool allow_ovewrite) const override { @@ -239,7 +231,7 @@ class MockIO : public IO { } - MOCK_CONST_METHOD1(RemoveFile_t, ErrorInterface * (const std::string& fname)); + MOCK_METHOD(ErrorInterface *, RemoveFile_t, (const std::string& fname), (const)); Error WriteDataToFile(const std::string& root_folder, const std::string& fname, const uint8_t* data, size_t length, bool create_directories, bool allow_ovewrite) const override { @@ -252,8 +244,7 @@ class MockIO : public IO { } - MOCK_CONST_METHOD6(ReceiveDataToFile_t, ErrorInterface * (SocketDescriptor socket, const std::string& root_folder, - const std::string& fname, size_t fsize, bool create_directories, bool allow_ovewrite)); + MOCK_METHOD(ErrorInterface *, ReceiveDataToFile_t, (SocketDescriptor socket, const std::string& root_folder, const std::string& fname, size_t fsize, bool create_directories, bool allow_ovewrite), (const)); Error ReceiveDataToFile(SocketDescriptor socket, const std::string& root_folder, const std::string& fname, size_t length, bool create_directories, bool allow_ovewrite) const override { @@ -261,8 +252,7 @@ class MockIO : public IO { } - MOCK_CONST_METHOD6(WriteDataToFile_t, ErrorInterface * (const std::string& root_folder, const std::string& fname, - const uint8_t* data, size_t fsize, bool create_directories, bool allow_ovewrite)); + MOCK_METHOD(ErrorInterface *, WriteDataToFile_t, (const std::string& root_folder, const std::string& fname, const uint8_t* data, size_t fsize, bool create_directories, bool allow_ovewrite), (const)); MessageMeta GetMessageMeta(const std::string& name, Error* err) const override { @@ -273,7 +263,7 @@ class MockIO : public IO { } - MOCK_CONST_METHOD2(GetMessageMeta_t, MessageMeta (const std::string& name, ErrorInterface** err)); + MOCK_METHOD(MessageMeta, GetMessageMeta_t, (const std::string& name, ErrorInterface** err), (const)); std::vector<MessageMeta> FilesInFolder(const std::string& folder, Error* err) const override { ErrorInterface* error = nullptr; @@ -281,7 +271,7 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD2(FilesInFolder_t, std::vector<MessageMeta>(const std::string& folder, ErrorInterface** err)); + MOCK_METHOD(std::vector<MessageMeta>, FilesInFolder_t, (const std::string& folder, ErrorInterface** err), (const)); SubDirList GetSubDirectories(const std::string& path, Error* err) const override { @@ -291,7 +281,7 @@ class MockIO : public IO { return data; }; - MOCK_CONST_METHOD2(GetSubDirectories_t, SubDirList(const std::string& path, ErrorInterface** err)); + MOCK_METHOD(SubDirList, GetSubDirectories_t, (const std::string& path, ErrorInterface** err), (const)); std::string ReadFileToString(const std::string& fname, Error* err) const override { @@ -300,7 +290,7 @@ class MockIO : public IO { err->reset(error); return data; } - MOCK_CONST_METHOD2(ReadFileToString_t, std::string(const std::string& fname, ErrorInterface** err)); + MOCK_METHOD(std::string, ReadFileToString_t, (const std::string& fname, ErrorInterface** err), (const)); diff --git a/common/cpp/include/asapo/unittests/MockLogger.h b/common/cpp/include/asapo/unittests/MockLogger.h index 0a8938ad392cae85b7d115ca2d61c048ee926c99..be3518fcf570bac6816cbe3b75cbb3d8c0090b90 100644 --- a/common/cpp/include/asapo/unittests/MockLogger.h +++ b/common/cpp/include/asapo/unittests/MockLogger.h @@ -10,10 +10,23 @@ namespace asapo { class MockLogger : public AbstractLogger { public: - MOCK_CONST_METHOD1(Info, void(const std::string&)); - MOCK_CONST_METHOD1(Error, void(const std::string& )); - MOCK_CONST_METHOD1(Debug, void(const std::string& )); - MOCK_CONST_METHOD1(Warning, void(const std::string& )); + void Info(const asapo::Error& msg) const override { + Info(msg->ExplainInJSON()); + }; + void Error(const asapo::Error& msg) const override { + Error(msg->ExplainInJSON()); + }; + void Debug(const asapo::Error& msg) const override { + Debug(msg->ExplainInJSON()); + }; + void Warning(const asapo::Error& msg) const override { + Warning(msg->ExplainInJSON()); + }; + + MOCK_METHOD(void, Info, (const std::string&), (const, override)); + MOCK_METHOD(void, Error, (const std::string&), (const, override)); + MOCK_METHOD(void, Debug, (const std::string&), (const, override)); + MOCK_METHOD(void, Warning, (const std::string&), (const, override)); void Info(const LogMessageWithFields& msg) const override { Info(msg.LogString()); }; @@ -27,9 +40,9 @@ class MockLogger : public AbstractLogger { Warning(msg.LogString()); }; - MOCK_METHOD1(SetLogLevel, void(LogLevel)); - MOCK_METHOD1(EnableLocalLog, void(bool)); - MOCK_METHOD1(EnableRemoteLog, void(bool)); + MOCK_METHOD(void, SetLogLevel, (LogLevel), (override)); + MOCK_METHOD(void, EnableLocalLog, (bool), (override)); + MOCK_METHOD(void, EnableRemoteLog, (bool), (override)); }; } diff --git a/common/cpp/include/asapo/unittests/replace_mocks.py b/common/cpp/include/asapo/unittests/replace_mocks.py new file mode 100755 index 0000000000000000000000000000000000000000..f91b901bac087b47b3bd7917450fad14ab51e1e5 --- /dev/null +++ b/common/cpp/include/asapo/unittests/replace_mocks.py @@ -0,0 +1,53 @@ +#!/usr/bin/python + +import sys +import re + +fname = sys.argv[1] +fnameo = sys.argv[2] + +with open(fname) as f: + lines = f.readlines() + +pattern = '.*(MOCK_.*?)\((.*?), (.*?)\((.*)\)\)' + +f = open(fnameo, "w") + +fulline = "" +in_mock = False +for line in lines: + if not in_mock and re.match(r".*MOCK_.*", line): + in_mock = True + if in_mock: + if fulline: + fulline = fulline.rstrip() + " " + line.lstrip() + else: + fulline = line + if not line.strip().endswith(";"): + continue + else: + f.write(line) + continue + result = re.search(pattern, fulline) + if result: + result = result.groups() + in_mock = False + else: + f.write(line) + continue + specifiers = "" + if not result[1].endswith("_t"): + specifiers = "override" + if "CONST" in result[0]: + if specifiers: + specifiers = "const, " + specifiers + else: + specifiers = "const" + ret = result[2].strip() + if "," in ret: + ret = "("+ret+")" + s="MOCK_METHOD"+"("+ret+", "+result[1].strip()+", ("+result[3].strip()+"), ("+specifiers+"));" + f.write(re.sub('MOCK_.*;', s , fulline)) + print (re.sub('MOCK_.*;', s , fulline)) + fulline = "" +f.close() \ No newline at end of file diff --git a/common/cpp/scripts/replace_mocks.py b/common/cpp/scripts/replace_mocks.py new file mode 100755 index 0000000000000000000000000000000000000000..f91b901bac087b47b3bd7917450fad14ab51e1e5 --- /dev/null +++ b/common/cpp/scripts/replace_mocks.py @@ -0,0 +1,53 @@ +#!/usr/bin/python + +import sys +import re + +fname = sys.argv[1] +fnameo = sys.argv[2] + +with open(fname) as f: + lines = f.readlines() + +pattern = '.*(MOCK_.*?)\((.*?), (.*?)\((.*)\)\)' + +f = open(fnameo, "w") + +fulline = "" +in_mock = False +for line in lines: + if not in_mock and re.match(r".*MOCK_.*", line): + in_mock = True + if in_mock: + if fulline: + fulline = fulline.rstrip() + " " + line.lstrip() + else: + fulline = line + if not line.strip().endswith(";"): + continue + else: + f.write(line) + continue + result = re.search(pattern, fulline) + if result: + result = result.groups() + in_mock = False + else: + f.write(line) + continue + specifiers = "" + if not result[1].endswith("_t"): + specifiers = "override" + if "CONST" in result[0]: + if specifiers: + specifiers = "const, " + specifiers + else: + specifiers = "const" + ret = result[2].strip() + if "," in ret: + ret = "("+ret+")" + s="MOCK_METHOD"+"("+ret+", "+result[1].strip()+", ("+result[3].strip()+"), ("+specifiers+"));" + f.write(re.sub('MOCK_.*;', s , fulline)) + print (re.sub('MOCK_.*;', s , fulline)) + fulline = "" +f.close() \ No newline at end of file diff --git a/common/cpp/scripts/test.h b/common/cpp/scripts/test.h new file mode 100644 index 0000000000000000000000000000000000000000..610917b7e3b7824996deae9c0406fbda9959bcea --- /dev/null +++ b/common/cpp/scripts/test.h @@ -0,0 +1,20 @@ + #MOCK_CONST_METHOD0(GetFileName, std::string()); + MOCK_CONST_METHOD0(GetOriginUri_t, + const std::string & ()); +MOCK_CONST_METHOD0(GetOriginHost, const std::string & ()); +MOCK_CONST_METHOD0(GetDataSize, uint64_t()); +MOCK_CONST_METHOD0(GetDataID, uint64_t()); +MOCK_CONST_METHOD0(GetSlotId, uint64_t()); +MOCK_CONST_METHOD0(GetData, void* ()); +MOCK_CONST_METHOD0(GetBeamtimeId, const std::string & ()); +MOCK_CONST_METHOD0(GetDataSource, const std::string & ()); +MOCK_METHOD0(SetAlreadyProcessedFlag, void()); +MOCK_METHOD2(SetResponseMessage, void(std::string, ResponseMessageType)); +MOCK_CONST_METHOD0(GetResponseMessage, const std::string & ()); +MOCK_CONST_METHOD1(NewThread_t, std::thread * (std::function<void()> function)); +MOCK_CONST_METHOD2(InetAcceptConnection_t, std::tuple<std::string, SocketDescriptor>* (SocketDescriptor socket_fd, + ErrorInterface** err)); + dfgd + gds + gdfsg + diff --git a/common/cpp/src/data_structs/data_structs.cpp b/common/cpp/src/data_structs/data_structs.cpp index c55d6017629b2c3ba24dfa9b59303e70b411968b..0e1562ea7059ca162feec7ef81794b0d46f2c1d7 100644 --- a/common/cpp/src/data_structs/data_structs.cpp +++ b/common/cpp/src/data_structs/data_structs.cpp @@ -1,4 +1,6 @@ #include "asapo/common/data_structs.h" +#include "asapo/common/error.h" + #include <chrono> #include <iostream> @@ -40,7 +42,7 @@ Error GetSourceTypeFromString(std::string stype, SourceType* type) { *type = SourceType::kProcessed; return nullptr; } else { - return TextError("cannot parse/wrong source type: " + stype); + return GeneralErrorTemplates::kSimpleError.Generate("cannot parse/wrong source type: " + stype); } } @@ -234,4 +236,9 @@ uint64_t NanosecsEpochFromISODate(std::string date_time) { return ns > 0 ? ns : 1; } +std::string HostFromUri(const std::string& uri) { + return uri.substr(0, uri.find(':')); +} + + } diff --git a/common/cpp/src/database/database.cpp b/common/cpp/src/database/database.cpp index df1c69ea322e5287a25dd40a0f695dc115a39ec3..6ad05bb967e981ddbf32dcf26f11cff3f4cb9976 100644 --- a/common/cpp/src/database/database.cpp +++ b/common/cpp/src/database/database.cpp @@ -9,7 +9,7 @@ std::unique_ptr<Database> DatabaseFactory::Create(Error* err) const noexcept { p.reset(new MongoDBClient()); *err = nullptr; } catch (...) { - *err = ErrorTemplates::kMemoryAllocationError.Generate(); + *err = GeneralErrorTemplates::kMemoryAllocationError.Generate(); } return p; } diff --git a/common/cpp/src/database/encoding.cpp b/common/cpp/src/database/encoding.cpp index 5e589436fb52a0cf476ad5dff7f9af8ba1aa7f40..3a3b48432f22dbb6515a63c946cc449a211d0f5b 100644 --- a/common/cpp/src/database/encoding.cpp +++ b/common/cpp/src/database/encoding.cpp @@ -86,13 +86,12 @@ std::string EncodeColName(const std::string& colname) { } std::string DecodeName(const std::string& name) { - char* decoded = new char[name.size() + 1]; - auto res = decode(name.c_str(), decoded); + auto decoded = std::unique_ptr<char[]> {new char[name.size() + 1]}; + auto res = decode(name.c_str(), decoded.get()); if (res < 0) { return ""; } - std::string str = std::string{decoded}; - delete[] decoded; + std::string str = std::string{decoded.get()}; return str; } @@ -102,7 +101,7 @@ bool ShouldEscapeQuery(char c) { if (c == chars[i]) { return true; } - }; + } return false; } diff --git a/common/cpp/src/database/mongodb_client.cpp b/common/cpp/src/database/mongodb_client.cpp index d57c3a27538c60c84c5b73b52bb799843ce7672a..50db4ae16cccf1f3dacd8701e708cb7e2c3ba968 100644 --- a/common/cpp/src/database/mongodb_client.cpp +++ b/common/cpp/src/database/mongodb_client.cpp @@ -180,7 +180,7 @@ bson_p PrepareUpdateDocument(const uint8_t* json, Error* err) { bson_p PrepareInjestDocument(const uint8_t* json, ssize_t len, Error* err) { bson_error_t mongo_err; if (json == nullptr) { - *err = TextError("empty metadata"); + *err = GeneralErrorTemplates::kSimpleError.Generate("empty metadata"); return nullptr; } @@ -771,7 +771,7 @@ Error MongoDBClient::DeleteCollections(const std::string& prefix) const { bson_destroy(opts); bson_destroy(query); mongoc_database_destroy(database); - return nullptr; + return err; } Error MongoDBClient::DeleteCollection(const std::string& name) const { diff --git a/common/cpp/src/http_client/curl_http_client.cpp b/common/cpp/src/http_client/curl_http_client.cpp index 6eed5c45770a6df33c6a8d0dc54f8c932111904b..6ee5dba352a088f8c5358d4a273fdc04f04a0f20 100644 --- a/common/cpp/src/http_client/curl_http_client.cpp +++ b/common/cpp/src/http_client/curl_http_client.cpp @@ -113,7 +113,7 @@ MessageData AllocateMemory(uint64_t size, Error* err) { try { data = MessageData{new uint8_t[(size_t)size + 1 ]}; } catch (...) { - *err = ErrorTemplates::kMemoryAllocationError.Generate(); + *err = GeneralErrorTemplates::kMemoryAllocationError.Generate(); return nullptr; } *err = nullptr; diff --git a/common/cpp/src/json_parser/rapid_json.cpp b/common/cpp/src/json_parser/rapid_json.cpp index d2a9afe150afa40e34fd515c74fce9e3862811e4..a9883d134374785d5c801c5a33356cd7951c32fd 100644 --- a/common/cpp/src/json_parser/rapid_json.cpp +++ b/common/cpp/src/json_parser/rapid_json.cpp @@ -14,7 +14,7 @@ RapidJson::RapidJson(const std::string& json, const std::unique_ptr<IO>* io) : i Error RapidJson::LazyInitialize() const noexcept { if (embedded_error_) { - return TextError(embedded_error_->Explain()); + return GeneralErrorTemplates::kSimpleError.Generate(embedded_error_->Explain()); } if (initialized_) @@ -31,7 +31,7 @@ Error RapidJson::LazyInitialize() const noexcept { ParseResult ok = doc_.Parse(str.c_str()); if (!ok || !doc_.IsObject()) { - return TextError("Cannot parse document"); + return GeneralErrorTemplates::kSimpleError.Generate("Cannot parse document"); } object_ = doc_.GetObject(); @@ -42,7 +42,7 @@ Error RapidJson::LazyInitialize() const noexcept { } asapo::Error RapidJson::CheckValueType(const std::string& name, ValueType type, const Value* val) const { - bool res = false; + bool res; switch (type) { case ValueType::kObject: res = val->IsObject(); @@ -62,9 +62,11 @@ 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_); + return GeneralErrorTemplates::kSimpleError.Generate("wrong type for: " + name + " in: " + json_); } return nullptr; @@ -77,7 +79,7 @@ asapo::Error RapidJson::GetValuePointer(const std::string& name, ValueType type, auto iterator = object_p_->FindMember(name.c_str()); if (iterator == object_p_->MemberEnd()) { - return TextError("cannot find: " + name); + return GeneralErrorTemplates::kSimpleError.Generate("cannot find: " + name); } *val = &iterator->value; @@ -106,7 +108,8 @@ Error RapidJson::GetUInt64(const std::string& name, uint64_t* val) const noexcep } Value* json_val; - if (Error err = GetValuePointer(name, ValueType::kUint64, &json_val)) { + err = GetValuePointer(name, ValueType::kUint64, &json_val); + if (err) { return err; } *val = json_val->GetUint64(); @@ -140,7 +143,7 @@ Error RapidJson::GetArrayUInt64(const std::string& name, std::vector<uint64_t>* val->clear(); for (auto& v : json_val->GetArray()) { if (!v.IsUint64()) { - return TextError("wrong type of array element: " + name); + return GeneralErrorTemplates::kSimpleError.Generate("wrong type of array element: " + name); } val->push_back(v.GetUint64()); } @@ -157,7 +160,7 @@ Error RapidJson::GetArrayString(const std::string& name, std::vector<std::string val->clear(); for (auto& v : json_val->GetArray()) { if (!v.IsString()) { - return TextError("wrong type of array element: " + name); + return GeneralErrorTemplates::kSimpleError.Generate("wrong type of array element: " + name); } val->push_back(v.GetString()); } @@ -199,7 +202,7 @@ Error RapidJson::GetArrayRawStrings(const std::string& name, std::vector<std::st val->clear(); for (auto& v : json_val->GetArray()) { if (!v.IsObject()) { - return TextError("wrong type of array element: " + name); + return GeneralErrorTemplates::kSimpleError.Generate("wrong type of array element: " + name); } StringBuffer buffer; Writer<StringBuffer> writer(buffer); diff --git a/common/cpp/src/logger/logger.cpp b/common/cpp/src/logger/logger.cpp index 7e09a5da12289bab67f0a27a455019059fb7132a..546112130bee461f1dc39e9160e0ecddbe865454 100644 --- a/common/cpp/src/logger/logger.cpp +++ b/common/cpp/src/logger/logger.cpp @@ -1,4 +1,8 @@ + +#include <asapo/logger/logger.h> + #include "spd_logger.h" +#include "asapo/common/error.h" namespace asapo { @@ -15,7 +19,6 @@ Logger CreateLogger(std::string name, bool console, bool centralized_log, const return Logger{logger}; } - Logger CreateDefaultLoggerBin(const std::string& name) { return CreateLogger(name, true, false, ""); } @@ -32,19 +35,18 @@ LogLevel StringToLogLevel(const std::string& name, Error* err) { if (name == "none") return LogLevel::None; if (name == "error") return LogLevel::Error; - *err = TextError("wrong log level: " + name); + *err = GeneralErrorTemplates::kSimpleError.Generate("wrong log level: " + name); return LogLevel::None; } template<typename ... Args> -std::string string_format( const std::string& format, Args ... args ) { - size_t size = static_cast<size_t>(snprintf( nullptr, 0, format.c_str(), args ... ) + 1); - std::unique_ptr<char[]> buf( new char[ size ] ); - snprintf( buf.get(), size, format.c_str(), args ... ); - return std::string( buf.get(), buf.get() + size - 1 ); +std::string string_format(const std::string& format, Args ... args) { + size_t size = static_cast<size_t>(snprintf(nullptr, 0, format.c_str(), args ...) + 1); + std::unique_ptr<char[]> buf(new char[size]); + snprintf(buf.get(), size, format.c_str(), args ...); + return std::string(buf.get(), buf.get() + size - 1); } - std::string EncloseQuotes(std::string str) { return "\"" + std::move(str) + "\""; } @@ -57,26 +59,45 @@ LogMessageWithFields::LogMessageWithFields(std::string key, double val, int prec log_string_ = EncloseQuotes(key) + ":" + string_format("%." + std::to_string(precision) + "f", val); } +LogMessageWithFields::LogMessageWithFields(std::string val) { + if (!val.empty()) { + log_string_ = EncloseQuotes("message") + ":" + EncloseQuotes(escape_json(val)); + } +} + LogMessageWithFields::LogMessageWithFields(std::string key, std::string val) { - log_string_ = EncloseQuotes(key) + ":" + EncloseQuotes(val); + log_string_ = EncloseQuotes(key) + ":" + EncloseQuotes(escape_json(val)); +} + +inline std::string LogMessageWithFields::QuoteIFNeeded() { + return log_string_.empty() ? "" : ","; } LogMessageWithFields& LogMessageWithFields::Append(std::string key, uint64_t val) { - log_string_ += "," + EncloseQuotes(key) + ":" + std::to_string(val); + log_string_ += QuoteIFNeeded() + EncloseQuotes(key) + ":" + std::to_string(val); return *this; } LogMessageWithFields& LogMessageWithFields::Append(std::string key, double val, int precision) { - log_string_ += "," + EncloseQuotes(key) + ":" + string_format("%." + std::to_string(precision) + "f", val); + log_string_ += QuoteIFNeeded() + EncloseQuotes(key) + ":" + string_format("%." + std::to_string(precision) + "f", val); return *this; } LogMessageWithFields& LogMessageWithFields::Append(std::string key, std::string val) { - log_string_ += "," + EncloseQuotes(key) + ":" + EncloseQuotes(val); + log_string_ += QuoteIFNeeded() + EncloseQuotes(key) + ":" + EncloseQuotes(escape_json(val)); return *this; } std::string LogMessageWithFields::LogString() const { return log_string_; } + +LogMessageWithFields::LogMessageWithFields(const Error& error) { + log_string_ = error->ExplainInJSON(); +} +LogMessageWithFields& LogMessageWithFields::Append(const LogMessageWithFields& log_msg) { + log_string_ += QuoteIFNeeded() + log_msg.LogString(); + return *this; +} + } diff --git a/common/cpp/src/logger/spd_logger.cpp b/common/cpp/src/logger/spd_logger.cpp index 4cc5c49b098abdbb2ef4321642055c64ca913943..21f9f6ec381949f793b39b5cac63d05ab3ceb1e5 100644 --- a/common/cpp/src/logger/spd_logger.cpp +++ b/common/cpp/src/logger/spd_logger.cpp @@ -141,4 +141,20 @@ void SpdLogger::Warning(const LogMessageWithFields& msg) const { Warning(msg.LogString()); } +void SpdLogger::Info(const asapo::Error& error) const { + Info(error->ExplainInJSON()); +} + +void SpdLogger::Error(const asapo::Error& error) const { + Error(error->ExplainInJSON()); +} + +void SpdLogger::Debug(const asapo::Error& error) const { + Debug(error->ExplainInJSON()); +} + +void SpdLogger::Warning(const asapo::Error& error) const { + Warning(error->ExplainInJSON()); +} + } diff --git a/common/cpp/src/logger/spd_logger.h b/common/cpp/src/logger/spd_logger.h index db0d6ee63c12eca8be3c3e9b37e15c63b63e7097..1c2485f95f8520012223e06b4609a28aeffd89fd 100644 --- a/common/cpp/src/logger/spd_logger.h +++ b/common/cpp/src/logger/spd_logger.h @@ -19,6 +19,10 @@ class SpdLogger : public AbstractLogger { void Error(const LogMessageWithFields& msg) const override; void Debug(const LogMessageWithFields& msg) const override; void Warning(const LogMessageWithFields& msg) const override; + void Info(const asapo::Error& error) const override; + void Error(const asapo::Error& error) const override; + void Debug(const asapo::Error& error) const override; + void Warning(const asapo::Error& error) const override; void EnableLocalLog(bool enable) override; void EnableRemoteLog(bool enable) override; @@ -34,6 +38,7 @@ class SpdLogger : public AbstractLogger { }; std::string EncloseMsg(std::string msg); +std::string escape_json(const std::string& s); } diff --git a/common/cpp/src/request/request_pool.cpp b/common/cpp/src/request/request_pool.cpp index b0c6d3a80c9644e83c539da2bafa4e77ffee2b66..d634ead542d7bb483ee941d440b800b1fd95c2b5 100644 --- a/common/cpp/src/request/request_pool.cpp +++ b/common/cpp/src/request/request_pool.cpp @@ -144,7 +144,7 @@ void RequestPool::ThreadHandler(uint64_t id) { //after wait, we own the lock if (!quit_ && do_work) { ProcessRequest(request_handler, &thread_info); - }; + } } while (!quit_); } diff --git a/common/cpp/src/system_io/system_io.cpp b/common/cpp/src/system_io/system_io.cpp index 6b35e0491e8759315ec469a3d4918d3277de2e38..3165a6a3d26c5c4654dbcb09f5f6dfd57fd015ed 100644 --- a/common/cpp/src/system_io/system_io.cpp +++ b/common/cpp/src/system_io/system_io.cpp @@ -85,7 +85,7 @@ uint8_t* SystemIO::AllocateArray(uint64_t fsize, Error* err) const { try { data_array = new uint8_t[(size_t)fsize]; } catch (...) { - *err = ErrorTemplates::kMemoryAllocationError.Generate(); + *err = GeneralErrorTemplates::kMemoryAllocationError.Generate(); return nullptr; } return data_array; @@ -116,7 +116,7 @@ MessageData SystemIO::GetDataFromFile(const std::string& fname, uint64_t* fsize, Read(fd, data_array, (size_t)*fsize, err); if (*err != nullptr) { - (*err)->Append(fname + ", expected size: " + std::to_string(*fsize)); + (*err)->AddContext("name", fname)->AddContext("expected size", std::to_string(*fsize)); Close(fd, nullptr); return nullptr; } @@ -191,7 +191,7 @@ Error SystemIO::WriteDataToFile(const std::string& root_folder, const std::strin Write(fd, data, length, &err); if (err) { - err->Append(fname); + err->AddContext("name", fname); return err; } @@ -238,7 +238,7 @@ void SystemIO::Skip(SocketDescriptor socket_fd, size_t length, Error* err) const try { buffer.reset(new uint8_t[kSkipBufferSize]); } catch (...) { - *err = ErrorTemplates::kMemoryAllocationError.Generate(); + *err = GeneralErrorTemplates::kMemoryAllocationError.Generate(); return; } size_t already_skipped = 0; @@ -402,7 +402,7 @@ asapo::FileDescriptor asapo::SystemIO::Open(const std::string& filename, FileDescriptor fd = _open(filename.c_str(), flags); if (fd == -1) { *err = GetLastError(); - (*err)->Append(filename); + (*err)->AddContext("name", filename); } else { *err = nullptr; } @@ -585,7 +585,7 @@ size_t SystemIO::Transfer(ssize_t (* method)(FileDescriptor, void*, size_t), Fil ssize_t received_amount = method(fd, (uint8_t*) buf + already_transferred, std::min(kMaxTransferChunkSize, length - already_transferred)); if (received_amount == 0) { - *err = ErrorTemplates::kEndOfFile.Generate(); + *err = GeneralErrorTemplates::kEndOfFile.Generate(); return already_transferred; } if (received_amount == -1) { @@ -616,7 +616,7 @@ Error SystemIO::CreateDirectoryWithParents(const std::string& root_path, const s Error err; CreateNewDirectory(new_path, &err); if (err && err != IOErrorTemplates::kFileAlreadyExists) { - err->Append(new_path); + err->AddContext("name", new_path); return err; } if (iter != path.end()) { @@ -665,7 +665,7 @@ Error SystemIO::SendFile(SocketDescriptor socket_fd, const std::string& fname, s while (total_bytes_sent < length) { auto bytes_read = Read(fd, data_array.get(), buf_size, &err); - if (err != nullptr && err != ErrorTemplates::kEndOfFile) { + if (err != nullptr && err != GeneralErrorTemplates::kEndOfFile) { Close(fd, nullptr); return err; } @@ -698,7 +698,7 @@ Error SystemIO:: ReceiveDataToFile(SocketDescriptor socket, const std::string& r size_t total_bytes_written = 0; while (total_bytes_written < length) { auto bytes_received = Receive(socket, data_array.get(), std::min(buf_size, length - total_bytes_written), &err); - if (err != nullptr && err != ErrorTemplates::kEndOfFile) { + if (err != nullptr && err != GeneralErrorTemplates::kEndOfFile) { Close(fd, nullptr); return err; } diff --git a/common/cpp/src/system_io/system_io.h b/common/cpp/src/system_io/system_io.h index d016fc5d2c73d5317d77b71e710f08fb6f4b337d..87cbce74b516d0a942d30202ee2d030787158795 100644 --- a/common/cpp/src/system_io/system_io.h +++ b/common/cpp/src/system_io/system_io.h @@ -17,10 +17,6 @@ typedef SSIZE_T ssize_t; #include "netinet/in.h" #endif -#ifdef __APPLE__ -# define MSG_NOSIGNAL 0 -#endif - namespace asapo { class SystemIO final : public IO { diff --git a/common/cpp/src/system_io/system_io_linux.cpp b/common/cpp/src/system_io/system_io_linux.cpp index 2c97e377fa03feb64a112bcf4abba10754f30c16..f4256bddba5fdecb3e9bb9869943d03c9c642d81 100644 --- a/common/cpp/src/system_io/system_io_linux.cpp +++ b/common/cpp/src/system_io/system_io_linux.cpp @@ -28,7 +28,7 @@ Error SystemIO::AddToEpool(SocketDescriptor sd) const { event.data.fd = sd; if((epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, sd, &event) == -1) && (errno != EEXIST)) { auto err = GetLastError(); - err->Append("add to epoll"); + err->AddContext("where", "add to epoll"); close(epoll_fd_); return err; } @@ -43,7 +43,7 @@ Error SystemIO::CreateEpoolIfNeeded(SocketDescriptor master_socket) const { epoll_fd_ = epoll_create1(0); if(epoll_fd_ == kDisconnectedSocketDescriptor) { auto err = GetLastError(); - err->Append("Create epoll"); + err->AddContext("where", "create epoll"); return err; } return AddToEpool(master_socket); @@ -84,7 +84,7 @@ ListSocketDescriptors SystemIO::WaitSocketsActivity(SocketDescriptor master_sock } if (event_count < 0) { *err = GetLastError(); - (*err)->Append("epoll wait"); + (*err)->AddContext("where", "epoll wait"); return {}; } diff --git a/common/cpp/src/system_io/system_io_linux_mac.cpp b/common/cpp/src/system_io/system_io_linux_mac.cpp index 9d36dca7b3830fdd7af0221e203cca47d2ab669c..371c12e4d3464ac2478bab25c8733bf068f5989a 100644 --- a/common/cpp/src/system_io/system_io_linux_mac.cpp +++ b/common/cpp/src/system_io/system_io_linux_mac.cpp @@ -32,7 +32,7 @@ Error GetLastErrorFromErrno() { case 0: return nullptr; case EINTR: - return TextError("Interrupt occurred, is a debugger attached?"); + return GeneralErrorTemplates::kSimpleError.Generate("Interrupt occurred, is a debugger attached?"); case EBADF: return IOErrorTemplates::kBadFileNumber.Generate(); case EAGAIN: @@ -67,9 +67,8 @@ Error GetLastErrorFromErrno() { case EPIPE: return IOErrorTemplates::kBrokenPipe.Generate(); default: - std::cout << "[IOErrorsFromErrno] Unknown error code: " << errno << std::endl; Error err = IOErrorTemplates::kUnknownIOError.Generate(); - (*err).Append("Unknown error code: " + std::to_string(errno)); + (*err).AddContext("Unknown error code: ", std::to_string(errno)); return err; } } @@ -123,7 +122,7 @@ MessageMeta GetMessageMeta(const string& name, Error* err) { auto t_stat = FileStat(name, err); if (*err != nullptr) { - (*err)->Append(name); + (*err)->AddContext("name", name); return MessageMeta{}; } @@ -158,7 +157,7 @@ void SystemIO::GetSubDirectoriesRecursively(const std::string& path, SubDirList* auto dir = opendir((path).c_str()); if (dir == nullptr) { *err = GetLastError(); - (*err)->Append(path); + (*err)->AddContext("name", path); return; } @@ -184,7 +183,7 @@ void SystemIO::CollectMessageMetarmationRecursively(const std::string& path, auto dir = opendir((path).c_str()); if (dir == nullptr) { *err = GetLastError(); - (*err)->Append(path); + (*err)->AddContext("name", path); return; } diff --git a/common/cpp/src/system_io/system_io_windows.cpp b/common/cpp/src/system_io/system_io_windows.cpp index 22b9c9d4315b5e7b764643230a331c200032fc05..b847d747b70f0a9c4204ce375518453fbc505475 100644 --- a/common/cpp/src/system_io/system_io_windows.cpp +++ b/common/cpp/src/system_io/system_io_windows.cpp @@ -66,7 +66,7 @@ Error IOErrorFromGetLastError() { default: std::cout << "[IOErrorFromGetLastError] Unknown error code: " << last_error << std::endl; Error err = IOErrorTemplates::kUnknownIOError.Generate(); - (*err).Append("Unknown error code: " + std::to_string(last_error)); + (*err).AddContext("Unknown error code", std::to_string(last_error)); return err; } } @@ -151,7 +151,7 @@ MessageMeta SystemIO::GetMessageMeta(const std::string& name, Error* err) const auto hFind = FindFirstFile(name.c_str(), &f); if (hFind == INVALID_HANDLE_VALUE) { *err = IOErrorFromGetLastError(); - (*err)->Append(name); + (*err)->AddContext("name", name); return {}; } FindClose(hFind); @@ -179,7 +179,7 @@ void SystemIO::GetSubDirectoriesRecursively(const std::string& path, SubDirList* HANDLE handle = FindFirstFile((path + "\\*.*").c_str(), &find_data); if (handle == INVALID_HANDLE_VALUE) { *err = IOErrorFromGetLastError(); - (*err)->Append(path); + (*err)->AddContext("name", path); return; } @@ -208,7 +208,7 @@ void SystemIO::CollectMessageMetarmationRecursively(const std::string& path, HANDLE handle = FindFirstFile((path + "\\*.*").c_str(), &find_data); if (handle == INVALID_HANDLE_VALUE) { *err = IOErrorFromGetLastError(); - (*err)->Append(path); + (*err)->AddContext("name", path); return; } diff --git a/common/cpp/unittests/common/test_error.cpp b/common/cpp/unittests/common/test_error.cpp index 73f025bc2ca628a485f128d356a95c8f872ed014..c588ea0526be16f5977367ee9e5fdb36cdaf3cee 100644 --- a/common/cpp/unittests/common/test_error.cpp +++ b/common/cpp/unittests/common/test_error.cpp @@ -3,24 +3,74 @@ #include "gtest/gtest.h" using asapo::Error; -using ::testing::Eq; -using ::testing::Ne; +using namespace testing; namespace { TEST(ErrorTemplate, GenerateNoNullptr) { - Error error = asapo::ErrorTemplates::kEndOfFile.Generate(); + Error error = asapo::GeneralErrorTemplates::kEndOfFile.Generate(); ASSERT_THAT(error, Ne(nullptr)); } TEST(ErrorTemplate, EqCheck) { - Error error = asapo::ErrorTemplates::kEndOfFile.Generate(); - ASSERT_TRUE(asapo::ErrorTemplates::kEndOfFile == error); + Error error = asapo::GeneralErrorTemplates::kEndOfFile.Generate(); + ASSERT_TRUE(asapo::GeneralErrorTemplates::kEndOfFile == error); } - TEST(ErrorTemplate, NeCheck) { - Error error = asapo::ErrorTemplates::kEndOfFile.Generate(); - ASSERT_FALSE(asapo::ErrorTemplates::kMemoryAllocationError == error); + Error error = asapo::GeneralErrorTemplates::kEndOfFile.Generate(); + ASSERT_FALSE(asapo::GeneralErrorTemplates::kMemoryAllocationError == error); +} + +TEST(ErrorTemplate, Explain) { + Error error = asapo::GeneralErrorTemplates::kEndOfFile.Generate("test"); + ASSERT_THAT(error->Explain(), HasSubstr("test")); } + +TEST(ErrorTemplate, Context) { + Error error = asapo::GeneralErrorTemplates::kEndOfFile.Generate("test"); + error->AddContext("key", "value"); + error->AddContext("key2", "value2"); + + ASSERT_THAT(error->Explain(), AllOf(HasSubstr("test"), + HasSubstr("context"), + HasSubstr("key:value"), + HasSubstr("key2:value2") + )); +} + +TEST(ErrorTemplate, Cause) { + Error error = asapo::GeneralErrorTemplates::kEndOfFile.Generate("test"); + Error error_c = asapo::GeneralErrorTemplates::kMemoryAllocationError.Generate("cause_test"); + Error error_c1 = asapo::GeneralErrorTemplates::kSimpleError.Generate("simple error"); + error->AddContext("key", "value"); + error_c->AddContext("key2", "value2"); + error_c->SetCause(std::move(error_c1)); + error->SetCause(std::move(error_c)); + ASSERT_THAT(error->Explain(), AllOf(HasSubstr("test"), + HasSubstr("caused"), + HasSubstr("key:value"), + HasSubstr("key:value"), + HasSubstr("key2:value2") + )); + ASSERT_THAT(error->ExplainPretty(), AllOf(HasSubstr("test"), + HasSubstr("caused"), + HasSubstr("key:value"), + HasSubstr("key:value"), + HasSubstr("key2:value2") + )); +} + +TEST(ErrorTemplate, Json) { + Error error = asapo::GeneralErrorTemplates::kEndOfFile.Generate("test"); + Error error_c = asapo::GeneralErrorTemplates::kMemoryAllocationError.Generate("cause_test"); + error->AddContext("key", "value"); + error->SetCause(std::move(error_c)); + auto expected_string = + R"("error":"end of file","message":"test","context":{"key":"value"},"cause":{"error":"memory allocation","message":"cause_test"})"; + ASSERT_THAT(error->ExplainInJSON(), Eq(expected_string)); +} + + + } diff --git a/common/cpp/unittests/data_structs/test_data_structs.cpp b/common/cpp/unittests/data_structs/test_data_structs.cpp index d1a35ea664ca66a5cfb91510e4d4feaa31813378..a8bb9c468085b9126edaa19021bb240891b9158d 100644 --- a/common/cpp/unittests/data_structs/test_data_structs.cpp +++ b/common/cpp/unittests/data_structs/test_data_structs.cpp @@ -305,4 +305,23 @@ TEST(DeletaStreamOpt, EncodeDecode) { } + +struct TestUri { + std::string uri; + std::string host; +}; + + +auto testsUri = std::vector<TestUri> { + TestUri{"123.234.24.13:123", "123.234.24.13"}, + TestUri{"1.1.1.1", "1.1.1.1"}, +}; + +TEST(HostFromUri, HostFromUri) { + for (auto test : testsUri) { + auto res = asapo::HostFromUri(test.uri); + ASSERT_THAT(res, Eq(test.host)); + } +} + } diff --git a/common/cpp/unittests/logger/test_logger.cpp b/common/cpp/unittests/logger/test_logger.cpp index ed67359e1479f6d65fda1b7dc1d7a8a1cb4e5382..f5346e0261619c032385d456e044a8e36fa366a6 100644 --- a/common/cpp/unittests/logger/test_logger.cpp +++ b/common/cpp/unittests/logger/test_logger.cpp @@ -70,6 +70,7 @@ class LoggerTests : public Test { asapo::SpdLogger logger{"test", "test_uri"}; spdlog::details::log_msg msg; spdlog::details::log_msg msg_json; + spdlog::details::log_msg msg_error; std::string test_string{"Hello\""}; std::string test_string_json{R"("Hello":"test","int":1,"double":123.234)"}; @@ -77,6 +78,7 @@ class LoggerTests : public Test { void SetUp() override { msg.raw << R"("message":"Hello\"")"; msg_json.raw << R"("Hello":"test","int":1,"double":123.234)"; + msg_error.raw << R"("error":"unnamed error","message":"err")"; log.reset(new spdlog::logger("mylogger", mock_sink)); logger.log__ = std::move(log); } @@ -114,6 +116,18 @@ TEST_F(LoggerTests, InfoJson) { logger.Info(test_string_json); } + +TEST_F(LoggerTests, InfoError) { + msg_error.level = spdlog::level::info; + logger.SetLogLevel(LogLevel::Info); + EXPECT_CALL(*mock_sink, _sink_it(CompareMsg(&msg_error))); + + auto err = asapo::GeneralErrorTemplates::kSimpleError.Generate("err"); + + logger.Info(err); +} + + TEST_F(LoggerTests, InfoMessage) { msg_json.level = spdlog::level::info; diff --git a/config/nomad/receiver_tcp.nmd.in b/config/nomad/receiver_tcp.nmd.in index 07bc0a4798abf454cde610ddbe352402b2b641b3..b8a5bb56238ddfdd25b07eb1e44e2c1e8bebd488 100644 --- a/config/nomad/receiver_tcp.nmd.in +++ b/config/nomad/receiver_tcp.nmd.in @@ -27,14 +27,6 @@ job "receiver" { service { name = "asapo-receiver" port = "recv" - check { - name = "alive" - type = "tcp" - port = "recv" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } check { name = "metrics" type = "http" diff --git a/consumer/api/cpp/include/asapo/consumer/consumer_error.h b/consumer/api/cpp/include/asapo/consumer/consumer_error.h index efa0631dab069a96595de024b4873d2d36e68235..e524e1c1e68d7a56d42fa3358942a1b3852b00bd 100644 --- a/consumer/api/cpp/include/asapo/consumer/consumer_error.h +++ b/consumer/api/cpp/include/asapo/consumer/consumer_error.h @@ -18,7 +18,7 @@ enum class ConsumerErrorType { kUnsupportedClient }; -using ConsumerErrorTemplate = ServiceErrorTemplate<ConsumerErrorType, ErrorType::kConsumerError>; +using ConsumerErrorTemplate = ServiceErrorTemplate<ConsumerErrorType>; class PartialErrorData : public CustomErrorData { diff --git a/consumer/api/cpp/src/consumer.cpp b/consumer/api/cpp/src/consumer.cpp index cb7e6bc1616b3326e4bac1a7f95b804d0cf91b59..ea1fa64a91c5ec917fd05bf6b41c55baaa57523d 100644 --- a/consumer/api/cpp/src/consumer.cpp +++ b/consumer/api/cpp/src/consumer.cpp @@ -19,7 +19,7 @@ std::unique_ptr<Consumer> Create(const std::string& source_name, p.reset(new C(source_name, std::forward<Args>(args)...)); error->reset(nullptr); } catch (...) { // we do not test this part - error->reset(new SimpleError("Memory error")); + *error = asapo::GeneralErrorTemplates::kMemoryAllocationError.Generate(); } return p; diff --git a/consumer/api/cpp/src/consumer_c_glue.cpp b/consumer/api/cpp/src/consumer_c_glue.cpp index 83b83d2a1235ad4db8d02afa6fab63c1b1fa4f69..2671106030e1631b57d656408a04efdf62e65ccc 100644 --- a/consumer/api/cpp/src/consumer_c_glue.cpp +++ b/consumer/api/cpp/src/consumer_c_glue.cpp @@ -80,7 +80,7 @@ extern "C" { kWrongInput == asapo::ConsumerErrorType::kWrongInput&& kPartialData == asapo::ConsumerErrorType::kPartialData&& kUnsupportedClient == asapo::ConsumerErrorType::kUnsupportedClient, - "incompatible bit reps between c++ and c for asapo::ErrorType"); + "incompatible bit reps between c++ and c for asapo::ConsumerErrorType"); static_assert(kAllStreams == asapo::StreamFilter::kAllStreams&& kFinishedStreams == asapo::StreamFilter::kFinishedStreams&& kUnfinishedStreams == asapo::StreamFilter::kUnfinishedStreams, @@ -92,8 +92,7 @@ extern "C" { enum AsapoConsumerErrorType asapo_error_get_type(const AsapoErrorHandle error) { auto consumer_err = - dynamic_cast<const asapo::ServiceError<asapo::ConsumerErrorType, - asapo::ErrorType::kConsumerError> *>(error->handle.get()); + dynamic_cast<const asapo::ServiceError<asapo::ConsumerErrorType> *>(error->handle.get()); if (consumer_err != nullptr) { return static_cast<AsapoConsumerErrorType>(consumer_err->GetServiceErrorType()); } else { @@ -422,9 +421,9 @@ extern "C" { AsapoMessageDataHandle* data, const char* stream, AsapoErrorHandle* error) { - dataGetterStart; + dataGetterStart auto err = consumer->handle->GetById(id, fi, data ? &d : nullptr, stream); - dataGetterStop; + dataGetterStop return process_error(error, std::move(err)); } @@ -438,9 +437,10 @@ extern "C" { AsapoMessageDataHandle* data, const char* stream, AsapoErrorHandle* error) { - dataGetterStart; + dataGetterStart auto err = consumer->handle->GetLast(fi, data ? &d : nullptr, stream); - dataGetterStop; + dataGetterStop + return process_error(error, std::move(err)); } @@ -454,9 +454,10 @@ extern "C" { AsapoMessageDataHandle* data, const char* stream, AsapoErrorHandle* error) { - dataGetterStart; + dataGetterStart auto err = consumer->handle->GetLast(*group_id->handle, fi, data ? &d : nullptr, stream); - dataGetterStop; + dataGetterStop + return process_error(error, std::move(err)); } @@ -470,9 +471,11 @@ extern "C" { AsapoMessageDataHandle* data, const char* stream, AsapoErrorHandle* error) { - dataGetterStart; + dataGetterStart + auto err = consumer->handle->GetNext(*group_id->handle, fi, data ? &d : nullptr, stream); - dataGetterStop; + dataGetterStop + return process_error(error, std::move(err)); } @@ -613,7 +616,7 @@ extern "C" { /// \param[in] asapo error /// \return handle to partial error data or NULL if error is wrong type AsapoPartialErrorDataHandle asapo_error_get_payload_from_partial_error(const AsapoErrorHandle error) { - if (error == nullptr && error->handle == nullptr) { + if (error == nullptr || error->handle == nullptr) { return nullptr; } auto payload = dynamic_cast<asapo::PartialErrorData*>(error->handle->GetCustomData()); @@ -642,7 +645,7 @@ extern "C" { /// \param[in] asapo error /// \return handle to partial error data or NULL if error is wrong type AsapoConsumerErrorDataHandle asapo_error_get_payload_from_consumer_error(const AsapoErrorHandle error) { - if (error == nullptr && error->handle == nullptr) { + if (error == nullptr || error->handle == nullptr) { return nullptr; } auto payload = dynamic_cast<asapo::ConsumerErrorData*>(error->handle->GetCustomData()); diff --git a/consumer/api/cpp/src/consumer_impl.cpp b/consumer/api/cpp/src/consumer_impl.cpp index 02cd9b9818c012c4c69326d694a999beca43c90d..0fda0f43709ff1e1d72915856043e11244415f49 100644 --- a/consumer/api/cpp/src/consumer_impl.cpp +++ b/consumer/api/cpp/src/consumer_impl.cpp @@ -105,26 +105,26 @@ Error ConsumerErrorFromHttpCode(const RequestOutput* response, const HttpCode& c } Error ConsumerErrorFromServerError(const Error& server_err) { if (server_err == HttpErrorTemplates::kTransferError) { - return ConsumerErrorTemplates::kInterruptedTransaction.Generate(server_err->Explain()); + return ConsumerErrorTemplates::kInterruptedTransaction.Generate(); } else { - return ConsumerErrorTemplates::kUnavailableService.Generate(server_err->Explain()); + return ConsumerErrorTemplates::kUnavailableService.Generate(); } } Error ProcessRequestResponce(const RequestInfo& request, - const Error& server_err, + Error server_err, const RequestOutput* response, const HttpCode& code) { Error err; if (server_err != nullptr) { err = ConsumerErrorFromServerError(server_err); + err->SetCause(std::move(server_err)); } else { err = ConsumerErrorFromHttpCode(response, code); } if (err != nullptr) { - std::string prefix = "Error processing request " + request.host + request.api; - err->Prepend(prefix); + err->AddContext("host", request.host)->AddContext("api", "request.api"); } return err; @@ -202,7 +202,7 @@ Error ConsumerImpl::ProcessRequest(RequestOutput* response, const RequestInfo& r if (err && service_uri) { service_uri->clear(); } - return ProcessRequestResponce(request, err, response, code); + return ProcessRequestResponce(request, std::move(err), response, code); } RequestInfo ConsumerImpl::GetDiscoveryRequest(const std::string& service_name) const { @@ -740,7 +740,7 @@ StreamInfos ParseStreamsFromResponse(std::string response, Error* err) { StreamInfo si; auto ok = si.SetFromJson(stream_encoded); if (!ok) { - *err = TextError("cannot parse " + stream_encoded); + *err = GeneralErrorTemplates::kSimpleError.Generate("cannot parse " + stream_encoded); return StreamInfos{}; } streams.emplace_back(si); diff --git a/consumer/api/cpp/src/consumer_impl.h b/consumer/api/cpp/src/consumer_impl.h index e8228e60aacdb135a0bb560266269fe50578020c..d25f4327a757d588c8027f91bef48b2f072f999f 100644 --- a/consumer/api/cpp/src/consumer_impl.h +++ b/consumer/api/cpp/src/consumer_impl.h @@ -47,7 +47,7 @@ struct RequestOutput { } }; -Error ProcessRequestResponce(const RequestInfo& request, const Error& server_err, const RequestOutput* response, +Error ProcessRequestResponce(const RequestInfo& request, Error server_err, const RequestOutput* response, const HttpCode& code); Error ConsumerErrorFromNoDataResponse(const std::string& response); Error ConsumerErrorFromPartialDataResponse(const std::string& response); diff --git a/consumer/api/cpp/src/rds_response_error.h b/consumer/api/cpp/src/rds_response_error.h index 8bc8d64c53d24138e10b17458e8af4311df08391..27565d8c3f95f75cf519f11ef3d5c0d17432762e 100644 --- a/consumer/api/cpp/src/rds_response_error.h +++ b/consumer/api/cpp/src/rds_response_error.h @@ -5,8 +5,8 @@ namespace asapo { -using RdsResponseError = ServiceError<NetworkErrorCode, ErrorType::kFabricError>; -using RdsResponseErrorTemplate = ServiceErrorTemplate<NetworkErrorCode, ErrorType::kFabricError>; +using RdsResponseError = ServiceError<NetworkErrorCode>; +using RdsResponseErrorTemplate = ServiceErrorTemplate<NetworkErrorCode>; namespace RdsResponseErrorTemplates { auto const kNetErrorReauthorize = RdsResponseErrorTemplate { @@ -53,7 +53,7 @@ inline Error ConvertRdsResponseToError(NetworkErrorCode error_code) { case kNetErrorInternalServerError: return RdsResponseErrorTemplates::kNetErrorInternalServerError.Generate(); default: - return TextError("Unknown RDS response code " + std::to_string(error_code)); + return GeneralErrorTemplates::kSimpleError.Generate("Unknown RDS response code " + std::to_string(error_code)); } } } diff --git a/consumer/api/cpp/src/tcp_connection_pool.cpp b/consumer/api/cpp/src/tcp_connection_pool.cpp index 40407b89a621f9187ef3153405fee34471f3a8e9..38bc9a76242532057850002b80bc6a69ef36b019 100644 --- a/consumer/api/cpp/src/tcp_connection_pool.cpp +++ b/consumer/api/cpp/src/tcp_connection_pool.cpp @@ -55,7 +55,7 @@ SocketDescriptor TcpConnectionPool::Reconnect(SocketDescriptor sd, Error* err) { } } - *err = Error{new SimpleError("cannot find connection in pool")}; + *err = asapo::GeneralErrorTemplates::kSimpleError.Generate("cannot find connection in pool"); return kDisconnectedSocketDescriptor; } diff --git a/consumer/api/cpp/src/tcp_consumer_client.cpp b/consumer/api/cpp/src/tcp_consumer_client.cpp index 11ea5626fbc11fff505ebbb5e1093df0a7d6a155..2f5ea5396e01772d61c097d869d31228659a57ef 100644 --- a/consumer/api/cpp/src/tcp_consumer_client.cpp +++ b/consumer/api/cpp/src/tcp_consumer_client.cpp @@ -85,7 +85,7 @@ Error TcpConsumerClient::ReceiveData(SocketDescriptor sd, const MessageMeta* inf data_array = new uint8_t[(size_t)info->size]; } catch (...) { connection_pool__->ReleaseConnection(sd); - return ErrorTemplates::kMemoryAllocationError.Generate(); + return GeneralErrorTemplates::kMemoryAllocationError.Generate(); } io__->Receive(sd, data_array, (size_t)info->size, &err); connection_pool__->ReleaseConnection(sd); diff --git a/consumer/api/cpp/unittests/test_consumer_api.cpp b/consumer/api/cpp/unittests/test_consumer_api.cpp index f9d0a0cf2516df59c6c55c8dec5daded5dfbbd21..c96b738218fdb8a2cb5f7e195af1d3f1c5e03f1b 100644 --- a/consumer/api/cpp/unittests/test_consumer_api.cpp +++ b/consumer/api/cpp/unittests/test_consumer_api.cpp @@ -20,7 +20,7 @@ class ConsumerFactoryTests : public Test { public: Error error; void SetUp() override { - error.reset(new asapo::SimpleError("SomeErrorToBeOverwritten")); + error = asapo::GeneralErrorTemplates::kSimpleError.Generate("SomeErrorToBeOverwritten"); } }; diff --git a/consumer/api/cpp/unittests/test_consumer_impl.cpp b/consumer/api/cpp/unittests/test_consumer_impl.cpp index ef3ea07bf8e8abcd633ae2833c5d5748137c286e..ed8e8b07558d63f97d7f1a9e27a4706815d67b3a 100644 --- a/consumer/api/cpp/unittests/test_consumer_impl.cpp +++ b/consumer/api/cpp/unittests/test_consumer_impl.cpp @@ -26,7 +26,6 @@ using asapo::MockIO; using asapo::MockHttpClient; using asapo::MockNetClient; using asapo::HttpCode; -using asapo::SimpleError; using ::testing::AtLeast; using ::testing::Eq; @@ -183,7 +182,7 @@ class ConsumerImplTests : public Test { } auto simple_error = [] { - return new asapo::SimpleError{"s"}; + return asapo::GeneralErrorTemplates::kSimpleError.Generate("s").release(); }; EXPECT_CALL(mock_io, GetDataFromFile_t(expected_full_path, testing::Pointee(100), _)).Times(AtLeast(times)). diff --git a/consumer/api/cpp/unittests/test_tcp_connection_pool.cpp b/consumer/api/cpp/unittests/test_tcp_connection_pool.cpp index 74f3990dff74f074075a62a5a870d4a0bd309bf9..d8e3f9f363ab84763d17efb99877f7d464ddc83c 100644 --- a/consumer/api/cpp/unittests/test_tcp_connection_pool.cpp +++ b/consumer/api/cpp/unittests/test_tcp_connection_pool.cpp @@ -12,7 +12,6 @@ using asapo::IO; using asapo::MessageMeta; using asapo::MessageData; using asapo::MockIO; -using asapo::SimpleError; using asapo::TcpConnectionPool; using asapo::SocketDescriptor; using asapo::Error; diff --git a/consumer/api/cpp/unittests/test_tcp_consumer_client.cpp b/consumer/api/cpp/unittests/test_tcp_consumer_client.cpp index a17255045177ac9a1c6affd397604002415d4fa6..7ae50313b23a99956de616bd90c709d3868a1b6a 100644 --- a/consumer/api/cpp/unittests/test_tcp_consumer_client.cpp +++ b/consumer/api/cpp/unittests/test_tcp_consumer_client.cpp @@ -12,7 +12,6 @@ using asapo::IO; using asapo::MessageMeta; using asapo::MessageData; using asapo::MockIO; -using asapo::SimpleError; using asapo::TcpConsumerClient; using asapo::MockTCPConnectionPool; diff --git a/consumer/api/python/asapo_wrappers.h b/consumer/api/python/asapo_wrappers.h index c59b8d8c7e0de1e7dd84dd7d36a0e52f09d8badc..f87eb91d0b415cf7e10727ee58a7c8df1f15bba7 100644 --- a/consumer/api/python/asapo_wrappers.h +++ b/consumer/api/python/asapo_wrappers.h @@ -1,6 +1,8 @@ #ifndef ASAPO_ASAPO_WRAPPERS_H #define ASAPO_ASAPO_WRAPPERS_H +#include <string> + namespace asapo { inline std::string GetErrorString(asapo::Error* err) { diff --git a/consumer/tools/folder_to_db/src/main.cpp b/consumer/tools/folder_to_db/src/main.cpp index ef92b81dbd624e1dad80932e7916087586dab761..d8dcf2b773aaabc4664d04572bc38f6921c49c1e 100644 --- a/consumer/tools/folder_to_db/src/main.cpp +++ b/consumer/tools/folder_to_db/src/main.cpp @@ -34,7 +34,7 @@ void ProcessFlags(ConvertParameters* params, int argc, int* narg, char* argv[]) } } catch (...) { Usage(argv[0]); - }; + } } else { Usage(argv[0]); } @@ -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/consumer/tools/folder_to_db/unittests/test_folder_to_db.cpp b/consumer/tools/folder_to_db/unittests/test_folder_to_db.cpp index cee9a314d7e5cf44e16f8f7b74cab771bbd1d19d..ae1e1193976130949c8175273be6a5391f76dd25 100644 --- a/consumer/tools/folder_to_db/unittests/test_folder_to_db.cpp +++ b/consumer/tools/folder_to_db/unittests/test_folder_to_db.cpp @@ -90,7 +90,7 @@ class MockDatabaseFactory : public DatabaseFactory { class FakeDatabaseFactory : public DatabaseFactory { std::unique_ptr<Database> Create(Error* err) const noexcept override { - *err = asapo::ErrorTemplates::kMemoryAllocationError.Generate(); + *err = asapo::GeneralErrorTemplates::kMemoryAllocationError.Generate(); return {}; } }; @@ -166,7 +166,7 @@ TEST_F(FolderDBConverterTests, ErrorWhenCannotGetFileList) { EXPECT_CALL(mock_io, FilesInFolder_t(folder, _)). - WillOnce(DoAll(testing::SetArgPointee<1>(new asapo::SimpleError("err")), + WillOnce(DoAll(testing::SetArgPointee<1>(asapo::GeneralErrorTemplates::kSimpleError.Generate("err").release()), testing::Return(MessageMetas {}))); auto error = converter.Convert(uri, folder, db_name); 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/examples/CMakeLists.txt b/examples/CMakeLists.txt index 70a3f64fdf4b577b7d1ab10b2fb8fd5f58cd0332..26a9ae22aca6e16a6aed820021f6d6e75f5dc0e2 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -3,6 +3,9 @@ if(BUILD_EXAMPLES) endif() if(BUILD_EXAMPLES OR INSTALL_EXAMPLES) - add_subdirectory(producer) add_subdirectory(consumer) endif() + +if(BUILD_EXAMPLES OR INSTALL_EXAMPLES OR BUILD_INTEGRATION_TESTS) + add_subdirectory(producer) +endif() \ No newline at end of file diff --git a/examples/consumer/CMakeLists.txt b/examples/consumer/CMakeLists.txt index 3d5359f708d9f0ed2a0a64f8edd5c207be82b261..ef375cd94d8960b4c08ceb252195259b1930288f 100644 --- a/examples/consumer/CMakeLists.txt +++ b/examples/consumer/CMakeLists.txt @@ -1,7 +1,5 @@ find_package(Threads) -add_subdirectory(getnext) - if(BUILD_EXAMPLES AND BUILD_PYTHON) add_subdirectory(getnext_python) endif() diff --git a/examples/consumer/getnext/CMakeLists.txt b/examples/consumer/getnext/CMakeLists.txt deleted file mode 100644 index 1f6310650bf3527c71358fcf444891c343a60993..0000000000000000000000000000000000000000 --- a/examples/consumer/getnext/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -set(TARGET_NAME getnext) -set(SOURCE_FILES getnext.cpp) - -if (BUILD_EXAMPLES) - -add_executable(${TARGET_NAME} ${SOURCE_FILES}) -target_link_libraries(${TARGET_NAME} asapo-consumer) - -#use expression generator to get rid of VS adding Debug/Release folders -set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}$<$<CONFIG:Debug>:> - ) - -add_script_test("${TARGET_NAME}" "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}") - -endif() - -set (dir share/asapo/examples/consumer/${TARGET_NAME}) -install(FILES ${SOURCE_FILES} DESTINATION "${dir}") - -configure_file(CMakeLists_separate.in CMakeLists_separate.txt @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists_separate.txt DESTINATION "${dir}" RENAME CMakeLists.txt) - -configure_file(Makefile.in Makefile_LINUX @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile_LINUX DESTINATION "${dir}") diff --git a/examples/consumer/getnext/CMakeLists_separate.in b/examples/consumer/getnext/CMakeLists_separate.in deleted file mode 100644 index 3ced42a8eca4502729ff794770bd97fe1f4b4a04..0000000000000000000000000000000000000000 --- a/examples/consumer/getnext/CMakeLists_separate.in +++ /dev/null @@ -1,34 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -project(@TARGET_NAME@) - -set(CMAKE_CXX_STANDARD 11) - -IF(CMAKE_C_COMPILER_ID STREQUAL "GNU") - SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") -ENDIF() - -find_package (Threads) - -if (NOT "$ENV{LIBCURL_DIR}" STREQUAL "") - if (NOT LIBCURL_DIR) - set(LIBCURL_DIR $ENV{LIBCURL_DIR}) - endif() -endif () - - -set (CMAKE_PREFIX_PATH "${LIBCURL_DIR}") -find_package (CURL REQUIRED) -message (STATUS "Found cURL libraries: ${CURL_LIBRARIES}") -message (STATUS "cURL include: ${CURL_INCLUDE_DIRS}") - - -set(TARGET_NAME ${CMAKE_PROJECT_NAME}) - -set(SOURCE_FILES @SOURCE_FILES@) - -link_directories(@CMAKE_INSTALL_PREFIX@/lib) - -add_executable(${TARGET_NAME} ${SOURCE_FILES}) -target_include_directories(${TARGET_NAME} PUBLIC @CMAKE_INSTALL_PREFIX@/include) -target_link_libraries(${TARGET_NAME} asapo-consumer dl ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/examples/pipeline/in_to_out/in_to_out.cpp b/examples/pipeline/in_to_out/in_to_out.cpp index dbf5bb66aca741ca4d67c8d5ae8fe0a578951fab..ac47de215c60c4682ffec1f3a4d61e5ba36b5d3f 100644 --- a/examples/pipeline/in_to_out/in_to_out.cpp +++ b/examples/pipeline/in_to_out/in_to_out.cpp @@ -151,7 +151,7 @@ std::vector<std::thread> StartConsumerThreads(const Args& args, const ProducerPt } while (true) { - auto err = ProcessNextEvent(args, consumer, producer); + err = ProcessNextEvent(args, consumer, producer); if (err) { (*errors)[i] += ProcessError(err); if (err == asapo::ConsumerErrorTemplates::kEndOfStream @@ -205,7 +205,23 @@ std::unique_ptr<asapo::Producer> CreateProducer(const Args& args) { return producer; } -int main(int argc, char* argv[]) { +void OutputResults(const Args& args, int nfiles, int nerrors, uint64_t duration_ms, uint64_t duration_streamout ) { + std::cout << "Data source in " << std::endl; + std::cout << " Processed " << nfiles << " file(s)" << std::endl; + std::cout << " Successfully: " << nfiles - nerrors << std::endl; + std::cout << " Errors : " << nerrors << std::endl; + std::cout << " Elapsed : " << duration_ms - static_cast<unsigned long long int>(args.timeout_ms) << "ms" << std::endl; + std::cout << " Rate : " << 1000.0f * static_cast<float>(nfiles) / (static_cast<float>(duration_ms + - static_cast<unsigned long long int>(args.timeout_ms))) << std::endl; + + std::cout << "Data source out " << std::endl; + std::cout << " Sent " << files_sent << " file(s)" << std::endl; + std::cout << " Elapsed : " << duration_streamout << "ms" << std::endl; + std::cout << " Rate : " << 1000.0f * static_cast<float>(static_cast<uint64_t>(files_sent) / duration_streamout) << + std::endl; +} + +Args GetCommandArgs(int argc, char* argv[]) { Args args; if (argc != 11) { std::cout << "Usage: " + std::string{argv[0]} @@ -224,7 +240,11 @@ int main(int argc, char* argv[]) { args.timeout_ms = atoi(argv[8]); args.timeout_ms_producer = atoi(argv[9]); args.transfer_data = atoi(argv[10]) == 1; + return args; +} +int main(int argc, char* argv[]) { + auto args = GetCommandArgs(argc, argv); auto producer = CreateProducer(args); files_sent = 0; streamout_timer_started = false; @@ -236,22 +256,11 @@ int main(int argc, char* argv[]) { if (producer->WaitRequestsFinished(static_cast<uint64_t>(args.timeout_ms_producer)) != nullptr) { std::cerr << "Data source out exit on timeout " << std::endl; } - auto duration_streamout = std::chrono::duration_cast<std::chrono::milliseconds>(streamout_finish - streamout_start); - std::cout << "Data source in " << std::endl; - std::cout << " Processed " << nfiles << " file(s)" << std::endl; - std::cout << " Successfully: " << nfiles - nerrors << std::endl; - std::cout << " Errors : " << nerrors << std::endl; - std::cout << " Elapsed : " << duration_ms - static_cast<unsigned long long int>(args.timeout_ms) << "ms" << std::endl; - std::cout << " Rate : " << 1000.0f * static_cast<float>(nfiles) / (static_cast<float>(duration_ms - - static_cast<unsigned long long int>(args.timeout_ms))) << std::endl; - - std::cout << "Data source out " << std::endl; - std::cout << " Sent " << files_sent << " file(s)" << std::endl; - std::cout << " Elapsed : " << duration_streamout.count() << "ms" << std::endl; - std::cout << " Rate : " << 1000.0f * static_cast<float>(files_sent / duration_streamout.count()) << std::endl; - - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + auto duration_streamout = static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::milliseconds> + (streamout_finish - streamout_start).count()); + OutputResults(args, nfiles, nerrors, duration_ms, duration_streamout); return (nerrors == 0) && (files_sent == nfiles) ? 0 : 1; } + diff --git a/examples/producer/dummy-data-producer/dummy_data_producer.cpp b/examples/producer/dummy-data-producer/dummy_data_producer.cpp index 8efc8b9c686e6c6cf1bd40e6acf937e1cd388e97..9792fec457829d2c0aad41f37a379d43185cb0d4 100644 --- a/examples/producer/dummy-data-producer/dummy_data_producer.cpp +++ b/examples/producer/dummy-data-producer/dummy_data_producer.cpp @@ -20,23 +20,26 @@ struct Args { std::string beamtime_id; std::string data_source; std::string token; - size_t number_of_bytes; + size_t data_size; uint64_t iterations; uint8_t nthreads; uint64_t mode; uint64_t timeout_ms; uint64_t messages_in_set; + bool write_files; + asapo::SourceType type; + asapo::RequestHandlerType handler; }; void PrintCommandArguments(const Args& args) { std::cout << "discovery_service_endpoint: " << args.discovery_service_endpoint << std::endl << "beamtime_id: " << args.beamtime_id << std::endl - << "Package size: " << args.number_of_bytes / 1000 << "k" << std::endl + << "Package size: " << args.data_size / 1000 << "k" << std::endl << "iterations: " << args.iterations << std::endl << "nthreads: " << args.nthreads << std::endl << "mode: " << args.mode << std::endl - << "Write files: " << ((args.mode % 100) / 10 == 1) << std::endl - << "Tcp mode: " << ((args.mode % 10) == 0 ) << std::endl + << "Write files: " << args.write_files << std::endl + << "Tcp mode: " << ((args.mode % 10) == 0) << std::endl << "Raw: " << (args.mode / 100 == 1) << std::endl << "timeout: " << args.timeout_ms << std::endl << "messages in set: " << args.messages_in_set << std::endl @@ -48,7 +51,7 @@ void TryGetDataSourceAndToken(Args* args) { std::string segment; std::vector<std::string> seglist; - while(std::getline(test, segment, '%')) { + while (std::getline(test, segment, '%')) { seglist.push_back(segment); } if (seglist.size() == 1) { @@ -65,9 +68,6 @@ void TryGetDataSourceAndToken(Args* args) { } - - - void ProcessCommandArguments(int argc, char* argv[], Args* args) { if (argc != 8 && argc != 9) { std::cout << @@ -81,7 +81,7 @@ void ProcessCommandArguments(int argc, char* argv[], Args* args) { args->discovery_service_endpoint = argv[1]; args->beamtime_id = argv[2]; TryGetDataSourceAndToken(args); - args->number_of_bytes = std::stoull(argv[3]) * 1000; + args->data_size = std::stoull(argv[3]) * 1000; args->iterations = std::stoull(argv[4]); args->nthreads = static_cast<uint8_t>(std::stoi(argv[5])); args->mode = std::stoull(argv[6]); @@ -91,9 +91,13 @@ void ProcessCommandArguments(int argc, char* argv[], Args* args) { } else { args->messages_in_set = 1; } + args->write_files = (args->mode % 100) / 10 == 0; + args->type = args->mode / 100 == 0 ? asapo::SourceType::kProcessed : asapo::SourceType::kRaw; + args->handler = args->mode % 10 == 0 ? asapo::RequestHandlerType::kTcp + : asapo::RequestHandlerType::kFilesystem; PrintCommandArguments(*args); return; - } catch(std::exception& e) { + } catch (std::exception& e) { std::cerr << "Fail to parse arguments" << std::endl; std::cerr << e.what() << std::endl; exit(EXIT_FAILURE); @@ -127,12 +131,55 @@ asapo::MessageData CreateMemoryBuffer(size_t size) { return asapo::MessageData(new uint8_t[size]); } +asapo::MessageHeader PrepareMessageHeader(uint64_t i, const Args& args) { + std::string message_folder = GetStringFromSourceType(args.type) + asapo::kPathSeparator; + asapo::MessageHeader message_header{i + 1, args.data_size, std::to_string(i + 1)}; + std::string meta = "{\"user_meta\":\"test" + std::to_string(i + 1) + "\"}"; + if (!args.data_source.empty()) { + message_header.file_name = args.data_source + "/" + message_header.file_name; + } + message_header.file_name = message_folder + message_header.file_name; + message_header.user_metadata = meta; + return message_header; +} + +asapo::Error Send(asapo::Producer* producer, const asapo::MessageHeader& message_header, const Args& args) { + auto buffer = CreateMemoryBuffer(args.data_size); + return producer->Send(message_header, + std::move(buffer), + args.write_files ? asapo::kDefaultIngestMode : asapo::kTransferData, + "default", + &ProcessAfterSend); +} + +bool SendSingleMesssage(asapo::Producer* producer, uint64_t i, const Args& args) { + asapo::MessageHeader message_header = PrepareMessageHeader(i, args); + auto err = Send(producer, message_header, args); + if (err) { + std::cerr << "Cannot send file: " << err << std::endl; + return false; + } + return true; +} + +bool SendDataset(asapo::Producer* producer, uint64_t i, uint64_t id, const Args& args) { + asapo::MessageHeader message_header = PrepareMessageHeader(i, args); + message_header.dataset_substream = id + 1; + message_header.dataset_size = args.messages_in_set; + message_header.file_name += "_" + std::to_string(id + 1); + auto err = Send(producer, message_header, args); + if (err) { + std::cerr << "Cannot send file: " << err << std::endl; + return false; + } + return true; +} -bool SendDummyData(asapo::Producer* producer, size_t number_of_byte, uint64_t iterations, uint64_t messages_in_set, - const std::string& data_source, bool write_files, asapo::SourceType type) { + +bool SendDummyData(asapo::Producer* producer, const Args& args) { asapo::Error err; - if (iterations == 0) { + if (args.iterations == 0) { auto mode = asapo::MetaIngestMode{asapo::MetaIngestOp::kReplace, true}; err = producer->SendBeamtimeMetadata("{\"dummy_meta\":\"test\"}", mode, &ProcessAfterMetaDataSend); if (err) { @@ -141,65 +188,30 @@ bool SendDummyData(asapo::Producer* producer, size_t number_of_byte, uint64_t it } } - std::string message_folder = GetStringFromSourceType(type) + asapo::kPathSeparator; - - - for (uint64_t i = 0; i < iterations; i++) { - auto buffer = CreateMemoryBuffer(number_of_byte); - asapo::MessageHeader message_header{i + 1, number_of_byte, std::to_string(i + 1)}; - std::string meta = "{\"user_meta\":\"test" + std::to_string(i + 1) + "\"}"; - if (!data_source.empty()) { - message_header.file_name = data_source + "/" + message_header.file_name; - } - message_header.file_name = message_folder + message_header.file_name; - message_header.user_metadata = std::move(meta); - if (messages_in_set == 1) { - auto err = producer->Send(message_header, - std::move(buffer), - write_files ? asapo::kDefaultIngestMode : - asapo::kTransferData, - "default", - &ProcessAfterSend); - if (err) { - std::cerr << "Cannot send file: " << err << std::endl; - return false; - } + for (uint64_t i = 0; i < args.iterations; i++) { + bool res = true; + if (args.messages_in_set == 1) { + res = SendSingleMesssage(producer, i, args); } else { - for (uint64_t id = 0; id < messages_in_set; id++) { - auto buffer = CreateMemoryBuffer(number_of_byte); - message_header.dataset_substream = id + 1; - message_header.dataset_size = messages_in_set; - message_header.message_id = i + 1; - message_header.file_name = std::to_string(i + 1) + "_" + std::to_string(id + 1); - if (!data_source.empty()) { - message_header.file_name = data_source + "/" + message_header.file_name; - } - message_header.file_name = message_folder + message_header.file_name; - message_header.user_metadata = meta; - auto err = - producer->Send(message_header, - std::move(buffer), - write_files ? asapo::kDefaultIngestMode : - asapo::kTransferData, - "default", - &ProcessAfterSend); - if (err) { - std::cerr << "Cannot send file: " << err << std::endl; - return false; - } + for (uint64_t id = 0; id < args.messages_in_set; id++) { + res &= SendDataset(producer, i, id, args); } } + if (!res) { + return false; + } } - return producer->SendStreamFinishedFlag("default", iterations, "", nullptr) == nullptr; + return producer->SendStreamFinishedFlag("default", args.iterations, "", nullptr) == nullptr; } std::unique_ptr<asapo::Producer> CreateProducer(const Args& args) { asapo::Error err; - auto producer = asapo::Producer::Create(args.discovery_service_endpoint, args.nthreads, - args.mode % 10 == 0 ? asapo::RequestHandlerType::kTcp : asapo::RequestHandlerType::kFilesystem, - asapo::SourceCredentials{args.mode / 100 == 0 ? asapo::SourceType::kProcessed : asapo::SourceType::kRaw, args.beamtime_id, "", args.data_source, args.token }, - 3600000, &err); - if(err) { + auto producer = asapo::Producer::Create(args.discovery_service_endpoint, args.nthreads, args.handler, + asapo::SourceCredentials{ + args.type, args.beamtime_id, + "", args.data_source, args.token}, + 3600000, &err); + if (err) { std::cerr << "Cannot start producer. ProducerError: " << err << std::endl; exit(EXIT_FAILURE); } @@ -211,16 +223,17 @@ std::unique_ptr<asapo::Producer> CreateProducer(const Args& args) { void PrintOutput(const Args& args, const system_clock::time_point& start) { system_clock::time_point t2 = system_clock::now(); - double duration_sec = static_cast<double>(std::chrono::duration_cast<std::chrono::milliseconds>(t2 - start).count()) - / 1000.0; - double size_gb = static_cast<double>(args.number_of_bytes * args.iterations) / 1000.0 / 1000.0 / 1000.0 * 8.0; + double duration_sec = + static_cast<double>(std::chrono::duration_cast<std::chrono::milliseconds>(t2 - start).count()) + / 1000.0; + double size_gb = static_cast<double>(args.data_size * args.iterations) / 1000.0 / 1000.0 / 1000.0 * 8.0; double rate = static_cast<double>(args.iterations) / duration_sec; std::cout << "Rate: " << rate << " Hz" << std::endl; std::cout << "Bandwidth " << size_gb / duration_sec << " Gbit/s" << std::endl; std::cout << "Bandwidth " << size_gb / duration_sec / 8 << " GBytes/s" << std::endl; } -int main (int argc, char* argv[]) { +int main(int argc, char* argv[]) { Args args; ProcessCommandArguments(argc, argv, &args); @@ -234,8 +247,7 @@ int main (int argc, char* argv[]) { system_clock::time_point start_time = system_clock::now(); - if(!SendDummyData(producer.get(), args.number_of_bytes, args.iterations, args.messages_in_set, args.data_source, - (args.mode % 100) / 10 == 0, args.mode / 100 == 0 ? asapo::SourceType::kProcessed : asapo::SourceType::kRaw)) { + if (!SendDummyData(producer.get(), args)) { return EXIT_FAILURE; } diff --git a/producer/api/cpp/include/asapo/producer/producer_error.h b/producer/api/cpp/include/asapo/producer/producer_error.h index 7b6bc174d88293c1b553a8206cf2098a9c4027f2..e73e113ae789c43778c13d235f36b72186d286c1 100644 --- a/producer/api/cpp/include/asapo/producer/producer_error.h +++ b/producer/api/cpp/include/asapo/producer/producer_error.h @@ -17,7 +17,7 @@ enum class ProducerErrorType { kTimeout }; -using ProducerErrorTemplate = ServiceErrorTemplate<ProducerErrorType, ErrorType::kProducerError>; +using ProducerErrorTemplate = ServiceErrorTemplate<ProducerErrorType>; class OriginalData : public CustomErrorData { public: diff --git a/producer/api/cpp/src/producer.cpp b/producer/api/cpp/src/producer.cpp index 3c277fcfe1e70b06019b5f315c70585ef6af8c14..a437fcc560587ac237cbba174d7594fc17057bbf 100644 --- a/producer/api/cpp/src/producer.cpp +++ b/producer/api/cpp/src/producer.cpp @@ -15,10 +15,10 @@ std::unique_ptr<asapo::Producer> asapo::Producer::Create(const std::string& endp try { producer.reset(new ProducerImpl(endpoint, n_processing_threads, timeout_ms, type)); } catch (const std::exception& ex) { - *err = TextError(ex.what()); + *err = GeneralErrorTemplates::kSimpleError.Generate(ex.what()); return nullptr; } catch (...) { - *err = TextError("Unknown exception in producer_api "); + *err = GeneralErrorTemplates::kSimpleError.Generate("Unknown exception in producer_api "); return nullptr; } diff --git a/producer/api/cpp/src/producer_impl.cpp b/producer/api/cpp/src/producer_impl.cpp index 2c99c0147899f8770beeff094910b444e332039c..a0b68f07018a2281f5df907387107f5164b3e3f2 100644 --- a/producer/api/cpp/src/producer_impl.cpp +++ b/producer/api/cpp/src/producer_impl.cpp @@ -197,7 +197,7 @@ Error ProducerImpl::Send(const MessageHeader& message_header, } bool WantTransferData(uint64_t ingest_mode) { - return ingest_mode & IngestModeFlags::kTransferData; + return static_cast<bool>(ingest_mode & IngestModeFlags::kTransferData); } Error CheckData(uint64_t ingest_mode, const MessageHeader& message_header, const MessageData* data) { diff --git a/producer/api/cpp/src/receiver_discovery_service.cpp b/producer/api/cpp/src/receiver_discovery_service.cpp index e36d038a69fa3b51e04234a8cec25a3029561a8b..45e7c4195869acada195dcb2760ff4b341c8ab8e 100644 --- a/producer/api/cpp/src/receiver_discovery_service.cpp +++ b/producer/api/cpp/src/receiver_discovery_service.cpp @@ -46,7 +46,7 @@ Error ReceiverDiscoveryService::UpdateFromEndpoint(ReceiversList* list, uint64_t return err; } if (code != HttpCode::OK) { - return TextError(responce); + return GeneralErrorTemplates::kSimpleError.Generate(responce); } return ParseResponse(responce, list, max_connections); @@ -54,7 +54,9 @@ Error ReceiverDiscoveryService::UpdateFromEndpoint(ReceiversList* list, uint64_t void ReceiverDiscoveryService::LogUriList(const ReceiversList& uris) { std::string s; - s = std::accumulate(std::begin(uris), std::end(uris), s); + for (const auto& uri : uris) { + s += uri; + } log__->Debug("got receivers from " + endpoint_ + ":" + s); } diff --git a/producer/api/cpp/src/request_handler_tcp.cpp b/producer/api/cpp/src/request_handler_tcp.cpp index a2f2409e1721b39d82ca9fdfdf6fe1f2dc539071..9595e3146b790beae689cb043978678cea7285db 100644 --- a/producer/api/cpp/src/request_handler_tcp.cpp +++ b/producer/api/cpp/src/request_handler_tcp.cpp @@ -93,22 +93,22 @@ Error RequestHandlerTcp::ReceiveResponse(std::string* response) { switch (sendDataResponse.error_code) { case kNetAuthorizationError : { auto res_err = ProducerErrorTemplates::kWrongInput.Generate(); - res_err->Append(sendDataResponse.message); + res_err->AddContext("response", sendDataResponse.message); return res_err; } case kNetErrorNotSupported : { auto res_err = ProducerErrorTemplates::kUnsupportedClient.Generate(); - res_err->Append(sendDataResponse.message); + res_err->AddContext("response", sendDataResponse.message); return res_err; } case kNetErrorWrongRequest : { auto res_err = ProducerErrorTemplates::kWrongInput.Generate(); - res_err->Append(sendDataResponse.message); + res_err->AddContext("response", sendDataResponse.message); return res_err; } case kNetErrorWarning: { auto res_err = ProducerErrorTemplates::kServerWarning.Generate(); - res_err->Append(sendDataResponse.message); + res_err->AddContext("response", sendDataResponse.message); return res_err; } case kNetErrorReauthorize: { @@ -122,7 +122,7 @@ Error RequestHandlerTcp::ReceiveResponse(std::string* response) { return nullptr; default: auto res_err = ProducerErrorTemplates::kInternalServerError.Generate(); - res_err->Append(sendDataResponse.message); + res_err->AddContext("response", sendDataResponse.message); return res_err; } } diff --git a/producer/api/cpp/unittests/mocking.h b/producer/api/cpp/unittests/mocking.h index e2d182f1694dbc51cd80dda8dcfa0cfbcdb811b4..32aab9047bdd22e4594f30d461e2d890d9d36f3f 100644 --- a/producer/api/cpp/unittests/mocking.h +++ b/producer/api/cpp/unittests/mocking.h @@ -22,9 +22,9 @@ class MockDiscoveryService : public asapo::ReceiverDiscoveryService { } }; -class MockRequestPull : public RequestPool { +class MockRequestPool : public RequestPool { public: - MockRequestPull(RequestHandlerFactory* request_handler_factory, AbstractLogger* log) : + MockRequestPool(RequestHandlerFactory* request_handler_factory, AbstractLogger* log) : RequestPool{1, request_handler_factory, log} {}; asapo::Error AddRequest(std::unique_ptr<asapo::GenericRequest> request, bool top_priority = false) override { if (request == nullptr) { @@ -52,6 +52,6 @@ class MockRequestPull : public RequestPool { } using asapo::MockDiscoveryService; -using asapo::MockRequestPull; +using asapo::MockRequestPool; #endif //ASAPO_MOCKING_H diff --git a/producer/api/cpp/unittests/test_producer_impl.cpp b/producer/api/cpp/unittests/test_producer_impl.cpp index e62c21735ead0d311de4b2cf6a221e0ad244679e..8c0fda47f6e3651b6508047ce0fe6e13713e6c9f 100644 --- a/producer/api/cpp/unittests/test_producer_impl.cpp +++ b/producer/api/cpp/unittests/test_producer_impl.cpp @@ -73,7 +73,7 @@ class ProducerImplTests : public testing::Test { testing::NiceMock<MockDiscoveryService> service; asapo::ProducerRequestHandlerFactory factory{&service}; testing::NiceMock<asapo::MockLogger> mock_logger; - testing::NiceMock<MockRequestPull> mock_pull{&factory, &mock_logger}; + testing::NiceMock<MockRequestPool> mock_pull{&factory, &mock_logger}; std::string expected_server_uri = "127.0.0.1:9400"; asapo::ProducerImpl producer{expected_server_uri, 1, 3600000, asapo::RequestHandlerType::kTcp}; uint64_t expected_size = 100; @@ -588,6 +588,7 @@ TEST_F(ProducerImplTests, ReturnDataIfCanotAddToQueue) { std::move(pool_err).release())); asapo::MessageHeader message_header{expected_id, 0, expected_name}; + data = asapo::MessageData{new uint8_t[100]}; auto err = producer.Send(message_header, std::move(data), expected_ingest_mode, expected_stream, nullptr); auto err_data = static_cast<asapo::OriginalData*>(err->GetCustomData()); diff --git a/producer/api/cpp/unittests/test_receiver_discovery_service.cpp b/producer/api/cpp/unittests/test_receiver_discovery_service.cpp index 0c501e6329373afbb3a796486355bfe891860756..c4103b8df771b76e27368df658a8678da3514541 100644 --- a/producer/api/cpp/unittests/test_receiver_discovery_service.cpp +++ b/producer/api/cpp/unittests/test_receiver_discovery_service.cpp @@ -64,7 +64,7 @@ TEST_F(ReceiversStatusTests, LogWhenHttpError) { EXPECT_CALL(*mock_http_client, Get_t(expected_endpoint, _, _)) .Times(1) .WillOnce( - DoAll(SetArgPointee<2>(new asapo::IOError("Test Read Error", asapo::IOErrorType::kReadError)), + DoAll(SetArgPointee<2>(new asapo::IOError("Test Read Error", "", asapo::IOErrorType::kReadError)), Return("") )); diff --git a/producer/event_monitor_producer/src/event_monitor_error.h b/producer/event_monitor_producer/src/event_monitor_error.h index f3dcf37ccf9e04c89c11f8c7af752d6984c63591..3ed7c91cfaf1d247436eaed8fcce3ce36e5e4794 100644 --- a/producer/event_monitor_producer/src/event_monitor_error.h +++ b/producer/event_monitor_producer/src/event_monitor_error.h @@ -10,7 +10,7 @@ enum class EventMonitorErrorType { kSystemError }; -using EventMonitorErrorTemplate = ServiceErrorTemplate<EventMonitorErrorType, ErrorType::kAsapoError>; +using EventMonitorErrorTemplate = ServiceErrorTemplate<EventMonitorErrorType>; namespace EventMonitorErrorTemplates { auto const kNoNewEvent = EventMonitorErrorTemplate { diff --git a/producer/event_monitor_producer/src/eventmon_config.cpp b/producer/event_monitor_producer/src/eventmon_config.cpp index d3d403950319b4713b90194c3276ad60b96839cb..5341fd14c168dd7983f30fe504bd647d0e61c9a2 100644 --- a/producer/event_monitor_producer/src/eventmon_config.cpp +++ b/producer/event_monitor_producer/src/eventmon_config.cpp @@ -28,7 +28,7 @@ Error DatasetModeToEnum(const std::string& mode_str, DatasetMode* mode) { } - return TextError("Wrone dataset mode:" + mode_str); + return GeneralErrorTemplates::kSimpleError.Generate("Wrone dataset mode:" + mode_str); } Error EventMonConfigFactory::ParseConfigFile(std::string file_name) { @@ -59,8 +59,8 @@ Error EventMonConfigFactory::ParseConfigFile(std::string file_name) { } if (config.dataset_mode == DatasetMode::kMultiSource) { - err = parser.Embedded("Dataset").GetUInt64("NSources", &config.dataset_multisource_nsources); - err = parser.Embedded("Dataset").GetUInt64("SourceId", &config.dataset_multisource_sourceid); + (err = parser.Embedded("Dataset").GetUInt64("NSources", &config.dataset_multisource_nsources)) || + ((err = parser.Embedded("Dataset").GetUInt64("SourceId", &config.dataset_multisource_sourceid))); } @@ -95,7 +95,7 @@ Error EventMonConfigFactory::CheckMode() { } else if (config.mode_str == "filesystem") { config.mode = RequestHandlerType::kFilesystem; } else { - return TextError("wrong producer mode: " + config.mode_str); + return GeneralErrorTemplates::kSimpleError.Generate("wrong producer mode: " + config.mode_str); } return nullptr; } @@ -108,19 +108,20 @@ Error EventMonConfigFactory::CheckLogLevel() { Error EventMonConfigFactory::CheckNThreads() { if (config.nthreads == 0 || config.nthreads > kMaxProcessingThreads ) { - return TextError("NThreads should between 1 and " + std::to_string(kMaxProcessingThreads)); + return GeneralErrorTemplates::kSimpleError.Generate("NThreads should between 1 and " + std::to_string( + kMaxProcessingThreads)); } return nullptr; } Error EventMonConfigFactory::CheckDatasets() { if (config.dataset_mode == DatasetMode::kBatch && config.dataset_batch_size < 1) { - return TextError("Batch size should > 0"); + return GeneralErrorTemplates::kSimpleError.Generate("Batch size should > 0"); } if (config.dataset_mode == DatasetMode::kMultiSource && config.dataset_multisource_nsources < 1) { - return TextError("Number of sources size should be > 0"); + return GeneralErrorTemplates::kSimpleError.Generate("Number of sources size should be > 0"); } diff --git a/producer/event_monitor_producer/src/folder_event_detector.cpp b/producer/event_monitor_producer/src/folder_event_detector.cpp index e108144ba696211143e033c46e1d98d5a897bddf..3cabedc5fdeece40408dd9c5f41c03bef37713c2 100644 --- a/producer/event_monitor_producer/src/folder_event_detector.cpp +++ b/producer/event_monitor_producer/src/folder_event_detector.cpp @@ -59,7 +59,7 @@ Error FolderEventDetector::UpdateEventsBuffer() { Error FolderEventDetector::GetNextEvent(MessageHeader* message_header) { if (!monitoring_started_) { - auto err = TextError("monitoring is not started yet"); + auto err = GeneralErrorTemplates::kSimpleError.Generate("monitoring is not started yet"); return err; } diff --git a/producer/event_monitor_producer/unittests/test_folder_event_detector.cpp b/producer/event_monitor_producer/unittests/test_folder_event_detector.cpp index c1c8b43a0ae6cff754634045b4d04bddad97ad9e..66d5433267150f4b1f4b8019708309ecec6f8875 100644 --- a/producer/event_monitor_producer/unittests/test_folder_event_detector.cpp +++ b/producer/event_monitor_producer/unittests/test_folder_event_detector.cpp @@ -101,7 +101,7 @@ TEST_F(FolderEventDetectorTests, StartFolderMonitoringReturnsError) { EXPECT_CALL(mock_system_folder_watch, StartFolderMonitor_t(expected_root_folder, expected_folders)) .Times(2) .WillOnce( - Return(asapo::ErrorTemplates::kMemoryAllocationError.Generate().release()) + Return(asapo::GeneralErrorTemplates::kMemoryAllocationError.Generate().release()) ) .WillOnce( Return(nullptr) diff --git a/receiver/CMakeLists.txt b/receiver/CMakeLists.txt index 5dd1bde163c50e9cdd81cd325526d39d847fdfaf..af41e773a067d3b546a3c471cb2d4062f2fc6912 100644 --- a/receiver/CMakeLists.txt +++ b/receiver/CMakeLists.txt @@ -16,6 +16,9 @@ set(RECEIVER_CORE_FILES src/request_handler/request_handler_db_write.cpp src/request_handler/request_handler_receive_data.cpp src/request_handler/request_handler_authorize.cpp + src/request_handler/request_handler_initial_authorization.cpp + src/request_handler/request_handler_secondary_authorization.cpp + src/request_handler/authorization_client.cpp src/request_handler/request_handler_db_meta_write.cpp src/request_handler/request_handler_db_stream_info.cpp src/request_handler/request_handler_db_last_stream.cpp @@ -25,9 +28,9 @@ set(RECEIVER_CORE_FILES src/request_handler/request_handler_db_get_meta.cpp src/request_handler/request_factory.cpp src/request_handler/request_handler_db.cpp - src/file_processors/write_file_processor.cpp - src/file_processors/file_processor.cpp - src/file_processors/receive_file_processor.cpp + src/request_handler/file_processors/write_file_processor.cpp + src/request_handler/file_processors/file_processor.cpp + src/request_handler/file_processors/receive_file_processor.cpp src/metrics/receiver_prometheus_metrics.cpp src/metrics/receiver_mongoose_server.cpp ) @@ -53,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> @@ -99,7 +100,9 @@ set(TEST_SOURCE_FILES unittests/request_handler/test_request_handler_db_stream_info.cpp unittests/request_handler/test_request_handler_db_last_stream.cpp unittests/request_handler/test_request_handler_db.cpp - unittests/request_handler/test_request_handler_authorizer.cpp + unittests/request_handler/test_authorization_client.cpp + unittests/request_handler/test_request_handler_initial_authorization.cpp + unittests/request_handler/test_request_handler_secondary_authorization.cpp unittests/request_handler/test_request_handler_receive_data.cpp unittests/request_handler/test_request_handler_receive_metadata.cpp unittests/request_handler/test_request_handler_delete_stream.cpp @@ -109,9 +112,9 @@ set(TEST_SOURCE_FILES unittests/mock_receiver_config.cpp unittests/request_handler/test_requests_dispatcher.cpp unittests/test_datacache.cpp - unittests/file_processors/test_write_file_processor.cpp - unittests/file_processors/test_file_processor.cpp - unittests/file_processors/test_receive_file_processor.cpp + unittests/request_handler/file_processors/test_write_file_processor.cpp + unittests/request_handler/file_processors/test_file_processor.cpp + unittests/request_handler/file_processors/test_receive_file_processor.cpp ) # set(TEST_LIBRARIES "${TARGET_NAME};system_io") 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 ad8b30d09471d2af42ea5a6e8eda9b99731636e1..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) + @@ -44,10 +42,9 @@ void Connection::Listen() const noexcept { } io__->CloseSocket(socket_fd_, nullptr); statistics__->SendIfNeeded(true); - log__->Info("disconnected from " + address_); + log__->Info(LogMessageWithFields("disconnected from producer").Append("origin", HostFromUri(address_))); } - } diff --git a/receiver/src/data_cache.cpp b/receiver/src/data_cache.cpp index f6765f46fac8db9a24e5b76b9f8dae40dfffffa5..d0b6b32a847cfd8b48346505b56a27b0108995e9 100644 --- a/receiver/src/data_cache.cpp +++ b/receiver/src/data_cache.cpp @@ -1,5 +1,4 @@ #include "data_cache.h" -#include "data_cache.h" #include <iostream> #include <chrono> @@ -13,12 +12,12 @@ DataCache::DataCache(uint64_t cache_size, float keepunlocked_ratio) : cache_size try { cache_.reset(new uint8_t[cache_size]); } catch (std::exception& e) { - std::cout << "Cannot allocate data cache: " << e.what() << std::endl; + std::cout << "cannot allocate data cache: " << e.what() << std::endl; exit(1); } srand(static_cast<unsigned int>(time(NULL))); - counter_ = rand() % 100 + 1; + counter_ = static_cast<uint32_t>(rand() % 100 + 1); } void* DataCache::AllocateSlot(uint64_t size) { 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/metrics/receiver_mongoose_server.cpp b/receiver/src/metrics/receiver_mongoose_server.cpp index fa601ed71667d22345edf649bae959e9464bc9e3..d705bea0c795f8819b8bdb37f3fd7ac240ce8b51 100644 --- a/receiver/src/metrics/receiver_mongoose_server.cpp +++ b/receiver/src/metrics/receiver_mongoose_server.cpp @@ -32,10 +32,11 @@ static void fn(struct mg_connection* c, int ev, void* ev_data, void* fn_data) { void asapo::ReceiverMongooseServer::ListenAndServe(std::string port, std::unique_ptr<ReceiverMetricsProvider> provider) { struct mg_mgr mgr; // Event manager + mg_log_set("0"); mg_mgr_init(&mgr); // Initialise event manager auto uri = "0.0.0.0:" + port; if (mg_http_listen(&mgr, uri.c_str(), fn, (void*) provider.get()) == NULL) { - log__->Error("cannot listen on port " + port); + log__->Error("metrics server: cannot listen on port " + port); mg_mgr_free(&mgr); return; } diff --git a/receiver/src/receiver.cpp b/receiver/src/receiver.cpp index f28976609bd09ecd04ae959a191143040313b5ff..e3ef529d402f141d51004104e3ab01bbbda5bfcd 100644 --- a/receiver/src/receiver.cpp +++ b/receiver/src/receiver.cpp @@ -1,4 +1,3 @@ -#include <cstring> #include <iostream> #include "receiver.h" #include "receiver_error.h" @@ -45,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; } @@ -54,7 +52,7 @@ void Receiver::ProcessConnections(Error* err) { } void Receiver::StartNewConnectionInSeparateThread(int connection_socket_fd, const std::string& address) { - log__->Info("new connection from " + address); + log__->Info(LogMessageWithFields("new connection with producer").Append("origin", HostFromUri(address))); auto thread = io__->NewThread("ConFd:" + std::to_string(connection_socket_fd), [connection_socket_fd, address, this] { auto connection = std::unique_ptr<Connection>(new Connection(connection_socket_fd, address, cache_, GetReceiverConfig()->tag)); 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/receiver_data_server/net_server/rds_fabric_server.cpp b/receiver/src/receiver_data_server/net_server/rds_fabric_server.cpp index 3c07fd7855e3265b27b2d85fcdd998bec644e840..a31ab18747093992b53c9665bbfaa5f6906f53ea 100644 --- a/receiver/src/receiver_data_server/net_server/rds_fabric_server.cpp +++ b/receiver/src/receiver_data_server/net_server/rds_fabric_server.cpp @@ -19,7 +19,7 @@ RdsFabricServer::~RdsFabricServer() { Error RdsFabricServer::Initialize() { if (server__) { - return TextError("Server was already initialized"); + return GeneralErrorTemplates::kSimpleError.Generate("Server was already initialized"); } Error err; std::string hostname; diff --git a/receiver/src/receiver_data_server/net_server/rds_tcp_server.cpp b/receiver/src/receiver_data_server/net_server/rds_tcp_server.cpp index eacb5fc0d82f7062de3fdc049f5d6794fff8720d..fc8efd3fee6b67a12a13681e71832a3be0ba7319 100644 --- a/receiver/src/receiver_data_server/net_server/rds_tcp_server.cpp +++ b/receiver/src/receiver_data_server/net_server/rds_tcp_server.cpp @@ -19,7 +19,7 @@ Error RdsTcpServer::Initialize() { log__->Error("TCP ReceiverDataServer cannot listen on " + address_ + ": " + err->Explain()); } } else { - err = TextError("Server was already initialized"); + err = GeneralErrorTemplates::kSimpleError.Generate("Server was already initialized"); } return err; } @@ -44,7 +44,7 @@ ReceiverDataServerRequestPtr RdsTcpServer::ReadRequest(SocketDescriptor socket, GenericRequestHeader header; io__->Receive(socket, &header, sizeof(GenericRequestHeader), err); - if (*err == ErrorTemplates::kEndOfFile) { + if (*err == GeneralErrorTemplates::kEndOfFile) { CloseSocket(socket); return nullptr; } else if (*err) { diff --git a/receiver/src/receiver_data_server/receiver_data_server_error.h b/receiver/src/receiver_data_server/receiver_data_server_error.h index 02befb4cad4cb24b4e2fe9f74ecd36b42eef8a7a..3e2e48601aa4b2d886ba216b7d731a15c593bfd7 100644 --- a/receiver/src/receiver_data_server/receiver_data_server_error.h +++ b/receiver/src/receiver_data_server/receiver_data_server_error.h @@ -10,7 +10,7 @@ enum class ReceiverDataServerErrorType { kWrongRequest }; -using ReceiverDataServerErrorTemplate = ServiceErrorTemplate<ReceiverDataServerErrorType, ErrorType::kReceiverError>; +using ReceiverDataServerErrorTemplate = ServiceErrorTemplate<ReceiverDataServerErrorType>; namespace ReceiverDataServerErrorTemplates { auto const kMemoryPool = ReceiverDataServerErrorTemplate { diff --git a/receiver/src/receiver_data_server/request_handler/receiver_data_server_request_handler.cpp b/receiver/src/receiver_data_server/request_handler/receiver_data_server_request_handler.cpp index 6de6edf6f542a6c9c1091ad2ea703cc957b799ff..f2409de029b5cb2cfcb49b469ed16a8d5b13f987 100644 --- a/receiver/src/receiver_data_server/request_handler/receiver_data_server_request_handler.cpp +++ b/receiver/src/receiver_data_server/request_handler/receiver_data_server_request_handler.cpp @@ -103,7 +103,7 @@ void ReceiverDataServerRequestHandler::HandleInvalidRequest(const ReceiverDataSe break; default: break; - }; + } } diff --git a/receiver/src/receiver_error.h b/receiver/src/receiver_error.h index 23d0669d6b09f113224f9981f03f0e31281094e3..dff04fc0655265a5de163b14ae28f1e532548998 100644 --- a/receiver/src/receiver_error.h +++ b/receiver/src/receiver_error.h @@ -12,10 +12,11 @@ enum class ReceiverErrorType { kInternalServerError, kReAuthorizationFailure, kWarningDuplicatedRequest, - kUnsupportedClient + kUnsupportedClient, + kProcessingError }; -using ReceiverErrorTemplate = ServiceErrorTemplate<ReceiverErrorType, ErrorType::kReceiverError>; +using ReceiverErrorTemplate = ServiceErrorTemplate<ReceiverErrorType>; namespace ReceiverErrorTemplates { @@ -33,6 +34,10 @@ auto const kInternalServerError = ReceiverErrorTemplate { "server error", ReceiverErrorType::kInternalServerError }; +auto const kProcessingError = ReceiverErrorTemplate { + "processing error", ReceiverErrorType::kProcessingError +}; + auto const kBadRequest = ReceiverErrorTemplate { "Bad request", ReceiverErrorType::kBadRequest diff --git a/receiver/src/receiver_logger.cpp b/receiver/src/receiver_logger.cpp index 1f297a68073f4d0863a9be0a1f0f69af149cafcd..05edc430a5d22542e9d7e6029214fb01a32f8326 100644 --- a/receiver/src/receiver_logger.cpp +++ b/receiver/src/receiver_logger.cpp @@ -1,11 +1,59 @@ #include "receiver_logger.h" -namespace asapo { +#include "request.h" + +#include "request_handler/structs.h" +namespace asapo { AbstractLogger* GetDefaultReceiverLogger() { static Logger logger = asapo::CreateDefaultLoggerBin("receiver"); return logger.get(); } + +void AppendIdToLogMessageIfNeeded(const Request* request, LogMessageWithFields* msg) { + switch (request->GetOpCode()) { + case Opcode::kOpcodeTransferData: + msg->Append("id", request->GetDataID()); + break; + case Opcode::kOpcodeTransferDatasetData: + msg->Append("id", request->GetDataID()); + msg->Append("substream", request->GetCustomData()[1]); + break; + default: + break; + } +} + +LogMessageWithFields AuthorizationLog(std::string message, const Request* request, const AuthorizationData* data) { + LogMessageWithFields msg{std::move(message)}; + msg.Append("beamtime", data->beamtime_id) + .Append("dataSource", data->data_source) + .Append("beamline", data->beamline) + .Append("origin", request->GetOriginHost()); + + if (request->GetOpCode() != kOpcodeAuthorize) { + msg.Append("stream", request->GetStream()); + AppendIdToLogMessageIfNeeded(request, &msg); + } + + return msg; +} + + +LogMessageWithFields RequestLog(std::string message, const Request* request) { + LogMessageWithFields msg{std::move(message)}; + msg.Append("beamtime", request->GetBeamtimeId()) + .Append("beamline", request->GetBeamline()) + .Append("dataSource", request->GetDataSource()) + .Append("stream", request->GetStream()) + .Append("origin", request->GetOriginHost()) + .Append("operation", OpcodeToString(request->GetOpCode())); + + AppendIdToLogMessageIfNeeded(request, &msg); + + return msg; +} + } diff --git a/receiver/src/receiver_logger.h b/receiver/src/receiver_logger.h index 75ce25072555f98d10aca9195355cb50598e22ab..e1cd160448d8ff500df6549ee0f8c316f48c535d 100644 --- a/receiver/src/receiver_logger.h +++ b/receiver/src/receiver_logger.h @@ -5,8 +5,12 @@ namespace asapo { +struct AuthorizationData; +class Request; AbstractLogger* GetDefaultReceiverLogger(); +LogMessageWithFields RequestLog(std::string message, const Request* request); +LogMessageWithFields AuthorizationLog(std::string message, const Request* request, const AuthorizationData* data); } diff --git a/receiver/src/request.cpp b/receiver/src/request.cpp index f6aa6223bc30f08ca8b651ebb35cd7d4476d1fc0..0c4ed721b105dc68bf7a93c044ecc8b71150d212 100644 --- a/receiver/src/request.cpp +++ b/receiver/src/request.cpp @@ -1,6 +1,6 @@ #include "request.h" #include "asapo/io/io_factory.h" -#include "receiver_config.h" +#include "request_handler/request_handler_db_check_request.h" namespace asapo { @@ -10,6 +10,7 @@ Request::Request(const GenericRequestHeader& header, cache__{cache}, request_header_(header), socket_fd_{socket_fd}, origin_uri_{std::move(origin_uri)}, check_duplicate_request_handler_{db_check_handler} { + origin_host_ = HostFromUri(origin_uri_); } Error Request::PrepareDataBufferAndLockIfNeeded() { @@ -17,8 +18,7 @@ Error Request::PrepareDataBufferAndLockIfNeeded() { try { data_buffer_.reset(new uint8_t[(size_t)request_header_.data_size]); } catch(std::exception& e) { - auto err = ErrorTemplates::kMemoryAllocationError.Generate(); - err->Append(e.what()); + auto err = GeneralErrorTemplates::kMemoryAllocationError.Generate(e.what()); return err; } } else { @@ -27,7 +27,7 @@ Error Request::PrepareDataBufferAndLockIfNeeded() { if (data_ptr) { slot_meta_ = slot; } else { - return ErrorTemplates::kMemoryAllocationError.Generate("cannot allocate slot in cache"); + return GeneralErrorTemplates::kMemoryAllocationError.Generate("cannot allocate slot in cache"); } } return nullptr; @@ -93,7 +93,6 @@ std::string Request::GetApiVersion() const { return request_header_.api_version; } - const std::string& Request::GetOriginUri() const { return origin_uri_; } @@ -205,4 +204,8 @@ SourceType Request::GetSourceType() const { return source_type_; } +const std::string& Request::GetOriginHost() const { + return origin_host_; +} + } diff --git a/receiver/src/request.h b/receiver/src/request.h index 916a04358932d82dfe8de23386edead3ebf26eb4..47e3eacffb43d6aaaebce476aaa8f9146f741ec6 100644 --- a/receiver/src/request.h +++ b/receiver/src/request.h @@ -7,19 +7,11 @@ #include "asapo/common/networking.h" #include "asapo/io/io.h" #include "request_handler/request_handler.h" -#include "request_handler/request_handler_file_process.h" -#include "request_handler/request_handler_db_write.h" -#include "request_handler/request_handler_authorize.h" -#include "request_handler/request_handler_db_meta_write.h" -#include "request_handler/request_handler_receive_data.h" -#include "request_handler/request_handler_receive_metadata.h" -#include "request_handler/request_handler_db_check_request.h" #include "statistics/receiver_statistics.h" #include "data_cache.h" #include "asapo/preprocessor/definitions.h" -#include "file_processors/file_processor.h" namespace asapo { @@ -30,6 +22,8 @@ enum class ResponseMessageType { kInfo }; +class RequestHandlerDbCheckRequest; + class Request { public: VIRTUAL Error Handle(ReceiverStatistics*); @@ -49,7 +43,8 @@ class Request { VIRTUAL Opcode GetOpCode() const; VIRTUAL const char* GetMessage() const; - const std::string& GetOriginUri() const; + VIRTUAL const std::string& GetOriginUri() const; + VIRTUAL const std::string& GetOriginHost() const; VIRTUAL const std::string& GetMetaData() const; VIRTUAL const std::string& GetBeamtimeId() const; VIRTUAL void SetBeamtimeId(std::string beamtime_id); @@ -88,6 +83,7 @@ class Request { void* data_ptr; RequestHandlerList handlers_; std::string origin_uri_; + std::string origin_host_; std::string beamtime_id_; std::string data_source_; std::string beamline_; diff --git a/receiver/src/request_handler/authorization_client.cpp b/receiver/src/request_handler/authorization_client.cpp new file mode 100644 index 0000000000000000000000000000000000000000..183fac7cb8fd1e2d2b9de895704f22f7993c5303 --- /dev/null +++ b/receiver/src/request_handler/authorization_client.cpp @@ -0,0 +1,133 @@ +#include "authorization_client.h" + +#include <chrono> + +#include "asapo/json_parser/json_parser.h" + +#include "../receiver_config.h" +#include "../receiver_logger.h" +#include "../request.h" + +namespace asapo { + +std::string GetRequestString(const Request *request, const std::string &source_credentials) { + std::string request_string = std::string("{\"SourceCredentials\":\"") + + source_credentials + "\",\"OriginHost\":\"" + request->GetOriginUri() + "\"}"; + return request_string; +} + +Error ErrorFromAuthorizationServerResponse(Error err, const std::string response, + HttpCode code) { + Error return_err; + if (err) { + return_err = asapo::ReceiverErrorTemplates::kInternalServerError.Generate( + "cannot authorize request"); + return_err->SetCause(std::move(err)); + } else { + if (code != HttpCode::Unauthorized) { + return_err = asapo::ReceiverErrorTemplates::kInternalServerError.Generate(); + return_err->AddContext("response", response)->AddContext("errorCode", std::to_string(int( + code))); + } else { + return_err = asapo::ReceiverErrorTemplates::kAuthorizationFailure.Generate(); + } + } + return return_err; +} + +Error CheckAccessType(SourceType source_type, const std::vector<std::string> &access_types) { + if (std::find(access_types.begin(), access_types.end(), + source_type == SourceType::kProcessed ? "write" : "writeraw") != access_types.end()) { + return nullptr; + } else { + auto err = asapo::ReceiverErrorTemplates::kAuthorizationFailure.Generate("wrong access types"); + std::string types; + for (size_t i = 0; i < access_types.size(); i++) { + types += (i > 0 ? "," : "") + access_types[i]; + } + err->AddContext("expected", source_type == SourceType::kProcessed ? "write" : "writeraw")->AddContext("have", + types); + return err; + } +} + +Error ParseServerResponse(const std::string &response, + HttpCode code, + std::vector<std::string> *access_types, + AuthorizationData *data) { + Error err; + AuthorizationData creds; + JsonStringParser parser{response}; + std::string stype; + + (err = parser.GetString("beamtimeId", &data->beamtime_id)) || + (err = parser.GetString("dataSource", &data->data_source)) || + (err = parser.GetString("corePath", &data->offline_path)) || + (err = parser.GetString("beamline-path", &data->online_path)) || + (err = parser.GetString("source-type", &stype)) || + (err = parser.GetArrayString("access-types", access_types)) || + (err = GetSourceTypeFromString(stype, &data->source_type)) || + (err = parser.GetString("beamline", &data->beamline)); + if (err) { + return ErrorFromAuthorizationServerResponse(std::move(err), "", code); + } + return nullptr; +} + +Error UpdateDataFromServerResponse(const std::string &response, HttpCode code, AuthorizationData *data) { + Error err; + std::string stype; + std::vector<std::string> access_types; + AuthorizationData old_data = *data; + err = ParseServerResponse(response, code, &access_types, data); + if (err) { + *data = old_data; + return ErrorFromAuthorizationServerResponse(std::move(err), response, code); + } + + err = CheckAccessType(data->source_type, access_types); + if (err) { + *data = old_data; + return err; + } + data->last_update = std::chrono::system_clock::now(); + return nullptr; +} + +Error AuthorizationClient::DoServerRequest(const std::string &request_string, + std::string *response, + HttpCode *code) const { + Error err; + *response = + http_client__->Post(GetReceiverConfig()->authorization_server + "/authorize", "", request_string, code, + &err); + if (err || *code != HttpCode::OK) { + auto auth_error = ErrorFromAuthorizationServerResponse(std::move(err), *response, *code); + return auth_error; + } + return nullptr; +} + +Error AuthorizationClient::Authorize(const Request *request, AuthorizationData *data) const { + HttpCode code; + std::string response; + std::string request_string = GetRequestString(request, data->source_credentials); + auto err = DoServerRequest(request_string, &response, &code); + if (err != nullptr) { + return err; + } + + err = UpdateDataFromServerResponse(response, code, data); + if (err != nullptr) { + return err; + } + log__->Debug(AuthorizationLog( + request->GetOpCode() == kOpcodeAuthorize ? "authorized connection" : "reauthorized connection", request, data)); + return nullptr; +} + +AuthorizationClient::AuthorizationClient() : log__{GetDefaultReceiverLogger()}, + http_client__{DefaultHttpClient()} { +} + +} diff --git a/receiver/src/request_handler/authorization_client.h b/receiver/src/request_handler/authorization_client.h new file mode 100644 index 0000000000000000000000000000000000000000..2312a41dbbad39b757cd6b29cd0e55fd24736ab2 --- /dev/null +++ b/receiver/src/request_handler/authorization_client.h @@ -0,0 +1,28 @@ +#ifndef ASAPO_RECEIVER_SRC_REQUEST_HANDLER_AUTHORIZATION_CLIENT_H_ +#define ASAPO_RECEIVER_SRC_REQUEST_HANDLER_AUTHORIZATION_CLIENT_H_ + +#include "asapo/io/io.h" +#include "asapo/http_client/http_client.h" +#include "structs.h" +#include "asapo/preprocessor/definitions.h" + +namespace asapo { + +class Request; +class AbstractLogger; + +class AuthorizationClient { + public: + AuthorizationClient(); + VIRTUAL Error Authorize(const Request* request, AuthorizationData* data) const; + const AbstractLogger* log__; + std::unique_ptr<HttpClient> http_client__; + VIRTUAL ~AuthorizationClient() = default; + private: + Error DoServerRequest(const std::string& request_string, std::string* response, HttpCode* code) const; + +}; + +} + +#endif //ASAPO_RECEIVER_SRC_REQUEST_HANDLER_AUTHORIZATION_CLIENT_H_ diff --git a/receiver/src/file_processors/file_processor.cpp b/receiver/src/request_handler/file_processors/file_processor.cpp similarity index 94% rename from receiver/src/file_processors/file_processor.cpp rename to receiver/src/request_handler/file_processors/file_processor.cpp index 422f6dfe96937ab9e756bcc195806cdf65161ce9..52dd708c236de585ceddde0af0e17d6919425dae 100644 --- a/receiver/src/file_processors/file_processor.cpp +++ b/receiver/src/request_handler/file_processors/file_processor.cpp @@ -1,9 +1,8 @@ #include "file_processor.h" #include "asapo/io/io_factory.h" -#include "../receiver_logger.h" -#include "../receiver_config.h" -#include "../request.h" +#include "../../receiver_logger.h" +#include "../../request.h" namespace asapo { diff --git a/receiver/src/file_processors/file_processor.h b/receiver/src/request_handler/file_processors/file_processor.h similarity index 100% rename from receiver/src/file_processors/file_processor.h rename to receiver/src/request_handler/file_processors/file_processor.h diff --git a/receiver/src/file_processors/receive_file_processor.cpp b/receiver/src/request_handler/file_processors/receive_file_processor.cpp similarity index 89% rename from receiver/src/file_processors/receive_file_processor.cpp rename to receiver/src/request_handler/file_processors/receive_file_processor.cpp index 676c82a14e430c5ad02f1683d053eb48edad2828..3ff0d607e6c98e7d30d9f5dcc0e0e4cc12d0ae08 100644 --- a/receiver/src/file_processors/receive_file_processor.cpp +++ b/receiver/src/request_handler/file_processors/receive_file_processor.cpp @@ -1,10 +1,10 @@ #include "receive_file_processor.h" #include "asapo/io/io_factory.h" -#include "../receiver_error.h" #include "asapo/preprocessor/definitions.h" -#include "../request.h" -#include "../receiver_config.h" +#include "../../receiver_error.h" +#include "../../request.h" +#include "../../receiver_config.h" namespace asapo { diff --git a/receiver/src/file_processors/receive_file_processor.h b/receiver/src/request_handler/file_processors/receive_file_processor.h similarity index 100% rename from receiver/src/file_processors/receive_file_processor.h rename to receiver/src/request_handler/file_processors/receive_file_processor.h diff --git a/receiver/src/file_processors/write_file_processor.cpp b/receiver/src/request_handler/file_processors/write_file_processor.cpp similarity index 87% rename from receiver/src/file_processors/write_file_processor.cpp rename to receiver/src/request_handler/file_processors/write_file_processor.cpp index c995179237e550f6c64200884c691eb00264e7b4..3dcc5ae0076116e780f2d4ebc76e0bdaebfab68f 100644 --- a/receiver/src/file_processors/write_file_processor.cpp +++ b/receiver/src/request_handler/file_processors/write_file_processor.cpp @@ -1,10 +1,8 @@ #include "write_file_processor.h" -#include "asapo/io/io_factory.h" -#include "../receiver_error.h" #include "asapo/preprocessor/definitions.h" -#include "../request.h" -#include "../receiver_config.h" +#include "../../receiver_error.h" +#include "../../request.h" namespace asapo { diff --git a/receiver/src/file_processors/write_file_processor.h b/receiver/src/request_handler/file_processors/write_file_processor.h similarity index 100% rename from receiver/src/file_processors/write_file_processor.h rename to receiver/src/request_handler/file_processors/write_file_processor.h diff --git a/receiver/src/request_handler/request_factory.cpp b/receiver/src/request_handler/request_factory.cpp index 39a2737076ab9819947bc1ecc7afb73417d46350..e9c5fdd8d5db8d4d35e041fab1f013bae5a9c799 100644 --- a/receiver/src/request_handler/request_factory.cpp +++ b/receiver/src/request_handler/request_factory.cpp @@ -5,11 +5,11 @@ namespace asapo { bool NeedFileWriteHandler(const GenericRequestHeader& request_header) { - return request_header.custom_data[kPosIngestMode] & IngestModeFlags::kStoreInFilesystem; + return static_cast<bool>(request_header.custom_data[kPosIngestMode] & IngestModeFlags::kStoreInFilesystem); } bool NeedDbHandler(const GenericRequestHeader& request_header) { - return (request_header.custom_data[kPosIngestMode] & IngestModeFlags::kStoreInDatabase) || + return static_cast<bool>(request_header.custom_data[kPosIngestMode] & IngestModeFlags::kStoreInDatabase) || (request_header.custom_data[kPosIngestMode] == asapo::IngestModeFlags::kTransferMetaDataOnly); } @@ -48,7 +48,7 @@ Error RequestFactory::AddReceiveDirectToFileHandler(std::unique_ptr<Request>& re Error RequestFactory::AddHandlersToRequest(std::unique_ptr<Request>& request, const GenericRequestHeader& request_header) const { if (request_header.op_code != Opcode::kOpcodeAuthorize) { - request->AddHandler(&request_handler_authorize_); + request->AddHandler(&request_handler_secondary_authorize_); } switch (request_header.op_code) { @@ -76,7 +76,7 @@ Error RequestFactory::AddHandlersToRequest(std::unique_ptr<Request>& request, } case Opcode::kOpcodeAuthorize: { request->AddHandler(&request_handler_receive_metadata_); - request->AddHandler(&request_handler_authorize_); + request->AddHandler(&request_handler_initial_authorize_); break; } case Opcode::kOpcodeStreamInfo: { diff --git a/receiver/src/request_handler/request_factory.h b/receiver/src/request_handler/request_factory.h index edb2981cecda8b64743d868325ea09f774e43a19..04f871cdaa311cbf024e02122e27d3fab044c997 100644 --- a/receiver/src/request_handler/request_factory.h +++ b/receiver/src/request_handler/request_factory.h @@ -2,13 +2,23 @@ #define ASAPO_REQUEST_FACTORY_H #include "../request.h" -#include "../file_processors/write_file_processor.h" -#include "../file_processors/receive_file_processor.h" +#include "./file_processors/write_file_processor.h" +#include "./file_processors/receive_file_processor.h" #include "request_handler_db_stream_info.h" #include "request_handler_db_last_stream.h" #include "request_handler_db_delete_stream.h" #include "request_handler_db_get_meta.h" +#include "request_handler_file_process.h" +#include "request_handler_db_write.h" +#include "request_handler_initial_authorization.h" +#include "request_handler_secondary_authorization.h" +#include "request_handler_db_meta_write.h" +#include "request_handler_receive_data.h" +#include "request_handler_receive_metadata.h" +#include "request_handler_db_check_request.h" +#include "structs.h" + namespace asapo { class RequestFactory { @@ -32,9 +42,11 @@ class RequestFactory { RequestHandlerDbLastStream request_handler_db_last_stream_{kDBDataCollectionNamePrefix}; RequestHandlerDbMetaWrite request_handler_db_meta_write_{kDBMetaCollectionName}; RequestHandlerDbGetMeta request_handler_db_get_meta_{kDBMetaCollectionName}; - RequestHandlerAuthorize request_handler_authorize_; + RequestHandlerInitialAuthorization request_handler_initial_authorize_{&shared_auth_cache_}; + RequestHandlerSecondaryAuthorization request_handler_secondary_authorize_{&shared_auth_cache_}; RequestHandlerDbCheckRequest request_handler_db_check_{kDBDataCollectionNamePrefix}; SharedCache cache_; + AuthorizationData shared_auth_cache_; bool ReceiveDirectToFile(const GenericRequestHeader& request_header) const; Error AddReceiveDirectToFileHandler(std::unique_ptr<Request>& request, const GenericRequestHeader& request_header) const; diff --git a/receiver/src/request_handler/request_handler_authorize.cpp b/receiver/src/request_handler/request_handler_authorize.cpp index 0230988c1920527393d390d486fff1423d668ecf..f29681fec5f094fadd82c1394605d7d985d90933 100644 --- a/receiver/src/request_handler/request_handler_authorize.cpp +++ b/receiver/src/request_handler/request_handler_authorize.cpp @@ -1,5 +1,4 @@ #include "request_handler_authorize.h" -#include "../receiver_config.h" #include "../receiver_logger.h" #include "../request.h" @@ -10,164 +9,34 @@ using std::chrono::system_clock; namespace asapo { -std::string RequestHandlerAuthorize::GetRequestString(const Request* request, const char* source_credentials) const { - std::string request_string = std::string("{\"SourceCredentials\":\"") + - source_credentials + "\",\"OriginHost\":\"" + request->GetOriginUri() + "\"}"; - return request_string; -} - -Error RequestHandlerAuthorize::ErrorFromAuthorizationServerResponse(const Error& err, const std::string response, - HttpCode code) const { - if (err) { - return asapo::ReceiverErrorTemplates::kInternalServerError.Generate("cannot authorize request: " + err->Explain()); - } else { - if (code != HttpCode::Unauthorized) { - return asapo::ReceiverErrorTemplates::kInternalServerError.Generate(response + " return code " + std::to_string(int( - code))); - } - return asapo::ReceiverErrorTemplates::kAuthorizationFailure.Generate(response); - } -} - -Error CheckAccessType(SourceType source_type, const std::vector<std::string>& access_types) { - if(std::find(access_types.begin(), access_types.end(), - source_type == SourceType::kProcessed ? "write" : "writeraw") != access_types.end()) { - return nullptr; - } else { - return asapo::ReceiverErrorTemplates::kAuthorizationFailure.Generate("wrong access types"); - } -} - - -Error RequestHandlerAuthorize::Authorize(Request* request, const char* source_credentials) const { - HttpCode code; - Error err; - std::string request_string = GetRequestString(request, source_credentials); - auto response = http_client__->Post(GetReceiverConfig()->authorization_server + "/authorize", "", request_string, &code, - &err); - if (err || code != HttpCode::OK) { - auto auth_error = ErrorFromAuthorizationServerResponse(err, response, code); - log__->Error("failure authorizing at " + GetReceiverConfig()->authorization_server + " request: " + request_string + - " - " + - auth_error->Explain()); - return auth_error; - } - - std::string stype; - std::vector<std::string> access_types; - - JsonStringParser parser{response}; - (err = parser.GetString("beamtimeId", &beamtime_id_)) || - (err = parser.GetString("dataSource", &data_source_)) || - (err = parser.GetString("corePath", &offline_path_)) || - (err = parser.GetString("beamline-path", &online_path_)) || - (err = parser.GetString("source-type", &stype)) || - (err = parser.GetArrayString("access-types", &access_types)) || - (err = GetSourceTypeFromString(stype, &source_type_)) || - (err = parser.GetString("beamline", &beamline_)); - if (err) { - return ErrorFromAuthorizationServerResponse(err, "", code); - } - - err = CheckAccessType(source_type_, access_types); - if (err) { - log__->Error("failure authorizing at " + GetReceiverConfig()->authorization_server + " request: " + request_string + - " - " + - err->Explain()); - return err; - } - - log__->Debug(std::string("authorized connection from ") + request->GetOriginUri() + "source type: " + stype + - " beamline: " + - beamline_ + ", beamtime id: " + beamtime_id_ + ", data soucre: " + data_source_); - - last_updated_ = system_clock::now(); - cached_source_credentials_ = source_credentials; - - return nullptr; -} - -Error RequestHandlerAuthorize::CheckVersion(const std::string& version_from_client) const { +Error RequestHandlerAuthorize::CheckVersion(const Request* request) const { + auto version_from_client = request->GetApiVersion(); int verClient = VersionToNumber(version_from_client); int verService = VersionToNumber(GetReceiverApiVersion()); if (verClient > verService) { - auto err_string = "client version: " + version_from_client + ", server version: " + GetReceiverApiVersion(); - return asapo::ReceiverErrorTemplates::kUnsupportedClient.Generate(err_string); - log__->Error("failure serving client - unsupported version, " + err_string); - } - return nullptr; -} - -Error RequestHandlerAuthorize::ProcessAuthorizationRequest(Request* request) const { - if (!cached_source_credentials_.empty()) { - Error auth_error = asapo::ReceiverErrorTemplates::kAuthorizationFailure.Generate(); - auth_error->Append("already authorized"); - log__->Error("failure authorizing at " + GetReceiverConfig()->authorization_server + " - " + - "already authorized"); - return auth_error; - } - - auto err = CheckVersion(request->GetApiVersion()); - if (err) { - log__->Error("failure authorizing at client: " + err->Explain()); + auto err = asapo::ReceiverErrorTemplates::kUnsupportedClient.Generate(); + err->AddContext("client",version_from_client)->AddContext("server",GetReceiverApiVersion()); return err; } - - return Authorize(request, request->GetMetaData().c_str()); -} - -Error RequestHandlerAuthorize::ProcessReAuthorization(Request* request) const { - std::string old_beamtimeId = beamtime_id_; - auto err = Authorize(request, cached_source_credentials_.c_str()); - if (err == asapo::ReceiverErrorTemplates::kAuthorizationFailure || ( - err == nullptr && old_beamtimeId != beamtime_id_)) { - return asapo::ReceiverErrorTemplates::kReAuthorizationFailure.Generate(); - } - return err; -} - -bool RequestHandlerAuthorize::NeedReauthorize() const { - uint64_t elapsed_ms = (uint64_t) std::chrono::duration_cast<std::chrono::milliseconds> - (system_clock::now() - last_updated_).count(); - return elapsed_ms >= GetReceiverConfig()->authorization_interval_ms; -} - - -Error RequestHandlerAuthorize::ProcessOtherRequest(Request* request) const { - if (cached_source_credentials_.empty()) { - return ReceiverErrorTemplates::kAuthorizationFailure.Generate(); - } - - if (NeedReauthorize()) { - auto err = ProcessReAuthorization(request); - if (err) { - return err; - } - } - request->SetBeamtimeId(beamtime_id_); - request->SetBeamline(beamline_); - request->SetDataSource(data_source_); - request->SetOfflinePath(offline_path_); - request->SetOnlinePath(online_path_); - request->SetSourceType(source_type_); return nullptr; } - -Error RequestHandlerAuthorize::ProcessRequest(Request* request) const { - if (request->GetOpCode() == kOpcodeAuthorize) { - return ProcessAuthorizationRequest(request); - } else { - return ProcessOtherRequest(request); - } -} - -RequestHandlerAuthorize::RequestHandlerAuthorize(): log__{GetDefaultReceiverLogger()}, - http_client__{DefaultHttpClient()} { +RequestHandlerAuthorize::RequestHandlerAuthorize(AuthorizationData* authorization_cache) : log__{GetDefaultReceiverLogger()}, + auth_client__{new AuthorizationClient()}, authorization_cache_{authorization_cache} { } StatisticEntity RequestHandlerAuthorize::GetStatisticEntity() const { return StatisticEntity::kNetwork; } +void RequestHandlerAuthorize::SetRequestFields(Request* request) const { + request->SetBeamtimeId(authorization_cache_->beamtime_id); + request->SetBeamline(authorization_cache_->beamline); + request->SetDataSource(authorization_cache_->data_source); + request->SetOfflinePath(authorization_cache_->offline_path); + request->SetOnlinePath(authorization_cache_->online_path); + request->SetSourceType(authorization_cache_->source_type); +} + + } diff --git a/receiver/src/request_handler/request_handler_authorize.h b/receiver/src/request_handler/request_handler_authorize.h index adbb7b5af739d0f568791bad68139fdbaa3d2e8f..5e504fb5a11b66727c9cc2ab5b91e64f9374401c 100644 --- a/receiver/src/request_handler/request_handler_authorize.h +++ b/receiver/src/request_handler/request_handler_authorize.h @@ -6,37 +6,27 @@ #include "request_handler.h" #include "asapo/logger/logger.h" #include "asapo/http_client/http_client.h" +#include "authorization_client.h" #include "asapo/io/io.h" namespace asapo { -class RequestHandlerAuthorize final: public ReceiverRequestHandler { +class RequestHandlerAuthorize : public ReceiverRequestHandler { public: - RequestHandlerAuthorize(); + RequestHandlerAuthorize() = delete; + RequestHandlerAuthorize(AuthorizationData* authorization_cache); StatisticEntity GetStatisticEntity() const override; - Error ProcessRequest(Request* request) const override; + virtual Error ProcessRequest(Request* request) const override = 0; + virtual ~RequestHandlerAuthorize() = default; const AbstractLogger* log__; - std::unique_ptr<HttpClient>http_client__; + std::unique_ptr<AuthorizationClient> auth_client__; + protected: + AuthorizationData* authorization_cache_; + Error CheckVersion(const Request* request) const; private: - mutable std::string beamtime_id_; - mutable std::string data_source_; - mutable std::string beamline_; - mutable std::string offline_path_; - mutable std::string online_path_; - mutable SourceType source_type_; - mutable std::string cached_source_credentials_; - mutable std::chrono::system_clock::time_point last_updated_; - Error ProcessAuthorizationRequest(Request* request) const; - Error ProcessOtherRequest(Request* request) const; - Error Authorize(Request* request, const char* source_credentials) const; - Error ErrorFromAuthorizationServerResponse(const Error& err, const std::string response, HttpCode code) const; - Error ProcessReAuthorization(Request* request) const; - bool NeedReauthorize() const; - std::string GetRequestString(const Request* request, const char* source_credentials) const; - Error CheckVersion(const std::string& version_from_client) const; - + void SetRequestFields(Request* request) const; }; } diff --git a/receiver/src/request_handler/request_handler_db.cpp b/receiver/src/request_handler/request_handler_db.cpp index 60ad1eb9623789cb486915db718590c613c11c9d..fea6e82467656c132cd83a3300bb24f38f659d05 100644 --- a/receiver/src/request_handler/request_handler_db.cpp +++ b/receiver/src/request_handler/request_handler_db.cpp @@ -39,22 +39,21 @@ Error RequestHandlerDb::GetDatabaseServerUri(std::string* uri) const { Error http_err; *uri = http_client__->Get(GetReceiverConfig()->discovery_server + "/asapo-mongodb", &code, &http_err); if (http_err) { - log__->Error( - std::string{"http error when discover database server "} + " from " + GetReceiverConfig()->discovery_server - + " : " + http_err->Explain()); - return ReceiverErrorTemplates::kInternalServerError.Generate("http error when discover database server" + - http_err->Explain()); + log__->Error(LogMessageWithFields("http error while discovering database server: " + http_err->Explain()). + Append("origin", GetReceiverConfig()->discovery_server)); + auto err = ReceiverErrorTemplates::kInternalServerError.Generate("http error while discovering database server", + std::move(http_err)); + err->AddContext("discoveryEndpoint",GetReceiverConfig()->discovery_server); + return err; } if (code != HttpCode::OK) { - log__->Error( - std::string{"http error when discover database server "} + " from " + GetReceiverConfig()->discovery_server - + " : http code" + std::to_string((int) code)); - return ReceiverErrorTemplates::kInternalServerError.Generate("error when discover database server"); + auto err = ReceiverErrorTemplates::kInternalServerError.Generate("error when discover database server"); + err->AddContext("discoveryEndpoint",GetReceiverConfig()->discovery_server)->AddContext("errorCode",std::to_string((int) code)); + return err; } - log__->Debug(std::string{"found database server "} + *uri); - + log__->Debug(LogMessageWithFields("discovered database").Append("server",*uri)); return nullptr; } @@ -67,24 +66,26 @@ Error RequestHandlerDb::ConnectToDbIfNeeded() const { } err = db_client__->Connect(uri, db_name_); if (err) { - return DBErrorToReceiverError(err); + return DBErrorToReceiverError(std::move(err)); } connected_to_db = true; } return nullptr; } -Error RequestHandlerDb::DBErrorToReceiverError(const Error& err) const { +Error RequestHandlerDb::DBErrorToReceiverError(Error err) const { if (err == nullptr) { return nullptr; } - std::string msg = "database error: " + err->Explain(); + Error return_err; if (err == DBErrorTemplates::kWrongInput || err == DBErrorTemplates::kNoRecord || err == DBErrorTemplates::kJsonParseError) { - return ReceiverErrorTemplates::kBadRequest.Generate(msg); + return_err = ReceiverErrorTemplates::kBadRequest.Generate(); + } else { + return_err = ReceiverErrorTemplates::kInternalServerError.Generate(); } - - return ReceiverErrorTemplates::kInternalServerError.Generate(msg); + return_err->SetCause(std::move(err)); + return return_err; } } diff --git a/receiver/src/request_handler/request_handler_db.h b/receiver/src/request_handler/request_handler_db.h index 0c006e6e3eda365143ccae52baaa71ecca77a783..79e945323074d39552521288603b4a87abd5eb93 100644 --- a/receiver/src/request_handler/request_handler_db.h +++ b/receiver/src/request_handler/request_handler_db.h @@ -21,7 +21,7 @@ class RequestHandlerDb : public ReceiverRequestHandler { std::unique_ptr<HttpClient> http_client__; protected: Error ConnectToDbIfNeeded() const; - Error DBErrorToReceiverError(const Error& err) const; + Error DBErrorToReceiverError(Error err) const; mutable bool connected_to_db = false; mutable std::string db_name_; std::string collection_name_prefix_; diff --git a/receiver/src/request_handler/request_handler_db_check_request.cpp b/receiver/src/request_handler/request_handler_db_check_request.cpp index 3d33e1441c1eb2394ab4bcb75c1173cef5f11f0d..143221a5092e95c212968989183100dbdc80a97d 100644 --- a/receiver/src/request_handler/request_handler_db_check_request.cpp +++ b/receiver/src/request_handler/request_handler_db_check_request.cpp @@ -4,59 +4,57 @@ #include "asapo/database/db_error.h" #include "asapo/logger/logger.h" #include "request_handler_db.h" -#include "../receiver_config.h" -#include "asapo/io/io.h" +#include "../receiver_logger.h" #include "../request.h" namespace asapo { RequestHandlerDbCheckRequest::RequestHandlerDbCheckRequest(std::string collection_name_prefix) : RequestHandlerDb( - std::move( - collection_name_prefix)) { + std::move( + collection_name_prefix)) { } -Error RequestHandlerDbCheckRequest::GetRecordFromDb(const Request* request, MessageMeta* record ) const { +Error RequestHandlerDbCheckRequest::GetRecordFromDb(const Request *request, MessageMeta *record) const { auto op_code = request->GetOpCode(); auto id = request->GetDataID(); auto col_name = collection_name_prefix_ + "_" + request->GetStream(); Error err; if (op_code == Opcode::kOpcodeTransferData) { - err = db_client__->GetById(col_name, id, record); + err = db_client__->GetById(col_name, id, record); if (!err) { - log__->Debug(std::string{"get record id "} + std::to_string(id) + " from " + col_name + " in " + - db_name_ + " at " + GetReceiverConfig()->database_uri); + log__->Debug(RequestLog("read message from database", request). + Append("collection", col_name).Append("database", db_name_)); } return err; } else { auto id_in_set = request->GetCustomData()[1]; err = db_client__->GetDataSetById(col_name, id_in_set, id, record); if (!err) { - log__->Debug(std::string{"get dataset record id "} + std::to_string(id) + " from " + col_name + " in " + - db_name_ + " at " + GetReceiverConfig()->database_uri); + log__->Debug(RequestLog("read dataset from database", request). + Append("collection", col_name).Append("database", db_name_)); } return err; } } - -bool RequestHandlerDbCheckRequest::SameRequestInRecord(const Request* request, const MessageMeta& record) const { +bool RequestHandlerDbCheckRequest::SameRequestInRecord(const Request *request, const MessageMeta &record) const { std::string meta = request->GetMetaData(); - if (meta.size() == 0) { // so it is stored in database - meta = "{}"; + if (meta.size() == 0) { + meta = "{}"; // so empty meta is stored in database } return request->GetDataSize() == record.size - && request->GetFileName() == record.name - && meta == record.metadata; + && request->GetFileName() == record.name + && meta == record.metadata; } -Error RequestHandlerDbCheckRequest::ProcessRequest(Request* request) const { - if (auto err = RequestHandlerDb::ProcessRequest(request) ) { +Error RequestHandlerDbCheckRequest::ProcessRequest(Request *request) const { + if (auto err = RequestHandlerDb::ProcessRequest(request)) { return err; } MessageMeta record; - auto err = GetRecordFromDb(request, &record); + auto err = GetRecordFromDb(request, &record); if (err) { return DBErrorToReceiverError(err == DBErrorTemplates::kNoRecord ? nullptr : std::move(err)); } @@ -68,5 +66,4 @@ Error RequestHandlerDbCheckRequest::ProcessRequest(Request* request) const { } } - } diff --git a/receiver/src/request_handler/request_handler_db_delete_stream.cpp b/receiver/src/request_handler/request_handler_db_delete_stream.cpp index 8ff55033d85e767d33626914f7c667a75ca5a94a..da9595f6f94fd8410ca9bc7f715372ccb2f106e0 100644 --- a/receiver/src/request_handler/request_handler_db_delete_stream.cpp +++ b/receiver/src/request_handler/request_handler_db_delete_stream.cpp @@ -1,7 +1,8 @@ #include "request_handler_db_delete_stream.h" -#include "../receiver_config.h" #include <asapo/database/db_error.h> +#include "../receiver_logger.h" + namespace asapo { RequestHandlerDbDeleteStream::RequestHandlerDbDeleteStream(std::string collection_name_prefix) : RequestHandlerDb( @@ -19,8 +20,7 @@ Error RequestHandlerDbDeleteStream::ProcessRequest(Request* request) const { auto stream_name = request->GetStream(); if (!options.delete_meta) { - log__->Debug(std::string{"skipped deleting stream meta in "} + stream_name + " in " + - db_name_ + " at " + GetReceiverConfig()->database_uri); + log__->Debug(RequestLog("skipped deleting stream meta", request)); return nullptr; } auto err = db_client__->DeleteStream(stream_name); @@ -31,12 +31,11 @@ Error RequestHandlerDbDeleteStream::ProcessRequest(Request* request) const { } if (no_error) { - log__->Debug(std::string{"deleted stream meta in "} + stream_name + " in " + - db_name_ + " at " + GetReceiverConfig()->database_uri); + log__->Debug(RequestLog("deleted stream meta", request)); return nullptr; } - return DBErrorToReceiverError(err); + return DBErrorToReceiverError(std::move(err)); } diff --git a/receiver/src/request_handler/request_handler_db_get_meta.cpp b/receiver/src/request_handler/request_handler_db_get_meta.cpp index b046aa1195d0eb7511983370266895c56b45245c..b136731c77f82d1d3afadb1b300f1cfdb6b4d370 100644 --- a/receiver/src/request_handler/request_handler_db_get_meta.cpp +++ b/receiver/src/request_handler/request_handler_db_get_meta.cpp @@ -1,5 +1,5 @@ #include "request_handler_db_get_meta.h" -#include "../receiver_config.h" +#include "../receiver_logger.h" #include <asapo/database/db_error.h> namespace asapo { @@ -19,19 +19,13 @@ Error RequestHandlerDbGetMeta::ProcessRequest(Request* request) const { std::string meta; auto err = db_client__->GetMetaFromDb(kDBMetaCollectionName, metaid, &meta); - bool no_error = err == nullptr; - if (err == DBErrorTemplates::kNoRecord) { - no_error = true; - } - - if (no_error) { - log__->Debug(std::string{"get meta for "} + (stream_name.empty() ? "beamtime" : stream_name) + " in " + - db_name_ + " at " + GetReceiverConfig()->database_uri); + if (err == nullptr || err == DBErrorTemplates::kNoRecord) { + log__->Debug(RequestLog("retrieved meta from database", request)); request->SetResponseMessage(meta, ResponseMessageType::kInfo); return nullptr; } - return DBErrorToReceiverError(err); + return DBErrorToReceiverError(std::move(err)); } diff --git a/receiver/src/request_handler/request_handler_db_last_stream.cpp b/receiver/src/request_handler/request_handler_db_last_stream.cpp index f1c5b959494e26d3c8e1c139be7fc59d4b0d1f15..d44291c95071cc5f42f9ec03962a79b377b26f8f 100644 --- a/receiver/src/request_handler/request_handler_db_last_stream.cpp +++ b/receiver/src/request_handler/request_handler_db_last_stream.cpp @@ -1,5 +1,5 @@ #include "request_handler_db_last_stream.h" -#include "../receiver_config.h" +#include "../receiver_logger.h" namespace asapo { @@ -18,11 +18,10 @@ Error RequestHandlerDbLastStream::ProcessRequest(Request* request) const { StreamInfo info; auto err = db_client__->GetLastStream(&info); if (!err) { - log__->Debug(std::string{"get last stream "} + " in " + - db_name_ + " at " + GetReceiverConfig()->database_uri); + log__->Debug(RequestLog("get last stream from database", request)); request->SetResponseMessage(info.Json(), ResponseMessageType::kInfo); } - return DBErrorToReceiverError(err); + return DBErrorToReceiverError(std::move(err)); } } \ No newline at end of file diff --git a/receiver/src/request_handler/request_handler_db_meta_write.cpp b/receiver/src/request_handler/request_handler_db_meta_write.cpp index c1b096af12fcb93eeb2108f5b6b0a3602ef1672a..0db05803498e6664882c7a158bed9f7cc9604754 100644 --- a/receiver/src/request_handler/request_handler_db_meta_write.cpp +++ b/receiver/src/request_handler/request_handler_db_meta_write.cpp @@ -1,6 +1,5 @@ #include "request_handler_db_meta_write.h" #include "../request.h" -#include "../receiver_config.h" #include "../receiver_logger.h" #include "asapo/io/io_factory.h" #include "asapo/common/internal/version.h" @@ -30,17 +29,14 @@ Error RequestHandlerDbMetaWrite::ProcessRequest(Request* request) const { auto err = db_client__->InsertMeta(collection_name_prefix_, stream.empty() ? "bt" : "st_" + stream, meta, size, mode); if (!err) { if (stream.empty()) { - log__->Debug(std::string{"insert beamtime meta"} + " to " + collection_name_prefix_ + " in " + - db_name_ + - " at " + GetReceiverConfig()->database_uri); + log__->Debug(RequestLog("insert beamtime meta to database", request)); + } else { - log__->Debug(std::string{"insert stream meta for "} +stream + " to " + collection_name_prefix_ + " in " + - db_name_ + - " at " + GetReceiverConfig()->database_uri); + log__->Debug(RequestLog("insert stream meta to database", request)); } } - return DBErrorToReceiverError(err); + return DBErrorToReceiverError(std::move(err)); } RequestHandlerDbMetaWrite::RequestHandlerDbMetaWrite(std::string collection_name) : RequestHandlerDb(std::move( collection_name)) { diff --git a/receiver/src/request_handler/request_handler_db_stream_info.cpp b/receiver/src/request_handler/request_handler_db_stream_info.cpp index ff9a8ab935c208a986b41038a6be1ccd03e65c32..c26e1c564234f7e6cb1d8f26435c0b4bb60ac009 100644 --- a/receiver/src/request_handler/request_handler_db_stream_info.cpp +++ b/receiver/src/request_handler/request_handler_db_stream_info.cpp @@ -1,5 +1,5 @@ #include "request_handler_db_stream_info.h" -#include "../receiver_config.h" +#include "../receiver_logger.h" namespace asapo { @@ -18,12 +18,11 @@ Error RequestHandlerDbStreamInfo::ProcessRequest(Request* request) const { StreamInfo info; auto err = db_client__->GetStreamInfo(col_name, &info); if (!err) { - log__->Debug(std::string{"get stream info from "} + col_name + " in " + - db_name_ + " at " + GetReceiverConfig()->database_uri); + log__->Debug(RequestLog("get stream info from database", request)); info.name = request->GetStream(); request->SetResponseMessage(info.Json(), ResponseMessageType::kInfo); } - return DBErrorToReceiverError(err); + return DBErrorToReceiverError(std::move(err)); } } \ No newline at end of file diff --git a/receiver/src/request_handler/request_handler_db_write.cpp b/receiver/src/request_handler/request_handler_db_write.cpp index cf53fe3088798153299209f0105df9669e0c6d4f..14e348395aae1e424ff2407c92e71099a833d76a 100644 --- a/receiver/src/request_handler/request_handler_db_write.cpp +++ b/receiver/src/request_handler/request_handler_db_write.cpp @@ -2,13 +2,12 @@ #include <chrono> - -#include "../request.h" -#include "../receiver_config.h" -#include "../receiver_logger.h" #include "asapo/io/io_factory.h" #include "asapo/database/db_error.h" +#include "../request.h" +#include "../receiver_logger.h" +#include "../receiver_config.h" namespace asapo { @@ -34,7 +33,7 @@ Error RequestHandlerDbWrite::ProcessRequest(Request* request) const { if (err == DBErrorTemplates::kDuplicateID) { return ProcessDuplicateRecordSituation(request); } else { - return DBErrorToReceiverError(err); + return DBErrorToReceiverError(std::move(err)); } } @@ -43,7 +42,7 @@ Error RequestHandlerDbWrite::ProcessDuplicateRecordSituation(Request* request) c if (check_err == ReceiverErrorTemplates::kWarningDuplicatedRequest) { std::string warn_str = "ignoring duplicate record for id " + std::to_string(request->GetDataID()); request->SetResponseMessage(warn_str, ResponseMessageType::kWarning); - log__->Warning(warn_str); + log__->Warning(RequestLog("ignoring duplicate record", request)); return nullptr; } @@ -61,19 +60,14 @@ Error RequestHandlerDbWrite::InsertRecordToDb(const Request* request) const { uint64_t id_inserted{0}; err = db_client__->Insert(col_name, message_meta, false, &id_inserted); if (!err) { - log__->Debug(std::string{"insert record id "} + std::to_string(id_inserted) + " to " + col_name + " in " + - db_name_ + - " at " + GetReceiverConfig()->database_uri); + log__->Debug(RequestLog("insert record into database", request)); } } else { message_meta.dataset_substream = request->GetCustomData()[1]; auto dataset_size = request->GetCustomData()[2]; err = db_client__->InsertAsDatasetMessage(col_name, message_meta, dataset_size, false); if (!err) { - log__->Debug(std::string{"insert record to substream "} + std::to_string(message_meta.dataset_substream) + ", id: " + - std::to_string(message_meta.id) + " to " + col_name + " in " + - db_name_ + - " at " + GetReceiverConfig()->database_uri); + log__->Debug(RequestLog("insert substream record into database", request)); } } return err; diff --git a/receiver/src/request_handler/request_handler_file_process.cpp b/receiver/src/request_handler/request_handler_file_process.cpp index 8d1ecf0c91923eb6df2b75f5bc68a67553267b6c..ed1ad602030aecfe37d473f3af8088d07aa4565f 100644 --- a/receiver/src/request_handler/request_handler_file_process.cpp +++ b/receiver/src/request_handler/request_handler_file_process.cpp @@ -2,7 +2,6 @@ #include "asapo/io/io_factory.h" #include "../request.h" #include "../receiver_logger.h" -#include "../receiver_config.h" #include "asapo/preprocessor/definitions.h" namespace asapo { @@ -21,14 +20,14 @@ Error RequestHandlerFileProcess::ProcessFileExistSituation(Request* request) con auto err_duplicate = request->CheckForDuplicates(); if (err_duplicate == nullptr) { request->SetResponseMessage("file has been overwritten", ResponseMessageType::kWarning); - log__->Warning(std::string("overwriting file " ) + request->GetOfflinePath() + kPathSeparator + request->GetFileName()); + log__->Warning(RequestLog("overwritting file", request).Append("fileName",request->GetOfflinePath() + kPathSeparator + request->GetFileName())); return file_processor_->ProcessFile(request, true); } if (err_duplicate == ReceiverErrorTemplates::kWarningDuplicatedRequest) { request->SetAlreadyProcessedFlag(); request->SetResponseMessage("duplicated request, ignored", ResponseMessageType::kWarning); - log__->Warning("duplicated request, id: " + std::to_string(request->GetDataID())); + log__->Warning(RequestLog("duplicated request, ignored", request)); return nullptr; } diff --git a/receiver/src/request_handler/request_handler_file_process.h b/receiver/src/request_handler/request_handler_file_process.h index 84b26e3083a78c68716c6bdef2883fe4e09666b1..490eb18ac2dbe5b03c2929a5a9b93748a02b03b1 100644 --- a/receiver/src/request_handler/request_handler_file_process.h +++ b/receiver/src/request_handler/request_handler_file_process.h @@ -3,7 +3,7 @@ #include "request_handler.h" #include "asapo/logger/logger.h" -#include "../file_processors/file_processor.h" +#include "./file_processors/file_processor.h" #include "asapo/io/io.h" namespace asapo { diff --git a/receiver/src/request_handler/request_handler_initial_authorization.cpp b/receiver/src/request_handler/request_handler_initial_authorization.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e95c9a3718162880d11ae9ed9ec993a440bae97c --- /dev/null +++ b/receiver/src/request_handler/request_handler_initial_authorization.cpp @@ -0,0 +1,27 @@ +#include "request_handler_initial_authorization.h" + +#include "../request.h" + +namespace asapo { + +RequestHandlerInitialAuthorization::RequestHandlerInitialAuthorization(AuthorizationData* authorization_cache) + : RequestHandlerAuthorize(authorization_cache) { + +} + +Error RequestHandlerInitialAuthorization::ProcessRequest(asapo::Request* request) const { + auto err = CheckVersion(request); + if (err != nullptr) { + return err; + } + + if (!authorization_cache_->source_credentials.empty()) { + return ReceiverErrorTemplates::kAuthorizationFailure.Generate("already authorized"); + } + + authorization_cache_->source_credentials = request->GetMetaData(); + return auth_client__->Authorize(request, authorization_cache_); +} + + +} \ No newline at end of file diff --git a/receiver/src/request_handler/request_handler_initial_authorization.h b/receiver/src/request_handler/request_handler_initial_authorization.h new file mode 100644 index 0000000000000000000000000000000000000000..454a7bcaaa482e056b1d0ff1e2114e7f409bf56c --- /dev/null +++ b/receiver/src/request_handler/request_handler_initial_authorization.h @@ -0,0 +1,19 @@ +#ifndef ASAPO_RECEIVER_SRC_REQUEST_HANDLER_REQUEST_HANDLER_INITIAL_AUTHORIZATION_H_ +#define ASAPO_RECEIVER_SRC_REQUEST_HANDLER_REQUEST_HANDLER_INITIAL_AUTHORIZATION_H_ + +#include "request_handler_authorize.h" + +namespace asapo { + +class RequestHandlerInitialAuthorization final: public RequestHandlerAuthorize { + public: + RequestHandlerInitialAuthorization(AuthorizationData* authorization_cache); + Error ProcessRequest(Request* request) const override; + ~RequestHandlerInitialAuthorization() = default; +}; + +} + + + +#endif //ASAPO_RECEIVER_SRC_REQUEST_HANDLER_REQUEST_HANDLER_INITIAL_AUTHORIZATION_H_ diff --git a/receiver/src/request_handler/request_handler_receive_data.cpp b/receiver/src/request_handler/request_handler_receive_data.cpp index 4fa3141718677d34306148a4d0bd2acc771407f7..8c840c0266e684acae2eb7f3e4801c710102e44c 100644 --- a/receiver/src/request_handler/request_handler_receive_data.cpp +++ b/receiver/src/request_handler/request_handler_receive_data.cpp @@ -2,8 +2,6 @@ #include "asapo/io/io_factory.h" #include "../request.h" #include "../receiver_logger.h" -#include "../receiver_config.h" -#include "asapo/preprocessor/definitions.h" namespace asapo { diff --git a/receiver/src/request_handler/request_handler_receive_metadata.cpp b/receiver/src/request_handler/request_handler_receive_metadata.cpp index 36b723e0b0db7b03887effd4e70db927abf52fa5..71aab0b7423f5c767aa03075b2eb5e25bea1f41d 100644 --- a/receiver/src/request_handler/request_handler_receive_metadata.cpp +++ b/receiver/src/request_handler/request_handler_receive_metadata.cpp @@ -2,8 +2,6 @@ #include "asapo/io/io_factory.h" #include "../request.h" #include "../receiver_logger.h" -#include "../receiver_config.h" -#include "asapo/preprocessor/definitions.h" namespace asapo { diff --git a/receiver/src/request_handler/request_handler_secondary_authorization.cpp b/receiver/src/request_handler/request_handler_secondary_authorization.cpp new file mode 100644 index 0000000000000000000000000000000000000000..55ded2f08531dfb3e2d3f05f322e016175f2f24e --- /dev/null +++ b/receiver/src/request_handler/request_handler_secondary_authorization.cpp @@ -0,0 +1,84 @@ +#include "request_handler_secondary_authorization.h" + +#include "request_handler_authorize.h" +#include "../receiver_config.h" +#include "../receiver_logger.h" +#include "../request.h" + +#include "asapo/json_parser/json_parser.h" +#include "asapo/common/internal/version.h" + +using std::chrono::system_clock; + +namespace asapo { + +Error RequestHandlerSecondaryAuthorization::ProcessReAuthorization(const Request* request) const { + std::string old_beamtimeId = authorization_cache_->beamtime_id; + auto err = auth_client__->Authorize(request, authorization_cache_); + if (err == asapo::ReceiverErrorTemplates::kAuthorizationFailure || ( + err == nullptr && old_beamtimeId != authorization_cache_->beamtime_id)) { + InvalidateAuthCache(); + return asapo::ReceiverErrorTemplates::kReAuthorizationFailure.Generate(); + } + return err; +} + +bool RequestHandlerSecondaryAuthorization::NeedReauthorize() const { + uint64_t elapsed_ms = (uint64_t) std::chrono::duration_cast<std::chrono::milliseconds> + (system_clock::now() - authorization_cache_->last_update).count(); + return elapsed_ms >= GetReceiverConfig()->authorization_interval_ms; +} + +void RequestHandlerSecondaryAuthorization::SetRequestFields(Request* request) const { + request->SetBeamtimeId(authorization_cache_->beamtime_id); + request->SetBeamline(authorization_cache_->beamline); + request->SetDataSource(authorization_cache_->data_source); + request->SetOfflinePath(authorization_cache_->offline_path); + request->SetOnlinePath(authorization_cache_->online_path); + request->SetSourceType(authorization_cache_->source_type); +} + +RequestHandlerSecondaryAuthorization::RequestHandlerSecondaryAuthorization(AuthorizationData* authorization_cache) + : RequestHandlerAuthorize(authorization_cache) { + +} + +Error RequestHandlerSecondaryAuthorization::CheckRequest(const Request* request) const { + auto err = CheckVersion(request); + if (err != nullptr) { + return err; + } + + if (authorization_cache_->source_credentials.empty()) { + return ReceiverErrorTemplates::kAuthorizationFailure.Generate("not authorized"); + } + return nullptr; +} + +Error RequestHandlerSecondaryAuthorization::ProcessRequest(asapo::Request* request) const { + auto err = CheckRequest(request); + if (err != nullptr) { + return err; + } + + err = ReauthorizeIfNeeded(request); + if (err != nullptr) { + return err; + } + + SetRequestFields(request); + return nullptr; +} + +Error RequestHandlerSecondaryAuthorization::ReauthorizeIfNeeded(const Request* request) const { + if (!NeedReauthorize()) { + return nullptr; + } + return ProcessReAuthorization(request); +} + +void RequestHandlerSecondaryAuthorization::InvalidateAuthCache() const { + authorization_cache_->source_credentials = ""; +} + +} diff --git a/receiver/src/request_handler/request_handler_secondary_authorization.h b/receiver/src/request_handler/request_handler_secondary_authorization.h new file mode 100644 index 0000000000000000000000000000000000000000..9d568cf16406d1244e15d4a7f2e928ae3702590e --- /dev/null +++ b/receiver/src/request_handler/request_handler_secondary_authorization.h @@ -0,0 +1,34 @@ +#ifndef ASAPO_RECEIVER_SRC_REQUEST_HANDLER_REQUEST_HANDLER_SECONDARY_AUTHORIZATION_H_ +#define ASAPO_RECEIVER_SRC_REQUEST_HANDLER_REQUEST_HANDLER_SECONDARY_AUTHORIZATION_H_ + +#include <chrono> + +#include "request_handler.h" +#include "asapo/logger/logger.h" +#include "asapo/http_client/http_client.h" +#include "authorization_client.h" +#include "request_handler_authorize.h" + +#include "asapo/io/io.h" + +namespace asapo { + +class RequestHandlerSecondaryAuthorization final: public RequestHandlerAuthorize { + public: + RequestHandlerSecondaryAuthorization() = delete; + RequestHandlerSecondaryAuthorization(AuthorizationData* authorization_cache); + virtual Error ProcessRequest(Request* request) const override; + ~RequestHandlerSecondaryAuthorization() = default; + private: + bool NeedReauthorize() const; + void SetRequestFields(Request* request) const; + Error ProcessReAuthorization(const Request* request) const; + Error CheckRequest(const Request* request) const; + Error ReauthorizeIfNeeded(const Request* request) const; + void InvalidateAuthCache() const; + +}; + +} + +#endif //ASAPO_RECEIVER_SRC_REQUEST_HANDLER_REQUEST_HANDLER_SECONDARY_AUTHORIZATION_H_ diff --git a/receiver/src/request_handler/requests_dispatcher.cpp b/receiver/src/request_handler/requests_dispatcher.cpp index ad009aba5addd6dbc66bec875df4900554c3905f..e222465641aaaeb919976ed713d9ef316214cb40 100644 --- a/receiver/src/request_handler/requests_dispatcher.cpp +++ b/receiver/src/request_handler/requests_dispatcher.cpp @@ -1,5 +1,4 @@ #include "requests_dispatcher.h" -#include "../request.h" #include "asapo/io/io_factory.h" #include "../receiver_logger.h" #include "asapo/database/db_error.h" @@ -8,10 +7,14 @@ namespace asapo { RequestsDispatcher::RequestsDispatcher(SocketDescriptor socket_fd, std::string address, ReceiverStatistics* statistics, SharedCache cache) : statistics__{statistics}, io__{GenerateDefaultIO()}, - log__{GetDefaultReceiverLogger()}, - request_factory__{new RequestFactory{cache}}, - socket_fd_{socket_fd}, -producer_uri_{std::move(address)} { + log__{ + GetDefaultReceiverLogger()}, +request_factory__{ + new RequestFactory{ + cache}}, +socket_fd_{socket_fd}, +producer_uri_{ + std::move(address)} { } NetworkErrorCode GetNetworkCodeFromError(const Error& err) { @@ -50,55 +53,58 @@ GenericNetworkResponse RequestsDispatcher::CreateResponseToRequest(const std::un } Error RequestsDispatcher::HandleRequest(const std::unique_ptr<Request>& request) const { - log__->Debug("processing request id " + std::to_string(request->GetDataID()) + ", opcode " + - std::to_string(request->GetOpCode()) + " from " + producer_uri_ ); + log__->Debug(RequestLog("got new request", request.get())); Error handle_err; handle_err = request->Handle(statistics__); if (handle_err) { if (handle_err == ReceiverErrorTemplates::kReAuthorizationFailure) { - log__->Warning("warning processing request from " + producer_uri_ + " - " + handle_err->Explain()); + log__->Warning(LogMessageWithFields(handle_err).Append(RequestLog("", request.get()))); } else { - log__->Error("error processing request from " + producer_uri_ + " - " + handle_err->Explain()); + log__->Error(LogMessageWithFields(handle_err).Append(RequestLog("", request.get()))); } } return handle_err; } Error RequestsDispatcher::SendResponse(const std::unique_ptr<Request>& request, const Error& handle_error) const { - log__->Debug("sending response to " + producer_uri_ ); Error io_err; GenericNetworkResponse generic_response = CreateResponseToRequest(request, handle_error); + auto log = RequestLog("sending response", request.get()). + Append("response", NetworkErrorCodeToString(generic_response.error_code)); + log__->Debug(log); io__->Send(socket_fd_, &generic_response, sizeof(GenericNetworkResponse), &io_err); if (io_err) { - log__->Error("error sending response to " + producer_uri_ + " - " + io_err->Explain()); + auto err = ReceiverErrorTemplates::kProcessingError.Generate("cannot send response",std::move(io_err)); + log__->Error(LogMessageWithFields(err).Append(RequestLog("", request.get()))); + return err; } - return io_err; + return nullptr; } Error RequestsDispatcher::ProcessRequest(const std::unique_ptr<Request>& request) const noexcept { - auto handle_err = HandleRequest(request); - auto io_err = SendResponse(request, handle_err); - return handle_err == nullptr ? std::move(io_err) : std::move(handle_err); + auto handle_err = HandleRequest(request); + auto send_err = SendResponse(request, handle_err); + return handle_err == nullptr ? std::move(send_err) : std::move(handle_err); } std::unique_ptr<Request> RequestsDispatcher::GetNextRequest(Error* err) const noexcept { //TODO: to be overwritten with MessagePack (or similar) GenericRequestHeader generic_request_header; - statistics__-> StartTimer(StatisticEntity::kNetwork); - io__-> Receive(socket_fd_, &generic_request_header, - sizeof(GenericRequestHeader), err); - if(*err) { - if (*err == ErrorTemplates::kEndOfFile) { - log__->Debug("error getting next request from " + producer_uri_ + " - " + "peer has performed an orderly shutdown"); - } else { - log__->Error("error getting next request from " + producer_uri_ + " - " + (*err)->Explain()); + statistics__->StartTimer(StatisticEntity::kNetwork); + Error io_err; + io__->Receive(socket_fd_, &generic_request_header, + sizeof(GenericRequestHeader), &io_err); + if (io_err) { + *err = ReceiverErrorTemplates::kProcessingError.Generate("cannot get next request",std::move(io_err)); + if ((*err)->GetCause() != GeneralErrorTemplates::kEndOfFile) { + log__->Error(LogMessageWithFields(*err).Append("origin", HostFromUri(producer_uri_))); } return nullptr; } - statistics__-> StopTimer(); + statistics__->StopTimer(); auto request = request_factory__->GenerateRequest(generic_request_header, socket_fd_, producer_uri_, err); if (*err) { - log__->Error("error processing request from " + producer_uri_ + " - " + (*err)->Explain()); + log__->Error(LogMessageWithFields(*err).Append("origin", HostFromUri(producer_uri_))); } return request; } diff --git a/receiver/src/request_handler/structs.h b/receiver/src/request_handler/structs.h new file mode 100644 index 0000000000000000000000000000000000000000..80bd533af2f92a04247d4c63d0d41851f5ad2235 --- /dev/null +++ b/receiver/src/request_handler/structs.h @@ -0,0 +1,23 @@ +#ifndef ASAPO_RECEIVER_SRC_REQUEST_HANDLER_STRUCTS_H_ +#define ASAPO_RECEIVER_SRC_REQUEST_HANDLER_STRUCTS_H_ + +#include <chrono> + +#include "asapo/common/data_structs.h" + +namespace asapo { + +struct AuthorizationData { + std::string beamtime_id; + std::string data_source; + std::string beamline; + std::string offline_path; + std::string online_path; + SourceType source_type; + std::chrono::system_clock::time_point last_update; + std::string source_credentials; +}; + +} + +#endif //ASAPO_RECEIVER_SRC_REQUEST_HANDLER_STRUCTS_H_ diff --git a/receiver/src/statistics/receiver_statistics.cpp b/receiver/src/statistics/receiver_statistics.cpp index 1f54884d85bd6e6c7cbf8b35926a757d07715cf3..59e467517d9e12ccf3d23ee30ed48b749b602c9a 100644 --- a/receiver/src/statistics/receiver_statistics.cpp +++ b/receiver/src/statistics/receiver_statistics.cpp @@ -7,7 +7,9 @@ using std::chrono::system_clock; ReceiverStatistics::ReceiverStatistics(unsigned int write_interval) : Statistics(write_interval) { - ResetStatistics(); + for (size_t i = 0; i < kNStatisticEntities; i++) { + time_counters_[i] = std::chrono::nanoseconds{0}; + } } StatisticsToSend ReceiverStatistics::PrepareStatisticsToSend() const noexcept { diff --git a/receiver/src/statistics/statistics.cpp b/receiver/src/statistics/statistics.cpp index f16c144364efaf91452e6150489b071c46837e44..14f710233ef4a3a0ab5e2ce106af4984217b1d1a 100644 --- a/receiver/src/statistics/statistics.cpp +++ b/receiver/src/statistics/statistics.cpp @@ -1,6 +1,5 @@ #include "statistics.h" #include "statistics_sender_influx_db.h" -#include "statistics_sender_fluentd.h" #include "../receiver_config.h" #include <algorithm> @@ -59,8 +58,6 @@ void Statistics::IncreaseRequestCounter() noexcept { Statistics::Statistics(unsigned int write_frequency) : write_interval_{write_frequency} { statistics_sender_list__.emplace_back(std::unique_ptr<StatisticsSender> {new StatisticsSenderInfluxDb}); -// statistics_sender_list__.emplace_back(new StatisticsSenderFluentd); - ResetStatistics(); } diff --git a/receiver/src/statistics/statistics.h b/receiver/src/statistics/statistics.h index 73e191954655664b8301d7f508815298007c1dfb..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; @@ -41,9 +41,9 @@ class Statistics { private: void Send() noexcept; uint64_t GetTotalElapsedMs() const noexcept; - uint64_t nrequests_; - std::chrono::system_clock::time_point last_timepoint_; - uint64_t volume_counter_; + uint64_t nrequests_{0}; + std::chrono::system_clock::time_point last_timepoint_{std::chrono::system_clock::now()}; + uint64_t volume_counter_{0}; unsigned int write_interval_; std::vector<std::pair<std::string, std::string>> tags_; std::mutex mutex_; 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/receiver_data_server/net_server/test_rds_fabric_server.cpp b/receiver/unittests/receiver_data_server/net_server/test_rds_fabric_server.cpp index d185a4f7abcf9793d03339ae0830edd5406806ad..6b7dd8c873ac13a9dd1823be465a13efa0b3874f 100644 --- a/receiver/unittests/receiver_data_server/net_server/test_rds_fabric_server.cpp +++ b/receiver/unittests/receiver_data_server/net_server/test_rds_fabric_server.cpp @@ -207,7 +207,6 @@ TEST_F(RdsFabricServerTests, SendResponse_Error_SendError) { TEST_F(RdsFabricServerTests, SendResponseAndSlotData_Ok) { InitServer(); - GenericRequestHeader dummyHeader{}; FabricRdsRequest request(GenericRequestHeader{}, 41, 87); GenericNetworkResponse response; CacheMeta cacheSlot; @@ -225,7 +224,6 @@ TEST_F(RdsFabricServerTests, SendResponseAndSlotData_Ok) { TEST_F(RdsFabricServerTests, SendResponseAndSlotData_RdmaWrite_Error) { InitServer(); - GenericRequestHeader dummyHeader{}; FabricRdsRequest request(GenericRequestHeader{}, 41, 87); GenericNetworkResponse response; CacheMeta cacheSlot; @@ -244,7 +242,6 @@ TEST_F(RdsFabricServerTests, SendResponseAndSlotData_RdmaWrite_Error) { TEST_F(RdsFabricServerTests, SendResponseAndSlotData_Send_Error) { InitServer(); - GenericRequestHeader dummyHeader{}; FabricRdsRequest request(GenericRequestHeader{}, 41, 87); GenericNetworkResponse response; CacheMeta cacheSlot; diff --git a/receiver/unittests/receiver_data_server/net_server/test_rds_tcp_server.cpp b/receiver/unittests/receiver_data_server/net_server/test_rds_tcp_server.cpp index 83d2d8572b4ac878c505e2cc15a51534910d1c32..22a0aae334f80e050b2d7470f614f2ee59276daa 100644 --- a/receiver/unittests/receiver_data_server/net_server/test_rds_tcp_server.cpp +++ b/receiver/unittests/receiver_data_server/net_server/test_rds_tcp_server.cpp @@ -137,7 +137,7 @@ void RdsTCPServerTests::ExpectReceiveRequestEof() { for (auto conn : expected_client_sockets) { EXPECT_CALL(mock_io, Receive_t(conn, _, _, _)) .WillOnce( - DoAll(SetArgPointee<3>(asapo::ErrorTemplates::kEndOfFile.Generate().release()), + DoAll(SetArgPointee<3>(asapo::GeneralErrorTemplates::kEndOfFile.Generate().release()), Return(0)) ); EXPECT_CALL(mock_io, CloseSocket_t(conn, _)); diff --git a/receiver/unittests/receiver_mocking.h b/receiver/unittests/receiver_mocking.h index 74894756165b86e11e83b226cd020bce958752ff..eb587199f7ba24f3e85143431d98df407b147ce6 100644 --- a/receiver/unittests/receiver_mocking.h +++ b/receiver/unittests/receiver_mocking.h @@ -7,7 +7,9 @@ #include "../src/statistics/receiver_statistics.h" #include "../src/request.h" #include "../src/data_cache.h" -#include "../src/file_processors/file_processor.h" +#include "../src/request_handler/file_processors/file_processor.h" +#include "../src/request_handler/request_handler_db_check_request.h" +#include "../src/request_handler/authorization_client.h" namespace asapo { @@ -31,13 +33,11 @@ class MockStatistics : public asapo::ReceiverStatistics { StopTimer_t(); } - MOCK_METHOD1(SendIfNeeded_t, void(bool send_always)); - MOCK_METHOD0(IncreaseRequestCounter_t, void()); - MOCK_METHOD0(StopTimer_t, void()); - MOCK_METHOD1(IncreaseRequestDataVolume_t, void (uint64_t - transferred_data_volume)); - MOCK_METHOD1(StartTimer_t, void( - const asapo::StatisticEntity& entity)); + MOCK_METHOD(void, SendIfNeeded_t, (bool send_always), ()); + MOCK_METHOD(void, IncreaseRequestCounter_t, (), ()); + MOCK_METHOD(void, StopTimer_t, (), ()); + MOCK_METHOD(void, IncreaseRequestDataVolume_t, (uint64_t transferred_data_volume), ()); + MOCK_METHOD(void, StartTimer_t, (const asapo::StatisticEntity& entity), ()); }; @@ -53,7 +53,7 @@ class MockHandlerDbCheckRequest : public asapo::RequestHandlerDbCheckRequest { return StatisticEntity::kDatabase; } - MOCK_CONST_METHOD1(ProcessRequest_t, ErrorInterface * (const Request& request)); + MOCK_METHOD(ErrorInterface *, ProcessRequest_t, (const Request& request), (const)); }; @@ -64,43 +64,47 @@ class MockRequest: public Request { const RequestHandlerDbCheckRequest* db_check_handler ): Request(request_header, socket_fd, std::move(origin_uri), nullptr, db_check_handler) {}; - MOCK_CONST_METHOD0(GetFileName, std::string()); - MOCK_CONST_METHOD0(GetStream, std::string()); - MOCK_CONST_METHOD0(GetApiVersion, std::string()); - MOCK_CONST_METHOD0(GetDataSize, uint64_t()); - MOCK_CONST_METHOD0(GetDataID, uint64_t()); - MOCK_CONST_METHOD0(GetSlotId, uint64_t()); - MOCK_CONST_METHOD0(GetData, void* ()); - MOCK_CONST_METHOD0(GetBeamtimeId, const std::string & ()); - MOCK_CONST_METHOD0(GetDataSource, const std::string & ()); - MOCK_CONST_METHOD0(GetMetaData, const std::string & ()); - MOCK_CONST_METHOD0(GetBeamline, const std::string & ()); - MOCK_CONST_METHOD0(GetOpCode, asapo::Opcode ()); - MOCK_CONST_METHOD0(GetSocket, asapo::SocketDescriptor ()); - - MOCK_CONST_METHOD0(GetOnlinePath, const std::string & ()); - MOCK_CONST_METHOD0(GetOfflinePath, const std::string & ()); - +// MOCK_METHOD(, ), (const,override), (override)); + MOCK_METHOD(std::string, GetFileName, (), (const, override)); + MOCK_METHOD(std::string, GetStream, (), (const, override)); + MOCK_METHOD(std::string, GetApiVersion, (), (const, override)); + MOCK_METHOD(const std::string &, GetOriginUri, (), (const, override)); + MOCK_METHOD(const std::string &, GetOriginHost, (), (const, override)); + MOCK_METHOD(uint64_t, GetDataSize, (), (const, override)); + MOCK_METHOD(uint64_t, GetDataID, (), (const, override)); + MOCK_METHOD(uint64_t, GetSlotId, (), (const, override)); + MOCK_METHOD(void*, GetData, (), (const, override)); + MOCK_METHOD(const std::string &, GetBeamtimeId, (), (const, override)); + MOCK_METHOD(const std::string &, GetDataSource, (), (const, override)); + MOCK_METHOD(const std::string &, GetMetaData, (), (const, override)); + MOCK_METHOD(const std::string &, GetBeamline, (), (const, override)); + MOCK_METHOD(asapo::Opcode, GetOpCode, (), (const, override)); + MOCK_METHOD(asapo::SocketDescriptor, GetSocket, (), (const, override)); + + MOCK_METHOD(const std::string &, GetOnlinePath, (), (const, override)); + MOCK_METHOD(const std::string &, GetOfflinePath, (), (const, override)); + + // not nice casting, but mocking GetCustomData directly does not compile on Windows. const CustomRequestData& GetCustomData() const override { return (CustomRequestData&) * GetCustomData_t(); }; - MOCK_CONST_METHOD0(GetCustomData_t, const uint64_t* ()); - MOCK_CONST_METHOD0(GetMessage, const char* ()); - MOCK_METHOD1(SetBeamtimeId, void (std::string)); - MOCK_METHOD1(SetDataSource, void (std::string)); - MOCK_METHOD1(SetBeamline, void (std::string)); - MOCK_METHOD1(SetOnlinePath, void (std::string)); - MOCK_METHOD1(SetOfflinePath, void (std::string)); + MOCK_METHOD(const uint64_t*, GetCustomData_t, (), (const)); + MOCK_METHOD(const char*, GetMessage, (), (const)); //override does not compile on windows, not clear why () + MOCK_METHOD(void, SetBeamtimeId, (std::string), (override)); + MOCK_METHOD(void, SetDataSource, (std::string), (override)); + MOCK_METHOD(void, SetBeamline, (std::string), (override)); + MOCK_METHOD(void, SetOnlinePath, (std::string), (override)); + MOCK_METHOD(void, SetOfflinePath, (std::string), (override)); - MOCK_METHOD1(SetSourceType, void (SourceType)); - MOCK_CONST_METHOD0(GetSourceType, SourceType ()); + MOCK_METHOD(void, SetSourceType, (SourceType), (override)); + MOCK_METHOD(SourceType, GetSourceType, (), (const, override)); - MOCK_CONST_METHOD0(WasAlreadyProcessed, bool()); - MOCK_METHOD0(SetAlreadyProcessedFlag, void()); - MOCK_METHOD2(SetResponseMessage, void(std::string, ResponseMessageType)); - MOCK_CONST_METHOD0(GetResponseMessage, const std::string & ()); - MOCK_CONST_METHOD0(GetResponseMessageType_t, ResponseMessageType ()); + MOCK_METHOD(bool, WasAlreadyProcessed, (), (const, override)); + MOCK_METHOD(void, SetAlreadyProcessedFlag, (), (override)); + MOCK_METHOD(void, SetResponseMessage, (std::string, ResponseMessageType), (override)); + MOCK_METHOD(const std::string &, GetResponseMessage, (), (const, override)); + MOCK_METHOD(ResponseMessageType, GetResponseMessageType_t, (), (const)); ResponseMessageType GetResponseMessageType() const override { return GetResponseMessageType_t(); @@ -110,18 +114,16 @@ class MockRequest: public Request { return Error{CheckForDuplicates_t()}; } - MOCK_METHOD0(CheckForDuplicates_t, ErrorInterface * ()); + MOCK_METHOD(ErrorInterface *, CheckForDuplicates_t, (), ()); }; class MockDataCache: public DataCache { public: MockDataCache(): DataCache(0, 0) {}; - MOCK_METHOD2(GetFreeSlotAndLock, void* (uint64_t - size, CacheMeta** meta)); - MOCK_METHOD1(UnlockSlot, bool(CacheMeta* meta)); - MOCK_METHOD3(GetSlotToReadAndLock, void* (uint64_t - id, uint64_t data_size, CacheMeta** meta)); + MOCK_METHOD(void*, GetFreeSlotAndLock, (uint64_t size, CacheMeta** meta), (override)); + MOCK_METHOD(bool, UnlockSlot, (CacheMeta* meta), (override)); + MOCK_METHOD(void*, GetSlotToReadAndLock, (uint64_t id, uint64_t data_size, CacheMeta** meta), (override)); }; @@ -131,7 +133,7 @@ class MockStatisticsSender: public StatisticsSender { void SendStatistics(const StatisticsToSend& statistics) const noexcept override { SendStatistics_t(statistics); } - MOCK_CONST_METHOD1(SendStatistics_t, void (const StatisticsToSend&)); + MOCK_METHOD(void, SendStatistics_t, (const StatisticsToSend&), (const)); }; @@ -141,9 +143,30 @@ class MockFileProcessor: public FileProcessor { return Error{ProcessFile_t(request, overwrite)}; } - MOCK_CONST_METHOD2(ProcessFile_t, ErrorInterface * (const Request*, bool)); + MOCK_METHOD(ErrorInterface *, ProcessFile_t, (const Request*, bool), (const)); +}; + + +class MockAuthorizationClient: public AuthorizationClient { + public: + Error Authorize(const Request* request, AuthorizationData* data) const override { + return Error{Authorize_t(request, data)}; + } + MOCK_METHOD(ErrorInterface *, Authorize_t, (const Request*, AuthorizationData*), (const)); }; +inline void SetDefaultRequestCalls(MockRequest* mock_request,const std::string& bt) { + ON_CALL(*mock_request, GetBeamtimeId()).WillByDefault(::testing::ReturnRefOfCopy(bt)); + ON_CALL(*mock_request, GetBeamline()).WillByDefault(::testing::ReturnRefOfCopy(std::string(""))); + ON_CALL(*mock_request, GetDataSource()).WillByDefault(::testing::ReturnRefOfCopy(std::string(""))); + ON_CALL(*mock_request, GetStream()).WillByDefault(::testing::Return(std::string(""))); + ON_CALL(*mock_request, GetOriginHost()).WillByDefault(::testing::ReturnRefOfCopy(std::string(""))); + ON_CALL(*mock_request, GetOpCode()).WillByDefault(::testing::Return(Opcode::kOpcodeTransferData)); +} + + + + } #endif //ASAPO_RECEIVER_MOCKING_H diff --git a/receiver/unittests/file_processors/test_file_processor.cpp b/receiver/unittests/request_handler/file_processors/test_file_processor.cpp similarity index 95% rename from receiver/unittests/file_processors/test_file_processor.cpp rename to receiver/unittests/request_handler/file_processors/test_file_processor.cpp index 992d9dd5d7e7fe1ca756730a5ff15c862be75b69..5f2ac6d6acea527875fdebbfa45b8cd0e166d0c9 100644 --- a/receiver/unittests/file_processors/test_file_processor.cpp +++ b/receiver/unittests/request_handler/file_processors/test_file_processor.cpp @@ -4,12 +4,12 @@ #include "asapo/unittests/MockIO.h" #include "asapo/unittests/MockLogger.h" -#include "../../src/file_processors/receive_file_processor.h" +#include "../../../src/request_handler/file_processors/receive_file_processor.h" #include "asapo/common/networking.h" #include "asapo/preprocessor/definitions.h" -#include "../mock_receiver_config.h" +#include "../../mock_receiver_config.h" -#include "../receiver_mocking.h" +#include "../../receiver_mocking.h" using ::testing::Test; using ::testing::Return; diff --git a/receiver/unittests/file_processors/test_receive_file_processor.cpp b/receiver/unittests/request_handler/file_processors/test_receive_file_processor.cpp similarity index 93% rename from receiver/unittests/file_processors/test_receive_file_processor.cpp rename to receiver/unittests/request_handler/file_processors/test_receive_file_processor.cpp index 66c7eec1bdc12fd1fe23f6a607b3f5f4279e7c3f..4a129be53629b96b613fbd73079116bc14fd2ffe 100644 --- a/receiver/unittests/file_processors/test_receive_file_processor.cpp +++ b/receiver/unittests/request_handler/file_processors/test_receive_file_processor.cpp @@ -4,12 +4,12 @@ #include "asapo/unittests/MockIO.h" #include "asapo/unittests/MockLogger.h" -#include "../../src/file_processors/receive_file_processor.h" +#include "../../../src/request_handler/file_processors/receive_file_processor.h" #include "asapo/common/networking.h" #include "asapo/preprocessor/definitions.h" -#include "../mock_receiver_config.h" +#include "../../mock_receiver_config.h" -#include "../receiver_mocking.h" +#include "../../receiver_mocking.h" using ::testing::Test; using ::testing::Return; @@ -69,7 +69,7 @@ class ReceiveFileProcessorTests : public Test { asapo::kPathSeparator + expected_year + asapo::kPathSeparator + "data" + asapo::kPathSeparator + expected_beamtime_id; - void ExpectFileWrite(const asapo::SimpleErrorTemplate* error_template); + void ExpectFileWrite(const asapo::ErrorTemplateInterface* error_template); void MockRequestData(); void SetUp() override { GenericRequestHeader request_header; @@ -106,7 +106,7 @@ void ReceiveFileProcessorTests::MockRequestData() { .WillRepeatedly(Return(expected_file_name)); } -void ReceiveFileProcessorTests::ExpectFileWrite(const asapo::SimpleErrorTemplate* error_template) { +void ReceiveFileProcessorTests::ExpectFileWrite(const asapo::ErrorTemplateInterface* error_template) { EXPECT_CALL(mock_io, WriteDataToFile_t(expected_full_path, expected_file_name, _, expected_file_size, true, expected_overwrite)) .WillOnce( diff --git a/receiver/unittests/file_processors/test_write_file_processor.cpp b/receiver/unittests/request_handler/file_processors/test_write_file_processor.cpp similarity index 93% rename from receiver/unittests/file_processors/test_write_file_processor.cpp rename to receiver/unittests/request_handler/file_processors/test_write_file_processor.cpp index a4df078b7872ba9d347c84d4e0455ca10f71a3f8..02967f907b9120dfc063ce19ae0491ac585220b9 100644 --- a/receiver/unittests/file_processors/test_write_file_processor.cpp +++ b/receiver/unittests/request_handler/file_processors/test_write_file_processor.cpp @@ -4,12 +4,12 @@ #include "asapo/unittests/MockIO.h" #include "asapo/unittests/MockLogger.h" -#include "../../src/file_processors/write_file_processor.h" +#include "../../../src/request_handler/file_processors/write_file_processor.h" #include "asapo/common/networking.h" #include "asapo/preprocessor/definitions.h" -#include "../mock_receiver_config.h" +#include "../../mock_receiver_config.h" -#include "../receiver_mocking.h" +#include "../../receiver_mocking.h" using ::testing::Test; using ::testing::Return; @@ -68,7 +68,7 @@ class WriteFileProcessorTests : public Test { asapo::kPathSeparator + expected_year + asapo::kPathSeparator + "data" + asapo::kPathSeparator + expected_beamtime_id; - void ExpectFileWrite(const asapo::SimpleErrorTemplate* error_template); + void ExpectFileWrite(const asapo::ErrorTemplateInterface* error_template); void MockRequestData(int times = 1); void SetUp() override { GenericRequestHeader request_header; @@ -112,7 +112,7 @@ void WriteFileProcessorTests::MockRequestData(int times) { .WillRepeatedly(Return(expected_file_name)); } -void WriteFileProcessorTests::ExpectFileWrite(const asapo::SimpleErrorTemplate* error_template) { +void WriteFileProcessorTests::ExpectFileWrite(const asapo::ErrorTemplateInterface* error_template) { EXPECT_CALL(mock_io, WriteDataToFile_t(expected_full_path, expected_file_name, _, expected_file_size, true, expected_overwrite)) .WillOnce( diff --git a/receiver/unittests/request_handler/test_authorization_client.cpp b/receiver/unittests/request_handler/test_authorization_client.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1bff5c3fc5aff1e4f1510c8fec6629af16f89b44 --- /dev/null +++ b/receiver/unittests/request_handler/test_authorization_client.cpp @@ -0,0 +1,180 @@ +#include <gtest/gtest.h> +#include <gmock/gmock.h> + +#include "asapo/unittests/MockHttpClient.h" +#include "asapo/unittests/MockLogger.h" + +#include "../../src/receiver_error.h" +#include "asapo/common/networking.h" +#include "../mock_receiver_config.h" +#include "asapo/preprocessor/definitions.h" + +#include "../receiver_mocking.h" + +#include "../../src/receiver_config.h" +#include "../../src/request_handler/authorization_client.h" +#include "../../src/receiver_logger.h" + + +using namespace testing; +using namespace asapo; + + +namespace { + +TEST(Authorizer, Constructor) { + AuthorizationClient client; + ASSERT_THAT(dynamic_cast<const asapo::AbstractLogger*>(client.log__), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<asapo::HttpClient*>(client.http_client__.get()), Ne(nullptr)); +} + + +class AuthorizerClientTests : public Test { + public: + AuthorizationClient client; + AuthorizationData expected_auth_data; + MockHttpClient mock_http_client; + std::unique_ptr<NiceMock<MockRequest>> mock_request; + ReceiverConfig config; + + NiceMock<asapo::MockLogger> mock_logger; + std::string expected_beamtime_id = "beamtime_id"; + std::string expected_data_source = "source"; + std::string expected_beamline = "beamline"; + std::string expected_beamline_path = "/beamline/p01/current"; + std::string expected_core_path = "/gpfs/blabla"; + std::string expected_producer_uri = "producer_uri"; + std::string expected_authorization_server = "authorizer_host"; + std::string expect_request_string; + std::string expected_source_credentials; + asapo::SourceType expected_source_type = asapo::SourceType::kProcessed; + + std::string expected_source_type_str = "processed"; + std::string expected_access_type_str = "[\"write\"]"; + void SetUp() override { + GenericRequestHeader request_header; + expected_source_credentials = "processed%" + expected_beamtime_id + "%source%token"; + expected_auth_data.source_credentials = expected_source_credentials; + expect_request_string = std::string("{\"SourceCredentials\":\"") + expected_source_credentials + + "\",\"OriginHost\":\"" + + expected_producer_uri + "\"}"; + + mock_request.reset(new NiceMock<MockRequest>{request_header, 1, expected_producer_uri, nullptr}); + client.http_client__ = std::unique_ptr<asapo::HttpClient> {&mock_http_client}; + client.log__ = &mock_logger; + config.authorization_server = expected_authorization_server; + config.authorization_interval_ms = 0; + SetReceiverConfig(config, "none"); + SetDefaultRequestCalls(mock_request.get(),expected_beamtime_id); + } + void TearDown() override { + client.http_client__.release(); + } + void MockAuthRequest(bool error, HttpCode code = HttpCode::OK) { + EXPECT_CALL(*mock_request, + GetOriginUri()).WillOnce(ReturnRef(expected_producer_uri)); + if (error) { + EXPECT_CALL(mock_http_client, + Post_t(expected_authorization_server + "/authorize", _, expect_request_string, _, _)). + WillOnce( + DoAll(SetArgPointee<4>(asapo::GeneralErrorTemplates::kSimpleError.Generate("http error").release()), + Return("") + )); + } else { + EXPECT_CALL(mock_http_client, + Post_t(expected_authorization_server + "/authorize", _, expect_request_string, _, _)). + WillOnce( + DoAll(SetArgPointee<4>(nullptr), + SetArgPointee<3>(code), + Return("{\"beamtimeId\":\"" + expected_beamtime_id + + "\",\"dataSource\":" + "\"" + expected_data_source + + "\",\"beamline-path\":" + "\"" + expected_beamline_path + + "\",\"corePath\":" + "\"" + expected_core_path + + "\",\"source-type\":" + "\"" + expected_source_type_str + + "\",\"beamline\":" + "\"" + expected_beamline + + "\",\"access-types\":" + expected_access_type_str + "}") + )); + } + } +}; + + +TEST_F(AuthorizerClientTests, AuthorizeRequestReturnsInternalerror) { + MockAuthRequest(true); + + auto err = client.Authorize(mock_request.get(), &expected_auth_data); + + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kInternalServerError)); +} + +TEST_F(AuthorizerClientTests, AuthorizeRequestReturns401) { + MockAuthRequest(false, HttpCode::Unauthorized); + + auto err = client.Authorize(mock_request.get(), &expected_auth_data); + + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); +} + + +TEST_F(AuthorizerClientTests, AuthorizeOk) { + MockAuthRequest(false, HttpCode::OK); + + EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("authorized"), + HasSubstr(expected_beamtime_id) + ))); + + auto err = client.Authorize(mock_request.get(), &expected_auth_data); + + ASSERT_THAT(err, Eq(nullptr)); + ASSERT_THAT(expected_auth_data.data_source, Eq(expected_data_source)); + ASSERT_THAT(expected_auth_data.source_type, Eq(expected_source_type)); + ASSERT_THAT(expected_auth_data.beamline, Eq(expected_beamline)); + ASSERT_THAT(expected_auth_data.beamtime_id, Eq(expected_beamtime_id)); + ASSERT_THAT(expected_auth_data.offline_path, Eq(expected_core_path)); + ASSERT_THAT(expected_auth_data.online_path, Eq(expected_beamline_path)); + ASSERT_THAT(expected_auth_data.last_update, Gt(std::chrono::system_clock::time_point{})); + ASSERT_THAT(expected_auth_data.source_credentials, Eq(expected_source_credentials)); + +} + +TEST_F(AuthorizerClientTests, AuthorizeFailsOnWrongAccessType) { + expected_access_type_str = "[\"read\"]"; + MockAuthRequest(false, HttpCode::OK); + + auto err = client.Authorize(mock_request.get(), &expected_auth_data); + + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); +} + +TEST_F(AuthorizerClientTests, AuthorizeFailsOnWrongAccessTypeForRaw) { + expected_access_type_str = "[\"write\"]"; + expected_source_type_str = "raw"; + MockAuthRequest(false, HttpCode::OK); + + auto err = client.Authorize(mock_request.get(), &expected_auth_data); + + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); +} + +TEST_F(AuthorizerClientTests, AuthorizeFailsOnWrongAccessTypeForProcessed) { + expected_access_type_str = "[\"writeraw\"]"; + expected_source_type_str = "processed"; + MockAuthRequest(false, HttpCode::OK); + + auto err = client.Authorize(mock_request.get(), &expected_auth_data); + + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); +} + +TEST_F(AuthorizerClientTests, AuthorizeOkForRaw) { + expected_access_type_str = "[\"writeraw\"]"; + expected_source_type_str = "raw"; + expected_source_type = asapo::SourceType::kRaw; + MockAuthRequest(false, HttpCode::OK); + + auto err = client.Authorize(mock_request.get(), &expected_auth_data); + + ASSERT_THAT(err, Eq(nullptr)); +} + +} diff --git a/receiver/unittests/request_handler/test_request_common.h b/receiver/unittests/request_handler/test_request_common.h new file mode 100644 index 0000000000000000000000000000000000000000..42b82617cc87ba3b0aafba2fec94bee6c8041349 --- /dev/null +++ b/receiver/unittests/request_handler/test_request_common.h @@ -0,0 +1,53 @@ +#include <functional> + +#include <gtest/gtest.h> +#include <gmock/gmock.h> +#include "asapo/database/db_error.h" + +#include "asapo/unittests/MockIO.h" +#include "asapo/unittests/MockDatabase.h" +#include "asapo/unittests/MockLogger.h" + +#include "../../src/receiver_error.h" +#include "../../src/request.h" +#include "../../src/request_handler/request_factory.h" +#include "../../src/request_handler/request_handler.h" +#include "../../src/request_handler/request_handler_db_check_request.h" +#include "asapo/common/networking.h" +#include "../../../common/cpp/src/database/mongodb_client.h" +#include "../mock_receiver_config.h" +#include "asapo/common/data_structs.h" + +#include "../receiver_mocking.h" + +using namespace testing; +using namespace asapo; + +namespace { + +class ReceiverTests : public Test { + public: + std::string expected_collection_name = "test"; + RequestHandlerDb handler{expected_collection_name}; + std::unique_ptr<NiceMock<MockRequest>> mock_request; + NiceMock<MockDatabase> mock_db; + NiceMock<asapo::MockLogger> mock_logger; + ReceiverConfig config; + std::string expected_beamtime_id = "beamtime_id"; + std::string expected_stream = "source"; + std::string expected_default_source = "detector"; + std::string expected_discovery_server = "discovery"; + std::string expected_database_server = "127.0.0.1:27017"; + GenericRequestHeader request_header; + virtual void SetUp() override { + handler.db_client__ = std::unique_ptr<asapo::Database> {&mock_db}; + handler.log__ = &mock_logger; + mock_request.reset(new NiceMock<MockRequest> {request_header, 1, "", nullptr}); + SetDefaultRequestCalls(mock_request.get(),expected_beamtime_id); + } + virtual void TearDown() override { + handler.db_client__.release(); + } + +}; + diff --git a/receiver/unittests/request_handler/test_request_factory.cpp b/receiver/unittests/request_handler/test_request_factory.cpp index 64029d2ee34c89dd6071bce0a13aff4730d4bc0d..f2c6179a22a17ad97f823dc5fa11747ea9c5cf06 100644 --- a/receiver/unittests/request_handler/test_request_factory.cpp +++ b/receiver/unittests/request_handler/test_request_factory.cpp @@ -10,16 +10,6 @@ #include "../../src/request.h" #include "../../src/request_handler/request_factory.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 "../../src/request_handler/request_handler_authorize.h" -#include "../../src/request_handler/request_handler_db_stream_info.h" -#include "../../src/request_handler/request_handler_db_last_stream.h" -#include "../../src/request_handler/request_handler_db_delete_stream.h" -#include "../../src/request_handler/request_handler_db_get_meta.h" - -#include "../../src/request_handler/request_handler_receive_data.h" -#include "../../src/request_handler/request_handler_receive_metadata.h" #include "asapo/database/database.h" @@ -27,33 +17,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::InSequence; -using ::testing::SetArgPointee; -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::GenericRequestHeader; -using ::asapo::GenericNetworkResponse; -using ::asapo::Opcode; -using ::asapo::Connection; -using ::asapo::MockIO; -using asapo::Request; -using asapo::MockStatistics; - -using asapo::StatisticEntity; - -using asapo::ReceiverConfig; -using asapo::SetReceiverConfig; -using asapo::RequestFactory; +using namespace testing; +using namespace asapo; namespace { @@ -89,7 +54,8 @@ TEST_F(FactoryTests, ReturnsDataRequestOnkNetOpcodeSendCode) { ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(dynamic_cast<asapo::Request*>(request.get()), Ne(nullptr)); ASSERT_THAT(request->GetListHandlers().size(), Eq(5)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[0]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerSecondaryAuthorization*>(request->GetListHandlers()[0]), + Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerReceiveMetaData*>(request->GetListHandlers()[1]), Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerReceiveData*>(request->GetListHandlers()[2]), Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerFileProcess*>(request->GetListHandlers()[3]), Ne(nullptr)); @@ -109,7 +75,8 @@ TEST_F(FactoryTests, ReturnsDataRequestOnkNetOpcodeSendCodeLargeFile) { ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(dynamic_cast<asapo::Request*>(request.get()), Ne(nullptr)); ASSERT_THAT(request->GetListHandlers().size(), Eq(4)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[0]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerSecondaryAuthorization*>(request->GetListHandlers()[0]), + Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerReceiveMetaData*>(request->GetListHandlers()[1]), Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerFileProcess*>(request->GetListHandlers()[2]), Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerDbWrite*>(request->GetListHandlers().back()), Ne(nullptr)); @@ -124,7 +91,7 @@ TEST_F(FactoryTests, ReturnsDataRequestForAuthorizationCode) { ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(dynamic_cast<asapo::Request*>(request.get()), Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerReceiveMetaData*>(request->GetListHandlers()[0]), Ne(nullptr)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[1]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerInitialAuthorization*>(request->GetListHandlers()[1]), Ne(nullptr)); } TEST_F(FactoryTests, DoNotAddDiskAndDbWriterIfNotWantedInRequest) { @@ -132,7 +99,8 @@ TEST_F(FactoryTests, DoNotAddDiskAndDbWriterIfNotWantedInRequest) { auto request = factory.GenerateRequest(generic_request_header, 1, origin_uri, &err); ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(request->GetListHandlers().size(), Eq(3)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[0]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerSecondaryAuthorization*>(request->GetListHandlers()[0]), + Ne(nullptr)); } TEST_F(FactoryTests, DoNotAddDbWriterIfNotWanted) { @@ -144,7 +112,8 @@ TEST_F(FactoryTests, DoNotAddDbWriterIfNotWanted) { auto request = factory.GenerateRequest(generic_request_header, 1, origin_uri, &err); ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(request->GetListHandlers().size(), Eq(4)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[0]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerSecondaryAuthorization*>(request->GetListHandlers()[0]), + Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerReceiveMetaData*>(request->GetListHandlers()[1]), Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerReceiveData*>(request->GetListHandlers()[2]), Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerFileProcess*>(request->GetListHandlers()[3]), Ne(nullptr)); @@ -166,7 +135,8 @@ TEST_F(FactoryTests, ReturnsMetaDataRequestOnTransferMetaDataOnly) { ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(dynamic_cast<asapo::Request*>(request.get()), Ne(nullptr)); ASSERT_THAT(request->GetListHandlers().size(), Eq(4)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[0]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerSecondaryAuthorization*>(request->GetListHandlers()[0]), + Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerReceiveMetaData*>(request->GetListHandlers()[1]), Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerReceiveData*>(request->GetListHandlers()[2]), Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerDbWrite*>(request->GetListHandlers()[3]), Ne(nullptr)); @@ -181,7 +151,8 @@ TEST_F(FactoryTests, ReturnsMetaDataRequestOnkOpcodeTransferMetaData) { ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(dynamic_cast<asapo::Request*>(request.get()), Ne(nullptr)); ASSERT_THAT(dynamic_cast<asapo::Request*>(request->cache__), Eq(nullptr)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[0]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerSecondaryAuthorization*>(request->GetListHandlers()[0]), + Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerReceiveData*>(request->GetListHandlers()[1]), Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerDbMetaWrite*>(request->GetListHandlers().back()), Ne(nullptr)); } @@ -204,7 +175,8 @@ TEST_F(FactoryTests, StreamInfoRequest) { auto request = factory.GenerateRequest(generic_request_header, 1, origin_uri, &err); ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(request->GetListHandlers().size(), Eq(2)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[0]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerSecondaryAuthorization*>(request->GetListHandlers()[0]), + Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerDbStreamInfo*>(request->GetListHandlers()[1]), Ne(nullptr)); } @@ -213,7 +185,8 @@ TEST_F(FactoryTests, LastStreamRequest) { auto request = factory.GenerateRequest(generic_request_header, 1, origin_uri, &err); ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(request->GetListHandlers().size(), Eq(2)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[0]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerSecondaryAuthorization*>(request->GetListHandlers()[0]), + Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerDbLastStream*>(request->GetListHandlers()[1]), Ne(nullptr)); } @@ -222,7 +195,8 @@ TEST_F(FactoryTests, DeleteStreamRequest) { auto request = factory.GenerateRequest(generic_request_header, 1, origin_uri, &err); ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(request->GetListHandlers().size(), Eq(2)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[0]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerSecondaryAuthorization*>(request->GetListHandlers()[0]), + Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerDbDeleteStream*>(request->GetListHandlers()[1]), Ne(nullptr)); } @@ -231,7 +205,8 @@ TEST_F(FactoryTests, GetMetamRequest) { auto request = factory.GenerateRequest(generic_request_header, 1, origin_uri, &err); ASSERT_THAT(err, Eq(nullptr)); ASSERT_THAT(request->GetListHandlers().size(), Eq(2)); - ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerAuthorize*>(request->GetListHandlers()[0]), Ne(nullptr)); + ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerSecondaryAuthorization*>(request->GetListHandlers()[0]), + Ne(nullptr)); ASSERT_THAT(dynamic_cast<const asapo::RequestHandlerDbGetMeta*>(request->GetListHandlers()[1]), Ne(nullptr)); } diff --git a/receiver/unittests/request_handler/test_request_handler_authorizer.cpp b/receiver/unittests/request_handler/test_request_handler_authorizer.cpp deleted file mode 100644 index 30069b6e2531890a4a8ac168f0ab092ea964e620..0000000000000000000000000000000000000000 --- a/receiver/unittests/request_handler/test_request_handler_authorizer.cpp +++ /dev/null @@ -1,332 +0,0 @@ -#include <gtest/gtest.h> -#include <gmock/gmock.h> - -#include "asapo/unittests/MockHttpClient.h" -#include "asapo/unittests/MockLogger.h" - -#include "../../src/receiver_error.h" -#include "../../src/request.h" -#include "../../src/request_handler/request_handler.h" -#include "../../src/request_handler/request_handler_authorize.h" -#include "asapo/common/networking.h" -#include "../mock_receiver_config.h" -#include "asapo/preprocessor/definitions.h" - -#include "../receiver_mocking.h" - -#include "../../src/receiver_config.h" - - -using ::testing::Test; -using ::testing::Return; -using ::testing::ReturnRef; -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 ::testing::AllOf; -using ::testing::HasSubstr; - -using asapo::MockRequest; -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockHttpClient; -using asapo::Request; -using asapo::RequestHandlerAuthorize; -using ::asapo::GenericRequestHeader; -using asapo::ReceiverConfig; -using asapo::SetReceiverConfig; -using asapo::HttpCode; - -namespace { - -TEST(Authorizer, Constructor) { - RequestHandlerAuthorize handler; - ASSERT_THAT(dynamic_cast<asapo::HttpClient*>(handler.http_client__.get()), Ne(nullptr)); - ASSERT_THAT(dynamic_cast<const asapo::AbstractLogger*>(handler.log__), Ne(nullptr)); -} - - -class AuthorizerHandlerTests : public Test { - public: - RequestHandlerAuthorize handler; - MockHttpClient mock_http_client; - std::unique_ptr<MockRequest> mock_request; - ReceiverConfig config; - - NiceMock<asapo::MockLogger> mock_logger; - std::string expected_beamtime_id = "beamtime_id"; - std::string expected_data_source = "source"; - std::string expected_beamline = "beamline"; - std::string expected_beamline_path = "/beamline/p01/current"; - std::string expected_core_path = "/gpfs/blabla"; - std::string expected_producer_uri = "producer_uri"; - std::string expected_authorization_server = "authorizer_host"; - std::string expect_request_string; - std::string expected_source_credentials; - std::string expected_api_version = "v0.1"; - - asapo::SourceType expected_source_type = asapo::SourceType::kProcessed; - std::string expected_source_type_str = "processed"; - std::string expected_access_type_str = "[\"write\"]"; - void MockRequestData(); - void SetUp() override { - GenericRequestHeader request_header; - expected_source_credentials = "processed%" + expected_beamtime_id + "%source%token"; - expect_request_string = std::string("{\"SourceCredentials\":\"") + expected_source_credentials + - "\",\"OriginHost\":\"" + - expected_producer_uri + "\"}"; - - mock_request.reset(new MockRequest{request_header, 1, expected_producer_uri, nullptr}); - handler.http_client__ = std::unique_ptr<asapo::HttpClient> {&mock_http_client}; - handler.log__ = &mock_logger; - config.authorization_server = expected_authorization_server; - config.authorization_interval_ms = 0; - SetReceiverConfig(config, "none"); - } - void TearDown() override { - handler.http_client__.release(); - } - void MockAuthRequest(bool error, HttpCode code = HttpCode::OK, bool opError = false) { - if (error) { - EXPECT_CALL(mock_http_client, Post_t(expected_authorization_server + "/authorize", _, expect_request_string, _, _)). - WillOnce( - DoAll(SetArgPointee<4>(new asapo::SimpleError("http error")), - Return("") - )); - EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("failure authorizing"), - HasSubstr("http error"), - HasSubstr(expected_beamtime_id), - HasSubstr(expected_producer_uri), - HasSubstr(expected_authorization_server)))); - - } else { - EXPECT_CALL(mock_http_client, Post_t(expected_authorization_server + "/authorize", _, expect_request_string, _, _)). - WillOnce( - DoAll(SetArgPointee<4>(nullptr), - SetArgPointee<3>(code), - Return("{\"beamtimeId\":\"" + expected_beamtime_id + - "\",\"dataSource\":" + "\"" + expected_data_source + - "\",\"beamline-path\":" + "\"" + expected_beamline_path + - "\",\"corePath\":" + "\"" + expected_core_path + - "\",\"source-type\":" + "\"" + expected_source_type_str + - "\",\"beamline\":" + "\"" + expected_beamline + - "\",\"access-types\":" + expected_access_type_str + "}") - )); - if (code != HttpCode::OK) { - EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("failure authorizing"), - HasSubstr(expected_source_type_str), - HasSubstr(expected_beamtime_id), - HasSubstr(expected_data_source), - HasSubstr(expected_producer_uri), - HasSubstr(expected_authorization_server)))); - } else if (!opError) { - EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("authorized"), - HasSubstr(expected_beamtime_id), - HasSubstr(expected_beamline), - HasSubstr(expected_source_type_str), - HasSubstr(expected_data_source), - HasSubstr(expected_producer_uri)))); - } else { - EXPECT_CALL(mock_logger, Error(HasSubstr("wrong"))); - } - } - - - } - Error MockFirstAuthorization(bool error, HttpCode code = HttpCode::OK, bool opError = false) { - EXPECT_CALL(*mock_request, GetOpCode()) - .WillOnce(Return(asapo::kOpcodeAuthorize)) - ; - EXPECT_CALL(*mock_request, GetMetaData()) - .WillOnce(ReturnRef(expected_source_credentials)) - ; - - EXPECT_CALL(*mock_request, GetApiVersion()) - .WillOnce(Return(expected_api_version)) - ; - - - MockAuthRequest(error, code, opError); - return handler.ProcessRequest(mock_request.get()); - } - Error MockRequestAuthorization(bool error, HttpCode code = HttpCode::OK, bool set_request = true) { - EXPECT_CALL(*mock_request, GetOpCode()) - .WillOnce(Return(asapo::kOpcodeTransferData)) - ; - - if (!error && code == HttpCode::OK && set_request) { - EXPECT_CALL(*mock_request, SetBeamtimeId(expected_beamtime_id)); - EXPECT_CALL(*mock_request, SetDataSource(expected_data_source)); - EXPECT_CALL(*mock_request, SetOfflinePath(expected_core_path)); - EXPECT_CALL(*mock_request, SetOnlinePath(expected_beamline_path)); - EXPECT_CALL(*mock_request, SetBeamline(expected_beamline)); - EXPECT_CALL(*mock_request, SetSourceType(expected_source_type)); - } - - MockAuthRequest(error, code); - return handler.ProcessRequest(mock_request.get()); - } - -}; - -TEST_F(AuthorizerHandlerTests, CheckStatisticEntity) { - auto entity = handler.GetStatisticEntity(); - ASSERT_THAT(entity, Eq(asapo::StatisticEntity::kNetwork)); -} - -TEST_F(AuthorizerHandlerTests, ErrorNotAuthorizedYet) { - EXPECT_CALL(*mock_request, GetOpCode()) - .WillOnce(Return(asapo::kOpcodeTransferData)) - ; - - auto err = handler.ProcessRequest(mock_request.get()); - - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); -} - -TEST_F(AuthorizerHandlerTests, ErrorProcessingAuthorizeRequest) { - - auto err = MockFirstAuthorization(true); - - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kInternalServerError)); -} - - -TEST_F(AuthorizerHandlerTests, AuthorizeRequestreturns401) { - - auto err = MockFirstAuthorization(false, HttpCode::Unauthorized); - - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); -} - - -TEST_F(AuthorizerHandlerTests, AuthorizeOk) { - auto err = MockFirstAuthorization(false); - - ASSERT_THAT(err, Eq(nullptr)); -} - - -TEST_F(AuthorizerHandlerTests, AuthorizeFailsOnWrongAccessType) { - expected_access_type_str = "[\"read\"]"; - auto err = MockFirstAuthorization(false, HttpCode::OK, true); - - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); -} - -TEST_F(AuthorizerHandlerTests, AuthorizeFailsOnWrongAccessTypeForRaw) { - expected_access_type_str = "[\"write\"]"; - expected_source_type_str = "raw"; - auto err = MockFirstAuthorization(false, HttpCode::OK, true); - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); -} - -TEST_F(AuthorizerHandlerTests, AuthorizeFailsOnWrongAccessTypeForProcessed) { - expected_access_type_str = "[\"writeraw\"]"; - expected_source_type_str = "processed"; - auto err = MockFirstAuthorization(false, HttpCode::OK, true); - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); -} - -TEST_F(AuthorizerHandlerTests, AuthorizeOkForRaw) { - expected_access_type_str = "[\"writeraw\"]"; - expected_source_type_str = "raw"; - auto err = MockFirstAuthorization(false, HttpCode::OK, false); - ASSERT_THAT(err, Eq(nullptr)); -} - -TEST_F(AuthorizerHandlerTests, ErrorOnSecondAuthorize) { - MockFirstAuthorization(false); - EXPECT_CALL(*mock_request, GetOpCode()) - .WillOnce(Return(asapo::kOpcodeAuthorize)); - - EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("failure authorizing"), - HasSubstr("already authorized"), - HasSubstr(expected_authorization_server)))); - - - auto err = handler.ProcessRequest(mock_request.get()); - - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); -} - -TEST_F(AuthorizerHandlerTests, ErrorOnDataTransferRequestAuthorize) { - MockFirstAuthorization(false); - - auto err = MockRequestAuthorization(true); - - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kInternalServerError)); -} - - -TEST_F(AuthorizerHandlerTests, DataTransferRequestAuthorizeReturns401) { - MockFirstAuthorization(false); - - auto err = MockRequestAuthorization(false, HttpCode::Unauthorized); - - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kReAuthorizationFailure)); -} - -TEST_F(AuthorizerHandlerTests, DataTransferRequestAuthorizeReturnsSameBeamtimeId) { - MockFirstAuthorization(false); - auto err = MockRequestAuthorization(false); - - ASSERT_THAT(err, Eq(nullptr)); -} - -TEST_F(AuthorizerHandlerTests, RequestAuthorizeReturnsDifferentBeamtimeId) { - MockFirstAuthorization(false); - - expected_beamtime_id = "different_id"; - auto err = MockRequestAuthorization(false, HttpCode::OK, false); - - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kReAuthorizationFailure)); -} - - -TEST_F(AuthorizerHandlerTests, RequestFromUnsupportedClient) { - EXPECT_CALL(*mock_request, GetOpCode()) - .WillOnce(Return(asapo::kOpcodeAuthorize)) - ; - EXPECT_CALL(*mock_request, GetApiVersion()) - .WillOnce(Return("v1000.2")) - ; - - auto err = handler.ProcessRequest(mock_request.get()); - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kUnsupportedClient)); -} - - - - -TEST_F(AuthorizerHandlerTests, DataTransferRequestAuthorizeUsesCachedValue) { - config.authorization_interval_ms = 10000; - SetReceiverConfig(config, "none"); - MockFirstAuthorization(false); - EXPECT_CALL(*mock_request, GetOpCode()) - .WillOnce(Return(asapo::kOpcodeTransferData)); - EXPECT_CALL(mock_http_client, Post_t(_, _, _, _, _)).Times(0); - EXPECT_CALL(*mock_request, SetBeamtimeId(expected_beamtime_id)); - EXPECT_CALL(*mock_request, SetBeamline(expected_beamline)); - EXPECT_CALL(*mock_request, SetDataSource(expected_data_source)); - EXPECT_CALL(*mock_request, SetOnlinePath(expected_beamline_path)); - EXPECT_CALL(*mock_request, SetOfflinePath(expected_core_path)); - EXPECT_CALL(*mock_request, SetSourceType(expected_source_type)); - auto err = handler.ProcessRequest(mock_request.get()); - - ASSERT_THAT(err, Eq(nullptr)); -} - - - - -} diff --git a/receiver/unittests/request_handler/test_request_handler_db.cpp b/receiver/unittests/request_handler/test_request_handler_db.cpp index 8f3bf1549c27064bc53ed1fe7320b9ef45e5d2a7..d56fe78f79566b2c2a8be316b3e62c0f875645c8 100644 --- a/receiver/unittests/request_handler/test_request_handler_db.cpp +++ b/receiver/unittests/request_handler/test_request_handler_db.cpp @@ -18,41 +18,8 @@ #include "../receiver_mocking.h" -using asapo::MockRequest; -using asapo::MessageMeta; -using ::testing::Test; -using ::testing::Return; -using ::testing::ReturnRef; -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 ::testing::AllOf; -using ::testing::HasSubstr; - - -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockIO; -using asapo::Request; -using asapo::RequestHandlerDb; -using ::asapo::GenericRequestHeader; - -using asapo::MockDatabase; -using ::asapo::MockHttpClient; - -using asapo::RequestFactory; -using asapo::SetReceiverConfig; -using asapo::ReceiverConfig; -using asapo::HttpCode; +using namespace testing; +using namespace asapo; namespace { @@ -97,10 +64,10 @@ void DbHandlerTests::MockAuthRequest(bool error, HttpCode code) { if (error) { EXPECT_CALL(mock_http_client, Get_t(expected_discovery_server + "/asapo-mongodb", _, _)). WillOnce( - DoAll(SetArgPointee<2>(new asapo::SimpleError("http error")), + DoAll(SetArgPointee<2>(asapo::GeneralErrorTemplates::kSimpleError.Generate("http error").release()), Return("") )); - EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("discover database server"), + EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("discovering database server"), HasSubstr("http error"), HasSubstr(expected_discovery_server)))); @@ -118,7 +85,7 @@ void DbHandlerTests::MockAuthRequest(bool error, HttpCode code) { HasSubstr(std::to_string(int(code))), HasSubstr(expected_discovery_server)))); } else { - EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("found database server"), + EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("discovered"), HasSubstr(expected_database_server)))); } } @@ -204,7 +171,7 @@ TEST_F(DbHandlerTests, ProcessRequestCallsConnectDbWhenNotConnected) { TEST_F(DbHandlerTests, ProcessRequestReturnsErrorWhenCannotConnect) { EXPECT_CALL(mock_db, Connect_t(_, _)). - WillOnce(testing::Return(new asapo::SimpleError(""))); + WillOnce(testing::Return(asapo::GeneralErrorTemplates::kSimpleError.Generate().release())); auto err = handler.ProcessRequest(mock_request.get()); diff --git a/receiver/unittests/request_handler/test_request_handler_db_check_request.cpp b/receiver/unittests/request_handler/test_request_handler_db_check_request.cpp index 05d43fca83158008680a543895734eb8dcf7e9f9..eb83c4f822c4830830cdf6a095c8fd1d2eda7dc1 100644 --- a/receiver/unittests/request_handler/test_request_handler_db_check_request.cpp +++ b/receiver/unittests/request_handler/test_request_handler_db_check_request.cpp @@ -20,38 +20,8 @@ #include "../receiver_mocking.h" -using asapo::MockRequest; -using asapo::MessageMeta; -using ::testing::Test; -using ::testing::Return; -using ::testing::ReturnRef; -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 ::testing::AllOf; -using ::testing::HasSubstr; - - -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockIO; -using asapo::Request; -using asapo::RequestHandlerDbCheckRequest; -using ::asapo::GenericRequestHeader; - -using asapo::MockDatabase; -using asapo::RequestFactory; -using asapo::SetReceiverConfig; -using asapo::ReceiverConfig; +using namespace testing; +using namespace asapo; using MockFunctions = std::vector<std::function<void(asapo::ErrorInterface*, bool )>>; @@ -84,7 +54,7 @@ class DbCheckRequestHandlerTests : public Test { uint64_t expected_id = 15; uint64_t expected_dataset_id = 16; uint64_t expected_dataset_size = 2; - uint64_t expected_custom_data[asapo::kNCustomParams] {0, expected_dataset_id, expected_dataset_size}; + CustomRequestData expected_custom_data{0, expected_dataset_id, expected_dataset_size}; MessageMeta expected_message_meta; MockFunctions mock_functions; int n_run = 0; @@ -108,8 +78,7 @@ class DbCheckRequestHandlerTests : public Test { MockGetSetByID(error, expect_compare); n_run++; }); - - ON_CALL(*mock_request, GetBeamtimeId()).WillByDefault(ReturnRef(expected_beamtime_id)); + SetDefaultRequestCalls(mock_request.get(),expected_beamtime_id); } void ExpectRequestParams(asapo::Opcode op_code, const std::string& data_source, bool expect_compare = true); @@ -144,44 +113,41 @@ void DbCheckRequestHandlerTests::ExpectRequestParams(asapo::Opcode op_code, cons if (n_run == 0) { EXPECT_CALL(mock_db, Connect_t(config.database_uri, db_name)). WillOnce(testing::Return(nullptr)); - EXPECT_CALL(*mock_request, GetBeamtimeId()) - .WillOnce(ReturnRef(expected_beamtime_id)) - ; EXPECT_CALL(*mock_request, GetDataSource()) - .WillOnce(ReturnRef(data_source)) + .WillRepeatedly(ReturnRef(data_source)) ; } if (expect_compare) { EXPECT_CALL(*mock_request, GetDataSize()) - .WillOnce(Return(expected_file_size)) + .WillRepeatedly(Return(expected_file_size)) ; EXPECT_CALL(*mock_request, GetFileName()) - .WillOnce(Return(expected_file_name)) + .WillRepeatedly(Return(expected_file_name)) ; EXPECT_CALL(*mock_request, GetMetaData()) - .WillOnce(ReturnRef(expected_metadata)) + .WillRepeatedly(ReturnRef(expected_metadata)) ; } EXPECT_CALL(*mock_request, GetStream()) - .WillOnce(Return(expected_stream)) + .WillRepeatedly(Return(expected_stream)) ; EXPECT_CALL(*mock_request, GetDataID()) - .WillOnce(Return(expected_id)) + .WillRepeatedly(Return(expected_id)) ; EXPECT_CALL(*mock_request, GetOpCode()) - .WillOnce(Return(op_code)) + .WillRepeatedly(Return(op_code)) ; if (op_code == asapo::Opcode::kOpcodeTransferDatasetData) { EXPECT_CALL(*mock_request, GetCustomData_t()) - .WillOnce(Return(expected_custom_data)) + .WillRepeatedly(Return(expected_custom_data)) ; } } diff --git a/receiver/unittests/request_handler/test_request_handler_db_get_meta.cpp b/receiver/unittests/request_handler/test_request_handler_db_get_meta.cpp index bfb4a89e527069cdf111d72c815539d8be11b84c..8f5e390eda3a6c5727d996a5c2f0a8d2c5dfebb0 100644 --- a/receiver/unittests/request_handler/test_request_handler_db_get_meta.cpp +++ b/receiver/unittests/request_handler/test_request_handler_db_get_meta.cpp @@ -18,38 +18,8 @@ #include "asapo/common/networking.h" #include "../receiver_mocking.h" -using asapo::MockRequest; -using asapo::MessageMeta; -using ::testing::Test; -using ::testing::Return; -using ::testing::ReturnRef; -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 ::testing::AllOf; -using ::testing::HasSubstr; - - -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockIO; -using asapo::Request; -using asapo::RequestHandlerDbGetMeta; -using ::asapo::GenericRequestHeader; - -using asapo::MockDatabase; -using asapo::RequestFactory; -using asapo::SetReceiverConfig; -using asapo::ReceiverConfig; +using namespace testing; +using namespace asapo; namespace { @@ -70,30 +40,28 @@ class DbMetaGetMetaTests : public Test { handler.db_client__ = std::unique_ptr<asapo::Database> {&mock_db}; handler.log__ = &mock_logger; mock_request.reset(new NiceMock<MockRequest> {request_header, 1, "", nullptr}); - ON_CALL(*mock_request, GetBeamtimeId()).WillByDefault(ReturnRef(expected_beamtime_id)); + SetDefaultRequestCalls(mock_request.get(),expected_beamtime_id); } void TearDown() override { handler.db_client__.release(); } void ExpectGet(bool stream, const asapo::DBErrorTemplate* errorTemplate) { SetReceiverConfig(config, "none"); - EXPECT_CALL(*mock_request, GetDataSource()).WillOnce(ReturnRef(expected_data_source)); + EXPECT_CALL(*mock_request, GetDataSource()).WillRepeatedly(ReturnRef(expected_data_source)); if (stream) { - EXPECT_CALL(*mock_request, GetStream()).WillOnce(Return(expected_stream)); + EXPECT_CALL(*mock_request, GetStream()).WillRepeatedly(Return(expected_stream)); } EXPECT_CALL(mock_db, Connect_t(config.database_uri, expected_beamtime_id + "_" + expected_data_source)). WillOnce(testing::Return(nullptr)); EXPECT_CALL(mock_db, GetMetaFromDb_t("meta", stream ? "st_" + expected_stream : "bt", _)). - WillOnce(DoAll( + WillOnce(DoAll( SetArgPointee<2>(expected_meta), testing::Return(errorTemplate == nullptr ? nullptr : errorTemplate->Generate().release()) )); if (errorTemplate == nullptr) { EXPECT_CALL(*mock_request, SetResponseMessage(expected_meta, asapo::ResponseMessageType::kInfo)); EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("meta"), - HasSubstr(config.database_uri), - HasSubstr(expected_data_source), HasSubstr(stream ? expected_stream : "beamtime"), HasSubstr(expected_beamtime_id) ) diff --git a/receiver/unittests/request_handler/test_request_handler_db_last_stream.cpp b/receiver/unittests/request_handler/test_request_handler_db_last_stream.cpp index 7889f95b4702344688259542ba30950d502110ba..3c56e9d3d22c54d24c6970fdd8d1849c16c68e1c 100644 --- a/receiver/unittests/request_handler/test_request_handler_db_last_stream.cpp +++ b/receiver/unittests/request_handler/test_request_handler_db_last_stream.cpp @@ -17,38 +17,8 @@ #include "asapo/common/networking.h" #include "../receiver_mocking.h" -using asapo::MockRequest; -using asapo::MessageMeta; -using ::testing::Test; -using ::testing::Return; -using ::testing::ReturnRef; -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 ::testing::AllOf; -using ::testing::HasSubstr; - - -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockIO; -using asapo::Request; -using asapo::RequestHandlerDbLastStream; -using ::asapo::GenericRequestHeader; - -using asapo::MockDatabase; -using asapo::RequestFactory; -using asapo::SetReceiverConfig; -using asapo::ReceiverConfig; +using namespace testing; +using namespace asapo; namespace { @@ -78,7 +48,7 @@ class DbMetaLastStreamTests : public Test { handler.db_client__ = std::unique_ptr<asapo::Database> {&mock_db}; handler.log__ = &mock_logger; mock_request.reset(new NiceMock<MockRequest> {request_header, 1, "", nullptr}); - ON_CALL(*mock_request, GetBeamtimeId()).WillByDefault(ReturnRef(expected_beamtime_id)); + SetDefaultRequestCalls(mock_request.get(),expected_beamtime_id); } void TearDown() override { handler.db_client__.release(); @@ -89,10 +59,10 @@ TEST_F(DbMetaLastStreamTests, CallsUpdate) { SetReceiverConfig(config, "none"); EXPECT_CALL(*mock_request, GetBeamtimeId()) - .WillOnce(ReturnRef(expected_beamtime_id)) + .WillRepeatedly(ReturnRef(expected_beamtime_id)) ; - EXPECT_CALL(*mock_request, GetDataSource()).WillOnce(ReturnRef(expected_data_source)); + EXPECT_CALL(*mock_request, GetDataSource()).WillRepeatedly(ReturnRef(expected_data_source)); EXPECT_CALL(mock_db, Connect_t(config.database_uri, expected_beamtime_id + "_" + expected_data_source)). WillOnce(testing::Return(nullptr)); @@ -106,8 +76,7 @@ TEST_F(DbMetaLastStreamTests, CallsUpdate) { EXPECT_CALL(*mock_request, SetResponseMessage(info_str, asapo::ResponseMessageType::kInfo)); - EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("get last stream"), - HasSubstr(config.database_uri), + EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("last stream"), HasSubstr(expected_beamtime_id) ) ) diff --git a/receiver/unittests/request_handler/test_request_handler_db_meta_writer.cpp b/receiver/unittests/request_handler/test_request_handler_db_meta_writer.cpp index 56d3ad7a8be794d60d3bc814bc39becda3ac63a2..b8f9eb4983742b6f45cfeacf4e685932423a5f1b 100644 --- a/receiver/unittests/request_handler/test_request_handler_db_meta_writer.cpp +++ b/receiver/unittests/request_handler/test_request_handler_db_meta_writer.cpp @@ -18,39 +18,8 @@ #include "asapo/common/internal/version.h" #include "../receiver_mocking.h" -using asapo::MockRequest; -using asapo::MessageMeta; -using ::testing::Test; -using ::testing::Return; -using ::testing::ReturnRef; -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 ::testing::AllOf; -using ::testing::HasSubstr; - - -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockIO; -using asapo::Request; -using asapo::RequestHandlerDbMetaWrite; -using ::asapo::GenericRequestHeader; - -using asapo::MockDatabase; -using asapo::RequestFactory; -using asapo::SetReceiverConfig; -using asapo::ReceiverConfig; - +using namespace testing; +using namespace asapo; namespace { @@ -70,14 +39,14 @@ class DbMetaWriterHandlerTests : public Test { const uint8_t* expected_meta = reinterpret_cast<const uint8_t*>(meta_str.c_str()); uint64_t expected_meta_size = meta_str.size(); std::string expected_meta_name = "bt"; - uint64_t expected_custom_data[asapo::kNCustomParams] {0, 0, 0}; + CustomRequestData expected_custom_data{0, 0, 0}; void SetUp() override { GenericRequestHeader request_header; request_header.data_id = 0; handler.db_client__ = std::unique_ptr<asapo::Database> {&mock_db}; handler.log__ = &mock_logger; mock_request.reset(new NiceMock<MockRequest> {request_header, 1, "", nullptr}); - ON_CALL(*mock_request, GetBeamtimeId()).WillByDefault(ReturnRef(expected_beamtime_id)); + SetDefaultRequestCalls(mock_request.get(),expected_beamtime_id); } void TearDown() override { handler.db_client__.release(); @@ -95,7 +64,7 @@ MATCHER_P(M_CheckIngestMode, mode, "") { void DbMetaWriterHandlerTests::ExpectRequestParams(const std::string& ver, uint64_t mode, const std::string& stream) { EXPECT_CALL(*mock_request, GetDataSource()) - .WillOnce(ReturnRef(expected_data_source)) + .WillRepeatedly(ReturnRef(expected_data_source)) ; EXPECT_CALL(mock_db, Connect_t(config.database_uri, expected_beamtime_id + "_" + expected_data_source)). @@ -103,23 +72,23 @@ void DbMetaWriterHandlerTests::ExpectRequestParams(const std::string& ver, uint6 EXPECT_CALL(*mock_request, GetDataSize()) - .WillOnce(Return(expected_meta_size)) + .WillRepeatedly(Return(expected_meta_size)) ; EXPECT_CALL(*mock_request, GetData()) - .WillOnce(Return((void*)expected_meta)) + .WillRepeatedly(Return((void*)expected_meta)) ; EXPECT_CALL(*mock_request, GetApiVersion()) - .WillOnce(Return(ver)) + .WillRepeatedly(Return(ver)) ; if (mode > 0) { EXPECT_CALL(*mock_request, GetStream()) - .WillOnce(Return(stream)) + .WillRepeatedly(Return(stream)) ; expected_custom_data[asapo::kPosMetaIngestMode] = mode; - EXPECT_CALL(*mock_request, GetCustomData_t()).WillOnce(Return(expected_custom_data)); + EXPECT_CALL(*mock_request, GetCustomData_t()).WillRepeatedly(Return(expected_custom_data)); } } @@ -178,10 +147,7 @@ TEST_F(DbMetaWriterHandlerTests, CallsIngestStreamMeta) { WillOnce(testing::Return(nullptr)); EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("insert stream meta"), - HasSubstr(expected_beamtime_id), - HasSubstr(expected_stream), - HasSubstr(config.database_uri), - HasSubstr(expected_collection_name) + HasSubstr(expected_beamtime_id) ) ) ); diff --git a/receiver/unittests/request_handler/test_request_handler_db_stream_info.cpp b/receiver/unittests/request_handler/test_request_handler_db_stream_info.cpp index 9c9753598fbd3dc35eea456373dd86a53963fb97..2257c44f753ad57da26067bc140640f8aa5b3527 100644 --- a/receiver/unittests/request_handler/test_request_handler_db_stream_info.cpp +++ b/receiver/unittests/request_handler/test_request_handler_db_stream_info.cpp @@ -17,39 +17,8 @@ #include "asapo/common/networking.h" #include "../receiver_mocking.h" -using asapo::MockRequest; -using asapo::MessageMeta; -using ::testing::Test; -using ::testing::Return; -using ::testing::ReturnRef; -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 ::testing::AllOf; -using ::testing::HasSubstr; - - -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockIO; -using asapo::Request; -using asapo::RequestHandlerDbStreamInfo; -using ::asapo::GenericRequestHeader; - -using asapo::MockDatabase; -using asapo::RequestFactory; -using asapo::SetReceiverConfig; -using asapo::ReceiverConfig; - +using namespace testing; +using namespace asapo; namespace { @@ -79,7 +48,7 @@ class DbMetaStreamInfoTests : public Test { handler.db_client__ = std::unique_ptr<asapo::Database> {&mock_db}; handler.log__ = &mock_logger; mock_request.reset(new NiceMock<MockRequest> {request_header, 1, "", nullptr}); - ON_CALL(*mock_request, GetBeamtimeId()).WillByDefault(ReturnRef(expected_beamtime_id)); + SetDefaultRequestCalls(mock_request.get(),expected_beamtime_id); } void TearDown() override { handler.db_client__.release(); @@ -90,12 +59,12 @@ TEST_F(DbMetaStreamInfoTests, CallsUpdate) { SetReceiverConfig(config, "none"); EXPECT_CALL(*mock_request, GetBeamtimeId()) - .WillOnce(ReturnRef(expected_beamtime_id)) + .WillRepeatedly(ReturnRef(expected_beamtime_id)) ; - EXPECT_CALL(*mock_request, GetDataSource()).WillOnce(ReturnRef(expected_data_source)); + EXPECT_CALL(*mock_request, GetDataSource()).WillRepeatedly(ReturnRef(expected_data_source)); - EXPECT_CALL(*mock_request, GetStream()).Times(2) + EXPECT_CALL(*mock_request, GetStream()) .WillRepeatedly(Return(expected_stream)) ; @@ -112,9 +81,7 @@ TEST_F(DbMetaStreamInfoTests, CallsUpdate) { EXPECT_CALL(*mock_request, SetResponseMessage(info_str, asapo::ResponseMessageType::kInfo)); EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("get stream info"), - HasSubstr(config.database_uri), - HasSubstr(expected_beamtime_id), - HasSubstr(expected_collection_name) + HasSubstr(expected_beamtime_id) ) ) ); diff --git a/receiver/unittests/request_handler/test_request_handler_db_writer.cpp b/receiver/unittests/request_handler/test_request_handler_db_writer.cpp index 14e8a1ca978bd2f63297fb539cc4e5001bd04df5..97102f50c5d07e3528d0cb6ee44391257385d740 100644 --- a/receiver/unittests/request_handler/test_request_handler_db_writer.cpp +++ b/receiver/unittests/request_handler/test_request_handler_db_writer.cpp @@ -20,39 +20,8 @@ #include "../receiver_mocking.h" -using asapo::MockRequest; -using asapo::MessageMeta; -using ::testing::Test; -using ::testing::Return; -using ::testing::ReturnRef; -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 ::testing::AllOf; -using ::testing::HasSubstr; -using ::testing::AtLeast; - - -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockIO; -using asapo::Request; -using asapo::RequestHandlerDbWrite; -using ::asapo::GenericRequestHeader; - -using asapo::MockDatabase; -using asapo::RequestFactory; -using asapo::SetReceiverConfig; -using asapo::ReceiverConfig; +using namespace testing; +using namespace asapo; namespace { @@ -100,7 +69,7 @@ class DbWriterHandlerTests : public Test { config.dataserver.listen_port = expected_port; SetReceiverConfig(config, "none"); - ON_CALL(*mock_request, GetBeamtimeId()).WillByDefault(ReturnRef(expected_beamtime_id)); + SetDefaultRequestCalls(mock_request.get(),expected_beamtime_id); } void ExpectRequestParams(asapo::Opcode op_code, const std::string& data_source); void ExpectLogger(); @@ -137,11 +106,11 @@ void DbWriterHandlerTests::ExpectRequestParams(asapo::Opcode op_code, const std: ; EXPECT_CALL(*mock_request, GetBeamtimeId()) - .WillOnce(ReturnRef(expected_beamtime_id)) + .WillRepeatedly(ReturnRef(expected_beamtime_id)) ; EXPECT_CALL(*mock_request, GetDataSource()) - .WillOnce(ReturnRef(data_source)) + .WillRepeatedly(ReturnRef(data_source)) ; @@ -164,7 +133,7 @@ void DbWriterHandlerTests::ExpectRequestParams(asapo::Opcode op_code, const std: ; EXPECT_CALL(*mock_request, GetStream()) - .WillOnce(Return(expected_stream)) + .WillRepeatedly(Return(expected_stream)) ; @@ -177,11 +146,11 @@ void DbWriterHandlerTests::ExpectRequestParams(asapo::Opcode op_code, const std: ; EXPECT_CALL(*mock_request, GetOpCode()) - .WillOnce(Return(op_code)) + .WillRepeatedly(Return(op_code)) ; if (op_code == asapo::Opcode::kOpcodeTransferDatasetData) { - EXPECT_CALL(*mock_request, GetCustomData_t()).Times(2). + EXPECT_CALL(*mock_request, GetCustomData_t()). WillRepeatedly(Return(expected_custom_data)) ; } @@ -204,11 +173,8 @@ MessageMeta DbWriterHandlerTests::PrepareMessageMeta(bool substream) { return message_meta; } void DbWriterHandlerTests::ExpectLogger() { - EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("insert record"), - HasSubstr(config.database_uri), - HasSubstr(expected_beamtime_id), - HasSubstr(expected_data_source), - HasSubstr(expected_collection_name) + EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("insert"), + HasSubstr(expected_beamtime_id) ) ) ); diff --git a/receiver/unittests/request_handler/test_request_handler_delete_stream.cpp b/receiver/unittests/request_handler/test_request_handler_delete_stream.cpp index bb169b257b73b39600a8c553f4b3ba0e712bbf61..a98675580e68f109115d8a2295443af7810ff89e 100644 --- a/receiver/unittests/request_handler/test_request_handler_delete_stream.cpp +++ b/receiver/unittests/request_handler/test_request_handler_delete_stream.cpp @@ -18,39 +18,8 @@ #include "asapo/common/networking.h" #include "../receiver_mocking.h" -using asapo::MockRequest; -using asapo::MessageMeta; -using ::testing::Test; -using ::testing::Return; -using ::testing::ReturnRef; -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 ::testing::AllOf; -using ::testing::HasSubstr; - - -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockIO; -using asapo::Request; -using asapo::RequestHandlerDbDeleteStream; -using ::asapo::GenericRequestHeader; - -using asapo::MockDatabase; -using asapo::RequestFactory; -using asapo::SetReceiverConfig; -using asapo::ReceiverConfig; - +using namespace testing; +using namespace asapo; namespace { @@ -64,14 +33,14 @@ class DbMetaDeleteStreamTests : public Test { std::string expected_beamtime_id = "beamtime_id"; std::string expected_data_source = "source"; std::string expected_stream = "stream"; - uint64_t expected_custom_data[asapo::kNCustomParams] {0, 0, 0}; + CustomRequestData expected_custom_data {0, 0, 0}; void SetUp() override { GenericRequestHeader request_header; handler.db_client__ = std::unique_ptr<asapo::Database> {&mock_db}; handler.log__ = &mock_logger; mock_request.reset(new NiceMock<MockRequest> {request_header, 1, "", nullptr}); - ON_CALL(*mock_request, GetBeamtimeId()).WillByDefault(ReturnRef(expected_beamtime_id)); + SetDefaultRequestCalls(mock_request.get(),expected_beamtime_id); } void TearDown() override { handler.db_client__.release(); @@ -79,9 +48,9 @@ class DbMetaDeleteStreamTests : public Test { void ExpectDelete(uint64_t flag, const asapo::DBErrorTemplate* errorTemplate) { expected_custom_data[0] = flag; SetReceiverConfig(config, "none"); - EXPECT_CALL(*mock_request, GetCustomData_t()).WillOnce(Return(expected_custom_data)); - EXPECT_CALL(*mock_request, GetDataSource()).WillOnce(ReturnRef(expected_data_source)); - EXPECT_CALL(*mock_request, GetStream()).WillOnce(Return(expected_stream)); + EXPECT_CALL(*mock_request, GetCustomData_t()).WillRepeatedly(Return(expected_custom_data)); + EXPECT_CALL(*mock_request, GetDataSource()).WillRepeatedly(ReturnRef(expected_data_source)); + EXPECT_CALL(*mock_request, GetStream()).WillRepeatedly(Return(expected_stream)); asapo::DeleteStreamOptions opt; opt.Decode(flag); @@ -98,9 +67,9 @@ class DbMetaDeleteStreamTests : public Test { } EXPECT_CALL(mock_db, Connect_t(config.database_uri, expected_beamtime_id + "_" + expected_data_source)). - WillOnce(testing::Return(nullptr)); + WillRepeatedly(testing::Return(nullptr)); EXPECT_CALL(mock_db, DeleteStream_t(expected_stream)). - WillOnce(testing::Return(errorTemplate == nullptr ? nullptr : errorTemplate->Generate().release())); + WillRepeatedly(testing::Return(errorTemplate == nullptr ? nullptr : errorTemplate->Generate().release())); if (errorTemplate == nullptr) { EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("deleted stream meta"), HasSubstr(config.database_uri), diff --git a/receiver/unittests/request_handler/test_request_handler_file_process.cpp b/receiver/unittests/request_handler/test_request_handler_file_process.cpp index 4dbaef79401b8503bc137d382509eae82aa1b484..d058fab903c193eec12fbeae9ddaf1becf4384d8 100644 --- a/receiver/unittests/request_handler/test_request_handler_file_process.cpp +++ b/receiver/unittests/request_handler/test_request_handler_file_process.cpp @@ -14,32 +14,8 @@ #include "../receiver_mocking.h" -using ::testing::Test; -using ::testing::Return; -using ::testing::ReturnRef; -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 ::testing::AllOf; -using ::testing::HasSubstr; - - -using ::asapo::Error; -using ::asapo::ErrorInterface; -using ::asapo::FileDescriptor; -using ::asapo::SocketDescriptor; -using ::asapo::MockIO; -using asapo::Request; -using asapo::RequestHandlerFileProcess; -using ::asapo::GenericRequestHeader; -using asapo::MockRequest; +using namespace testing; +using namespace asapo; namespace { @@ -54,14 +30,15 @@ class FileWriteHandlerTests : public Test { asapo::MockFileProcessor mock_file_processor; RequestHandlerFileProcess handler{&mock_file_processor}; NiceMock<MockIO> mock_io; - std::unique_ptr<MockRequest> mock_request; + std::unique_ptr<NiceMock<MockRequest>> mock_request; NiceMock<asapo::MockLogger> mock_logger; - void ExpecFileProcess(const asapo::SimpleErrorTemplate* error_template, bool overwrite); + void ExpecFileProcess(const asapo::ErrorTemplateInterface* error_template, bool overwrite); void SetUp() override { GenericRequestHeader request_header; - mock_request.reset(new MockRequest{request_header, 1, "", nullptr}); + mock_request.reset(new NiceMock<MockRequest>{request_header, 1, "", nullptr}); handler.io__ = std::unique_ptr<asapo::IO> {&mock_io}; handler.log__ = &mock_logger; + SetDefaultRequestCalls(mock_request.get(),""); } void TearDown() override { handler.io__.release(); @@ -74,7 +51,7 @@ TEST_F(FileWriteHandlerTests, CheckStatisticEntity) { ASSERT_THAT(entity, Eq(asapo::StatisticEntity::kDisk)); } -void FileWriteHandlerTests::ExpecFileProcess(const asapo::SimpleErrorTemplate* error_template, bool overwrite) { +void FileWriteHandlerTests::ExpecFileProcess(const asapo::ErrorTemplateInterface* error_template, bool overwrite) { EXPECT_CALL(mock_file_processor, ProcessFile_t(mock_request.get(), overwrite)) .WillOnce( Return(error_template == nullptr ? nullptr : error_template->Generate().release())); @@ -87,14 +64,14 @@ TEST_F(FileWriteHandlerTests, FileAlreadyExists_NoRecordInDb) { Return(nullptr) ); std::string ref_str; - EXPECT_CALL(*mock_request, GetOfflinePath()).WillOnce + EXPECT_CALL(*mock_request, GetOfflinePath()).WillRepeatedly (ReturnRef(ref_str)); - EXPECT_CALL(*mock_request, GetFileName()).WillOnce + EXPECT_CALL(*mock_request, GetFileName()).WillRepeatedly (Return("")); - EXPECT_CALL(mock_logger, Warning(HasSubstr("overwriting"))); + EXPECT_CALL(mock_logger, Warning(HasSubstr("overwritting"))); ExpecFileProcess(&asapo::IOErrorTemplates::kFileAlreadyExists, false); ExpecFileProcess(nullptr, true); @@ -109,7 +86,7 @@ TEST_F(FileWriteHandlerTests, FileAlreadyExists_DuplicatedRecordInDb) { EXPECT_CALL(*mock_request, SetResponseMessage(HasSubstr("ignore"), asapo::ResponseMessageType::kWarning)); EXPECT_CALL(*mock_request, SetAlreadyProcessedFlag()); EXPECT_CALL(mock_logger, Warning(HasSubstr("duplicated"))); - EXPECT_CALL(*mock_request, GetDataID()).WillOnce(Return(1)); + EXPECT_CALL(*mock_request, GetDataID()).WillRepeatedly(Return(1)); ExpecFileProcess(&asapo::IOErrorTemplates::kFileAlreadyExists, false); diff --git a/receiver/unittests/request_handler/test_request_handler_initial_authorization.cpp b/receiver/unittests/request_handler/test_request_handler_initial_authorization.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e758290ddb4d70cb59cbcfbf0308884022e0786c --- /dev/null +++ b/receiver/unittests/request_handler/test_request_handler_initial_authorization.cpp @@ -0,0 +1,78 @@ +#include <gtest/gtest.h> +#include <gmock/gmock.h> + +#include "asapo/common/internal/version.h" +#include "asapo/common/networking.h" + +#include "../../src/request_handler/request_handler_initial_authorization.h" +#include "../../src/request.h" +#include "../receiver_mocking.h" + +using namespace testing; +using namespace asapo; + +namespace { + +class InitialAuthorizationHandlerTests : public Test { + public: + AuthorizationData auth_data; + AuthorizationData* expected_auth_data{&auth_data}; + RequestHandlerInitialAuthorization handler{&auth_data}; + asapo::MockAuthorizationClient mock_authorization_client; + std::unique_ptr<MockRequest> mock_request; + + std::string expected_source_credentials = "source_creds"; + + void SetUp() override { + GenericRequestHeader request_header; + mock_request.reset(new MockRequest{request_header, 1, "", nullptr}); + handler.auth_client__ = std::unique_ptr<asapo::AuthorizationClient> {&mock_authorization_client}; + SetDefaultRequestCalls(mock_request.get(),""); + + } + void ExpectAuthMocks() { + EXPECT_CALL(*mock_request, GetApiVersion()).WillRepeatedly(Return(asapo::GetReceiverApiVersion())); + EXPECT_CALL(*mock_request, GetMetaData()) + .WillOnce(ReturnRef(expected_source_credentials)) + ; + EXPECT_CALL(mock_authorization_client, + Authorize_t(mock_request.get(), expected_auth_data)).WillOnce(Return(nullptr)); + } + void TearDown() override { + handler.auth_client__.release(); + } +}; + +TEST_F(InitialAuthorizationHandlerTests, AuthorizeOk) { + ExpectAuthMocks(); + auto err = handler.ProcessRequest(mock_request.get()); + + ASSERT_THAT(err, Eq(nullptr)); + ASSERT_THAT(expected_auth_data->source_credentials, Eq(expected_source_credentials)); + +} + +TEST_F(InitialAuthorizationHandlerTests, ErrorOnSecondAuthorize) { + ExpectAuthMocks(); + + handler.ProcessRequest(mock_request.get()); + auto err = handler.ProcessRequest(mock_request.get()); + + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); +} + +TEST_F(InitialAuthorizationHandlerTests, RequestFromUnsupportedClient) { + EXPECT_CALL(*mock_request, GetApiVersion()) + .WillOnce(Return("v1000.2")); + + auto err = handler.ProcessRequest(mock_request.get()); + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kUnsupportedClient)); +} + +TEST_F(InitialAuthorizationHandlerTests, CheckStatisticEntity) { + auto entity = handler.GetStatisticEntity(); + ASSERT_THAT(entity, Eq(asapo::StatisticEntity::kNetwork)); +} + + +} diff --git a/receiver/unittests/request_handler/test_request_handler_receive_data.cpp b/receiver/unittests/request_handler/test_request_handler_receive_data.cpp index bc9a9116a8b62dc0d31825e3a31b299be211fbbd..d3e679b7c4f57a3459975acf9e0ff18698001b82 100644 --- a/receiver/unittests/request_handler/test_request_handler_receive_data.cpp +++ b/receiver/unittests/request_handler/test_request_handler_receive_data.cpp @@ -12,37 +12,9 @@ #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::MockDataCache; -using asapo::StatisticEntity; - -using asapo::ReceiverConfig; -using asapo::SetReceiverConfig; -using asapo::RequestFactory; -using asapo:: RequestHandlerReceiveData; +using namespace testing; +using namespace asapo; + namespace { TEST(ReceiveData, Constructor) { @@ -97,7 +69,7 @@ void ReceiveDataHandlerTests::ExpectReceive(uint64_t expected_size, bool ok) { EXPECT_CALL(mock_io, Receive_t(socket_fd_, _, expected_size, _)).WillOnce( DoAll( CopyStr(expected_metadata), - SetArgPointee<3>(ok ? nullptr : new asapo::IOError("Test Read Error", asapo::IOErrorType::kReadError)), + SetArgPointee<3>(ok ? nullptr : new asapo::IOError("Test Read Error", "", asapo::IOErrorType::kReadError)), Return(0) )); @@ -176,7 +148,7 @@ TEST_F(ReceiveDataHandlerTests, ErrorGetMemoryFromCache) { auto err = handler.ProcessRequest(request.get()); ASSERT_THAT(request->GetSlotId(), Eq(0)); - ASSERT_THAT(err, Eq(asapo::ErrorTemplates::kMemoryAllocationError)); + ASSERT_THAT(err, Eq(asapo::GeneralErrorTemplates::kMemoryAllocationError)); } diff --git a/receiver/unittests/request_handler/test_request_handler_receive_metadata.cpp b/receiver/unittests/request_handler/test_request_handler_receive_metadata.cpp index fbef728d127d162d4aebf03bb2255b31d322cdff..99b3e4ed5136293068adacbfa3413e763c858266 100644 --- a/receiver/unittests/request_handler/test_request_handler_receive_metadata.cpp +++ b/receiver/unittests/request_handler/test_request_handler_receive_metadata.cpp @@ -12,37 +12,11 @@ #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::MockDataCache; -using asapo::StatisticEntity; - -using asapo::ReceiverConfig; -using asapo::SetReceiverConfig; -using asapo::RequestFactory; -using asapo:: RequestHandlerReceiveMetaData; + +using namespace testing; +using namespace asapo; + + namespace { TEST(ReceiveData, Constructor) { @@ -95,7 +69,7 @@ void ReceiveMetaDataHandlerTests::ExpectReceive(uint64_t expected_size, bool ok) EXPECT_CALL(mock_io, Receive_t(socket_fd_, _, expected_size, _)).WillOnce( DoAll( CopyStr(expected_metadata), - SetArgPointee<3>(ok ? nullptr : new asapo::IOError("Test Read Error", asapo::IOErrorType::kReadError)), + SetArgPointee<3>(ok ? nullptr : new asapo::IOError("Test Read Error", "", asapo::IOErrorType::kReadError)), Return(0) )); diff --git a/receiver/unittests/request_handler/test_request_handler_secondary_authorization.cpp b/receiver/unittests/request_handler/test_request_handler_secondary_authorization.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0e28dcbbeada20f7652a8220f30f53948ad816f4 --- /dev/null +++ b/receiver/unittests/request_handler/test_request_handler_secondary_authorization.cpp @@ -0,0 +1,143 @@ +#include <gtest/gtest.h> +#include <gmock/gmock.h> + +#include <chrono> + +#include "asapo/common/internal/version.h" +#include "asapo/common/networking.h" +#include "asapo/common/data_structs.h" + + +#include "../../src/request_handler/request_handler_secondary_authorization.h" +#include "../../src/request.h" +#include "../receiver_mocking.h" +#include "../mock_receiver_config.h" +#include "../../src/receiver_config.h" + +using namespace testing; +using namespace asapo; + +namespace { + +class SecondaryAuthorizationHandlerTests : public Test { + public: + AuthorizationData auth_data; + ReceiverConfig config; + AuthorizationData* expected_auth_data{&auth_data}; + RequestHandlerSecondaryAuthorization handler{&auth_data}; + asapo::MockAuthorizationClient mock_authorization_client; + std::unique_ptr<NiceMock<MockRequest>> mock_request; + + std::string expected_source_credentials = "source_creds"; + std::string expected_beamtime_id = "expected_beamtime"; + std::string expected_beamline = "expected_beamline"; + std::string expected_data_source = "expected_data_source"; + std::string expected_beamline_path = "expected_beamline_path"; + std::string expected_core_path = "expected_core_path"; + SourceType expected_source_type = SourceType::kProcessed; + + void SetUp() override { + auth_data.data_source = expected_data_source; + auth_data.source_credentials = expected_data_source; + auth_data.source_type = expected_source_type; + auth_data.beamtime_id = expected_beamtime_id; + auth_data.last_update = std::chrono::system_clock::now(); + auth_data.online_path = expected_beamline_path; + auth_data.offline_path = expected_core_path; + auth_data.beamline = expected_beamline; + + auth_data.source_credentials = expected_source_credentials; + GenericRequestHeader request_header; + mock_request.reset(new NiceMock<MockRequest> {request_header, 1, "", nullptr}); + handler.auth_client__ = std::unique_ptr<asapo::AuthorizationClient> {&mock_authorization_client}; + config.authorization_interval_ms = 10000; + SetReceiverConfig(config, "none"); + ON_CALL(*mock_request, GetApiVersion()).WillByDefault(Return(asapo::GetReceiverApiVersion())); + SetDefaultRequestCalls(mock_request.get(),expected_beamtime_id); + + } + void ExpectAuth(); + void ExpectSetRequest() { + EXPECT_CALL(*mock_request, SetBeamtimeId(expected_beamtime_id)); + EXPECT_CALL(*mock_request, SetBeamline(expected_beamline)); + EXPECT_CALL(*mock_request, SetDataSource(expected_data_source)); + EXPECT_CALL(*mock_request, SetOnlinePath(expected_beamline_path)); + EXPECT_CALL(*mock_request, SetOfflinePath(expected_core_path)); + EXPECT_CALL(*mock_request, SetSourceType(expected_source_type)); + } + void TearDown() override { + handler.auth_client__.release(); + } +}; + +ACTION_P(A_WriteCache, beamtime_id) { + ((AuthorizationData*)arg1)->beamtime_id = static_cast<std::string>(beamtime_id); +} + +void SecondaryAuthorizationHandlerTests::ExpectAuth() { + EXPECT_CALL(mock_authorization_client, + Authorize_t(mock_request.get(), expected_auth_data)).WillOnce(DoAll( + A_WriteCache(expected_beamtime_id), + Return(nullptr) + )); +} + + +TEST_F(SecondaryAuthorizationHandlerTests, AuthorizeWithCacheOk) { + ExpectSetRequest(); + + auto err = handler.ProcessRequest(mock_request.get()); + ASSERT_THAT(err, Eq(nullptr)); + ASSERT_THAT(expected_auth_data->source_credentials, Eq(expected_source_credentials)); + ASSERT_THAT(expected_auth_data->beamtime_id, Eq(expected_beamtime_id)); +} + +TEST_F(SecondaryAuthorizationHandlerTests, ReauthorizeOk) { + ExpectAuth(); + ExpectSetRequest(); + auth_data.last_update = std::chrono::system_clock::time_point{}; + + auto err = handler.ProcessRequest(mock_request.get()); + ASSERT_THAT(err, Eq(nullptr)); + ASSERT_THAT(expected_auth_data->source_credentials, Eq(expected_source_credentials)); + ASSERT_THAT(expected_auth_data->beamtime_id, Eq(expected_beamtime_id)); +} + +TEST_F(SecondaryAuthorizationHandlerTests, ReauthorizeWrongBeamtime) { + expected_beamtime_id = "new_beamtime"; + ExpectAuth(); + auth_data.last_update = std::chrono::system_clock::time_point{}; + + auto err = handler.ProcessRequest(mock_request.get()); + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kReAuthorizationFailure)); + ASSERT_THAT(expected_auth_data->source_credentials, Eq("")); +} + +TEST_F(SecondaryAuthorizationHandlerTests, ReauthorizeWithAutherror) { + EXPECT_CALL(mock_authorization_client, Authorize_t(_, _)).WillOnce(Return( + ReceiverErrorTemplates::kAuthorizationFailure.Generate().release())); + auth_data.last_update = std::chrono::system_clock::time_point{}; + + auto err = handler.ProcessRequest(mock_request.get()); + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kReAuthorizationFailure)); + ASSERT_THAT(expected_auth_data->source_credentials, Eq("")); +} + + +TEST_F(SecondaryAuthorizationHandlerTests, ErrorOnEmptyCache) { + auth_data.source_credentials = ""; + + auto err = handler.ProcessRequest(mock_request.get()); + + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kAuthorizationFailure)); +} + +TEST_F(SecondaryAuthorizationHandlerTests, RequestFromUnsupportedClient) { + EXPECT_CALL(*mock_request, GetApiVersion()) + .WillOnce(Return("v1000.2")); + + auto err = handler.ProcessRequest(mock_request.get()); + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kUnsupportedClient)); +} + +} diff --git a/receiver/unittests/request_handler/test_requests_dispatcher.cpp b/receiver/unittests/request_handler/test_requests_dispatcher.cpp index aad695db0406141df911288ce466a8400b66722b..c7831accb35c3ca48c118e3825fded1a086bdce1 100644 --- a/receiver/unittests/request_handler/test_requests_dispatcher.cpp +++ b/receiver/unittests/request_handler/test_requests_dispatcher.cpp @@ -13,43 +13,8 @@ #include "asapo/database/db_error.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::SocketDescriptor; -using asapo::GenericRequestHeader; -using asapo::SendResponse; -using asapo::GenericRequestHeader; -using asapo::GenericNetworkResponse; -using asapo::Opcode; -using asapo::MockIO; -using asapo::MockLogger; -using asapo::Request; -using asapo::Statistics; -using asapo::StatisticEntity; -using asapo::MockStatistics; - - -using asapo::RequestsDispatcher; -using asapo::ReceiverStatistics; +using namespace testing; +using namespace asapo; namespace { @@ -64,8 +29,8 @@ TEST(RequestDispatcher, Constructor) { class MockRequest: public Request { public: - MockRequest(const GenericRequestHeader& request_header, SocketDescriptor socket_fd): - Request(request_header, socket_fd, "", nullptr, nullptr) {}; + MockRequest(const GenericRequestHeader& request_header, SocketDescriptor socket_fd, std::string uri = ""): + Request(request_header, socket_fd, uri, nullptr, nullptr) {}; Error Handle(ReceiverStatistics*) override { return Error{Handle_t()}; }; @@ -109,7 +74,7 @@ class RequestsDispatcherTests : public Test { asapo::ReceiverConfig test_config; GenericRequestHeader header; - MockRequest mock_request{GenericRequestHeader{}, 1}; + MockRequest mock_request{GenericRequestHeader{}, 1, connected_uri}; std::unique_ptr<Request> request{&mock_request}; GenericNetworkResponse response; void SetUp() override { @@ -134,7 +99,7 @@ class RequestsDispatcherTests : public Test { Return(0)) ); if (error) { - EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("getting next request"), HasSubstr(connected_uri)))); + EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("cannot get next request"), HasSubstr(connected_uri)))); } } @@ -145,33 +110,32 @@ class RequestsDispatcherTests : public Test { Return(nullptr)) ); if (error) { - EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("error processing request from"), HasSubstr(connected_uri)))); + EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("error"), HasSubstr(connected_uri)))); } } void MockHandleRequest(int error_mode, Error err = asapo::IOErrorTemplates::kUnknownIOError.Generate() ) { - EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("processing request"), HasSubstr(connected_uri)))); + EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("got new request"), HasSubstr(connected_uri)))); EXPECT_CALL(mock_request, Handle_t()).WillOnce( Return(error_mode > 0 ? err.release() : nullptr) ); if (error_mode == 1) { - EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("error processing request from"), HasSubstr(connected_uri)))); + EXPECT_CALL(mock_logger, Error(_)); } else if (error_mode == 2) { - EXPECT_CALL(mock_logger, Warning(AllOf(HasSubstr("warning processing request from"), HasSubstr(connected_uri)))); + EXPECT_CALL(mock_logger, Warning(_)); } } void MockSendResponse(GenericNetworkResponse* response, bool error ) { - EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("sending response to"), HasSubstr(connected_uri)))); - ; + EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("sending response"), HasSubstr(connected_uri)))); EXPECT_CALL(mock_io, Send_t(_, _, _, _)).WillOnce( DoAll(SetArgPointee<3>(error ? asapo::IOErrorTemplates::kConnectionRefused.Generate().release() : nullptr), SaveArg1ToGenericNetworkResponse(response), Return(0) )); if (error) { - EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("error sending response"), HasSubstr(connected_uri)))); + EXPECT_CALL(mock_logger, Error(AllOf(HasSubstr("cannot send response"), HasSubstr(connected_uri)))); } return; @@ -186,7 +150,7 @@ TEST_F(RequestsDispatcherTests, ErrorReceivetNextRequest) { Error err; dispatcher->GetNextRequest(&err); - ASSERT_THAT(err, Eq(asapo::IOErrorTemplates::kUnknownIOError)); + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kProcessingError)); } @@ -194,16 +158,13 @@ TEST_F(RequestsDispatcherTests, ClosedConnectionOnReceivetNextRequest) { EXPECT_CALL(mock_statictics, StartTimer_t(StatisticEntity::kNetwork)); EXPECT_CALL(mock_io, Receive_t(_, _, _, _)) .WillOnce( - DoAll(SetArgPointee<3>(asapo::ErrorTemplates::kEndOfFile.Generate().release()), + DoAll(SetArgPointee<3>(asapo::GeneralErrorTemplates::kEndOfFile.Generate().release()), Return(0)) ); - EXPECT_CALL(mock_logger, Debug(AllOf(HasSubstr("peer has performed an orderly shutdown"), - HasSubstr("getting next request"), HasSubstr(connected_uri)))); - Error err; dispatcher->GetNextRequest(&err); - ASSERT_THAT(err, Eq(asapo::ErrorTemplates::kEndOfFile)); + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kProcessingError)); } @@ -215,7 +176,7 @@ TEST_F(RequestsDispatcherTests, ErrorCreatetNextRequest) { Error err; dispatcher->GetNextRequest(&err); - ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kInvalidOpCode)); + ASSERT_THAT(err, Eq(asapo::IOErrorTemplates::kUnknownIOError)); } TEST_F(RequestsDispatcherTests, OkCreatetNextRequest) { @@ -245,7 +206,7 @@ TEST_F(RequestsDispatcherTests, OkProcessRequestErrorSend) { auto err = dispatcher->ProcessRequest(request); - ASSERT_THAT(err, Eq(asapo::IOErrorTemplates::kConnectionRefused)); + ASSERT_THAT(err, Eq(asapo::ReceiverErrorTemplates::kProcessingError)); } 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..d6c2eb77997b113e0c985b112e89050e7896d951 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 { @@ -84,7 +64,7 @@ TEST_F(SenderInfluxDbTests, SendStatisticsCallsPost) { "n_requests=4,db_share=0.1000,network_share=0.3000,disk_share=0.6000"; EXPECT_CALL(mock_http_client, Post_t("test_uri/write?db=test_name", _, expect_string, _, _)). WillOnce( - DoAll(SetArgPointee<4>(new asapo::IOError("Test Read Error", asapo::IOErrorType::kReadError)), + DoAll(SetArgPointee<4>(new asapo::IOError("Test Read Error", "", asapo::IOErrorType::kReadError)), Return("") )); 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..d8d24445a227ebd121a83cadd3f3b547a3307ac1 100644 --- a/receiver/unittests/test_connection.cpp +++ b/receiver/unittests/test_connection.cpp @@ -2,57 +2,14 @@ #include <gmock/gmock.h> #include "asapo/unittests/MockIO.h" +#include "asapo/common/error.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 { @@ -115,7 +72,7 @@ class ConnectionTests : public Test { if (error ) { EXPECT_CALL(mock_dispatcher, GetNextRequest_t(_)) .WillOnce(DoAll( - SetArgPointee<0>(new asapo::SimpleError{"error"}), + SetArgPointee<0>(asapo::GeneralErrorTemplates::kSimpleError.Generate("error").release()), Return(nullptr) )); return nullptr; @@ -135,7 +92,7 @@ class ConnectionTests : public Test { if (error ) { EXPECT_CALL(mock_dispatcher, ProcessRequest_t(request)) .WillOnce( - Return(new asapo::SimpleError{"error"}) + Return(asapo::GeneralErrorTemplates::kSimpleError.Generate("error").release()) ); } else { EXPECT_CALL(mock_dispatcher, ProcessRequest_t(request)) 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 512eca149db0f0ffbe8cfd3bd0bb247c011cf742..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) { @@ -39,6 +23,7 @@ class StartListenerFixture : public testing::Test { const asapo::SocketDescriptor expected_socket_descriptor = 20; const asapo::SocketDescriptor expected_socket_descriptor_client = 23; const std::string expected_address = "somehost:13579"; + const std::string expected_host = "somehost"; const uint64_t expected_file_id = 314322; const uint64_t expected_file_size = 784387; const FileDescriptor expected_fd = 12643; @@ -103,7 +88,7 @@ TEST_F(StartListenerFixture, Ok) { Return(nullptr) ); - EXPECT_CALL(mock_logger, Info(HasSubstr("new connection from " + expected_address))); + EXPECT_CALL(mock_logger, Info(AllOf(HasSubstr("new connection"), HasSubstr(expected_host)))); receiver.Listen(expected_address, &err, true); diff --git a/receiver/unittests/test_request.cpp b/receiver/unittests/test_request.cpp index 93d018c37b86b12dfca749f1b0f5f29ba639f444..a8c96669096df6cd64ed805e987fb856e2696e53 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 { @@ -119,7 +85,7 @@ TEST_F(RequestTests, HandleProcessesRequests) { EXPECT_CALL(mock_request_handler, ProcessRequest_t(_)).WillOnce( Return(nullptr) ).WillOnce( - Return(new asapo::IOError("Test Send Error", asapo::IOErrorType::kUnknownIOError)) + Return(new asapo::IOError("Test Send Error", "", asapo::IOErrorType::kUnknownIOError)) ); request->AddHandler(&mock_request_handler); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4fbf5ab06f9058a9f31ff4a938826d91a31f9f06..3a5d764fc2e24c793cd399f432eb1aa3243f7f54 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,9 +1 @@ add_subdirectory(automatic) - - -configure_files(${CMAKE_CURRENT_SOURCE_DIR}/manual/tests_via_nomad ${CMAKE_CURRENT_BINARY_DIR}/manual/tests_via_nomad @ONLY) - -add_subdirectory(manual/performance_broker_receiver) - -add_subdirectory(manual/asapo_fabric) -add_subdirectory(manual/producer_cpp) diff --git a/tests/automatic/CMakeLists.txt b/tests/automatic/CMakeLists.txt index bf5f7ca3bc632f771b358b8e0fa5bfce39b44914..9f8a5fc243b467afd24f04547c52d9cfa35c1e23 100644 --- a/tests/automatic/CMakeLists.txt +++ b/tests/automatic/CMakeLists.txt @@ -3,9 +3,10 @@ find_package(Threads) add_subdirectory(common_scripts) - +add_subdirectory(support/getnext) add_subdirectory(common/cpp) + add_subdirectory(system_io) add_subdirectory(json_parser) 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/broker/check_monitoring/check_linux.sh b/tests/automatic/broker/check_monitoring/check_linux.sh index 734ffd75b0e3a3595a93d8f7262f71e85f2da10b..d0b81c6ee5bfeaaf635fa83be46c8238ba98a7e2 100644 --- a/tests/automatic/broker/check_monitoring/check_linux.sh +++ b/tests/automatic/broker/check_monitoring/check_linux.sh @@ -9,10 +9,10 @@ trap Cleanup EXIT Cleanup() { set +e echo cleanup - influx -execute "drop database ${database_name}" + influx -database ${database_name} -execute "drop series from statistics, RequestsRate" } -! influx -execute "drop database ${database_name}" +! influx -database ${database_name} -execute "drop series from statistics, RequestsRate" token=$BT_DATA_TOKEN diff --git a/tests/automatic/consumer/consumer_api/consumer_api.c b/tests/automatic/consumer/consumer_api/consumer_api.c index d9996dddedfb6461620e0c0a267275efbd311742..34f23dfe0df64df089cd4f8ecb3fad887d236cc2 100644 --- a/tests/automatic/consumer/consumer_api/consumer_api.c +++ b/tests/automatic/consumer/consumer_api/consumer_api.c @@ -2,7 +2,6 @@ #include "testing_c.h" #include <string.h> -#include <stdio.h> #include <stdlib.h> void test_datasets(AsapoConsumerHandle consumer, AsapoStringHandle group_id) { diff --git a/tests/automatic/consumer/consumer_api/consumer_api.cpp b/tests/automatic/consumer/consumer_api/consumer_api.cpp index 4e1f99ec0320f10b265715a2c3632bffad4c5f6e..f388fd945e8f9f7ce6fdcf3a735018788300c359 100644 --- a/tests/automatic/consumer/consumer_api/consumer_api.cpp +++ b/tests/automatic/consumer/consumer_api/consumer_api.cpp @@ -1,5 +1,4 @@ #include <iostream> -#include <vector> #include <thread> #include <algorithm> #include <asapo/asapo_consumer.h> @@ -161,9 +160,9 @@ void TestSingle(const std::unique_ptr<asapo::Consumer>& consumer, const std::str M_AssertTrue(streams[0].name == "default", "streams0.name"); M_AssertTrue(streams[1].name == "stream1", "streams1.name"); M_AssertTrue(streams[2].name == "stream2", "streams2.name"); - M_AssertTrue(streams[1].finished == true, "stream1 finished"); + M_AssertTrue(streams[1].finished, "stream1 finished"); M_AssertTrue(streams[1].next_stream == "ns", "stream1 next stream"); - M_AssertTrue(streams[2].finished == true, "stream2 finished"); + M_AssertTrue(streams[2].finished, "stream2 finished"); M_AssertTrue(streams[2].next_stream == "", "stream2 no next stream"); M_AssertTrue(asapo::NanosecsEpochFromTimePoint(streams[0].timestamp_created) == 0, "streams0.timestamp"); M_AssertTrue(asapo::NanosecsEpochFromTimePoint(streams[0].timestamp_lastentry) == 0, "streams0.timestamp lastentry"); @@ -356,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/full_chain/simple_chain/check_linux.sh b/tests/automatic/full_chain/simple_chain/check_linux.sh index a442e63f4227d6554285670167db9ab334e8c850..ac9a737c668eb860c96eb2f3234b8d5e76d45a85 100755 --- a/tests/automatic/full_chain/simple_chain/check_linux.sh +++ b/tests/automatic/full_chain/simple_chain/check_linux.sh @@ -25,7 +25,7 @@ Cleanup() { rm -rf ${receiver_root_folder} rm -rf out echo "db.dropDatabase()" | mongo ${beamtime_id}_detector - influx -execute "drop database ${monitor_database_name}" + influx -database ${monitor_database_name} -execute "drop series from statistics, RequestsRate" } token=`$asapo_tool_bin token -endpoint http://localhost:8400/asapo-authorizer -secret admin_token.key -types read $beamtime_id` diff --git a/tests/automatic/full_chain/simple_chain_dataset/check_linux.sh b/tests/automatic/full_chain/simple_chain_dataset/check_linux.sh index 165f48f54a0dbeb636017751b44967b1fb209b34..15964cc6e2b423dcb190e40704591badbe4d713b 100644 --- a/tests/automatic/full_chain/simple_chain_dataset/check_linux.sh +++ b/tests/automatic/full_chain/simple_chain_dataset/check_linux.sh @@ -26,7 +26,7 @@ Cleanup() { rm -rf ${receiver_root_folder} rm -rf out echo "db.dropDatabase()" | mongo ${beamtime_id}_detector - influx -execute "drop database ${monitor_database_name}" + influx -database ${monitor_database_name} -execute "drop series from statistics, RequestsRate" } token=`$asapo_tool_bin token -endpoint http://localhost:8400/asapo-authorizer -secret admin_token.key -types read $beamtime_id` diff --git a/tests/automatic/full_chain/simple_chain_filegen_readdata_cache/check_linux.sh b/tests/automatic/full_chain/simple_chain_filegen_readdata_cache/check_linux.sh index 7c22a733b5cb10e57e9f004b82951b63decd339f..00391dff42752e43ee8ee50eaec14060486c4f7c 100644 --- a/tests/automatic/full_chain/simple_chain_filegen_readdata_cache/check_linux.sh +++ b/tests/automatic/full_chain/simple_chain_filegen_readdata_cache/check_linux.sh @@ -40,7 +40,7 @@ Cleanup() { kill -9 $producerid rm -rf /tmp/asapo/test_in rm -rf ${receiver_folder} - influx -execute "drop database ${monitor_database_name}" + influx -database ${monitor_database_name} -execute "drop series from statistics, RequestsRate" echo "db.dropDatabase()" | mongo ${beamtime_id}_detector rm out.txt } diff --git a/tests/automatic/full_chain/simple_chain_filegen_readdata_file/check_linux.sh b/tests/automatic/full_chain/simple_chain_filegen_readdata_file/check_linux.sh index e3f49565c663a9e7cb61283ff932abf0e0165414..36e82adc9cdb5761f3c47f6e80ff0f1f9e85a1f7 100644 --- a/tests/automatic/full_chain/simple_chain_filegen_readdata_file/check_linux.sh +++ b/tests/automatic/full_chain/simple_chain_filegen_readdata_file/check_linux.sh @@ -27,7 +27,7 @@ Cleanup() { kill -9 $producerid rm -rf /tmp/asapo/test_in rm -rf ${receiver_folder} - influx -execute "drop database ${monitor_database_name}" + influx -database ${monitor_database_name} -execute "drop series from statistics, RequestsRate" echo "db.dropDatabase()" | mongo ${beamtime_id}_detector rm out.txt } diff --git a/tests/automatic/full_chain/simple_chain_metadata/check_linux.sh b/tests/automatic/full_chain/simple_chain_metadata/check_linux.sh index c0707599e13490f1e27acca4b5a2d241570729ff..b7594898e3a9a70412da154ae9b5aebb9609d937 100644 --- a/tests/automatic/full_chain/simple_chain_metadata/check_linux.sh +++ b/tests/automatic/full_chain/simple_chain_metadata/check_linux.sh @@ -25,7 +25,7 @@ Cleanup() { rm -rf ${receiver_root_folder} rm -rf out echo "db.dropDatabase()" | mongo ${beamtime_id}_detector - influx -execute "drop database ${monitor_database_name}" + influx -database ${monitor_database_name} -execute "drop series from statistics, RequestsRate" } token=`$asapo_tool_bin token -endpoint http://localhost:8400/asapo-authorizer -secret admin_token.key -types read $beamtime_id` diff --git a/tests/automatic/full_chain/simple_chain_raw/check_linux.sh b/tests/automatic/full_chain/simple_chain_raw/check_linux.sh index 109485d11a69321dfeb78938c64114722f50a96b..50214fb8142196677507e532e26f33bc11a8c643 100644 --- a/tests/automatic/full_chain/simple_chain_raw/check_linux.sh +++ b/tests/automatic/full_chain/simple_chain_raw/check_linux.sh @@ -19,7 +19,7 @@ Cleanup() { echo cleanup rm -rf out /tmp/asapo/asap3 /tmp/asapo/beamline echo "db.dropDatabase()" | mongo ${beamtime_id}_detector - influx -execute "drop database ${monitor_database_name}" + influx -database ${monitor_database_name} -execute "drop series from statistics, RequestsRate" } echo "db.dropDatabase()" | mongo ${beamtime_id}_detector diff --git a/tests/automatic/full_chain/simple_chain_usermeta_python/check_linux.sh b/tests/automatic/full_chain/simple_chain_usermeta_python/check_linux.sh index 53a8e3485a0bd5e016653b430aedf0890e004e9d..4054fef2804ddf41f3bf024f7ec467cfaa3daad4 100644 --- a/tests/automatic/full_chain/simple_chain_usermeta_python/check_linux.sh +++ b/tests/automatic/full_chain/simple_chain_usermeta_python/check_linux.sh @@ -24,7 +24,7 @@ Cleanup() { rm -rf ${receiver_root_folder} rm -rf out echo "db.dropDatabase()" | mongo ${beamtime_id}_detector - influx -execute "drop database ${monitor_database_name}" + influx -database ${monitor_database_name} -execute "drop series from statistics, RequestsRate" } token=`$asapo_tool_bin token -endpoint http://localhost:8400/asapo-authorizer -secret admin_token.key -types read $beamtime_id` diff --git a/tests/automatic/full_chain/two_beamlines/check_linux.sh b/tests/automatic/full_chain/two_beamlines/check_linux.sh index 057dd44c055fd9359f18e312078b51ba722b7c16..75be4ed22026e9719d0e328dfda1218e3ab16c87 100644 --- a/tests/automatic/full_chain/two_beamlines/check_linux.sh +++ b/tests/automatic/full_chain/two_beamlines/check_linux.sh @@ -43,7 +43,7 @@ Cleanup() { rm -rf ${receiver_root_folder} echo "db.dropDatabase()" | mongo ${beamtime_id1}_${data_source} echo "db.dropDatabase()" | mongo ${beamtime_id2}_${data_source} - influx -execute "drop database ${monitor_database_name}" + influx -database ${monitor_database_name} -execute "drop series from statistics, RequestsRate" } if [[ $network_type == "fabric" ]]; then diff --git a/tests/automatic/high_avail/broker_mongo_restart/check_linux.sh b/tests/automatic/high_avail/broker_mongo_restart/check_linux.sh index fc8a1a4869bfab4e436535145bbd3d6249c59d0b..a3a9895ec010fbec8dd0afe573e7c6950571fca5 100755 --- a/tests/automatic/high_avail/broker_mongo_restart/check_linux.sh +++ b/tests/automatic/high_avail/broker_mongo_restart/check_linux.sh @@ -52,7 +52,7 @@ Cleanup() { kill $producerid kill $workerid echo "db.dropDatabase()" | mongo --port 27015 ${beamtime_id}_detector || echo "db.dropDatabase()" | mongo --port 27016 ${beamtime_id}_detector - influx -execute "drop database ${monitor_database_name}" + influx -database ${monitor_database_name} -execute "drop series from statistics, RequestsRate" kill_mongo 27015 || kill_mongo 27016 sed -i 's/27015/27017/g' discovery.json.tpl nomad stop discovery diff --git a/tests/automatic/high_avail/services_restart/check_linux.sh b/tests/automatic/high_avail/services_restart/check_linux.sh index fa784e08b6aa1692d79b0cd82c39ea9e86bdc4f2..840d3e97cc89d16712fe52314efe13947d94ab4f 100644 --- a/tests/automatic/high_avail/services_restart/check_linux.sh +++ b/tests/automatic/high_avail/services_restart/check_linux.sh @@ -26,7 +26,7 @@ Cleanup() { rm -rf ${receiver_folder} echo "db.dropDatabase()" | mongo ${beamtime_id}_detector set +e - influx -execute "drop database ${monitor_database_name}" + influx -database ${monitor_database_name} -execute "drop series from statistics, RequestsRate" } diff --git a/tests/automatic/mongo_db/auto_id/auto_id.cpp b/tests/automatic/mongo_db/auto_id/auto_id.cpp index 019017e3e2041cb968be43c4b3a47ef5f9b9c84d..337360aa8d5a365445ea6d8636d3c8ddb0f2baa9 100644 --- a/tests/automatic/mongo_db/auto_id/auto_id.cpp +++ b/tests/automatic/mongo_db/auto_id/auto_id.cpp @@ -51,7 +51,7 @@ Args GetArgs(int argc, char* argv[]) { return args; } -void insert(const asapo::MongoDBClient& db, const std::string& name, asapo::MessageMeta fi, const Args& args) { +void Insert(const asapo::MongoDBClient& db, const std::string& name, asapo::MessageMeta fi, const Args& args) { auto start = fi.id; for (int i = 0; i < args.n_messages_per_thread; i++) { switch (args.mode) { @@ -61,14 +61,11 @@ void insert(const asapo::MongoDBClient& db, const std::string& name, asapo::Mess case Mode::kUpdateCounterThenIngest: fi.id = start + static_cast<uint64_t>(i) + 1; break; - default: - abort(); } uint64_t inserted_id{0}; Error err = db.Insert(std::string("data_") + name, fi, false, &inserted_id); if (err != nullptr) { printf("%s\n", err->Explain().c_str()); -// break; } else { if (inserted_id == 0) { M_AssertTrue(false); @@ -92,7 +89,7 @@ int main(int argc, char* argv[]) { fi.source = "host:1234"; fi.id = static_cast<uint64_t>(args.n_messages_per_thread * i); db.Connect("127.0.0.1", db_name); - insert(db, "stream", fi, args); + Insert(db, "stream", fi, args); }; auto t1 = high_resolution_clock::now(); @@ -121,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 2e51f8eac29661a3645a63d7eb8d98f70e2870b2..0beb953e44fc5d3473d9e83a017005727998e172 100644 --- a/tests/automatic/mongo_db/insert_retrieve/insert_retrieve_mongodb.cpp +++ b/tests/automatic/mongo_db/insert_retrieve/insert_retrieve_mongodb.cpp @@ -117,15 +117,15 @@ int main(int argc, char* argv[]) { db.Insert(std::string("acks_") + stream_name + "_blabla", fi, false, nullptr); db.Insert(std::string("acks_") + stream_name + "_blabla1", fi, false, nullptr); db.DeleteStream(stream_name); - err = db.GetStreamInfo(std::string("data_") + stream_name, &info); + db.GetStreamInfo(std::string("data_") + stream_name, &info); M_AssertTrue(info.last_id == 0); - err = db.GetStreamInfo(std::string("inprocess_") + stream_name + "_blabla", &info); + db.GetStreamInfo(std::string("inprocess_") + stream_name + "_blabla", &info); M_AssertTrue(info.last_id == 0); - err = db.GetStreamInfo(std::string("inprocess_") + stream_name + "_blabla1", &info); + db.GetStreamInfo(std::string("inprocess_") + stream_name + "_blabla1", &info); M_AssertTrue(info.last_id == 0); - err = db.GetStreamInfo(std::string("acks_") + stream_name + "_blabla", &info); + db.GetStreamInfo(std::string("acks_") + stream_name + "_blabla", &info); M_AssertTrue(info.last_id == 0); - err = db.GetStreamInfo(std::string("acks_") + stream_name + "_blabla1", &info); + db.GetStreamInfo(std::string("acks_") + stream_name + "_blabla1", &info); M_AssertTrue(info.last_id == 0); err = db.DeleteStream("test1"); M_AssertTrue(err == nullptr); @@ -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 4217c48e68601c211beba898c5d0bb9b752af71c..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 @@ -54,7 +54,7 @@ int main(int argc, char* argv[]) { if (args.keyword == "DuplicateID") { Assert(err, "OK"); - err = db.InsertAsDatasetMessage("data_test", fi, dataset_size, true); + db.InsertAsDatasetMessage("data_test", fi, dataset_size, true); err = db.InsertAsDatasetMessage("data_test", fi, dataset_size, false); } @@ -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 6a9f07b0c87eda088640d247e9c463698e989b78..abae70c4e1d9d8d825005f9d2a61c65be5fbe3de 100644 --- a/tests/automatic/mongo_db/meta/meta_mongodb.cpp +++ b/tests/automatic/mongo_db/meta/meta_mongodb.cpp @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) { Assert(err, args.keyword); if (args.keyword == "OK") { - asapo::MetaIngestMode mode{asapo::MetaIngestOp::kInsert, false}; + mode = {asapo::MetaIngestOp::kInsert, false}; std::string meta = R"({"data":"test","data1":"test1","embedded":{"edata":1}})"; err = db.InsertMeta("meta", stream_name, reinterpret_cast<const uint8_t*>(meta.c_str()), meta.size(), mode); @@ -78,7 +78,7 @@ int main(int argc, char* argv[]) { M_AssertTrue(err == asapo::DBErrorTemplates::kWrongInput); std::string meta_res; - err = db.GetMetaFromDb("meta", "0", &meta_res); + db.GetMetaFromDb("meta", "0", &meta_res); M_AssertEq(meta_res, json); @@ -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/aai/check_windows.bat b/tests/automatic/producer/aai/check_windows.bat index b576b7e959e9addbd90f46051ca0a5e6c8055994..28a3e3c9d0e230b2f91e1bba3df56382218b17d9 100644 --- a/tests/automatic/producer/aai/check_windows.bat +++ b/tests/automatic/producer/aai/check_windows.bat @@ -33,7 +33,7 @@ echo %NUM% | findstr 3 || goto error for /F %%N in ('find /C "reauthorization" ^< "out"') do set NUM=%%N echo %NUM% | findstr 1 || goto error -for /F %%N in ('find /C "} server warning: duplicated request" ^< "out"') do set NUM=%%N +for /F %%N in ('find /C "} error: server warning, context: response:duplicated request" ^< "out"') do set NUM=%%N echo %NUM% | findstr 1 || goto error goto :clean diff --git a/tests/automatic/producer/c_api/producer_api.c b/tests/automatic/producer/c_api/producer_api.c index 2aee99a912477ba2dca2fab789d39bb2e456c936..2829064da3461e38e539065c1f391bebc88f124c 100644 --- a/tests/automatic/producer/c_api/producer_api.c +++ b/tests/automatic/producer/c_api/producer_api.c @@ -2,7 +2,6 @@ #include "testing_c.h" #include <string.h> -#include <stdio.h> #include <stdlib.h> void callback(void* original_data, AsapoRequestCallbackPayloadHandle payload, AsapoErrorHandle error) { @@ -52,13 +51,13 @@ void test_meta(AsapoProducerHandle producer) { asapo_producer_wait_requests_finished(producer,5000,NULL); AsapoStringHandle meta_received = asapo_producer_get_beamtime_meta(producer,5000, &err); EXIT_IF_ERROR("asapo_producer_get_beamtime_meta", err); - ASSERT_EQ_STRING(meta,(const char*)asapo_string_c_str(meta_received),"returned same meta as was ingested"); + ASSERT_EQ_STRING(meta,asapo_string_c_str(meta_received),"returned same meta as was ingested"); asapo_producer_send_stream_metadata(producer,meta,kInsert,1,"default", NULL,&err); asapo_producer_wait_requests_finished(producer,5000,NULL); AsapoStringHandle stream_meta_received = asapo_producer_get_stream_meta(producer,"default",5000, &err); EXIT_IF_ERROR("asapo_producer_send_stream_metadata", err); - ASSERT_EQ_STRING(meta,(const char*)asapo_string_c_str(stream_meta_received),"stream meta returned same meta as was ingested"); + ASSERT_EQ_STRING(meta,asapo_string_c_str(stream_meta_received),"stream meta returned same meta as was ingested"); asapo_free_handle(&err); asapo_free_handle(&meta_received); asapo_free_handle(&stream_meta_received); @@ -120,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 d5e5982ab635c69bbbd2a55283465ab48396e0bd..699c3978d3c32851019bfae5b220d3a1eca0c2e7 100644 --- a/tests/automatic/producer/cpp_api/producer_api.cpp +++ b/tests/automatic/producer/cpp_api/producer_api.cpp @@ -1,5 +1,4 @@ #include <iostream> -#include <vector> #include <thread> #include <algorithm> #include <asapo/asapo_producer.h> @@ -95,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/producer/python_api/check_windows.bat b/tests/automatic/producer/python_api/check_windows.bat index c854be8786882fa78123896faabca55d1054942c..5920874f07bc788076de2dc13087d312561e8fb8 100644 --- a/tests/automatic/producer/python_api/check_windows.bat +++ b/tests/automatic/producer/python_api/check_windows.bat @@ -20,13 +20,13 @@ set NUM=0 for /F %%N in ('find /C "successfuly sent" ^< "out"') do set NUM=%%N echo %NUM% | findstr 17 || goto error -for /F %%N in ('find /C "} wrong input: Bad request: already have record with same id" ^< "out"') do set NUM=%%N +for /F %%N in ('find /C "} error: wrong input, context: response:error: Bad request, message: already have record with same id" ^< "out"') do set NUM=%%N echo %NUM% | findstr 2 || goto error -for /F %%N in ('find /C "} server warning: ignoring duplicate record" ^< "out"') do set NUM=%%N +for /F %%N in ('find /C "} error: server warning, context: response:ignoring duplicate record" ^< "out"') do set NUM=%%N echo %NUM% | findstr 2 || goto error -for /F %%N in ('find /C "} server warning: duplicated request" ^< "out"') do set NUM=%%N +for /F %%N in ('find /C "} error: server warning, context: response:duplicated request" ^< "out"') do set NUM=%%N echo %NUM% | findstr 1 || goto error diff --git a/tests/automatic/producer_receiver/check_monitoring/check_linux.sh b/tests/automatic/producer_receiver/check_monitoring/check_linux.sh index cf0863c9b152382e380a7f0c2d0ef1dc7a0d072a..8c08a2f3d30873a9bda0e608f6ac2fe9c4e43462 100644 --- a/tests/automatic/producer_receiver/check_monitoring/check_linux.sh +++ b/tests/automatic/producer_receiver/check_monitoring/check_linux.sh @@ -14,7 +14,7 @@ trap Cleanup EXIT Cleanup() { echo cleanup - influx -execute "drop database ${database_name}" + influx -database ${database_name} -execute "drop series from statistics, RequestsRate" echo "db.dropDatabase()" | mongo ${beamtime_id}_detector rm -rf ${receiver_root_folder} } diff --git a/tests/automatic/producer_receiver/transfer_datasets/check_linux.sh b/tests/automatic/producer_receiver/transfer_datasets/check_linux.sh index 2207d5a305ee1b0fa8e1288672bbfe7619ab5c16..1adb4357351474943a6a5ff3406617e31c0c409b 100644 --- a/tests/automatic/producer_receiver/transfer_datasets/check_linux.sh +++ b/tests/automatic/producer_receiver/transfer_datasets/check_linux.sh @@ -17,7 +17,7 @@ Cleanup() { echo cleanup rm -rf ${receiver_root_folder} echo "db.dropDatabase()" | mongo ${beamtime_id}_detector - influx -execute "drop database ${database_name}" + influx -database ${database_name} -execute "drop series from statistics, RequestsRate" } mkdir -p ${receiver_folder} diff --git a/tests/automatic/producer_receiver/transfer_single_file/check_linux.sh b/tests/automatic/producer_receiver/transfer_single_file/check_linux.sh index 90d116c91ce60bbb7c9a4a4a2ab1b84119ab6477..a02c953d9add44aa540f961e8487fef1a80be9bc 100644 --- a/tests/automatic/producer_receiver/transfer_single_file/check_linux.sh +++ b/tests/automatic/producer_receiver/transfer_single_file/check_linux.sh @@ -17,7 +17,7 @@ Cleanup() { echo cleanup rm -rf ${receiver_root_folder} echo "db.dropDatabase()" | mongo ${beamtime_id}_detector - influx -execute "drop database ${database_name}" + influx -database ${database_name} -execute "drop series from statistics, RequestsRate" } mkdir -p ${receiver_folder} diff --git a/tests/automatic/producer_receiver/transfer_single_file_bypass_buffer/check_linux.sh b/tests/automatic/producer_receiver/transfer_single_file_bypass_buffer/check_linux.sh index 1da3b56b61ce312af68c19ec582e0c2cc6e056c5..357c9185d353de2cb697ca5cb3ad998d3781730d 100644 --- a/tests/automatic/producer_receiver/transfer_single_file_bypass_buffer/check_linux.sh +++ b/tests/automatic/producer_receiver/transfer_single_file_bypass_buffer/check_linux.sh @@ -18,7 +18,7 @@ Cleanup() { echo cleanup rm -rf ${receiver_root_folder} echo "db.dropDatabase()" | mongo ${beamtime_id}_detector - influx -execute "drop database ${database_name}" + influx -database ${database_name} -execute "drop series from statistics, RequestsRate" } mkdir -p ${receiver_folder} 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 42c19b5e9b96f0c186dcf7d1b2b1341865001970..fd0c8bcf4ee897e4f3c14d8091a20028a0d37491 100644 --- a/tests/automatic/spd_logger/fluentd/spd_logger_fluentd.cpp +++ b/tests/automatic/spd_logger/fluentd/spd_logger_fluentd.cpp @@ -1,6 +1,3 @@ -#include <thread> -#include <vector> - #include "asapo/logger/logger.h" using namespace asapo; @@ -16,5 +13,5 @@ int main() { logger->Warning("test warning"); logger->Debug("test debug"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/manual/performance_broker_receiver/CMakeLists.txt b/tests/automatic/support/getnext/CMakeLists.txt similarity index 63% rename from tests/manual/performance_broker_receiver/CMakeLists.txt rename to tests/automatic/support/getnext/CMakeLists.txt index aee1d949e531283ba228feb2206593f37738e04d..f96714ed71b50d27a54016372658ca3b73481feb 100644 --- a/tests/manual/performance_broker_receiver/CMakeLists.txt +++ b/tests/automatic/support/getnext/CMakeLists.txt @@ -1,6 +1,7 @@ -set(TARGET_NAME getlast_broker) -set(SOURCE_FILES getlast_broker.cpp) +set(TARGET_NAME getnext) +set(SOURCE_FILES getnext.cpp) +if (BUILD_EXAMPLES) add_executable(${TARGET_NAME} ${SOURCE_FILES}) target_link_libraries(${TARGET_NAME} asapo-consumer) @@ -10,8 +11,6 @@ set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}$<$<CONFIG:Debug>:> ) -get_target_property(VAR ${TARGET_NAME} RUNTIME_OUTPUT_DIRECTORY) -add_dependencies(${TARGET_NAME} asapo-broker) - - +add_script_test("${TARGET_NAME}" "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}") +endif() \ No newline at end of file diff --git a/examples/consumer/getnext/Makefile.in b/tests/automatic/support/getnext/Makefile.in similarity index 100% rename from examples/consumer/getnext/Makefile.in rename to tests/automatic/support/getnext/Makefile.in diff --git a/examples/consumer/getnext/check_linux.sh b/tests/automatic/support/getnext/check_linux.sh similarity index 100% rename from examples/consumer/getnext/check_linux.sh rename to tests/automatic/support/getnext/check_linux.sh diff --git a/examples/consumer/getnext/check_windows.bat b/tests/automatic/support/getnext/check_windows.bat similarity index 100% rename from examples/consumer/getnext/check_windows.bat rename to tests/automatic/support/getnext/check_windows.bat diff --git a/examples/consumer/getnext/getnext.cpp b/tests/automatic/support/getnext/getnext.cpp similarity index 99% rename from examples/consumer/getnext/getnext.cpp rename to tests/automatic/support/getnext/getnext.cpp index 898ba41e6506edbc0f6cc6ca82a480c546c86aee..a5689ca1b5da3d92dc6e0ecf2128394c1868a067 100644 --- a/examples/consumer/getnext/getnext.cpp +++ b/tests/automatic/support/getnext/getnext.cpp @@ -142,8 +142,8 @@ StartThreads(const Args& params, std::vector<int>* nfiles, std::vector<int>* err if (params.datasets) { auto dataset = consumer->GetNextDataset(group_id, 0, "default", &err); if (err == nullptr) { - for (auto& fi : dataset.content) { - (*nbuf)[i] += fi.buf_id == 0 ? 0 : 1; + for (auto& ds_fi : dataset.content) { + (*nbuf)[i] += ds_fi.buf_id == 0 ? 0 : 1; (*nfiles_total)[i]++; } } 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 c551e5f8010dbf5e0280c04a6813ef885a942c8b..bbc90c53f0fb91ab55b2a907745a1acc380133e7 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 @@ -8,7 +8,6 @@ #include "testing.h" using asapo::Error; -using asapo::ErrorType; using asapo::AddressFamilies; using asapo::SocketTypes; using asapo::SocketProtocols; @@ -62,7 +61,7 @@ std::unique_ptr<std::thread> CreateEchoServerThread() { if (asapo::IOErrorTemplates::kTimeout == err) { continue; } - if (asapo::ErrorTemplates::kEndOfFile == err) { + if (asapo::GeneralErrorTemplates::kEndOfFile == err) { break; } } @@ -108,8 +107,8 @@ void CheckNormal(int times, size_t size) { for (int i = 0; i < times; i++) { std::cout << "[CLIENT] Allocate and create random numbers" << std::endl; std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]); - for (size_t i = 0; i < size; i++) { - buffer[i] = static_cast<uint8_t>(256 * rand() / RAND_MAX); + for (size_t ii = 0; ii < size; ii++) { + buffer[ii] = static_cast<uint8_t>(256 * rand() / RAND_MAX); } FILE* out = fopen("sent", "wb"); @@ -139,8 +138,8 @@ void CheckNormal(int times, size_t size) { } std::cout << "[CLIENT] buffer check" << std::endl; - for (size_t i = 0; i < size; i++) { - if (buffer[i] != buffer2[i]) { + for (size_t ii = 0; ii < size; ii++) { + if (buffer[ii] != buffer2[ii]) { Exit(207); } } @@ -155,8 +154,8 @@ void CheckNormal(int times, size_t size) { Exit(210); } std::cout << "[CLIENT] buffer check after receive file" << std::endl; - for (size_t i = 0; i < size; i++) { - if (buffer[i] != buffer2[i]) { + for (size_t ii = 0; ii < size; ii++) { + if (buffer[ii] != buffer2[ii]) { Exit(211); } } @@ -208,5 +207,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 7e914d0252ea640d9184eec27443388dd89e0859..faaecc454b45cc57605adaafd8a172f391d81908 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 @@ -1,6 +1,5 @@ #include <iostream> #include "asapo/io/io_factory.h" -#include <chrono> #include <thread> #include <future> #include <atomic> @@ -9,7 +8,6 @@ #include "testing.h" using asapo::Error; -using asapo::ErrorType; using asapo::AddressFamilies; using asapo::SocketTypes; using asapo::SocketProtocols; @@ -52,7 +50,7 @@ std::unique_ptr<std::thread> CreateEchoServerThread() { std::cout << "[SERVER] processing socket " << socket << std::endl; uint64_t message; io->Receive(socket, &message, sizeof(uint64_t), &err); - if (err == asapo::ErrorTemplates::kEndOfFile) { + if (err == asapo::GeneralErrorTemplates::kEndOfFile) { std::cout << "[SERVER] end of file " << socket << std::endl; io->CloseSocket(socket, &err); ExitIfErrIsNotOk(&err, 106); @@ -131,5 +129,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/CMakeLists.txt b/tests/automatic/system_io/read_file_content/CMakeLists.txt index ca5a9e0de6b73fb53c6717999828fff356c03a2d..5f302cdb12e8f9f74b452a88b5370b04dd26761e 100644 --- a/tests/automatic/system_io/read_file_content/CMakeLists.txt +++ b/tests/automatic/system_io/read_file_content/CMakeLists.txt @@ -17,6 +17,6 @@ set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX) add_test_setup_cleanup(${TARGET_NAME}) add_integration_test(${TARGET_NAME} readfile "test/1 123") add_integration_test(${TARGET_NAME} readfile_unkown_size "test/2 unknown_size") -add_integration_test(${TARGET_NAME} filenotfound "test_notexist Nosuchfileordirectory:test_notexist") -add_integration_test(${TARGET_NAME} filenoaccess "file_noaccess Permissiondenied:file_noaccess") +add_integration_test(${TARGET_NAME} filenotfound "test_notexist error:Nosuchfileordirectory,context:name:test_notexist") +add_integration_test(${TARGET_NAME} filenoaccess "file_noaccess error:Permissiondenied,context:name:file_noaccess") 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/CMakeLists.txt b/tests/automatic/system_io/read_folder_content/CMakeLists.txt index eb323e8c33fa0fd2340f0c5a9fc35e3487b65bd6..42bc1ec48ee536502e96f50e1ae26b59fac96683 100644 --- a/tests/automatic/system_io/read_folder_content/CMakeLists.txt +++ b/tests/automatic/system_io/read_folder_content/CMakeLists.txt @@ -27,6 +27,6 @@ ELSE() ENDIF(WIN32) -add_integration_test(${TARGET_NAME} foldernotfound "test_notexist Nosuchfileordirectory:test_notexist") -add_integration_test(${TARGET_NAME} foldernoaccess "test_noaccess1 Permissiondenied:test_noaccess1") +add_integration_test(${TARGET_NAME} foldernotfound "test_notexist error:Nosuchfileordirectory,context:name:test_notexist") +add_integration_test(${TARGET_NAME} foldernoaccess "test_noaccess1 error:Permissiondenied,context:name:test_noaccess1") 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/CMakeLists.txt b/tests/automatic/system_io/read_string_from_file/CMakeLists.txt index 6e133cc602f6a196810afaa09aab4d406505b896..8cfa3aed8aecbc37b1b8643f8812e9687c5f433d 100644 --- a/tests/automatic/system_io/read_string_from_file/CMakeLists.txt +++ b/tests/automatic/system_io/read_string_from_file/CMakeLists.txt @@ -16,6 +16,6 @@ set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX) add_test_setup_cleanup(${TARGET_NAME}) add_integration_test(${TARGET_NAME} readfile "test/1 123") -add_integration_test(${TARGET_NAME} filenotfound "test_notexist Nosuchfileordirectory:test_notexist") -add_integration_test(${TARGET_NAME} filenoaccess "file_noaccess Permissiondenied:file_noaccess") +add_integration_test(${TARGET_NAME} filenotfound "test_notexist error:Nosuchfileordirectory,context:name:test_notexist") +add_integration_test(${TARGET_NAME} filenoaccess "file_noaccess error:Permissiondenied,context:name:file_noaccess") 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/CMakeLists.txt b/tests/automatic/system_io/read_subdirectories/CMakeLists.txt index 6b24dd256c0df56f1fafef382d2828af3a4941c4..ab9b1908fa01a83bee13dfd7bf19ea9332c19cd4 100644 --- a/tests/automatic/system_io/read_subdirectories/CMakeLists.txt +++ b/tests/automatic/system_io/read_subdirectories/CMakeLists.txt @@ -27,6 +27,6 @@ ELSE() ENDIF(WIN32) -add_integration_test(${TARGET_NAME} foldernotfound "test_notexist Nosuchfileordirectory:test_notexist") -add_integration_test(${TARGET_NAME} foldernoaccess "test_noaccess1 Permissiondenied:test_noaccess1") +add_integration_test(${TARGET_NAME} foldernotfound "test_notexist error:Nosuchfileordirectory,context:name:test_notexist") +add_integration_test(${TARGET_NAME} foldernoaccess "test_noaccess1 error:Permissiondenied,context:name:test_noaccess1") 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..79a09683b294d34c622d07a0ec33d5b89a1c3e2a 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 @@ -4,7 +4,6 @@ #include "testing.h" using asapo::Error; -using asapo::ErrorType; void Check(const std::string& expected_ip_address, const std::string& hostname) { std::cout << "Checking: " << hostname << std::endl; @@ -34,5 +33,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/CMakeLists.txt b/tests/automatic/system_io/write_data_to_file/CMakeLists.txt index d10f4fcee45a4554763e0cc2c61659f915122e89..3e7a13c469495cc372c2132356ca9f1efc8d3993 100644 --- a/tests/automatic/system_io/write_data_to_file/CMakeLists.txt +++ b/tests/automatic/system_io/write_data_to_file/CMakeLists.txt @@ -22,5 +22,5 @@ else () endif() add_integration_test(${TARGET_NAME} writetwice "test_file ok dummy" nomem) -add_integration_test(${TARGET_NAME} dirnoaccess "test_noaccess/test_file error Permissiondenied:test_noaccess/test_file" nomem) +add_integration_test(${TARGET_NAME} dirnoaccess "test_noaccess/test_file error error:Permissiondenied,context:name:test_noaccess/test_file" nomem) 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; } diff --git a/tests/manual/asapo_fabric/CMakeLists.txt b/tests/manual/asapo_fabric/CMakeLists.txt deleted file mode 100644 index 84b2cd121ae782cb551c90b0c171d34578ed1e43..0000000000000000000000000000000000000000 --- a/tests/manual/asapo_fabric/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -GET_PROPERTY(ASAPO_COMMON_FABRIC_LIBRARIES GLOBAL PROPERTY ASAPO_COMMON_FABRIC_LIBRARIES) - -add_executable(example-fabric-server fabric_server.cpp $<TARGET_OBJECTS:logger> $<TARGET_OBJECTS:curl_http_client>) -target_link_libraries(example-fabric-server asapo-fabric CURL::libcurl ${ASAPO_COMMON_FABRIC_LIBRARIES}) - -add_executable(example-fabric-client fabric_client.cpp) -target_link_libraries(example-fabric-client asapo-fabric ${ASAPO_COMMON_FABRIC_LIBRARIES}) diff --git a/tests/manual/asapo_fabric/fabric_client.cpp b/tests/manual/asapo_fabric/fabric_client.cpp deleted file mode 100644 index 843e470abdc44dde1d83ddb779bbb41d04091bf5..0000000000000000000000000000000000000000 --- a/tests/manual/asapo_fabric/fabric_client.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include <asapo/asapo_fabric/asapo_fabric.h> -#include <iostream> -#include <asapo/common/data_structs.h> -#include <asapo/common/networking.h> - -using namespace asapo; -using namespace asapo::fabric; - -int main(int argc, char* argv[]) { - if (argc < 3 || argc > 5) { - std::cout - << "Usage: " << argv[0] << - " <serverAddress> <serverPort> [kiByte=1024*400/*400MiByte*/ /*MUST BE SYNC WITH SERVER*/] [count=10]" << std::endl -#ifdef LIBFARBIC_ALLOW_LOCALHOST - << "If the address is localhost or 127.0.0.1 the verbs connection will be emulated" << std::endl -#endif - ; - return 1; - } - - std::string serverAddressString = std::string(argv[1]) + ':' + std::string(argv[2]); - - int kByte = 1024 * 400 /*400 MiByte*/; - if (argc >= 4) { - kByte = std::stoi(argv[3]); - } - int count = 10; - if (argc >= 5) { - count = std::stoi(argv[4]); - } - - Error error; - auto factory = GenerateDefaultFabricFactory(); - - auto client = factory->CreateClient(&error); - if (error) { - std::cout << "Client exited with error: " << error << std::endl; - return 1; - } - - size_t dataBufferSize = static_cast<size_t>(1024 * kByte); - MessageData dataBuffer = MessageData{new uint8_t[dataBufferSize]}; - std::cout << "Expected file size: " << dataBufferSize << " byte" << std::endl; - - auto serverAddress = client->AddServerAddress(serverAddressString, &error); - if (error) { - std::cout << "Client exited with error: " << error << std::endl; - return 1; - } - std::cout << "Added server address" << std::endl; - - auto mr = client->ShareMemoryRegion(dataBuffer.get(), dataBufferSize, &error); - if (error) { - std::cout << "Client exited with error: " << error << std::endl; - return 1; - } - - uint64_t totalTransferSize = 0; - auto start = std::chrono::system_clock::now(); - - std::cout << "Starting message loop" << std::endl; - for (FabricMessageId messageId = 0; messageId < static_cast<FabricMessageId>(count) && !error; messageId++) { - GenericRequestHeader request{}; - memcpy(&request.message, mr->GetDetails(), sizeof(MemoryRegionDetails)); - client->Send(serverAddress, messageId, &request, sizeof(request), &error); - if (error) { - break; - } - - GenericNetworkResponse response{}; - client->Recv(serverAddress, messageId, &response, sizeof(response), &error); - if (error) { - break; - } - - if (strcmp((char*)dataBuffer.get(), "I (the server) wrote into your buffer.") != 0) { - error = TextError("The buffer was not written with the expected text"); - break; - } - memset(dataBuffer.get(), 0, 64); - - totalTransferSize += dataBufferSize; - } - auto end = std::chrono::system_clock::now(); - - if (error) { - std::cout << "Client exited with error: " << error << std::endl; - return 1; - } - - auto timeTook = end - start; - std::cout << "Transferred " << (((totalTransferSize) / 1024) / 1024) << " MiBytes in " - << std::chrono::duration_cast<std::chrono::milliseconds>(timeTook).count() << "ms" << std::endl; - - return 0; -} diff --git a/tests/manual/asapo_fabric/fabric_server.cpp b/tests/manual/asapo_fabric/fabric_server.cpp deleted file mode 100644 index 4e2f549ecd28110f546dc25e80be379a07fee0cd..0000000000000000000000000000000000000000 --- a/tests/manual/asapo_fabric/fabric_server.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include <iostream> - -#include "asapo/asapo_fabric/asapo_fabric.h" -#include "asapo/io/io_factory.h" -#include "asapo/common/networking.h" - -using namespace asapo; -using namespace asapo::fabric; - -volatile bool running = false; - -void ServerThread(FabricServer* server, size_t bufferSize, MessageData* buffer) { - Error error; - while(running && !error) { - FabricAddress clientAddress; - FabricMessageId messageId; - GenericRequestHeader request; - - server->RecvAny(&clientAddress, &messageId, &request, sizeof(request), &error); - if (error == IOErrorTemplates::kTimeout) { - error = nullptr; - continue; - } - if (error) { - break; - } - - std::cout << "Got a request from " << clientAddress << " id: " << messageId << std::endl; - server->RdmaWrite(clientAddress, (MemoryRegionDetails*)&request.message, buffer->get(), bufferSize, &error); - - GenericNetworkResponse response{}; - server->Send(clientAddress, messageId, &response, sizeof(response), &error); - } - - if (error) { - std::cerr << "Server thread exited with an error: " << error << std::endl; - } -} - -int main(int argc, char* argv[]) { - if (argc < 3 || argc > 4) { - std::cout - << "Usage: " << argv[0] << " <listenAddress> <listenPort> [kiByte=1024*400/*400MiByte*/ /*MUST BE SYNC WITH CLIENT*/]" - << std::endl -#ifdef LIBFARBIC_ALLOW_LOCALHOST - << "If the address is localhost or 127.0.0.1 the verbs connection will be emulated" << std::endl -#endif - ; - return 1; - } - - Error error; - auto io = GenerateDefaultIO(); - auto factory = GenerateDefaultFabricFactory(); - Logger log = CreateDefaultLoggerBin("FabricTestServer"); - - uint16_t port = (uint16_t)strtoul(argv[2], nullptr, 10); - auto server = factory->CreateAndBindServer(log.get(), argv[1], port, &error); - if (error) { - std::cerr << error << std::endl; - return 1; - } - - int kByte = 1024 * 400 /*400 MiByte*/; - if (argc >= 4) { - kByte = std::stoi(argv[3]); - } - - std::cout << "Server is listening on " << server->GetAddress() << std::endl; - - size_t dataBufferSize = static_cast<size_t>(1024 * kByte); - MessageData dataBuffer = MessageData{new uint8_t[dataBufferSize]}; - strcpy((char*)dataBuffer.get(), "I (the server) wrote into your buffer."); - std::cout << "Expected file size: " << dataBufferSize << " byte" << std::endl; - - running = true; - auto thread = io->NewThread("ServerThread", [&server, &dataBufferSize, &dataBuffer]() { - ServerThread(server.get(), dataBufferSize, &dataBuffer); - }); - - std::cout << "Press Enter to stop the server." << std::endl; - - getchar(); - std::cout << "Stopping server... Please wait until the RecvAny is timing out." << std::endl; - - running = false; - thread->join(); - - if (error) { - std::cerr << "Client exited with error: " << error << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/manual/broker_debug_local/asapo b/tests/manual/broker_debug_local/asapo deleted file mode 100755 index f7072c1eedeea64f1e2d2251d3ed14d4d59be014..0000000000000000000000000000000000000000 Binary files a/tests/manual/broker_debug_local/asapo and /dev/null differ diff --git a/tests/manual/broker_debug_local/auth_secret.key b/tests/manual/broker_debug_local/auth_secret.key deleted file mode 100644 index 1d100e0ec247d5df6a06e5029a392b93b2a6fbe2..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/auth_secret.key +++ /dev/null @@ -1 +0,0 @@ -12ljzgneasfd diff --git a/tests/manual/broker_debug_local/authorizer.json.tpl b/tests/manual/broker_debug_local/authorizer.json.tpl deleted file mode 100644 index 92292267951f4e5ddb9017fa3df32293531e3719..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/authorizer.json.tpl +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Port": {{ env "NOMAD_PORT_authorizer" }}, - "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","Year":"2019","Facility":"test_facility"}, - {"beamtimeId":"asapo_test1","beamline":"test1","Year":"2019","Facility":"test_facility"}, - {"beamtimeId":"asapo_test2","beamline":"test2","Year":"2019","Facility":"test_facility"}], - "UserSecretFile":"auth_secret.key", - "AdminSecretFile":"auth_secret_admin.key" -} - - diff --git a/tests/manual/broker_debug_local/authorizer.nmd b/tests/manual/broker_debug_local/authorizer.nmd deleted file mode 100644 index 8b32105cf2e4644e97b6fda5e4aba06c6c269822..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/authorizer.nmd +++ /dev/null @@ -1,55 +0,0 @@ -job "authorizer" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "authorizer" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/authorizer/asapo-authorizer", - args = ["-config","${NOMAD_TASK_DIR}/authorizer.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "authorizer" { - static = "5007" - } - } - } - - service { - name = "authorizer" - port = "authorizer" - check { - name = "alive" - type = "http" - path = "/health-check" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/authorizer.json.tpl" - destination = "local/authorizer.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/auth_secret.key" - destination = "auth_secret.key" - change_mode = "signal" - change_signal = "SIGHUP" - } - } - } -} diff --git a/tests/manual/broker_debug_local/broker.json b/tests/manual/broker_debug_local/broker.json deleted file mode 100644 index cb0155b9ccc950acfb202e8f403c3dda0f229609..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/broker.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "DatabaseServer":"auto", - "DiscoveryServer": "localhost:8400/discovery", - "AuthorizationServer": "localhost:8400/asapo-authorizer", - "PerformanceDbServer": "localhost:8086", - "MonitorPerformance": true, - "CheckResendInterval":10, - "PerformanceDbName": "db_test", - "Port": 5005, - "LogLevel":"info" -} diff --git a/tests/manual/broker_debug_local/broker.nmd b/tests/manual/broker_debug_local/broker.nmd deleted file mode 100644 index 6028eac3d3eb065186062d7447943f23aa22f8a5..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/broker.nmd +++ /dev/null @@ -1,55 +0,0 @@ -job "broker" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "broker" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/broker/asapo-broker", - args = ["-config","${NOMAD_TASK_DIR}/broker.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "broker" { - static = "5005" - } - } - } - - service { - name = "asapo-broker" - port = "broker" - check { - name = "alive" - type = "http" - path = "/health" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/tests/manual/broker_debug_local/broker.json.tpl" - destination = "local/broker.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - template { - source = "/home/yakubov/projects/asapo/tests/manual/broker_debug_local/auth_secret.key" - destination = "auth_secret.key" - change_mode = "signal" - change_signal = "SIGHUP" - } - } - } -} diff --git a/tests/manual/broker_debug_local/clean_db.sh b/tests/manual/broker_debug_local/clean_db.sh deleted file mode 100755 index 359d98df324b2135bc015a6c244ec3b63e79e47a..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/clean_db.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -beamtime_id=asapo_test - - -echo "db.dropDatabase()" | mongo ${beamtime_id}_detector diff --git a/tests/manual/broker_debug_local/discovery.json b/tests/manual/broker_debug_local/discovery.json deleted file mode 100644 index bde0a2b819081929bc7ac4ef3c081d6ec60b13c2..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/discovery.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "Mode": "static", - "Receiver": { - "StaticEndpoints": [ - "127.0.0.1:22001" - ], - "MaxConnections": 32 - }, - "Broker": { - "StaticEndpoint": "127.0.0.1:5005" - }, - "Mongo": { - "StaticEndpoint": "127.0.0.1:27017" - }, - "Port": 5900, - "LogLevel":"debug" -} - - diff --git a/tests/manual/broker_debug_local/discovery.json.tpl b/tests/manual/broker_debug_local/discovery.json.tpl deleted file mode 100644 index fb4358e09bdc8921c8b76be4022190c954ee22c0..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/discovery.json.tpl +++ /dev/null @@ -1,19 +0,0 @@ -{ - "Mode": "static", - "Receiver": { - "StaticEndpoints": [ - "127.0.0.1:22001" - ], - "MaxConnections": 32 - }, - "Broker": { - "StaticEndpoint": "localhost:5005" - }, - "Mongo": { - "StaticEndpoint": "asapo-services:27017" - }, - "Port": {{ env "NOMAD_PORT_discovery" }}, - "LogLevel":"debug" -} - - diff --git a/tests/manual/broker_debug_local/discovery.nmd b/tests/manual/broker_debug_local/discovery.nmd deleted file mode 100644 index 522d4753f290d2005f849d8a01727f54344e8500..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/discovery.nmd +++ /dev/null @@ -1,49 +0,0 @@ -job "discovery" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "discovery" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/discovery/asapo-discovery", - args = ["-config","${NOMAD_TASK_DIR}/discovery.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "discovery" { - static = "5006" - } - } - } - - service { - name = "discovery" - port = "discovery" - check { - name = "alive" - type = "http" - path = "/receivers" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/tests/manual/broker_debug_local/discovery.json.tpl" - destination = "local/discovery.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - } - } -} diff --git a/tests/manual/broker_debug_local/nginx.conf.tpl b/tests/manual/broker_debug_local/nginx.conf.tpl deleted file mode 100644 index b784d07256fc978f12d4aa94d8970a435b087df2..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/nginx.conf.tpl +++ /dev/null @@ -1,91 +0,0 @@ -worker_processes 1; - -events { - worker_connections 1024; -} - -http { -# include mime.types; -# default_type application/octet-stream; - -# sendfile on; -# tcp_nopush on; - -# keepalive_timeout 0; -# keepalive_timeout 65; - - resolver 127.0.0.1:8600 valid=1s; - server { - listen {{ env "NOMAD_PORT_nginx" }}; - set $discovery_endpoint discovery.service.asapo; - set $authorizer_endpoint authorizer.service.asapo; - set $fluentd_endpoint fluentd.service.asapo; - set $kibana_endpoint kibana.service.asapo; - set $grafana_endpoint grafana.service.asapo; - set $mongo_endpoint mongo.service.asapo; - set $influxdb_endpoint influxdb.service.asapo; - set $elasticsearch_endpoint elasticsearch.service.asapo; - - location /mongo/ { - rewrite ^/mongo(/.*) $1 break; - proxy_pass http://$mongo_endpoint:27017$uri$is_args$args; - } - - location /influxdb/ { - rewrite ^/influxdb(/.*) $1 break; - proxy_pass http://$influxdb_endpoint:8086$uri$is_args$args; - } - - location /elasticsearch/ { - rewrite ^/elasticsearch(/.*) $1 break; - proxy_pass http://$elasticsearch_endpoint:9200$uri$is_args$args; - } - - location /discovery/ { - rewrite ^/discovery(/.*) $1 break; - proxy_pass http://$discovery_endpoint:5006$uri$is_args$args; - } - - location /logs/ { - rewrite ^/logs(/.*) $1 break; - proxy_pass http://$fluentd_endpoint:9880$uri$is_args$args; - } - - location /logsview/ { - proxy_pass http://$kibana_endpoint:5601$uri$is_args$args; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - } - - location /performance/ { - rewrite ^/performance(/.*) $1 break; - proxy_pass http://$grafana_endpoint:3000$uri$is_args$args; - } - - location /authorizer/ { - rewrite ^/authorizer(/.*) $1 break; - proxy_pass http://$authorizer_endpoint:5007$uri$is_args$args; - } - - location /nginx-health { - return 200 "healthy\n"; - } - } -} - -stream { - resolver 127.0.0.1:8600 valid=1s; - - map $remote_addr $upstream { - default fluentd.service.asapo; - } - - - server { - listen 9881; - proxy_pass $upstream:24224; - } -} - - diff --git a/tests/manual/broker_debug_local/nginx.nmd b/tests/manual/broker_debug_local/nginx.nmd deleted file mode 100644 index b424e53874d17c7b0612106225f0250fa274fac4..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/nginx.nmd +++ /dev/null @@ -1,63 +0,0 @@ -job "nginx" { - datacenters = ["dc1"] - - type = "service" - - update { - max_parallel = 1 - min_healthy_time = "10s" - healthy_deadline = "3m" - auto_revert = false - } - - group "nginx" { - count = 1 - - restart { - attempts = 2 - interval = "30m" - delay = "15s" - mode = "fail" - } - - task "nginx" { - driver = "raw_exec" - - config { - command = "nginx", - args = ["-c","${NOMAD_TASK_DIR}/nginx.conf"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - mbits = 10 - port "nginx" { - static = 8400 - } - } - } - - service { - port = "nginx" - name = "nginx" - check { - name = "alive" - type = "http" - path = "/nginx-health" - timeout = "2s" - interval = "10s" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/nginx.conf.tpl" - destination = "local/nginx.conf" - change_mode = "restart" - } - - - } - } -} diff --git a/tests/manual/broker_debug_local/nginx_kill.nmd b/tests/manual/broker_debug_local/nginx_kill.nmd deleted file mode 100644 index cb3abbac259780ce7366042f24a19d635f032994..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/nginx_kill.nmd +++ /dev/null @@ -1,17 +0,0 @@ -job "nginx_kill" { - datacenters = ["dc1"] - - type = "batch" - - group "nginx_kill" { - count = 1 - - task "nginx_kill" { - driver = "raw_exec" - config { - command = "killall", - args = ["nginx"] - } - } - } -} diff --git a/tests/manual/broker_debug_local/receiver.json b/tests/manual/broker_debug_local/receiver.json deleted file mode 100644 index 3dfd35396ecf0c78607e5a9983ac33b28a64428c..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/receiver.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "PerformanceDbServer":"localhost:8086", - "MonitorPerformance": true, - "PerformanceDbName": "db_test", - "DatabaseServer":"localhost:27017", - "DiscoveryServer": "localhost:8400/discovery", - "DataServer": { - "AdvertiseURI":"127.0.0.1", - "NThreads": 2, - "ListenPort": 22000, - "NetworkMode": ["tcp"] - }, - "DataCache": { - "Use": true, - "SizeGB": 1, - "ReservedShare": 10 - }, - "AuthorizationServer": "localhost:8400/authorizer", - "AuthorizationInterval": 10000, - "ListenPort": 22001, - "Tag": "22001", - "ReceiveToDiskThresholdMB":50, - "LogLevel" : "debug" -} diff --git a/tests/manual/broker_debug_local/receiver.json.tpl b/tests/manual/broker_debug_local/receiver.json.tpl deleted file mode 100644 index 4de57e97bac84e89d88767697ef160ec04e85b39..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/receiver.json.tpl +++ /dev/null @@ -1,24 +0,0 @@ -{ - "PerformanceDbServer":"localhost:8086", - "MonitorPerformance": true, - "PerformanceDbName": "db_test", - "DatabaseServer":"auto", - "DiscoveryServer": "localhost:8400/discovery", - "DataServer": { - "AdvertiseURI": "127.0.0.1", - "NThreads": 2, - "ListenPort": {{ env "NOMAD_PORT_recv_ds" }}, - "NetworkMode": ["tcp"] - }, - "DataCache": { - "Use": true, - "SizeGB": 1, - "ReservedShare": 10 - }, - "AuthorizationServer": "localhost:8400/authorizer", - "AuthorizationInterval": 10000, - "ListenPort": {{ env "NOMAD_PORT_recv" }}, - "Tag": "{{ env "NOMAD_ADDR_recv" }}", - "ReceiveToDiskThresholdMB":50, - "LogLevel" : "debug" -} diff --git a/tests/manual/broker_debug_local/receiver.nmd b/tests/manual/broker_debug_local/receiver.nmd deleted file mode 100644 index 6d7986648fb477ff6446018f871e1f78c31fc173..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/receiver.nmd +++ /dev/null @@ -1,47 +0,0 @@ -job "receiver" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "receiver" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/receiver/receiver", - args = ["${NOMAD_TASK_DIR}/receiver.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "recv" {} - port "recv_ds" {} - } - } - - service { - name = "asapo-receiver" - port = "recv" - check { - name = "alive" - type = "tcp" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/producer_receiver/check_monitoring/receiver_tcp.json.tpl" - destination = "local/receiver.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - } - } -} diff --git a/tests/manual/broker_debug_local/start_broker.sh b/tests/manual/broker_debug_local/start_broker.sh deleted file mode 100755 index 020e1b1c8a91816f3c4bd019a47da976e601eb87..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/start_broker.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - - -exec=/home/yakubov/projects/asapo/cmake-build-debug/broker/asapo-broker - - -$exec -config broker.json diff --git a/tests/manual/broker_debug_local/start_getnext.sh b/tests/manual/broker_debug_local/start_getnext.sh deleted file mode 100755 index e40f3951d3cc73dc0b64406609b321cedc5519b5..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/start_getnext.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -beamtime_id=asapo_test - -token= -timeout=100 -metaonly=0 -nthreads=4 -token=IEfwsWa0GXky2S3MkxJSUHJT1sI8DD5teRdjBUXVRxk= - -exec=/home/yakubov/projects/asapo/cmake-build-debug/examples/consumer/getnext/getnext - -$exec localhost:8400 /tmp/asapo/receiver/files/test/asapo_test asapo_test $nthreads $token $timeout $metaonly diff --git a/tests/manual/broker_debug_local/start_services.sh b/tests/manual/broker_debug_local/start_services.sh deleted file mode 100755 index fe817656d3d39911b55c731da9ea569ca287fb84..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/start_services.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -nomad run authorizer.nmd -nomad run discovery.nmd -#nomad run broker.nmd -nomad run receiver_tcp.nmd -nomad run nginx.nmd diff --git a/tests/manual/broker_debug_local/stop_services.sh b/tests/manual/broker_debug_local/stop_services.sh deleted file mode 100755 index db503c59efa2b699d0563487cd44dd1315248a48..0000000000000000000000000000000000000000 --- a/tests/manual/broker_debug_local/stop_services.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -nomad stop -purge authorizer -nomad stop -purge discovery -nomad stop -purge broker -nomad stop -purge nginx -nomad run nginx_kill.nmd && nomad stop -yes -purge nginx_kill diff --git a/tests/manual/consumer_multithread_python/consumer.py b/tests/manual/consumer_multithread_python/consumer.py deleted file mode 100644 index 4bde969c0b6b193662bbcb4bdc1beb8cbd25bee9..0000000000000000000000000000000000000000 --- a/tests/manual/consumer_multithread_python/consumer.py +++ /dev/null @@ -1,45 +0,0 @@ -import asapo_consumer,os - -import _thread -import time - -# Define a function for the thread -def print_time( threadName, consumer): - while 1: - group_id = consumer.generate_group_id() - print (group_id) - -print ("consumer: ",asapo_consumer.__version__) -endpoint = "asap3-utl01.desy.de:8400" -beamtime = "asapo_test" -token = "KmUDdacgBzaOD3NIJvN1NmKGqWKtx0DK-NyPjdpeWkc=" -consumer = asapo_consumer.create_consumer(endpoint,"/gpfs/petra3/scratch/yakubov/asapo_shared/test_facility/gpfs/test/2019/data/asapo_test",False, beamtime,"",token,6000) - - -try: - _thread.start_new_thread( print_time, ("Thread-1", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-2", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-1", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-1", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-2", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-2", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-1", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-2", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-1", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-2", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-1", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-2", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-1", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-1", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-2", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-2", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-1", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-2", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-1", consumer, ) ) - _thread.start_new_thread( print_time, ("Thread-2", consumer, ) ) -except: - print ("Error: unable to start thread") - -while 1: - pass - diff --git a/tests/manual/maxwell/asapo_deploy/asapo_host b/tests/manual/maxwell/asapo_deploy/asapo_host deleted file mode 100644 index 165dea9fafd18f80586632c5c7a4ef7fcd48cbfc..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_deploy/asapo_host +++ /dev/null @@ -1 +0,0 @@ -max-wn001 diff --git a/tests/manual/maxwell/asapo_deploy/asapo_overwrite_vars.tfvars b/tests/manual/maxwell/asapo_deploy/asapo_overwrite_vars.tfvars deleted file mode 100644 index 873f70addc186ce01dfeeb8731a6348bfb9516d3..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_deploy/asapo_overwrite_vars.tfvars +++ /dev/null @@ -1,19 +0,0 @@ -#asapo_image_tag = "develop.19.09-64-g24f0c4c" - -elk_logs = true - -receiver_total_memory_size = 35000 -receiver_dataserver_cache_size = 30 #gb -receiver_dataserver_nthreads = 8 - -grafana_total_memory_size = 2000 -influxdb_total_memory_size = 2000 -fluentd_total_memory_size = 1000 -elasticsearch_total_memory_size = 3000 -kibana_total_memory_size = 1000 -mongo_total_memory_size = 20000 -authorizer_total_memory_size = 512 -discovery_total_memory_size = 512 - -n_receivers = 4 -n_brokers = 1 \ No newline at end of file diff --git a/tests/manual/maxwell/asapo_deploy/job.sh b/tests/manual/maxwell/asapo_deploy/job.sh deleted file mode 100755 index 561693a17b8a9ded8c47c033171b97308c2b1d38..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_deploy/job.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -#SBATCH --nodes=5 -#SBATCH -t 6-10:40:00 - - -echo start on $SLURM_JOB_NUM_NODES -srun --ntasks=$SLURM_JOB_NUM_NODES --ntasks-per-node=1 ./run_maxwell.sh - diff --git a/tests/manual/maxwell/asapo_deploy/start_asapo.sh b/tests/manual/maxwell/asapo_deploy/start_asapo.sh deleted file mode 100755 index ac98c90e0783803d50df879f488ffa9463bc260c..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_deploy/start_asapo.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -e - -asapo_host=`cat asapo_host` - -! ssh $asapo_host DOCKER_CONT_NAME=asapo dockerexec cat /var/nomad/token > token - - -ssh $asapo_host DOCKER_CONT_NAME=asapo dockerexec asapo-start $@ -ssh $asapo_host DOCKER_CONT_NAME=asapo dockerexec cat /var/nomad/token > token - -cat token \ No newline at end of file diff --git a/tests/manual/maxwell/asapo_deploy/stop_asapo.sh b/tests/manual/maxwell/asapo_deploy/stop_asapo.sh deleted file mode 100755 index 5c23ee746482255be76dd0eac26f167e4515e904..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_deploy/stop_asapo.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -e - -asapo_host=`cat asapo_host` - -ssh $asapo_host DOCKER_CONT_NAME=asapo dockerexec asapo-stop $@ - diff --git a/tests/manual/maxwell/asapo_test/asapo_host b/tests/manual/maxwell/asapo_test/asapo_host deleted file mode 100644 index 165dea9fafd18f80586632c5c7a4ef7fcd48cbfc..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_test/asapo_host +++ /dev/null @@ -1 +0,0 @@ -max-wn001 diff --git a/tests/manual/maxwell/asapo_test/clean.sh b/tests/manual/maxwell/asapo_test/clean.sh deleted file mode 100755 index 83475c376e73deea5a3ef941d3458e6f283670c9..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_test/clean.sh +++ /dev/null @@ -1,12 +0,0 @@ -export asapo_host=`cat asapo_host` - -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/asapo-discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/asapo-discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream0 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/asapo-discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream1 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/asapo-discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream2 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/asapo-discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream3 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/asapo-discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream4 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/asapo-discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream5 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/asapo-discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream6 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/asapo-discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream7 -dockerrun -v `pwd`:/tmp/yakubov mongo mongo --host `curl -s $asapo_host:8400/asapo-discovery/asapo-mongodb` --eval "db.dropDatabase()" asapo_test_stream8 diff --git a/tests/manual/maxwell/asapo_test/consume.py b/tests/manual/maxwell/asapo_test/consume.py deleted file mode 100644 index 8af7a6776de18eff0d6db6b794b7cdfd718d65a1..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_test/consume.py +++ /dev/null @@ -1,13 +0,0 @@ -from mpi4py import MPI -import os -comm = MPI.COMM_WORLD -rank = comm.Get_rank() - -with open('asapo_host', 'r') as file: - host = file.read().replace('\n', '') - -token="KmUDdacgBzaOD3NIJvN1NmKGqWKtx0DK-NyPjdpeWkc=" - -os.system("hostname") -os.system("./getnext "+host+":8400 /gpfs/petra3/scratch/yakubov/asapo_shared/test/asapo_test asapo_test%data_source"+str(rank)+" 8 "+token+" 1000 0") - diff --git a/tests/manual/maxwell/asapo_test/get_binaries.sh b/tests/manual/maxwell/asapo_test/get_binaries.sh deleted file mode 100755 index d08c0c29b5cfae28addec7ea51669e7e6d741fe0..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_test/get_binaries.sh +++ /dev/null @@ -1,5 +0,0 @@ -scp zitpcx27016:/home/yakubov/projects/asapo/cmake-build-release/examples/producer/dummy-data-producer/dummy-data-producer . -scp zitpcx27016:/home/yakubov/projects/asapo/cmake-build-release/examples/consumer/getnext/getnext . - - - diff --git a/tests/manual/maxwell/asapo_test/job_consume_python.sh b/tests/manual/maxwell/asapo_test/job_consume_python.sh deleted file mode 100755 index bece7e8f60c5d354b5c16ea0ee4882afecc5e953..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_test/job_consume_python.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -#SBATCH --nodes=4 -#SBATCH --ntasks=4 -#SBATCH -t 10:10:00 - -export asapo_host=`cat asapo_host` - -module load mpi/openmpi-x86_64 - -mpirun --map-by node --mca mpi_warn_on_fork 0 python consume.py - diff --git a/tests/manual/maxwell/asapo_test/job_produce_python.sh b/tests/manual/maxwell/asapo_test/job_produce_python.sh deleted file mode 100755 index d03788cf7e09e3b02ee4b16ad7ed07b843b0a4bb..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_test/job_produce_python.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -#SBATCH --nodes=4 -#SBATCH --ntasks=4 -#SBATCH -t 00:10:00 - -export asapo_host=`cat asapo_host` - -module load mpi/openmpi-x86_64 - -mpirun --map-by node --mca mpi_warn_on_fork 0 python produce.py - diff --git a/tests/manual/maxwell/asapo_test/produce.py b/tests/manual/maxwell/asapo_test/produce.py deleted file mode 100644 index 80f7292dde89407374e62f06f621e47fa55bf06f..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_test/produce.py +++ /dev/null @@ -1,13 +0,0 @@ -from mpi4py import MPI -import os -comm = MPI.COMM_WORLD -rank = comm.Get_rank() - -with open('asapo_host', 'r') as file: - host = file.read().replace('\n', '') - -token="KmUDdacgBzaOD3NIJvN1NmKGqWKtx0DK-NyPjdpeWkc=" -os.system("hostname") -os.system("./dummy-data-producer "+host+":8400 asapo_test%data_source"+str(rank)+"%"+token+" 1000000 50 8 0 1000") - - diff --git a/tests/manual/maxwell/asapo_test/token b/tests/manual/maxwell/asapo_test/token deleted file mode 100644 index 0071119ced72f72869422e2c286a5393a30e69dc..0000000000000000000000000000000000000000 --- a/tests/manual/maxwell/asapo_test/token +++ /dev/null @@ -1 +0,0 @@ -KmUDdacgBzaOD3NIJvN1NmKGqWKtx0DK-NyPjdpeWkc= diff --git a/tests/manual/mongodb_performance/go.mod b/tests/manual/mongodb_performance/go.mod deleted file mode 100644 index eb828f99573d51e8b9bfa728127e5466617f4c50..0000000000000000000000000000000000000000 --- a/tests/manual/mongodb_performance/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module perf - -go 1.16 - -require go.mongodb.org/mongo-driver v1.5.1 diff --git a/tests/manual/mongodb_performance/go.sum b/tests/manual/mongodb_performance/go.sum deleted file mode 100644 index 1ec00898ead19b91f2b3f8ba6106c18a2c51205d..0000000000000000000000000000000000000000 --- a/tests/manual/mongodb_performance/go.sum +++ /dev/null @@ -1,125 +0,0 @@ -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/aws/aws-sdk-go v1.34.28 h1:sscPpn/Ns3i0F4HPEWAVcwdIRaZZCuL7llJ2/60yPIk= -github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= -github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= -github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= -github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= -github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= -github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= -github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= -github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= -github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= -github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= -github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= -github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= -github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= -github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= -github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= -github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= -github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= -github.com/klauspost/compress v1.9.5 h1:U+CaK85mrNNb4k8BNOfgJtJ/gr6kswUCFj6miSzVC6M= -github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= -github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w= -github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= -github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc= -github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -go.mongodb.org/mongo-driver v1.5.1 h1:9nOVLGDfOaZ9R0tBumx/BcuqkbFpyTCU2r/Po7A2azI= -go.mongodb.org/mongo-driver v1.5.1/go.mod h1:gRXCHX4Jo7J0IJ1oDQyUxF7jfy19UfxniMS4xxMmUqw= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tests/manual/mongodb_performance/perf b/tests/manual/mongodb_performance/perf deleted file mode 100755 index 40103d1481d0a828eff4a7908ab4cc626316595a..0000000000000000000000000000000000000000 Binary files a/tests/manual/mongodb_performance/perf and /dev/null differ diff --git a/tests/manual/mongodb_performance/perf.go b/tests/manual/mongodb_performance/perf.go deleted file mode 100644 index 947aded3e8229ed76d6c7d4dda3cebdd22eb3753..0000000000000000000000000000000000000000 --- a/tests/manual/mongodb_performance/perf.go +++ /dev/null @@ -1,96 +0,0 @@ -package main - -import ( - "context" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx" - "log" - "os" - "strconv" - "time" -) - -var client *mongo.Client - -var address = "localhost:27017" - -func connectDb() error { - opts := options.Client().SetConnectTimeout(20 * time.Second). - ApplyURI("mongodb://" + address).SetWriteConcern(writeconcern.New(writeconcern.J(false))) - var err error - client, err = mongo.NewClient(opts) - if err != nil { - return err - } - ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) - defer cancel() - err = client.Connect(ctx) - if err != nil { - client = nil - return err - } - return nil -} - -type MessageRecord struct { - ID int `bson:"id" json:"id"` - Timestamp int `bson:"timestamp" json:"timestamp"` - Name string `bson:"name" json:"name"` - Meta map[string]interface{} `json:"meta"` - NextStream string - FinishedStream bool -} - -func getRecord(id int) *MessageRecord { - var rec MessageRecord - rec.ID = id - rec.Name = "rec_" + strconv.Itoa(id) - rec.NextStream = "ns" - rec.FinishedStream = true - return &rec -} - - -func main() { - if err := connectDb(); err != nil { - log.Fatal(err) - } - ctx := context.Background() - - dbName := "test" - client.Database(dbName).Drop(ctx) - - nRecords, _ := strconv.Atoi(os.Args[1]) - nCollections, _ := strconv.Atoi(os.Args[2]) - - keysDoc := bsonx.Doc{} - keysDoc = keysDoc.Append("name", bsonx.Int32(1)). - Append("id", bsonx.Int32(1)) - - mod := mongo.IndexModel{ - Keys: keysDoc, Options: nil, - } - - _, err := client.Database(dbName).Collection("data").Indexes().CreateOne(ctx, mod) - if err != nil { - log.Fatal(err) - } - - start := time.Now() - for col := 0; col < nCollections; col++ { - collection := "col" + strconv.Itoa(col+1) - for i := 0; i < nRecords/nCollections; i++ { - rec := getRecord(i+1) - rec.Name = collection - _, err := client.Database(dbName).Collection("data").InsertOne(ctx, rec) - if err != nil { - log.Fatal(err) - } - } - } - elapsed := time.Since(start) - log.Printf("write %d records/sec", int(float64(nRecords)/elapsed.Seconds())) - -} diff --git a/tests/manual/performance_broker/discovery.json b/tests/manual/performance_broker/discovery.json deleted file mode 100644 index a1438446b22a2d31e815c7f93185c44a5c14f066..0000000000000000000000000000000000000000 --- a/tests/manual/performance_broker/discovery.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Mode": "static", - "Broker": { - "StaticEndpoint": "localhost:5005" - }, - "Receiver": { - "MaxConnections":1, - "StaticEndpoints": [ - "test" - ] - }, - "Port": 5006, - "LogLevel": "info" -} \ No newline at end of file diff --git a/tests/manual/performance_broker/settings.json b/tests/manual/performance_broker/settings.json deleted file mode 100644 index b67ac89cdefb2b90aca59811a3675a8351eec59a..0000000000000000000000000000000000000000 --- a/tests/manual/performance_broker/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "DatabaseServer":"localhost:27017", - "PerformanceDbServer": "localhost:8086", - "MonitorPerformance": true, - "AuthorizationServer": "localhost:5007", - "PerformanceDbName": "db_test", - "Port":5005, - "LogLevel":"info", - "CheckResendInterval":10 -} \ No newline at end of file diff --git a/tests/manual/performance_broker/test.sh b/tests/manual/performance_broker/test.sh deleted file mode 100755 index 9963cb021adf33310ee1bd0e99b1a3c1db6841a8..0000000000000000000000000000000000000000 --- a/tests/manual/performance_broker/test.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -# starts broker, mongodb on $service_node -# reads fileset into database -# calls getnext example from $consumer_node - -nthreads=1 -# a directory with many files in it -dir=/gpfs/petra3/scratch/yakubov/test -run_name=test_run -token=K38Mqc90iRv8fC7prcFHd994mF_wfUiJnWBfIjIzieo= - -service_node=max-wgs - -monitor_node=zitpcx27016 -monitor_port=8086 - -consumer_node=max-display -#consumer_node=max-wgs - -consumer_dir=~/broker_test -service_dir=~/broker_test - - -cat settings.json | jq ".PerformanceDbServer = \"${monitor_node}:${monitor_port}\"" > settings_tmp.json - -cat discovery.json | jq ".Broker.StaticEndpoint = \"${service_node}:5005\"" > discovery_tmp.json - - -ssh ${monitor_node} influx -execute \"create database db_test\" - -ssh ${service_node} docker run -d -p 27017:27017 --name mongo mongo -#ssh ${service_node} docker run -d -p 8086 -p 8086 --name influxdb influxdb - -ssh ${service_node} mkdir -p ${service_dir} -ssh ${consumer_node} mkdir -p ${consumer_dir} - - -scp ../../../cmake-build-release/discovery/asapo-discovery ${service_node}:${service_dir} -scp discovery_tmp.json ${service_node}:${service_dir}/discovery.json -rm discovery_tmp.json - -ssh ${service_node} "bash -c 'cd ${service_dir}; nohup ./asapo-discovery -config discovery.json &> ${service_dir}/discovery.log &'" - - -scp settings_tmp.json ${service_node}:${service_dir}/settings.json - -scp ../../../tests/automatic/settings/auth_secret.key ${service_node}:${service_dir}/auth_secret.key - - - -rm settings_tmp.json -scp ../../../cmake-build-release/broker/asapo-broker ${service_node}:${service_dir} -ssh ${service_node} "bash -c 'cd ${service_dir}; nohup ./asapo-broker -config settings.json &> ${service_dir}/broker.log &'" -sleep 0.3 -scp ../../../cmake-build-release/consumer/tools/folder_to_db/folder2db ${consumer_node}:${consumer_dir} -ssh ${consumer_node} ${consumer_dir}/folder2db -n ${nthreads} ${dir} ${run_name} ${service_node} - -sleep 3 - -scp ../../../cmake-build-release/examples/consumer/getnext/getnext ${consumer_node}:${consumer_dir} -ssh ${consumer_node} ${consumer_dir}/getnext ${service_node}:8400 ${run_name} ${nthreads} $token - - - -ssh ${service_node} killall asapo-broker -ssh ${service_node} killall asapo-discovery - -ssh ${service_node} docker rm -f mongo -#ssh ${service_node} docker rm -f influxdb diff --git a/tests/manual/performance_broker_receiver/getlast_broker.cpp b/tests/manual/performance_broker_receiver/getlast_broker.cpp deleted file mode 100644 index ff58c1f5b7d50c1baf904daa494e3db58815ebf0..0000000000000000000000000000000000000000 --- a/tests/manual/performance_broker_receiver/getlast_broker.cpp +++ /dev/null @@ -1,212 +0,0 @@ -#include <iostream> -#include <memory> -#include <vector> -#include <algorithm> -#include <thread> -#include <chrono> -#include <iomanip> -#include <numeric> -#include <mutex> - -#include "asapo/asapo_consumer.h" - -using std::chrono::system_clock; -using asapo::Error; - -std::string group_id = ""; -std::mutex lock; - - -inline std::string ConnectionTypeToString(asapo::NetworkConnectionType type) { - switch (type) { - case asapo::NetworkConnectionType::kUndefined: - return "No connection"; - case asapo::NetworkConnectionType::kAsapoTcp: - return "TCP"; - case asapo::NetworkConnectionType::kFabric: - return "Fabric"; - } - return "Unknown type"; -} - -struct Args { - std::string server; - std::string file_path; - std::string beamtime_id; - std::string token; - int timeout_ms; - size_t nthreads; - bool read_data; - bool datasets; -}; - -void WaitThreads(std::vector<std::thread>* threads) { - for (auto& thread : *threads) { - thread.join(); - } -} - -int ProcessError(const Error& err) { - if (err == nullptr) return 0; - std::cout << err->Explain() << std::endl; - return err == asapo::ConsumerErrorTemplates::kEndOfStream ? 0 : 1; -} - -std::vector<std::thread> StartThreads(const Args& params, - std::vector<int>* nfiles, - std::vector<int>* errors, - std::vector<int>* nbuf, - std::vector<int>* nfiles_total) { - auto exec_next = [¶ms, nfiles, errors, nbuf, nfiles_total](size_t i) { - asapo::MessageMeta fi; - Error err; - auto consumer = asapo::ConsumerFactory::CreateConsumer(params.server, params.file_path, true, - asapo::SourceCredentials{asapo::SourceType::kProcessed, - params.beamtime_id, "", "", - params.token}, &err); - consumer->SetTimeout((uint64_t) params.timeout_ms); - asapo::MessageData data; - - lock.lock(); - - if (group_id.empty()) { - group_id = consumer->GenerateNewGroupId(&err); - if (err) { - (*errors)[i] += ProcessError(err); - return; - } - } - - lock.unlock(); - - auto start = system_clock::now(); - while (std::chrono::duration_cast<std::chrono::milliseconds>(system_clock::now() - start).count() < - params.timeout_ms) { - if (params.datasets) { - auto dataset = consumer->GetLastDataset(0, "default", &err); - if (err == nullptr) { - for (auto& fi : dataset.content) { - (*nbuf)[i] += fi.buf_id == 0 ? 0 : 1; - (*nfiles_total)[i]++; - } - } - } else { - err = consumer->GetLast(&fi, params.read_data ? &data : nullptr, "default"); - if (err == nullptr) { - (*nbuf)[i] += fi.buf_id == 0 ? 0 : 1; - if (params.read_data && (*nfiles)[i] < 10 && fi.size < 10) { - data[9] = 0; - std::cout << "Received: " << reinterpret_cast<char const*>(data.get()) << std::endl; - } - } - } - if (err) { - (*errors)[i] += ProcessError(err); - if (err == asapo::ConsumerErrorTemplates::kEndOfStream) { - break; - } - } - (*nfiles)[i]++; - } - }; - - std::vector<std::thread> threads; - for (size_t i = 0; i < params.nthreads; i++) { - threads.emplace_back(std::thread(exec_next, i)); - } - return threads; -} - -int ReadAllData(const Args& params, uint64_t* duration_ms, int* nerrors, int* nbuf, int* nfiles_total, - asapo::NetworkConnectionType* connection_type) { - asapo::MessageMeta fi; - system_clock::time_point t1 = system_clock::now(); - - std::vector<int> nfiles(params.nthreads, 0); - std::vector<int> errors(params.nthreads, 0); - std::vector<int> nfiles_frombuf(params.nthreads, 0); - std::vector<int> nfiles_total_in_datasets(params.nthreads, 0); - std::vector<asapo::NetworkConnectionType> connection_types(params.nthreads, asapo::NetworkConnectionType::kUndefined); - - auto threads = StartThreads(params, &nfiles, &errors, &nfiles_frombuf, &nfiles_total_in_datasets); - WaitThreads(&threads); - - int n_total = std::accumulate(nfiles.begin(), nfiles.end(), 0); - *nerrors = std::accumulate(errors.begin(), errors.end(), 0); - *nbuf = std::accumulate(nfiles_frombuf.begin(), nfiles_frombuf.end(), 0); - *nfiles_total = std::accumulate(nfiles_total_in_datasets.begin(), nfiles_total_in_datasets.end(), 0); - - system_clock::time_point t2 = system_clock::now(); - auto duration_read = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1); - *duration_ms = static_cast<uint64_t>(duration_read.count()); - - // The following two loops will check if all threads that processed some data were using the same network type - { - size_t firstThreadThatActuallyProcessedData = 0; - for (size_t i = 0; i < params.nthreads; i++) { - if (nfiles[i] > 0) { - firstThreadThatActuallyProcessedData = i; - break; - } - } - - *connection_type = connection_types[firstThreadThatActuallyProcessedData]; - for (size_t i = 0; i < params.nthreads; i++) { - if (*connection_type != connection_types[i] && nfiles[i] > 0) { - // The output will look like this: - // ERROR thread[0](processed 5 files) connection type is 'No connection' but thread[1](processed 3 files) is 'TCP' - - std::cout << "ERROR thread[" << i << "](processed " << nfiles[i] << " files) connection type is '" << - ConnectionTypeToString(connection_types[i]) << "' but thread[" - << firstThreadThatActuallyProcessedData << "](processed " - << nfiles[firstThreadThatActuallyProcessedData] << " files) is '" << ConnectionTypeToString( - *connection_type) << "'" << std::endl; - } - } - } - - return n_total; -} - -int main(int argc, char* argv[]) { - Args params; - params.datasets = false; - if (argc != 9 && argc != 10) { - std::cout << "Usage: " + std::string{argv[0]} - + " <server> <network_type> <files_path> <run_name> <nthreads> <token> <timeout ms> <metaonly> [use datasets]" - << - std::endl; - exit(EXIT_FAILURE); - } - params.server = std::string{argv[1]}; - params.file_path = std::string{argv[2]}; - params.beamtime_id = std::string{argv[3]}; - params.nthreads = static_cast<size_t>(atoi(argv[4])); - params.token = std::string{argv[5]}; - params.timeout_ms = atoi(argv[6]); - params.read_data = atoi(argv[7]) != 1; - if (argc == 9) { - params.datasets = atoi(argv[8]) == 1; - } - uint64_t duration_ms; - int nerrors, nbuf, nfiles_total; - asapo::NetworkConnectionType connectionType; - auto nfiles = ReadAllData(params, &duration_ms, &nerrors, &nbuf, &nfiles_total, &connectionType); - std::cout << "Processed " << nfiles << (params.datasets ? " dataset(s)" : " file(s)") << std::endl; - if (params.datasets) { - std::cout << " with " << nfiles_total << " file(s)" << std::endl; - } - std::cout << "Successfully: " << nfiles - nerrors << std::endl; - if (params.read_data && !params.datasets) { - std::cout << " from memory buffer: " << nbuf << std::endl; - std::cout << " from filesystem: " << nfiles - nerrors - nbuf << std::endl; - } - std::cout << "Errors : " << nerrors << std::endl; - std::cout << "Elapsed : " << duration_ms << "ms" << std::endl; - std::cout << "Rate : " << 1000.0f * static_cast<float>(nfiles) / (static_cast<float> - (duration_ms)) << " Hz" << std::endl; - - std::cout << "Using connection type: " << ConnectionTypeToString(connectionType) << std::endl; - - return nerrors == 0 ? 0 : 1; -} diff --git a/tests/manual/performance_full_chain_simple/authorizer.json b/tests/manual/performance_full_chain_simple/authorizer.json deleted file mode 100644 index be04b954b994f0317372212b67886a726a25e8f8..0000000000000000000000000000000000000000 --- a/tests/manual/performance_full_chain_simple/authorizer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Port": 5007, - "LogLevel":"info", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","Year":"2019","Facility":"test_facility"}], - "UserSecretFile":"auth_secret.key", - "AdminSecretFile":"auth_secret_admin.key" -} - - diff --git a/tests/manual/performance_full_chain_simple/broker.json b/tests/manual/performance_full_chain_simple/broker.json deleted file mode 100644 index b67ac89cdefb2b90aca59811a3675a8351eec59a..0000000000000000000000000000000000000000 --- a/tests/manual/performance_full_chain_simple/broker.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "DatabaseServer":"localhost:27017", - "PerformanceDbServer": "localhost:8086", - "MonitorPerformance": true, - "AuthorizationServer": "localhost:5007", - "PerformanceDbName": "db_test", - "Port":5005, - "LogLevel":"info", - "CheckResendInterval":10 -} \ No newline at end of file diff --git a/tests/manual/performance_full_chain_simple/discovery.json b/tests/manual/performance_full_chain_simple/discovery.json deleted file mode 100644 index 8cdd433a71f05e3d7408b696e0c1e220873b7de4..0000000000000000000000000000000000000000 --- a/tests/manual/performance_full_chain_simple/discovery.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Mode": "static", - "Receiver": { - "StaticEndpoints": [ - "localhost:4200" - ], - "MaxConnections": 32 - }, - "Broker": { - "StaticEndpoint": "localhost:5005" - }, - "Port": 5006, - "LogLevel": "info" -} - diff --git a/tests/manual/performance_full_chain_simple/fluentd.conf b/tests/manual/performance_full_chain_simple/fluentd.conf deleted file mode 100644 index 145dbce4bd148936c75da0c94b13786359908a25..0000000000000000000000000000000000000000 --- a/tests/manual/performance_full_chain_simple/fluentd.conf +++ /dev/null @@ -1,38 +0,0 @@ -#used to run fluentd on Maxwell -<source> - @type http - port 9880 - bind 0.0.0.0 - add_remote_addr true -</source> - -<source> - @type tail - path /logs/*.broker - pos_file /tmp/asapo.logrus.log.pos1 - tag asapo.logrus - format json - time_format %Y-%m-%d %H:%M:%S.%N -</source> - -<source> - @type tail - path /logs/*.receiver - pos_file /tmp/asapo.logrus.log.pos2 - tag asapo - format json - time_format %Y-%m-%d %H:%M:%S.%N -</source> - -<match asapo.**> - @type elasticsearch - host max-wgs001.desy.de - port 9200 - flush_interval 5s - logstash_format true - time_key_format %Y-%m-%dT%H:%M:%S.%N - time_key time - time_key_exclude_timestamp true - buffer_type memory - flush_interval 1s -</match> diff --git a/tests/manual/performance_full_chain_simple/receiver.json b/tests/manual/performance_full_chain_simple/receiver.json deleted file mode 100644 index 3c36dadd38dfa8d90994b45019396eefc119d44f..0000000000000000000000000000000000000000 --- a/tests/manual/performance_full_chain_simple/receiver.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "PerformanceDbServer":"localhost:8086", - "MonitorPerformance": true, - "PerformanceDbName": "db_test", - "DatabaseServer":"localhost:27017", - "AuthorizationServer": "localhost:5007", - "DiscoveryServer": "localhost:8400/discovery", - "AuthorizationInterval": 10000, - "ListenPort":4200, - "DataServer": { - "NThreads": 2, - "ListenPort": 23123 - }, - "DataCache": { - "Use": true, - "SizeGB": 1, - "ReservedShare": 10 - }, - "ReceiveToDiskThresholdMB":50, - "LogLevel":"info", - "Tag": "test_receiver" -} diff --git a/tests/manual/performance_full_chain_simple/test.sh b/tests/manual/performance_full_chain_simple/test.sh deleted file mode 100755 index d77c60cd4fa5ce38d44dd800cbe9d9289e49f87c..0000000000000000000000000000000000000000 --- a/tests/manual/performance_full_chain_simple/test.sh +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/env bash - -set -e - -trap Cleanup EXIT - -#clean-up -Cleanup() { -echo cleanup -set +e -ssh ${receiver_node} rm -f ${receiver_dir}/files/${beamline}/${beamtime_id}/* -ssh ${receiver_node} killall receiver -ssh ${receiver_node} killall asapo-discovery -ssh ${receiver_node} killall asapo-authorizer -ssh ${broker_node} killall asapo-broker -ssh ${broker_node} docker rm -f -v mongo -} - -beamtime_id=asapo_test -beamline=test - - -#monitoring_setup -monitor_node=zitpcx27016 -monitor_port=8086 - - -#logs -log_dir=~/fullchain_tests/logs - -# starts receiver on $receiver_node -# runs producer with various file sizes from $producer_node and measures performance - -file_size=10000 -file_num=$((10000000 / $file_size)) -#file_num=$((100000 / $file_size)) -echo filesize: ${file_size}K, filenum: $file_num - -# receiver_setup -receiver_node=max-wgs -receiver_port=4201 -receiver_dir=/gpfs/petra3/scratch/yakubov/receiver_tests -ssh ${receiver_node} mkdir -p ${receiver_dir}/files/${beamline}/${beamtime_id} -scp ../../../cmake-build-release/receiver/receiver ${receiver_node}:${receiver_dir} -cat receiver.json | - jq "to_entries | - map(if .key == \"PerformanceDbServer\" - then . + {value:\"${monitor_node}:${monitor_port}\"} - elif .key == \"ListenPort\" - then . + {value:${receiver_port}} - else . - end - ) | - from_entries" > receiver_tmp.json - -scp receiver_tmp.json ${receiver_node}:${receiver_dir}/receiver.json -rm receiver_tmp.json - -#authorizer_setup -scp ../../../cmake-build-release/authorizer/asapo-authorizer ${receiver_node}:${receiver_dir} -scp authorizer.json ${receiver_node}:${receiver_dir}/authorizer.json - - -# discovery_setup -discovery_port=5006 -cat discovery.json | - jq "to_entries | - map(if .key == \"Port\" - then . + {value:${discovery_port}} - elif .key == \"Endpoints\" - then . + {value:[\"${receiver_node}:${receiver_port}\"]} - else . - end - ) | - from_entries" > discovery_tmp.json - -cat discovery_tmp.json | jq ".Broker.StaticEndpoint = \"${receiver_node}:5005\"" > discovery_tmp1.json - -cat discovery_tmp1.json | jq ".Receiver.StaticEndpoints = [\"${receiver_node}:${receiver_port}\"]" > discovery_tmp2.json - -scp ../../../cmake-build-release/discovery/asapo-discovery ${receiver_node}:${receiver_dir} -scp discovery_tmp2.json ${receiver_node}:${receiver_dir}/discovery.json -discovery_ip=`resolveip -s ${receiver_node}` -rm discovery_tmp*.json - -#producer_setup -producer_node=max-display001 -#producer_node=max-wgs -producer_dir=~/fullchain_tests -scp ../../../cmake-build-release/examples/producer/dummy-data-producer/dummy-data-producer ${producer_node}:${producer_dir} -producer_nthreads=16 - - -#broker_setup -broker_node=max-wgs -broker_dir=~/fullchain_tests -ssh ${broker_node} mkdir -p ${broker_dir}/logs -cat broker.json | - jq "to_entries | - map(if .key == \"PerformanceDbServer\" - then . + {value:\"${monitor_node}:${monitor_port}\"} - else . - end - ) | - from_entries" > settings_tmp.json -scp settings_tmp.json ${broker_node}:${broker_dir}/broker.json -rm settings_tmp.json -scp ../../../cmake-build-release/broker/asapo-broker ${broker_node}:${broker_dir} - - -#consumer_setup -consumer_node=max-display002 -consumer_dir=~/fullchain_tests -nthreads=16 -scp ../../../cmake-build-release/examples/consumer/getnext/getnext ${consumer_node}:${consumer_dir} -scp ../../../cmake-build-release/asapo_tools/asapo ${consumer_node}:${consumer_dir} -scp ../../../tests/automatic/settings/auth_secret.key ${consumer_node}:${consumer_dir}/auth_secret.key - -#monitoring_start -#ssh ${monitor_node} docker run -d -p 8086 -p 8086 --name influxdb influxdb - -#mongo_start -ssh ${broker_node} docker run -d -p 27017:27017 --name mongo mongo - -#discovery_start -ssh ${receiver_node} "bash -c 'cd ${receiver_dir}; nohup ./asapo-discovery -config discovery.json &> ${log_dir}/discovery.log &'" -sleep 0.3 - -#authorizer_start -ssh ${receiver_node} "bash -c 'cd ${receiver_dir}; nohup ./asapo-authorizer -config authorizer.json &> ${log_dir}/log.authorizer &'" - -#receiver_start -ssh ${receiver_node} "bash -c 'cd ${receiver_dir}; nohup ./receiver receiver.json &> ${log_dir}/log.receiver &'" -sleep 0.3 - -#broker_start -ssh ${broker_node} "bash -c 'cd ${broker_dir}; nohup ./asapo-broker -config broker.json &> ${log_dir}/log.broker &'" -sleep 0.3 - -sleep 5 - -#producer_start -ssh ${producer_node} "bash -c 'cd ${producer_dir}; nohup ./dummy-data-producer ${receiver_node}:8400 ${beamtime_id} ${file_size} ${file_num} ${producer_nthreads} 0 100 &> ${log_dir}/producer.log &'" - -sleep 1 - -#prepare token -ssh ${consumer_node} "bash -c '${consumer_dir}/asapo token -secret ${consumer_dir}/auth_secret.key ${beamtime_id} >${consumer_dir}/token'" -#consumer_start -ssh ${consumer_node} "bash -c '${consumer_dir}/getnext ${receiver_node}:8400 ${beamtime_id} ${nthreads} \`cat ${consumer_dir}/token\`'" - - diff --git a/tests/manual/performance_producer_receiver/authorizer.json b/tests/manual/performance_producer_receiver/authorizer.json deleted file mode 100644 index be04b954b994f0317372212b67886a726a25e8f8..0000000000000000000000000000000000000000 --- a/tests/manual/performance_producer_receiver/authorizer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Port": 5007, - "LogLevel":"info", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","Year":"2019","Facility":"test_facility"}], - "UserSecretFile":"auth_secret.key", - "AdminSecretFile":"auth_secret_admin.key" -} - - diff --git a/tests/manual/performance_producer_receiver/discovery.json b/tests/manual/performance_producer_receiver/discovery.json deleted file mode 100644 index e741be430a6c727cd53b1f35753a2c3010f83deb..0000000000000000000000000000000000000000 --- a/tests/manual/performance_producer_receiver/discovery.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Mode": "static", - "Receiver": { - "StaticEndpoints": [ - "localhost:4200" - ], - "MaxConnections": 32 - }, - "Broker": { - "StaticEndpoint": "localhost:5005" - }, - "Port":5006, - "LogLevel":"info" -} \ No newline at end of file diff --git a/tests/manual/performance_producer_receiver/receiver.json b/tests/manual/performance_producer_receiver/receiver.json deleted file mode 100644 index 743e5035b20f458bb8183a475fb43d0427581a61..0000000000000000000000000000000000000000 --- a/tests/manual/performance_producer_receiver/receiver.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "PerformanceDbServer":"localhost:8086", - "MonitorPerformance": true, - "PerformanceDbName": "db_test", - "DatabaseServer":"localhost:27017", - "DiscoveryServer": "localhost:8400/discovery", - "AuthorizationServer": "localhost:5007", - "AuthorizationInterval": 10000, - "ListenPort":4200, - "DataServer": { - "NThreads": 2, - "ListenPort": 23123 - }, - "DataCache": { - "Use": true, - "SizeGB": 1, - "ReservedShare": 10 - }, - "ReceiveToDiskThresholdMB":50, - "LogLevel":"info", - "Tag": "test_receiver" -} diff --git a/tests/manual/performance_producer_receiver/test.sh b/tests/manual/performance_producer_receiver/test.sh deleted file mode 100755 index 030022133d7caaecd11e3d1668767a9724542bda..0000000000000000000000000000000000000000 --- a/tests/manual/performance_producer_receiver/test.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env bash - -set -e - -trap Cleanup EXIT - -Cleanup() { -set +e -ssh ${service_node} rm -f ${service_dir}/files/${beamline}/${beamtime_id}/* -ssh ${service_node} killall receiver -ssh ${service_node} killall asapo-discovery -ssh ${service_node} killall asapo-authorizer -ssh ${service_node} docker rm -f -v mongo -} - - -# starts receiver on $service_node -# runs producer with various file sizes from $consumer_node and measures performance - -# a working directory -service_node=max-wgs -service_ip=`resolveip -s ${service_node}` -discovery_port=5006 -receiver_port=4201 -beamtime_id=asapo_test -beamline=test - - -monitor_node=zitpcx27016 -monitor_port=8086 - -consumer_node=max-display -#consumer_node=max-wgs - -consumer_dir=~/producer_tests -service_dir=/gpfs/petra3/scratch/yakubov/receiver_tests - -ssh ${monitor_node} influx -execute \"create database db_test\" - -#ssh ${monitor_node} docker run -d -p 8086 -p 8086 --name influxdb influxdb - -ssh ${service_node} mkdir -p ${service_dir} -ssh ${service_node} mkdir -p ${service_dir}/files/${beamtime_id} -ssh ${consumer_node} mkdir -p ${consumer_dir} - -scp ../../../cmake-build-release/receiver/receiver ${service_node}:${service_dir} -scp ../../../cmake-build-release/discovery/asapo-discovery ${service_node}:${service_dir} - -scp ../../../cmake-build-release/authorizer/asapo-authorizer ${service_node}:${service_dir} -scp authorizer.json ${service_node}:${service_dir}/authorizer.json - -scp ../../../cmake-build-release/examples/producer/dummy-data-producer/dummy-data-producer ${consumer_node}:${consumer_dir} - -function do_work { -cat receiver.json | - jq "to_entries | - map(if .key == \"PerformanceDbServer\" - then . + {value:\"${monitor_node}:${monitor_port}\"} - elif .key == \"ListenPort\" - then . + {value:${receiver_port}} - end - ) | - from_entries" > receiver_tmp.json - -cat discovery.json | - jq "to_entries | - map(if .key == \"Port\" - then . + {value:${discovery_port}} - else . - end - ) | - from_entries" > discovery_tmp.json - -cat discovery.json | jq ".Port = ${discovery_port}" > discovery_tmp.json - -cat discovery_tmp.json | jq ".Receiver.StaticEndpoints = [\"${service_node}:${receiver_port}\"]" > discovery_tmp1.json - - -scp discovery_tmp1.json ${service_node}:${service_dir}/discovery.json -scp receiver_tmp.json ${service_node}:${service_dir}/receiver.json - - -rm discovery_tmp*.json receiver_tmp.json -ssh ${service_node} "bash -c 'cd ${service_dir}; nohup ./asapo-authorizer -config authorizer.json &> ${service_dir}/authorizer.log &'" -ssh ${service_node} "bash -c 'cd ${service_dir}; nohup ./receiver receiver.json &> ${service_dir}/receiver.log &'" -ssh ${service_node} "bash -c 'cd ${service_dir}; nohup ./asapo-discovery -config discovery.json &> ${service_dir}/discovery.log &'" - -sleep 0.3 -for size in 100 1000 10000 -do -ssh ${service_node} docker run -d -p 27017:27017 --name mongo mongo -echo =================================================================== -ssh ${consumer_node} ${consumer_dir}/dummy-data-producer ${service_ip}:8400 ${beamtime_id} ${size} 10000 8 0 100 -if [ "$1" == "true" ] -then - ssh ${service_node} rm -f ${service_dir}/files/${beamline}/${beamtime_id}/* -fi -ssh ${service_node} docker rm -f -v mongo -done -ssh ${service_node} killall receiver -ssh ${service_node} killall asapo-discovery -ssh ${service_node} killall asapo-authorizer -} - -echo -echo "With write to disk:" -do_work true - -echo -echo "Without write to disk:" -do_work false - - -#rm settings_tmp.json -#ssh ${service_node} docker rm -f influxdb - diff --git a/tests/manual/producer_cpp/CMakeLists.txt b/tests/manual/producer_cpp/CMakeLists.txt deleted file mode 100644 index 07d230c4b413da52d97373a31ed4e31d6a517dfd..0000000000000000000000000000000000000000 --- a/tests/manual/producer_cpp/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -set(TARGET_NAME producer) -set(SOURCE_FILES - producer.cpp - ) - -add_executable(${TARGET_NAME} ${SOURCE_FILES}) -target_include_directories(${TARGET_NAME} PUBLIC include ${CMAKE_SOURCE_DIR}/common/cpp/include) - -#Add all necessary common libraries -GET_PROPERTY(ASAPO_COMMON_IO_LIBRARIES GLOBAL PROPERTY ASAPO_COMMON_IO_LIBRARIES) -target_link_libraries(${TARGET_NAME} ${ASAPO_COMMON_IO_LIBRARIES} asapo-producer) diff --git a/tests/manual/producer_cpp/producer.cpp b/tests/manual/producer_cpp/producer.cpp deleted file mode 100644 index 78aa3c0daf23809255e49596b56d39196666404c..0000000000000000000000000000000000000000 --- a/tests/manual/producer_cpp/producer.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include <thread> -#include <chrono> -#include "asapo/asapo_producer.h" -#include <iostream> - -void ProcessAfterSend(asapo::RequestCallbackPayload payload, asapo::Error err) { - if (err) { - std::cerr << "error/warning during send: " << err << std::endl; - return; - } else { - std::cout << "successfuly send " << payload.original_header.Json() << std::endl; - return; - } -} - -void exit_if_error(std::string error_string, const asapo::Error& err) { - if (err) { - std::cerr << error_string << err << std::endl; - //exit(EXIT_FAILURE); - } -} - -std::string format_string(uint32_t in, std::string format = "%05d") { - if(in > 99999) - in = 0; - - char buf[6]; - snprintf(buf, sizeof(buf), format.c_str(), in); - return std::string(buf); - -} - - -int main(int argc, char* argv[]) { - - uint32_t submodule = 1; - uint32_t sleeptime = 1; - - - if(argc >= 2) - submodule = static_cast<uint32_t>(atoi(argv[1])); - - if(argc >= 3) - sleeptime = static_cast<uint32_t>(atoi(argv[2])); - - - asapo::Error err; - - auto endpoint = "localhost:8400"; // or your endpoint - auto beamtime = "asapo_test"; - - auto producer = asapo::Producer::Create(endpoint, 1, asapo::RequestHandlerType::kTcp, - asapo::SourceCredentials{asapo::SourceType::kProcessed, beamtime, "", "", ""}, 60000, &err); - exit_if_error("Cannot start producer", err); - - uint32_t start_number = 1; - - // number of files per acquistion per module - const uint32_t number_of_splitted_files = 5; - - // number of modules - const uint32_t modules = 3; - - while(true) { - for(uint32_t part = 1; part <= number_of_splitted_files; ++part) { - std::string to_send = "processed/lambdatest_" - + format_string(start_number) // file start number (acquistion id) - + "_part" + format_string(part) // file part id (chunk id) - + "_m" + format_string(submodule, std::string("%02d")); - auto send_size = to_send.size() + 1; - auto buffer = asapo::MessageData(new uint8_t[send_size]); - memcpy(buffer.get(), to_send.c_str(), send_size); - std::string stream = std::to_string(start_number); - // std::cout<<"submodule:"<<submodule - // <<"- stream:"<<stream - // <<"- filename:"<<to_send<<std::endl; - - asapo::MessageHeader message_header{submodule, send_size, to_send, "", part, modules}; - // err = producer->Send(message_header,stream, std::move(buffer), - // asapo::kTransferMetaDataOnly, &ProcessAfterSend); - - err = producer->Send(message_header, std::move(buffer), - asapo::kDefaultIngestMode, stream, &ProcessAfterSend); - exit_if_error("Cannot send file", err); - - err = producer->WaitRequestsFinished(1000); - exit_if_error("Producer exit on timeout", err); - std::this_thread::sleep_for (std::chrono::seconds(sleeptime)); - - // if(part == number_of_splitted_files) - // { - - // err = producer->SendStreamFinishedFlag(stream, - // part, - // std::to_string(start_number+1), - // &ProcessAfterSend); - // exit_if_error("Cannot send file", err); - // } - - } - start_number++; - - } - - - return EXIT_SUCCESS; -} diff --git a/tests/manual/python_tests/ASAPO-csb.ipynb b/tests/manual/python_tests/ASAPO-csb.ipynb deleted file mode 100644 index 5e2cb51dc3a8a05185b1bd08f5251b8f272639dc..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/ASAPO-csb.ipynb +++ /dev/null @@ -1,116 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "%matplotlib inline" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "import asapo_consumer\n", - "import h5py\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "import tempfile\n", - "import cbf\n", - "import time\n", - "from IPython import display\n", - "\n", - "broker, err = asapo_consumer.create_consumer(\"psana002:8400\", \"/tmp\", \"asapo_test2\",\"\",\"yzgAcLmijSLWIm8dBiGNCbc0i42u5HSm-zR6FRqo__Y=\", 1000000)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQYAAAD8CAYAAACVSwr3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzsvVuQZNl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KIp/6Of/YlEUT73L5/YbRVHcKIriW9mxez63oig+489fKoriM+/hub7r1bpv81zfqLr4SF7bd2yUZXnkfjCew2XgUaACvAA8cQTO63vAyUPH/lfgl/zvXwL+F//7U8C/xVK9nwC++i6f248BTwHfervnBjSAV/z3jP898x6d6y8D//0dnvuE3/8q8IjPi+H3ao4A88BT/ncdI+k9cVSv7Tv1c1Q9hrdVifk+jU9jzFD891/Njv9WaeMrwHRRFPN3eoN3YpRl+UXIqnfe3rn9BPD5sixbZVmuA5/HSuffi3N9o/GOVuu+jXN9o+riI3lt36lxVA3DPVdivkejBP6gKIpvFEXxc37sdOnUcP99yo8fhe9wr+f2fp/zu1qt++87DlUXf79d23saR9Uw3FUl5vswfqQsy6cwsZmfL4rix97kuUf1O8C/ZwXsuzTelWrdd2rcobr4DZ96h2Pv97W953FUDcNdVWK+16Msy9f99w3gX2Pu7HWFCP77hj/9KHyHez239+2cy3epWvedGHeqLub76Nq+nXFUDcPXgfNFUTxSFEUFk4r77Pt5QkVRTBRFUdffwCeBb/l5CWH+DPB7/vdngZ91lPoTwKZcz/dw3Ou5/T7wyaIoZtyV/6Qfe9fHIfzlPwWUsfgs8NNFUVSLongEq9T9Gu/RHCmKogD+KXCxLMtfzR76vrm2b2u83+jnm6DBn8IQ4MvA3z0C5/Mohny/ACzqnIBZrLR8yX83/HiBaVxeBl4Cnn6Xz+//wVzwXWx3+q/fzrkB/xUG8F0C/sZ7eK7/zM/lRWxxzWfP/7t+ri8DP/VezhHgRzGX/0Xgef/51FG9tu/UzzEl+ngcj+Nx2ziqocTxOB7H430cx4bheByP43HbODYMx+N4HI/bxrFhOB7H43jcNo4Nw/E4HsfjtnFsGI7H8Tget41jw3A8jsfxuG38/xmTDzyuJa88AAAAAElFTkSuQmCC\n", - "text/plain": [ - "<Figure size 432x288 with 1 Axes>" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'_id': 198, 'size': 6247362, 'name': 'data/file_lin/test_dir/sample_1_00001.cbf'}\n" - ] - } - ], - "source": [ - "last_id = 0\n", - "try: \n", - " while True:\n", - " data, meta, err = broker.get_last(meta_only=False)\n", - " id = meta['_id']\n", - " if id == last_id:\n", - " time.sleep(1)\n", - " continue\n", - " tmpfile = tempfile.NamedTemporaryFile()\n", - " tmpfile.write(data)\n", - " content = cbf.read(tmpfile.name)\n", - " numpy_array_with_data = content.data\n", - " header_metadata = content.metadata\n", - " plt.imshow(numpy_array_with_data, cmap='gnuplot', vmax=500)\n", - "# display.display(plt.gcf())\n", - " display.clear_output(wait=True)\n", - " plt.show()\n", - " print (meta) \n", - " last_id = id\n", - "except KeyboardInterrupt:\n", - " pass\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/tests/manual/python_tests/consumer/consumer_api.py b/tests/manual/python_tests/consumer/consumer_api.py deleted file mode 100644 index 2c72bf03f5a3b52c094868701d68aca2490a6684..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/consumer/consumer_api.py +++ /dev/null @@ -1,23 +0,0 @@ -from __future__ import print_function - -import asapo_consumer -import sys - -source, path, beamtime, token = sys.argv[1:] -consumer = asapo_consumer.create_consumer(source,path,False, beamtime,"",token,1000) -group_id = consumer.generate_group_id() - -res = consumer.query_messages("_id > 0", stream="1") - -print(res) - -#data, meta = consumer.get_by_id(5,group_id,"default", meta_only=False) - -#meta["buf_id"]=0 -#data = consumer.retrieve_data(meta) - -#print (meta) -#print (len(data),data[0:100]) -#data.tofile("out") - -sys.exit(0) diff --git a/tests/manual/python_tests/consumer/consumer_api.py_ b/tests/manual/python_tests/consumer/consumer_api.py_ deleted file mode 100644 index a4c784c0775952c687f7ad3dd388a7990f9947e9..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/consumer/consumer_api.py_ +++ /dev/null @@ -1,20 +0,0 @@ -from __future__ import print_function - -import asapo_consumer -import sys - -source, path,beamtime, token = sys.argv[1:] -consumer = asapo_consumer.create_consumer(source,path,False, beamtime,"",token,1000) -group_id = broker.generate_group_id() - - -_, meta = broker.get_by_id(1,group_id, meta_only=True) - -#meta["buf_id"]=0 -data = broker.retrieve_data(meta) - -print (meta) -print (len(data),data[0:100]) -data.tofile("out") - -sys.exit(0) \ No newline at end of file diff --git a/tests/manual/python_tests/consumer/consumer_api_test.py b/tests/manual/python_tests/consumer/consumer_api_test.py deleted file mode 100644 index a8f270ad7ce638145eb7cfe04acd8416252daf57..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/consumer/consumer_api_test.py +++ /dev/null @@ -1,27 +0,0 @@ -import asapo_consumer -import time - -endpoint = "asap3-utl01.desy.de:8400" -beamtime = "11012171" -token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzU3NTMxMDksImp0aSI6ImMyOTR0NWFodHY1am9vZHVoaGNnIiwic3ViIjoiYnRfMTEwMTIxNzEiLCJFeHRyYUNsYWltcyI6eyJBY2Nlc3NUeXBlcyI6WyJyZWFkIiwid3JpdGUiXX19.kITePbv_dXY2ACxpAQ-PeQJPQtnR02bMoFrXq0Pbcm0" -datasource = 'VmFyZXgx' - -consumer = asapo_consumer.create_consumer(endpoint,"/asap3/petra3/gpfs/p21.2/2021/data/11012171",False, - beamtime,datasource,token,20000) -laststream=consumer.get_stream_list()[-1]["name"] -print("laststream = " + laststream) - -group_id = consumer.generate_group_id() -t1=time.time() - -data, meta = consumer.get_next(group_id, meta_only = False, stream=laststream) -#meta['buf_id'] = 0 -#data = consumer.retrieve_data(meta) - - -print ("total time: %f" % (time.time()-t1)) - -print ('id:',meta['_id']) -print ('file name:',meta['name']) -print ('file content:',repr(data.tobytes()[:1000])) - diff --git a/tests/manual/python_tests/consumer/test.sh b/tests/manual/python_tests/consumer/test.sh deleted file mode 100644 index 9c9712593b009f4bc895e54907e27dd56b7d7e51..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/consumer/test.sh +++ /dev/null @@ -1 +0,0 @@ -python3 consumer_api.py asapo-services.desy.de:8400 asapo_test /shared_data/test_facility/gpfs/test/2019/data/asapo_test KmUDdacgBzaOD3NIJvN1NmKGqWKtx0DK-NyPjdpeWkc= diff --git a/tests/manual/python_tests/consumer/test_asap3.sh b/tests/manual/python_tests/consumer/test_asap3.sh deleted file mode 100755 index 1bea28cdbe132fd62f58cc3d0cbd95a3f658812d..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/consumer/test_asap3.sh +++ /dev/null @@ -1,4 +0,0 @@ -export PYTHONPATH=/Users/yakubov/projects/asapo/cmake-build-debug/consumer/api/python -export token=KmUDdacgBzaOD3NIJvN1NmKGqWKtx0DK-NyPjdpeWkc= -export token=_bVfWrAh4S36-xadWkE71i_oOsPPgwFjzIh6UBFCxxU= -python3 consumer_api.py asap3-utl.desy.de:8400 /gpfs/asapo/shared/test_dir/test_facility/gpfs/test/2019/data/asapo_test 11010325 $token diff --git a/tests/manual/python_tests/consumer/test_asapsrv.sh b/tests/manual/python_tests/consumer/test_asapsrv.sh deleted file mode 100755 index 9f37bbe661636b9241d1bc0a99089a9f373cedb6..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/consumer/test_asapsrv.sh +++ /dev/null @@ -1,3 +0,0 @@ -export PYTHONPATH=/Users/yakubov/Projects/asapo/cmake-build-debug/consumer/api/python -export token=KmUDdacgBzaOD3NIJvN1NmKGqWKtx0DK-NyPjdpeWkc= -python3 consumer_api.py asapo-services.desy.de:8400 /shared_data/test_facility/gpfs/test/2019/data/asapo_test asapo_test $token diff --git a/tests/manual/python_tests/consumer/test_k8s.sh b/tests/manual/python_tests/consumer/test_k8s.sh deleted file mode 100755 index 9ee6bb429689c22b6be068b889a89f1ad5a62094..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/consumer/test_k8s.sh +++ /dev/null @@ -1,4 +0,0 @@ -export PYTHONPATH=/Users/yakubov/projects/asapo/cmake-build-debug/consumer/api/python -export token=IEfwsWa0GXky2S3MkxJSUHJT1sI8DD5teRdjBUXVRxk= -python3 consumer_api.py gest-k8s-test2.desy.de/yakser /test_offline/test_facility/gpfs/test/2019/data/asapo_test asapo_test $token -#python3 getnext.py gest-k8s-test2.desy.de/yakser /test_offline/test_facility/gpfs/test/2019/data/asapo_test asapo_test $token new diff --git a/tests/manual/python_tests/copy-files.sh b/tests/manual/python_tests/copy-files.sh deleted file mode 100755 index ff5eebe0122b5682672c3838cfade1495030838f..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/copy-files.sh +++ /dev/null @@ -1 +0,0 @@ -ssh -l root asap3-tst01 scp max-wgs:/beegfs/desy/group/it/ReferenceData/MX/Pilatus/sample_1_0000$1.cbf /run/user/data/file_lin/test_dir/ diff --git a/tests/manual/python_tests/plot_images_online.py b/tests/manual/python_tests/plot_images_online.py deleted file mode 100644 index 53e63a99c38a64361d84f9d7309bc95b5c108754..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/plot_images_online.py +++ /dev/null @@ -1,39 +0,0 @@ -import asapo_consumer -import h5py -import numpy as np -import matplotlib.pyplot as plt - - -#d1 = np.random.random(size = (20)) -#f = h5py.File("mytestfile1.hdf5", "w") -#dset = f.create_dataset("mydataset", data = d1) -#f.close() - -consumer, err = asapo_consumer.create_consumer("psana002:8400", "/tmp", True, "asapo_test2","","yzgAcLmijSLWIm8dBiGNCbc0i42u5HSm-zR6FRqo__Y=", 1000000) - -last_id = 0 -while True: - data, meta, err = consumer.get_last(meta_only=False) - id = meta['_id'] - if id == last_id: - continue - fid = h5py.h5f.open_file_message(data) - f = h5py.File(fid) - data1 = np.array(f['mydataset']) - print(data1) - plt.plot(data1) - plt.ylabel('some numbers') - plt.show() - last_id = id - f.close() - - -#alternative - but tobytes creates an additional copy - not nice. -#import tables -#h5file1 = tables.open_file("in-memory-sample.h5", driver="H5FD_CORE", -# driver_core_message=data.tobytes(), -# driver_core_backing_store=0) -#data2 = h5file1.root.mydataset.read() - - - diff --git a/tests/manual/python_tests/producer/aaa b/tests/manual/python_tests/producer/aaa deleted file mode 100644 index ce013625030ba8dba906f756967f9e9ca394464a..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/aaa +++ /dev/null @@ -1 +0,0 @@ -hello diff --git a/tests/manual/python_tests/producer/authorizer.json.tpl b/tests/manual/python_tests/producer/authorizer.json.tpl deleted file mode 100644 index 92292267951f4e5ddb9017fa3df32293531e3719..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/authorizer.json.tpl +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Port": {{ env "NOMAD_PORT_authorizer" }}, - "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","Year":"2019","Facility":"test_facility"}, - {"beamtimeId":"asapo_test1","beamline":"test1","Year":"2019","Facility":"test_facility"}, - {"beamtimeId":"asapo_test2","beamline":"test2","Year":"2019","Facility":"test_facility"}], - "UserSecretFile":"auth_secret.key", - "AdminSecretFile":"auth_secret_admin.key" -} - - diff --git a/tests/manual/python_tests/producer/authorizer.nmd b/tests/manual/python_tests/producer/authorizer.nmd deleted file mode 100644 index e03b1538f1e0f0e99024c8e634d9ea36e2223147..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/authorizer.nmd +++ /dev/null @@ -1,55 +0,0 @@ -job "authorizer" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "asapo-authorizer" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/authorizer/asapo-authorizer", - args = ["-config","${NOMAD_TASK_DIR}/authorizer.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "authorizer" { - static = "5007" - } - } - } - - service { - name = "authorizer" - port = "authorizer" - check { - name = "alive" - type = "http" - path = "/health-check" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/authorizer.json.tpl" - destination = "local/authorizer.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/auth_secret.key" - destination = "auth_secret.key" - change_mode = "signal" - change_signal = "SIGHUP" - } - } - } -} diff --git a/tests/manual/python_tests/producer/clean_db.sh b/tests/manual/python_tests/producer/clean_db.sh deleted file mode 100755 index 1f89519f88aee0fe4571eb0a7defdb9487ecdd7d..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/clean_db.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -beamtime_id=asapo_test1 - - -echo "db.dropDatabase()" | mongo ${beamtime_id}_python2 -echo "db.dropDatabase()" | mongo ${beamtime_id}_python3 diff --git a/tests/manual/python_tests/producer/cons.py b/tests/manual/python_tests/producer/cons.py deleted file mode 100644 index 2491ef1aadaf2d6626b4c39c7ce3551a49101ebd..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/cons.py +++ /dev/null @@ -1,20 +0,0 @@ -from __future__ import print_function - -import asapo_consumer -import sys - -token="IEfwsWa0GXky2S3MkxJSUHJT1sI8DD5teRdjBUXVRxk=" -source="127.0.0.1:8400" -path="/tmp/petra3/gpfs/p01/2019/data/asapo_test" -beamtime="asapo_test" - -consumer = asapo_consumer.create_consumer(source,path,False, beamtime,"test",token,1000) -group_id = consumer.generate_group_id() - -data, meta = consumer.get_by_id(3,group_id,"default", meta_only=False) - -print (meta) -print (data.tostring() ) - - -sys.exit(0) \ No newline at end of file diff --git a/tests/manual/python_tests/producer/discovery.json.tpl b/tests/manual/python_tests/producer/discovery.json.tpl deleted file mode 100644 index 48836238323215f636d3db9abbb411ba22fc9d95..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/discovery.json.tpl +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Mode": "consul", - "Receiver": { - "MaxConnections": 32, - "UseIBAddress": false - }, - "Port": {{ env "NOMAD_PORT_discovery" }}, - "LogLevel":"debug", - "Mongo": { - "StaticEndpoint": "127.0.0.1:27017" - } -} - - diff --git a/tests/manual/python_tests/producer/discovery.nmd b/tests/manual/python_tests/producer/discovery.nmd deleted file mode 100644 index f95980bae862ec43bf59383d85b307bf36dc3bcf..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/discovery.nmd +++ /dev/null @@ -1,49 +0,0 @@ -job "discovery" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "discovery" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/discovery/asapo-discovery", - args = ["-config","${NOMAD_TASK_DIR}/discovery.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "discovery" { - static = "5006" - } - } - } - - service { - name = "discovery" - port = "discovery" - check { - name = "alive" - type = "http" - path = "/receivers" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/tests/manual/python_tests/producer/discovery.json.tpl" - destination = "local/discovery.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - } - } -} diff --git a/tests/manual/python_tests/producer/file1 b/tests/manual/python_tests/producer/file1 deleted file mode 100644 index a5bce3fd2565d8f458555a0c6f42d0504a848bd5..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/file1 +++ /dev/null @@ -1 +0,0 @@ -test1 diff --git a/tests/manual/python_tests/producer/nginx.conf.tpl b/tests/manual/python_tests/producer/nginx.conf.tpl deleted file mode 100644 index b784d07256fc978f12d4aa94d8970a435b087df2..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/nginx.conf.tpl +++ /dev/null @@ -1,91 +0,0 @@ -worker_processes 1; - -events { - worker_connections 1024; -} - -http { -# include mime.types; -# default_type application/octet-stream; - -# sendfile on; -# tcp_nopush on; - -# keepalive_timeout 0; -# keepalive_timeout 65; - - resolver 127.0.0.1:8600 valid=1s; - server { - listen {{ env "NOMAD_PORT_nginx" }}; - set $discovery_endpoint discovery.service.asapo; - set $authorizer_endpoint authorizer.service.asapo; - set $fluentd_endpoint fluentd.service.asapo; - set $kibana_endpoint kibana.service.asapo; - set $grafana_endpoint grafana.service.asapo; - set $mongo_endpoint mongo.service.asapo; - set $influxdb_endpoint influxdb.service.asapo; - set $elasticsearch_endpoint elasticsearch.service.asapo; - - location /mongo/ { - rewrite ^/mongo(/.*) $1 break; - proxy_pass http://$mongo_endpoint:27017$uri$is_args$args; - } - - location /influxdb/ { - rewrite ^/influxdb(/.*) $1 break; - proxy_pass http://$influxdb_endpoint:8086$uri$is_args$args; - } - - location /elasticsearch/ { - rewrite ^/elasticsearch(/.*) $1 break; - proxy_pass http://$elasticsearch_endpoint:9200$uri$is_args$args; - } - - location /discovery/ { - rewrite ^/discovery(/.*) $1 break; - proxy_pass http://$discovery_endpoint:5006$uri$is_args$args; - } - - location /logs/ { - rewrite ^/logs(/.*) $1 break; - proxy_pass http://$fluentd_endpoint:9880$uri$is_args$args; - } - - location /logsview/ { - proxy_pass http://$kibana_endpoint:5601$uri$is_args$args; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - } - - location /performance/ { - rewrite ^/performance(/.*) $1 break; - proxy_pass http://$grafana_endpoint:3000$uri$is_args$args; - } - - location /authorizer/ { - rewrite ^/authorizer(/.*) $1 break; - proxy_pass http://$authorizer_endpoint:5007$uri$is_args$args; - } - - location /nginx-health { - return 200 "healthy\n"; - } - } -} - -stream { - resolver 127.0.0.1:8600 valid=1s; - - map $remote_addr $upstream { - default fluentd.service.asapo; - } - - - server { - listen 9881; - proxy_pass $upstream:24224; - } -} - - diff --git a/tests/manual/python_tests/producer/nginx.nmd b/tests/manual/python_tests/producer/nginx.nmd deleted file mode 100644 index b424e53874d17c7b0612106225f0250fa274fac4..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/nginx.nmd +++ /dev/null @@ -1,63 +0,0 @@ -job "nginx" { - datacenters = ["dc1"] - - type = "service" - - update { - max_parallel = 1 - min_healthy_time = "10s" - healthy_deadline = "3m" - auto_revert = false - } - - group "nginx" { - count = 1 - - restart { - attempts = 2 - interval = "30m" - delay = "15s" - mode = "fail" - } - - task "nginx" { - driver = "raw_exec" - - config { - command = "nginx", - args = ["-c","${NOMAD_TASK_DIR}/nginx.conf"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - mbits = 10 - port "nginx" { - static = 8400 - } - } - } - - service { - port = "nginx" - name = "nginx" - check { - name = "alive" - type = "http" - path = "/nginx-health" - timeout = "2s" - interval = "10s" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/nginx.conf.tpl" - destination = "local/nginx.conf" - change_mode = "restart" - } - - - } - } -} diff --git a/tests/manual/python_tests/producer/receiver.json.tpl b/tests/manual/python_tests/producer/receiver.json.tpl deleted file mode 100644 index 14a4032cde80ba693285b7f03f1100dc49fbcba3..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/receiver.json.tpl +++ /dev/null @@ -1,24 +0,0 @@ -{ - "PerformanceDbServer":"localhost:8086", - "MonitorPerformance": true, - "PerformanceDbName": "db_test", - "DatabaseServer":"localhost:27017", - "DiscoveryServer": "localhost:8400/discovery", - "DataServer": { - "AdvertiseURI": "127.0.0.1", - "NThreads": 2, - "ListenPort": {{ env "NOMAD_PORT_recv_ds" }}, - "NetworkMode": ["tcp"] - }, - "DataCache": { - "Use": true, - "SizeGB": 1, - "ReservedShare": 10 - }, - "AuthorizationServer": "localhost:8400/authorizer", - "AuthorizationInterval": 10000, - "ListenPort": {{ env "NOMAD_PORT_recv" }}, - "Tag": "{{ env "NOMAD_ADDR_recv" }}", - "ReceiveToDiskThresholdMB":50, - "LogLevel" : "debug" -} diff --git a/tests/manual/python_tests/producer/receiver.nmd b/tests/manual/python_tests/producer/receiver.nmd deleted file mode 100644 index a25edbf7b68a661e2ee25261e3dcb2a3a8f17101..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/receiver.nmd +++ /dev/null @@ -1,47 +0,0 @@ -job "receiver" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "receiver" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/receiver/receiver", - args = ["${NOMAD_TASK_DIR}/receiver.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "recv" {} - port "recv_ds" {} - } - } - - service { - name = "asapo-receiver" - port = "recv" - check { - name = "alive" - type = "tcp" - interval = "10000s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/receiver_tcp.json.tpl" - destination = "local/receiver.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - } - } -} diff --git a/tests/manual/python_tests/producer/run.sh b/tests/manual/python_tests/producer/run.sh deleted file mode 100755 index 0a0f2a5a1f381db96e7701cec333e010c39a6bed..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/run.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -export PYTHONPATH=/home/yakubov/projects/asapo/cmake-build-debug/producer/api/python:${PYTHONPATH} - -mkdir -p /tmp/asapo/receiver/files/test1/asapo_test1 - -python test.py python2 - - -python3 test.py python3 diff --git a/tests/manual/python_tests/producer/short_test.py b/tests/manual/python_tests/producer/short_test.py deleted file mode 100644 index eaf47f8286862472a2313f307cd0abc9f01455e3..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/short_test.py +++ /dev/null @@ -1,38 +0,0 @@ -from __future__ import print_function - -import asapo_producer -import sys -import threading - -lock = threading.Lock() - - -endpoint = "127.0.0.1:8400" -beamtime = "asapo_test" -data_source = "test" -token = "" -nthreads = 8 - -def callback(header,err): - lock.acquire() # to print - if err is not None: - print("could not sent: ",header,err) - else: - print ("successfuly sent: ",header) - lock.release() - -def assert_err(err): - if err is not None: - print(err) - sys.exit(1) - -producer = asapo_producer.create_producer(endpoint,'processed',beamtime,'auto', data_source, token, nthreads ,0) - -producer.set_log_level("debug") - -#send meta only -producer.send_file(3, local_path = "/tmp/petra3/gpfs/p01/2019/data/asapo_test",exposed_path = "producer/aaa", - ingest_mode = asapo_producer.INGEST_MODE_TRANSFER_METADATA_ONLY, callback = callback) - -producer.wait_requests_finished(1000) - diff --git a/tests/manual/python_tests/producer/start_services.sh b/tests/manual/python_tests/producer/start_services.sh deleted file mode 100755 index 1b882a4a885571fcfa7e2e83340be585d0d9110a..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/start_services.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -nomad run authorizer.nmd -nomad run discovery.nmd -nomad run nginx.nmd -nomad run receiver_tcp.nmd diff --git a/tests/manual/python_tests/producer/stop_services.sh b/tests/manual/python_tests/producer/stop_services.sh deleted file mode 100755 index 1ce92c903f6004e91356155667f35ac23b8f0687..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/stop_services.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -nomad stop authorizer -nomad stop discovery -nomad stop nginx -nomad run nginx_kill.nmd && nomad stop -yes -purge nginx_kill -nomad stop receiver diff --git a/tests/manual/python_tests/producer/test.py b/tests/manual/python_tests/producer/test.py deleted file mode 100644 index 403dc1d4623bba660f17f94a428b274f5770cec5..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer/test.py +++ /dev/null @@ -1,76 +0,0 @@ -from __future__ import print_function - -import asapo_producer -import sys -import time -import numpy as np -import threading -lock = threading.Lock() - - -endpoint = "127.0.0.1:8400" -beamtime = "asapo_test1" -data_source = "detector" -token = "" -nthreads = 8 - -def callback(header,err): - lock.acquire() # to print - if err is not None: - print("could not sent: ",header,err) - else: - print ("successfuly sent: ",header) - lock.release() - -def assert_err(err): - if err is not None: - print(err) - sys.exit(1) - -producer = asapo_producer.create_producer(endpoint,'processed',beamtime,'auto', data_source, token, nthreads ,0) - -producer.set_log_level("info") - -#send single file -producer.send_file(1, local_path = "./file1", exposed_path = data_source+"/"+"file1", user_meta = '{"test_key":"test_val"}', callback = callback) - - -#send datasets -producer.send_file(2, local_path = "./file1", exposed_path = data_source+"/"+"file2",dataset=(2,2),user_meta = '{"test_key":"test_val"}', callback = callback) -producer.send_file(3, local_path = "./file1", exposed_path = data_source+"/"+"file3",dataset=(2,2),user_meta = '{"test_key":"test_val"}', callback = callback) - -#send meta only -producer.send_file(3, local_path = "./not_exist",exposed_path = "./whatever", - ingest_mode = asapo_producer.INGEST_MODE_TRANSFER_METADATA_ONLY, callback = callback) - -data = np.arange(10,dtype=np.float64) - -#send data from array -producer.send(4, data_source+"/"+"file5",data, - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) - -#send data from string -err = producer.send(5, data_source+"/"+"file6",b"hello", - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) - -#send metadata only -producer.send(6, data_source+"/"+"file7",None, - ingest_mode = asapo_producer.INGEST_MODE_TRANSFER_METADATA_ONLY, callback = callback) - - -x = np.array([[1, 2, 3], [4, 5, 6]], np.float32) -producer.send(4, data_source+"/"+"file5",x, - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) - -try: - x = x.T - producer.send(4, data_source+"/"+"file5",x, - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) -except: - pass -else: - print ("sohuld be exception") - - -producer.wait_requests_finished(1000) - diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/authorizer.json.tpl b/tests/manual/python_tests/producer_wait_bug_mongo/authorizer.json.tpl deleted file mode 100644 index 92292267951f4e5ddb9017fa3df32293531e3719..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/authorizer.json.tpl +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Port": {{ env "NOMAD_PORT_authorizer" }}, - "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","Year":"2019","Facility":"test_facility"}, - {"beamtimeId":"asapo_test1","beamline":"test1","Year":"2019","Facility":"test_facility"}, - {"beamtimeId":"asapo_test2","beamline":"test2","Year":"2019","Facility":"test_facility"}], - "UserSecretFile":"auth_secret.key", - "AdminSecretFile":"auth_secret_admin.key" -} - - diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/authorizer.nmd b/tests/manual/python_tests/producer_wait_bug_mongo/authorizer.nmd deleted file mode 100644 index e03b1538f1e0f0e99024c8e634d9ea36e2223147..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/authorizer.nmd +++ /dev/null @@ -1,55 +0,0 @@ -job "authorizer" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "asapo-authorizer" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/authorizer/asapo-authorizer", - args = ["-config","${NOMAD_TASK_DIR}/authorizer.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "authorizer" { - static = "5007" - } - } - } - - service { - name = "authorizer" - port = "authorizer" - check { - name = "alive" - type = "http" - path = "/health-check" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/authorizer.json.tpl" - destination = "local/authorizer.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/auth_secret.key" - destination = "auth_secret.key" - change_mode = "signal" - change_signal = "SIGHUP" - } - } - } -} diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/clean_db.sh b/tests/manual/python_tests/producer_wait_bug_mongo/clean_db.sh deleted file mode 100755 index 1f89519f88aee0fe4571eb0a7defdb9487ecdd7d..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/clean_db.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -beamtime_id=asapo_test1 - - -echo "db.dropDatabase()" | mongo ${beamtime_id}_python2 -echo "db.dropDatabase()" | mongo ${beamtime_id}_python3 diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/discovery.json.tpl b/tests/manual/python_tests/producer_wait_bug_mongo/discovery.json.tpl deleted file mode 100644 index 4a72abf42fd080c2f6b8331855323eb1b5c664bd..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/discovery.json.tpl +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Mode": "consul", - "Receiver": { - "MaxConnections": 32, - "UseIBAddress": false - }, - "Port": {{ env "NOMAD_PORT_discovery" }}, - "LogLevel":"debug", -} - - diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/discovery.nmd b/tests/manual/python_tests/producer_wait_bug_mongo/discovery.nmd deleted file mode 100644 index f95980bae862ec43bf59383d85b307bf36dc3bcf..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/discovery.nmd +++ /dev/null @@ -1,49 +0,0 @@ -job "discovery" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "discovery" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/discovery/asapo-discovery", - args = ["-config","${NOMAD_TASK_DIR}/discovery.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "discovery" { - static = "5006" - } - } - } - - service { - name = "discovery" - port = "discovery" - check { - name = "alive" - type = "http" - path = "/receivers" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/tests/manual/python_tests/producer/discovery.json.tpl" - destination = "local/discovery.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - } - } -} diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/file1 b/tests/manual/python_tests/producer_wait_bug_mongo/file1 deleted file mode 100644 index a5bce3fd2565d8f458555a0c6f42d0504a848bd5..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/file1 +++ /dev/null @@ -1 +0,0 @@ -test1 diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/nginx.conf.tpl b/tests/manual/python_tests/producer_wait_bug_mongo/nginx.conf.tpl deleted file mode 100644 index b784d07256fc978f12d4aa94d8970a435b087df2..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/nginx.conf.tpl +++ /dev/null @@ -1,91 +0,0 @@ -worker_processes 1; - -events { - worker_connections 1024; -} - -http { -# include mime.types; -# default_type application/octet-stream; - -# sendfile on; -# tcp_nopush on; - -# keepalive_timeout 0; -# keepalive_timeout 65; - - resolver 127.0.0.1:8600 valid=1s; - server { - listen {{ env "NOMAD_PORT_nginx" }}; - set $discovery_endpoint discovery.service.asapo; - set $authorizer_endpoint authorizer.service.asapo; - set $fluentd_endpoint fluentd.service.asapo; - set $kibana_endpoint kibana.service.asapo; - set $grafana_endpoint grafana.service.asapo; - set $mongo_endpoint mongo.service.asapo; - set $influxdb_endpoint influxdb.service.asapo; - set $elasticsearch_endpoint elasticsearch.service.asapo; - - location /mongo/ { - rewrite ^/mongo(/.*) $1 break; - proxy_pass http://$mongo_endpoint:27017$uri$is_args$args; - } - - location /influxdb/ { - rewrite ^/influxdb(/.*) $1 break; - proxy_pass http://$influxdb_endpoint:8086$uri$is_args$args; - } - - location /elasticsearch/ { - rewrite ^/elasticsearch(/.*) $1 break; - proxy_pass http://$elasticsearch_endpoint:9200$uri$is_args$args; - } - - location /discovery/ { - rewrite ^/discovery(/.*) $1 break; - proxy_pass http://$discovery_endpoint:5006$uri$is_args$args; - } - - location /logs/ { - rewrite ^/logs(/.*) $1 break; - proxy_pass http://$fluentd_endpoint:9880$uri$is_args$args; - } - - location /logsview/ { - proxy_pass http://$kibana_endpoint:5601$uri$is_args$args; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - } - - location /performance/ { - rewrite ^/performance(/.*) $1 break; - proxy_pass http://$grafana_endpoint:3000$uri$is_args$args; - } - - location /authorizer/ { - rewrite ^/authorizer(/.*) $1 break; - proxy_pass http://$authorizer_endpoint:5007$uri$is_args$args; - } - - location /nginx-health { - return 200 "healthy\n"; - } - } -} - -stream { - resolver 127.0.0.1:8600 valid=1s; - - map $remote_addr $upstream { - default fluentd.service.asapo; - } - - - server { - listen 9881; - proxy_pass $upstream:24224; - } -} - - diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/nginx.nmd b/tests/manual/python_tests/producer_wait_bug_mongo/nginx.nmd deleted file mode 100644 index b424e53874d17c7b0612106225f0250fa274fac4..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/nginx.nmd +++ /dev/null @@ -1,63 +0,0 @@ -job "nginx" { - datacenters = ["dc1"] - - type = "service" - - update { - max_parallel = 1 - min_healthy_time = "10s" - healthy_deadline = "3m" - auto_revert = false - } - - group "nginx" { - count = 1 - - restart { - attempts = 2 - interval = "30m" - delay = "15s" - mode = "fail" - } - - task "nginx" { - driver = "raw_exec" - - config { - command = "nginx", - args = ["-c","${NOMAD_TASK_DIR}/nginx.conf"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - mbits = 10 - port "nginx" { - static = 8400 - } - } - } - - service { - port = "nginx" - name = "nginx" - check { - name = "alive" - type = "http" - path = "/nginx-health" - timeout = "2s" - interval = "10s" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/nginx.conf.tpl" - destination = "local/nginx.conf" - change_mode = "restart" - } - - - } - } -} diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/receiver.json.tpl b/tests/manual/python_tests/producer_wait_bug_mongo/receiver.json.tpl deleted file mode 100644 index 14a4032cde80ba693285b7f03f1100dc49fbcba3..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/receiver.json.tpl +++ /dev/null @@ -1,24 +0,0 @@ -{ - "PerformanceDbServer":"localhost:8086", - "MonitorPerformance": true, - "PerformanceDbName": "db_test", - "DatabaseServer":"localhost:27017", - "DiscoveryServer": "localhost:8400/discovery", - "DataServer": { - "AdvertiseURI": "127.0.0.1", - "NThreads": 2, - "ListenPort": {{ env "NOMAD_PORT_recv_ds" }}, - "NetworkMode": ["tcp"] - }, - "DataCache": { - "Use": true, - "SizeGB": 1, - "ReservedShare": 10 - }, - "AuthorizationServer": "localhost:8400/authorizer", - "AuthorizationInterval": 10000, - "ListenPort": {{ env "NOMAD_PORT_recv" }}, - "Tag": "{{ env "NOMAD_ADDR_recv" }}", - "ReceiveToDiskThresholdMB":50, - "LogLevel" : "debug" -} diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/receiver.nmd b/tests/manual/python_tests/producer_wait_bug_mongo/receiver.nmd deleted file mode 100644 index a25edbf7b68a661e2ee25261e3dcb2a3a8f17101..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/receiver.nmd +++ /dev/null @@ -1,47 +0,0 @@ -job "receiver" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "receiver" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/receiver/receiver", - args = ["${NOMAD_TASK_DIR}/receiver.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "recv" {} - port "recv_ds" {} - } - } - - service { - name = "asapo-receiver" - port = "recv" - check { - name = "alive" - type = "tcp" - interval = "10000s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/receiver_tcp.json.tpl" - destination = "local/receiver.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - } - } -} diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/run.sh b/tests/manual/python_tests/producer_wait_bug_mongo/run.sh deleted file mode 100755 index 0a0f2a5a1f381db96e7701cec333e010c39a6bed..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/run.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -export PYTHONPATH=/home/yakubov/projects/asapo/cmake-build-debug/producer/api/python:${PYTHONPATH} - -mkdir -p /tmp/asapo/receiver/files/test1/asapo_test1 - -python test.py python2 - - -python3 test.py python3 diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/start_services.sh b/tests/manual/python_tests/producer_wait_bug_mongo/start_services.sh deleted file mode 100755 index 1b882a4a885571fcfa7e2e83340be585d0d9110a..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/start_services.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -nomad run authorizer.nmd -nomad run discovery.nmd -nomad run nginx.nmd -nomad run receiver_tcp.nmd diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/stop_services.sh b/tests/manual/python_tests/producer_wait_bug_mongo/stop_services.sh deleted file mode 100755 index 1ce92c903f6004e91356155667f35ac23b8f0687..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/stop_services.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -nomad stop authorizer -nomad stop discovery -nomad stop nginx -nomad run nginx_kill.nmd && nomad stop -yes -purge nginx_kill -nomad stop receiver diff --git a/tests/manual/python_tests/producer_wait_bug_mongo/test.py b/tests/manual/python_tests/producer_wait_bug_mongo/test.py deleted file mode 100644 index ead637fdfcfac7c07b70a9ff243e83861ac3933b..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_bug_mongo/test.py +++ /dev/null @@ -1,76 +0,0 @@ -from __future__ import print_function - -import asapo_producer -import sys -import time -import numpy as np -import threading -lock = threading.Lock() - - -endpoint = "127.0.0.1:8400" -beamtime = "asapo_test1" -data_source = "detector" -token = "" -nthreads = 8 - -def callback(header,err): - lock.acquire() # to print - if err is not None: - print("could not sent: ",header,err) - else: - print ("successfuly sent: ",header) - lock.release() - -def assert_err(err): - if err is not None: - print(err) - sys.exit(1) - -producer = asapo_producer.create_producer(endpoint,'processed',beamtime,'auto', data_source, token, nthreads, 600000) - -producer.set_log_level("debug") - -#send single file -producer.send_file(1, local_path = "./file1", exposed_path = data_source+"/"+"file1", user_meta = '{"test_key":"test_val"}', callback = callback) - - -#send datasets -producer.send_file(2, local_path = "./file1", exposed_path = data_source+"/"+"file2",dataset=(2,2),user_meta = '{"test_key":"test_val"}', callback = callback) -producer.send_file(3, local_path = "./file1", exposed_path = data_source+"/"+"file3",dataset=(2,2),user_meta = '{"test_key":"test_val"}', callback = callback) - -#send meta only -producer.send_file(3, local_path = "./not_exist",exposed_path = "./whatever", - ingest_mode = asapo_producer.INGEST_MODE_TRANSFER_METADATA_ONLY, callback = callback) - -data = np.arange(10,dtype=np.float64) - -#send data from array -producer.send(4, data_source+"/"+"file5",data, - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) - -#send data from string -err = producer.send(5, data_source+"/"+"file6",b"hello", - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) - -#send metadata only -producer.send(6, data_source+"/"+"file7",None, - ingest_mode = asapo_producer.INGEST_MODE_TRANSFER_METADATA_ONLY, callback = callback) - - -x = np.array([[1, 2, 3], [4, 5, 6]], np.float32) -producer.send(4, data_source+"/"+"file5",x, - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) - -try: - x = x.T - producer.send(4, data_source+"/"+"file5",x, - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) -except: - pass -else: - print ("should be exception") - - -producer.wait_requests_finished(1000) - diff --git a/tests/manual/python_tests/producer_wait_threads/producer_api.py b/tests/manual/python_tests/producer_wait_threads/producer_api.py deleted file mode 100644 index 1c19ec7f15d22b82a85a185c6b6c32e1060bdf89..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_threads/producer_api.py +++ /dev/null @@ -1,76 +0,0 @@ -from __future__ import print_function - -import asapo_producer -import sys -import time -import numpy as np -import threading -lock = threading.Lock() - -data_source = "python" -beamtime = "asapo_test" -endpoint = "127.0.0.1:8400" - -token = "" -nthreads = 8 - -def callback(header,err): - lock.acquire() # to print - if err is not None: - print("could not sent: ",header,err) - else: - print ("successfuly sent: ",header) - lock.release() - -producer = asapo_producer.create_producer(endpoint,'processed',beamtime, 'auto', data_source, token, nthreads, 600000) - -producer.set_log_level("info") - -#send single file -producer.send_file(1, local_path = "./file1", exposed_path = data_source+"/"+"file1", user_meta = '{"test_key":"test_val"}', callback = callback) - -#send single file without callback -producer.send_file(1, local_path = "./file1", exposed_path = data_source+"/"+"file1", user_meta = '{"test_key":"test_val"}',callback=None) - -#send datasets -producer.send_file(2, local_path = "./file1", exposed_path = data_source+"/"+"file2",dataset=(2,2),user_meta = '{"test_key":"test_val"}', callback = callback) -producer.send_file(3, local_path = "./file1", exposed_path = data_source+"/"+"file3",dataset=(2,2),user_meta = '{"test_key":"test_val"}', callback = callback) - -#send meta only -producer.send_file(3, local_path = "./not_exist",exposed_path = "./whatever", - ingest_mode = asapo_producer.INGEST_MODE_TRANSFER_METADATA_ONLY, callback = callback) - -data = np.arange(10,dtype=np.float64) - -#send data from array -producer.send(4, data_source+"/"+"file5",data, - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) - -#send data from string -producer.send(5, data_source+"/"+"file6",b"hello", - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) - -#send metadata only -producer.send(6, data_source+"/"+"file7",None, - ingest_mode = asapo_producer.INGEST_MODE_TRANSFER_METADATA_ONLY, callback = callback) - -producer.wait_requests_finished(1000) -n = producer.get_requests_queue_size() -if n!=0: - print("number of remaining requestst should be zero, got ",n) - sys.exit(1) - - -# create with error -try: - producer = asapo_producer.create_producer(endpoint,'processed',beamtime,'auto', data_source, token, 0, 600000) -except Exception as Asapo: - print(e) -else: - print("should be error") - sys.exit(1) - - - - - diff --git a/tests/manual/python_tests/producer_wait_threads/test.py b/tests/manual/python_tests/producer_wait_threads/test.py deleted file mode 100644 index 75983e6b30571a4bec77ea1243d923606a4c1ae1..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/producer_wait_threads/test.py +++ /dev/null @@ -1,60 +0,0 @@ -from __future__ import print_function -import threading -import asapo_producer -import sys -import time -import numpy as np -lock = threading.Lock() - -data_source = "python" -beamtime = "asapo_test" -endpoint = "127.0.0.1:8400" - -token = "" -nthreads = 8 - -def callback(header,err): - global lock - lock.acquire() # to print - if err is not None: - print("could not sent: ",header,err) - else: - print ("successfuly sent: ",header) - lock.release() - -producer = asapo_producer.create_producer(endpoint,'processed',beamtime,'auto', data_source, token, nthreads, 600000) - -producer.set_log_level("info") - -#send single file -producer.send_file(1, local_path = "./file1", exposed_path = data_source+"/"+"file1", user_meta = '{"test_key":"test_val"}', callback = callback) - -#send single file without callback -producer.send_file(1, local_path = "./file1", exposed_path = data_source+"/"+"file1", user_meta = '{"test_key":"test_val"}') - - -#send datasets -producer.send_file(2, local_path = "./file1", exposed_path = data_source+"/"+"file2",dataset=(2,2),user_meta = '{"test_key":"test_val"}', callback = callback) -producer.send_file(3, local_path = "./file1", exposed_path = data_source+"/"+"file3",dataset=(2,2),user_meta = '{"test_key":"test_val"}', callback = callback) - -#send meta only -producer.send_file(3, local_path = "./not_exist",exposed_path = "./whatever", - ingest_mode = asapo_producer.INGEST_MODE_TRANSFER_METADATA_ONLY, callback = callback) - -data = np.arange(10,dtype=np.float64) - -#send data from array -producer.send(4, data_source+"/"+"file5",data, - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) - -#send data from string -producer.send(5, data_source+"/"+"file6",b"hello", - ingest_mode = asapo_producer.DEFAULT_INGEST_MODE, callback = callback) - -#send metadata only -producer.send(6, data_source+"/"+"file7",None, - ingest_mode = asapo_producer.INGEST_MODE_TRANSFER_METADATA_ONLY, callback = callback) - -producer.wait_requests_finished(1) - - diff --git a/tests/manual/python_tests/test_p.py b/tests/manual/python_tests/test_p.py deleted file mode 100644 index a41224125fa8c5701d89ba2be0afbaf5830391f6..0000000000000000000000000000000000000000 --- a/tests/manual/python_tests/test_p.py +++ /dev/null @@ -1,28 +0,0 @@ -from __future__ import print_function - -import asapo_consumer -import sys -import json -import time - -source = "psana002:8400" -path = "/asapo_shared/asapo/data" -beamtime = "asapo_test" -token = "KmUDdacgBzaOD3NIJvN1NmKGqWKtx0DK-NyPjdpeWkc=" - -consumer, err = asapo_consumer.create_consumer( - source, path, True, beamtime, token, 1000) - -group_id, err = consumer.generate_group_id() -if err is not None: - print('cannot generate group id, err: ', err) -else: - print('generated group id: ', group_id) - -while True: - data, meta, err = consumer.get_last(group_id, meta_only=False) - if err is not None: - print('err: ', err) - else: - print('filename: ', meta['name']) - time.sleep(1) diff --git a/tests/manual/receiver_debug_local/asapo b/tests/manual/receiver_debug_local/asapo deleted file mode 100755 index f7072c1eedeea64f1e2d2251d3ed14d4d59be014..0000000000000000000000000000000000000000 Binary files a/tests/manual/receiver_debug_local/asapo and /dev/null differ diff --git a/tests/manual/receiver_debug_local/auth_secret.key b/tests/manual/receiver_debug_local/auth_secret.key deleted file mode 100644 index 1d100e0ec247d5df6a06e5029a392b93b2a6fbe2..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/auth_secret.key +++ /dev/null @@ -1 +0,0 @@ -12ljzgneasfd diff --git a/tests/manual/receiver_debug_local/authorizer.json.tpl b/tests/manual/receiver_debug_local/authorizer.json.tpl deleted file mode 100644 index 92292267951f4e5ddb9017fa3df32293531e3719..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/authorizer.json.tpl +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Port": {{ env "NOMAD_PORT_authorizer" }}, - "LogLevel":"debug", - "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","Year":"2019","Facility":"test_facility"}, - {"beamtimeId":"asapo_test1","beamline":"test1","Year":"2019","Facility":"test_facility"}, - {"beamtimeId":"asapo_test2","beamline":"test2","Year":"2019","Facility":"test_facility"}], - "UserSecretFile":"auth_secret.key", - "AdminSecretFile":"auth_secret_admin.key" -} - - diff --git a/tests/manual/receiver_debug_local/authorizer.nmd b/tests/manual/receiver_debug_local/authorizer.nmd deleted file mode 100644 index 8b32105cf2e4644e97b6fda5e4aba06c6c269822..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/authorizer.nmd +++ /dev/null @@ -1,55 +0,0 @@ -job "authorizer" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "authorizer" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/authorizer/asapo-authorizer", - args = ["-config","${NOMAD_TASK_DIR}/authorizer.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "authorizer" { - static = "5007" - } - } - } - - service { - name = "authorizer" - port = "authorizer" - check { - name = "alive" - type = "http" - path = "/health-check" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/authorizer.json.tpl" - destination = "local/authorizer.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/auth_secret.key" - destination = "auth_secret.key" - change_mode = "signal" - change_signal = "SIGHUP" - } - } - } -} diff --git a/tests/manual/receiver_debug_local/broker.json.tpl b/tests/manual/receiver_debug_local/broker.json.tpl deleted file mode 100644 index 968227cab95b7ca440592a2e1c3c0c2c9556d48b..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/broker.json.tpl +++ /dev/null @@ -1,12 +0,0 @@ -{ - "DatabaseServer":"auto", - "DiscoveryServer": "localhost:8400/discovery", - "PerformanceDbServer": "localhost:8086", - "MonitorPerformance": true, - "PerformanceDbName": "db_test", - "Port":{{ env "NOMAD_PORT_broker" }}, - "LogLevel":"info", - "CheckResendInterval":10, - "UserSecretFile":"auth_secret.key", - "AdminSecretFile":"auth_secret_admin.key" -} \ No newline at end of file diff --git a/tests/manual/receiver_debug_local/broker.nmd b/tests/manual/receiver_debug_local/broker.nmd deleted file mode 100644 index 825b09fc905f51723dc22b551e9b03a73eb8e9c5..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/broker.nmd +++ /dev/null @@ -1,55 +0,0 @@ -job "broker" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "broker" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/broker/asapo-broker", - args = ["-config","${NOMAD_TASK_DIR}/broker.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "broker" { - static = "5005" - } - } - } - - service { - name = "asapo-broker" - port = "broker" - check { - name = "alive" - type = "http" - path = "/health" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/tests/manual/receiver_debug_local/broker.json.tpl" - destination = "local/broker.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - template { - source = "/home/yakubov/projects/asapo/tests/manual/receiver_debug_local/auth_secret.key" - destination = "auth_secret.key" - change_mode = "signal" - change_signal = "SIGHUP" - } - } - } -} diff --git a/tests/manual/receiver_debug_local/clean_db.sh b/tests/manual/receiver_debug_local/clean_db.sh deleted file mode 100755 index 359d98df324b2135bc015a6c244ec3b63e79e47a..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/clean_db.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -beamtime_id=asapo_test - - -echo "db.dropDatabase()" | mongo ${beamtime_id}_detector diff --git a/tests/manual/receiver_debug_local/discovery.json b/tests/manual/receiver_debug_local/discovery.json deleted file mode 100644 index bde0a2b819081929bc7ac4ef3c081d6ec60b13c2..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/discovery.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "Mode": "static", - "Receiver": { - "StaticEndpoints": [ - "127.0.0.1:22001" - ], - "MaxConnections": 32 - }, - "Broker": { - "StaticEndpoint": "127.0.0.1:5005" - }, - "Mongo": { - "StaticEndpoint": "127.0.0.1:27017" - }, - "Port": 5900, - "LogLevel":"debug" -} - - diff --git a/tests/manual/receiver_debug_local/discovery.json.tpl b/tests/manual/receiver_debug_local/discovery.json.tpl deleted file mode 100644 index 26a1e3053fc66914e0e465be4a2f0d174f0da3e6..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/discovery.json.tpl +++ /dev/null @@ -1,19 +0,0 @@ -{ - "Mode": "static", - "Receiver": { - "StaticEndpoints": [ - "127.0.0.1:22001" - ], - "MaxConnections": 32 - }, - "Broker": { - "StaticEndpoint": "localhost:5005" - }, - "Mongo": { - "StaticEndpoint": "127.0.0.1:27017" - }, - "Port": {{ env "NOMAD_PORT_discovery" }}, - "LogLevel":"debug" -} - - diff --git a/tests/manual/receiver_debug_local/discovery.nmd b/tests/manual/receiver_debug_local/discovery.nmd deleted file mode 100644 index 4a10894aa5b00e2fa0483133ad96a4654a64daa6..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/discovery.nmd +++ /dev/null @@ -1,49 +0,0 @@ -job "discovery" { - datacenters = ["dc1"] - - type = "service" - - group "group" { - count = 1 - - task "discovery" { - driver = "raw_exec" - - config { - command = "/home/yakubov/projects/asapo/cmake-build-debug/discovery/asapo-discovery", - args = ["-config","${NOMAD_TASK_DIR}/discovery.json"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - port "discovery" { - static = "5006" - } - } - } - - service { - name = "discovery" - port = "discovery" - check { - name = "alive" - type = "http" - path = "/receivers" - interval = "10s" - timeout = "2s" - initial_status = "passing" - } - } - - template { - source = "/home/yakubov/projects/asapo/tests/manual/receiver_debug_local/discovery.json.tpl" - destination = "local/discovery.json" - change_mode = "signal" - change_signal = "SIGHUP" - } - - } - } -} diff --git a/tests/manual/receiver_debug_local/nginx.conf.tpl b/tests/manual/receiver_debug_local/nginx.conf.tpl deleted file mode 100644 index b784d07256fc978f12d4aa94d8970a435b087df2..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/nginx.conf.tpl +++ /dev/null @@ -1,91 +0,0 @@ -worker_processes 1; - -events { - worker_connections 1024; -} - -http { -# include mime.types; -# default_type application/octet-stream; - -# sendfile on; -# tcp_nopush on; - -# keepalive_timeout 0; -# keepalive_timeout 65; - - resolver 127.0.0.1:8600 valid=1s; - server { - listen {{ env "NOMAD_PORT_nginx" }}; - set $discovery_endpoint discovery.service.asapo; - set $authorizer_endpoint authorizer.service.asapo; - set $fluentd_endpoint fluentd.service.asapo; - set $kibana_endpoint kibana.service.asapo; - set $grafana_endpoint grafana.service.asapo; - set $mongo_endpoint mongo.service.asapo; - set $influxdb_endpoint influxdb.service.asapo; - set $elasticsearch_endpoint elasticsearch.service.asapo; - - location /mongo/ { - rewrite ^/mongo(/.*) $1 break; - proxy_pass http://$mongo_endpoint:27017$uri$is_args$args; - } - - location /influxdb/ { - rewrite ^/influxdb(/.*) $1 break; - proxy_pass http://$influxdb_endpoint:8086$uri$is_args$args; - } - - location /elasticsearch/ { - rewrite ^/elasticsearch(/.*) $1 break; - proxy_pass http://$elasticsearch_endpoint:9200$uri$is_args$args; - } - - location /discovery/ { - rewrite ^/discovery(/.*) $1 break; - proxy_pass http://$discovery_endpoint:5006$uri$is_args$args; - } - - location /logs/ { - rewrite ^/logs(/.*) $1 break; - proxy_pass http://$fluentd_endpoint:9880$uri$is_args$args; - } - - location /logsview/ { - proxy_pass http://$kibana_endpoint:5601$uri$is_args$args; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - } - - location /performance/ { - rewrite ^/performance(/.*) $1 break; - proxy_pass http://$grafana_endpoint:3000$uri$is_args$args; - } - - location /authorizer/ { - rewrite ^/authorizer(/.*) $1 break; - proxy_pass http://$authorizer_endpoint:5007$uri$is_args$args; - } - - location /nginx-health { - return 200 "healthy\n"; - } - } -} - -stream { - resolver 127.0.0.1:8600 valid=1s; - - map $remote_addr $upstream { - default fluentd.service.asapo; - } - - - server { - listen 9881; - proxy_pass $upstream:24224; - } -} - - diff --git a/tests/manual/receiver_debug_local/nginx.nmd b/tests/manual/receiver_debug_local/nginx.nmd deleted file mode 100644 index b424e53874d17c7b0612106225f0250fa274fac4..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/nginx.nmd +++ /dev/null @@ -1,63 +0,0 @@ -job "nginx" { - datacenters = ["dc1"] - - type = "service" - - update { - max_parallel = 1 - min_healthy_time = "10s" - healthy_deadline = "3m" - auto_revert = false - } - - group "nginx" { - count = 1 - - restart { - attempts = 2 - interval = "30m" - delay = "15s" - mode = "fail" - } - - task "nginx" { - driver = "raw_exec" - - config { - command = "nginx", - args = ["-c","${NOMAD_TASK_DIR}/nginx.conf"] - } - - resources { - cpu = 500 # 500 MHz - memory = 256 # 256MB - network { - mbits = 10 - port "nginx" { - static = 8400 - } - } - } - - service { - port = "nginx" - name = "nginx" - check { - name = "alive" - type = "http" - path = "/nginx-health" - timeout = "2s" - interval = "10s" - } - } - - template { - source = "/home/yakubov/projects/asapo/cmake-build-debug/tests/automatic/full_chain/simple_chain/nginx.conf.tpl" - destination = "local/nginx.conf" - change_mode = "restart" - } - - - } - } -} diff --git a/tests/manual/receiver_debug_local/nginx_kill.nmd b/tests/manual/receiver_debug_local/nginx_kill.nmd deleted file mode 100644 index cb3abbac259780ce7366042f24a19d635f032994..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/nginx_kill.nmd +++ /dev/null @@ -1,17 +0,0 @@ -job "nginx_kill" { - datacenters = ["dc1"] - - type = "batch" - - group "nginx_kill" { - count = 1 - - task "nginx_kill" { - driver = "raw_exec" - config { - command = "killall", - args = ["nginx"] - } - } - } -} diff --git a/tests/manual/receiver_debug_local/receiver.json b/tests/manual/receiver_debug_local/receiver.json deleted file mode 100644 index 3dfd35396ecf0c78607e5a9983ac33b28a64428c..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/receiver.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "PerformanceDbServer":"localhost:8086", - "MonitorPerformance": true, - "PerformanceDbName": "db_test", - "DatabaseServer":"localhost:27017", - "DiscoveryServer": "localhost:8400/discovery", - "DataServer": { - "AdvertiseURI":"127.0.0.1", - "NThreads": 2, - "ListenPort": 22000, - "NetworkMode": ["tcp"] - }, - "DataCache": { - "Use": true, - "SizeGB": 1, - "ReservedShare": 10 - }, - "AuthorizationServer": "localhost:8400/authorizer", - "AuthorizationInterval": 10000, - "ListenPort": 22001, - "Tag": "22001", - "ReceiveToDiskThresholdMB":50, - "LogLevel" : "debug" -} diff --git a/tests/manual/receiver_debug_local/start_dummyproducer.sh b/tests/manual/receiver_debug_local/start_dummyproducer.sh deleted file mode 100755 index 8cc44485485cb479ddfed9ac50df23aa42cec980..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/start_dummyproducer.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -beamtime_id=asapo_test - -nfiles=10 -timeout=100 -fsize=500000 -mode=0 #tcp & no file write -nthreads=3 - -exec=/home/yakubov/projects/asapo/cmake-build-debug/examples/producer/dummy-data-producer/dummy-data-producer - - -$exec localhost:8400 ${beamtime_id} $fsize $nfiles $nthreads $mode $timeout diff --git a/tests/manual/receiver_debug_local/start_getnext.sh b/tests/manual/receiver_debug_local/start_getnext.sh deleted file mode 100755 index e40f3951d3cc73dc0b64406609b321cedc5519b5..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/start_getnext.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -beamtime_id=asapo_test - -token= -timeout=100 -metaonly=0 -nthreads=4 -token=IEfwsWa0GXky2S3MkxJSUHJT1sI8DD5teRdjBUXVRxk= - -exec=/home/yakubov/projects/asapo/cmake-build-debug/examples/consumer/getnext/getnext - -$exec localhost:8400 /tmp/asapo/receiver/files/test/asapo_test asapo_test $nthreads $token $timeout $metaonly diff --git a/tests/manual/receiver_debug_local/start_receiver.sh b/tests/manual/receiver_debug_local/start_receiver.sh deleted file mode 100755 index 231051afff79b8daa029c44a33e54a33098b3949..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/start_receiver.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - - -exec=/home/yakubov/projects/asapo/cmake-build-debug/receiver/receiver - - -$exec receiver.json diff --git a/tests/manual/receiver_debug_local/start_services.sh b/tests/manual/receiver_debug_local/start_services.sh deleted file mode 100755 index 1ddf2b3c87d2f538319e877cac43ef68b83343eb..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/start_services.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -nomad run authorizer.nmd -nomad run discovery.nmd -nomad run broker.nmd -nomad run nginx.nmd diff --git a/tests/manual/receiver_debug_local/stop_services.sh b/tests/manual/receiver_debug_local/stop_services.sh deleted file mode 100755 index db503c59efa2b699d0563487cd44dd1315248a48..0000000000000000000000000000000000000000 --- a/tests/manual/receiver_debug_local/stop_services.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -nomad stop -purge authorizer -nomad stop -purge discovery -nomad stop -purge broker -nomad stop -purge nginx -nomad run nginx_kill.nmd && nomad stop -yes -purge nginx_kill diff --git a/tests/manual/tests_via_nomad/asapo-test_dummy_producer.nomad.in b/tests/manual/tests_via_nomad/asapo-test_dummy_producer.nomad.in deleted file mode 100644 index cae32b82fb9e9a82f4e8997316e23ffe2f816c6c..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_dummy_producer.nomad.in +++ /dev/null @@ -1,208 +0,0 @@ -job "asapo-test" { - datacenters = [ - "dc1"] - - type = "batch" - - group "producer-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - task "producer" { - driver = "raw_exec" - - config { - command = "local/dummy-data-producer.exe" - args = [ - "psana002:8400", - "asapo_test1", - "100", - "1000000", - "8", - "0", - "1000"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/dummy-data-producer-@ASAPO_VERSION@.exe" - mode = "file" - destination = "local/dummy-data-producer.exe" - } - - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - } - - } - #windows - - group "producer-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "producer" { - driver = "raw_exec" - - config { - command = "local/dummy-data-producer" - args = [ - "psana002:8400", - "asapo_test2", - "100", - "1000000", - "8", - "0", - "1000"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/dummy-data-producer-@ASAPO_VERSION@" - mode = "file" - destination = "local/dummy-data-producer" - } - - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - # } - - } - - } - #linux - - group "consumer-linux1" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test1/asapo_test1", - "asapo_test1", - "16", - "oTsKsj8i6WcW_gVzeIFvZCtSfMErjDELJEyAI23n7Ik=", - "30000", - "${CONSUMER_READ_META_ONLY}"] - } - - resources { - cpu = 5000 - memory = 128 - network { - mbits = 10000 - } - } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer-linux1 - - - group "consumer-linux2" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test2/asapo_test2", - "asapo_test2", - "16", - "yzgAcLmijSLWIm8dBiGNCbc0i42u5HSm-zR6FRqo__Y=", - "30000", - "${CONSUMER_READ_META_ONLY}"] - } - resources { - cpu = 5000 - memory = 128 - network { - mbits = 10000 - } - } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - - } - } - - } - -} -# consumer-linux2 diff --git a/tests/manual/tests_via_nomad/asapo-test_dummy_producer_only.nomad.in b/tests/manual/tests_via_nomad/asapo-test_dummy_producer_only.nomad.in deleted file mode 100644 index d4416301aecc43d40ba2ddecd6ea5e8ac88ffde6..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_dummy_producer_only.nomad.in +++ /dev/null @@ -1,211 +0,0 @@ -job "asapo-test" { - datacenters = [ - "dc1"] - - type = "batch" - - group "producer-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 0 - task "producer" { - driver = "raw_exec" - - config { - command = "local/dummy-data-producer.exe" - args = [ - "psana002:8400", - "asapo_test1", - "100", - "1000000", - "8", - "0", - "1000"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/dummy-data-producer-@ASAPO_VERSION@.exe" - mode = "file" - destination = "local/dummy-data-producer.exe" - } - - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - } - - } - #windows - - group "producer-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "producer" { - driver = "raw_exec" - - config { - command = "local/dummy-data-producer" - args = [ - "psana002:8400", - "asapo_test2", - "100", - "1000", - "8", - "0", - "1000", - "1000"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/dummy-data-producer-@ASAPO_VERSION@" - mode = "file" - destination = "local/dummy-data-producer" - } - - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - # } - - } - - } - #linux - - group "consumer-linux1" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 0 - - - task "consumer-linux" { - driver = "raw_exec" - - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test1/asapo_test1", - "asapo_test1", - "16", - "oTsKsj8i6WcW_gVzeIFvZCtSfMErjDELJEyAI23n7Ik=", - "30000", - "${CONSUMER_READ_META_ONLY}"] - } - - resources { - cpu = 5000 - memory = 128 - network { - mbits = 10000 - } - } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer-linux1 - - - group "consumer-linux2" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - - count = 0 - - task "consumer-linux" { - driver = "raw_exec" - - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test2/asapo_test2", - "asapo_test2", - "16", - "yzgAcLmijSLWIm8dBiGNCbc0i42u5HSm-zR6FRqo__Y=", - "30000", - "${CONSUMER_READ_META_ONLY}"] - } - resources { - cpu = 5000 - memory = 128 - network { - mbits = 10000 - } - } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - - } - } - - } - -} -# consumer-linux2 diff --git a/tests/manual/tests_via_nomad/asapo-test_filegen_consumer.nomad.in b/tests/manual/tests_via_nomad/asapo-test_filegen_consumer.nomad.in deleted file mode 100644 index 4379531262f22dbec2c58acad98dbd85ace6b8e8..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_filegen_consumer.nomad.in +++ /dev/null @@ -1,197 +0,0 @@ -job "asapo-test" { - datacenters = [ - "dc1"] - - type = "batch" - - group "filegen-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_win.exe" - args = [ - "1", - "10M", - "10000", - "120", - "u:/asapo/test_folder/file_win"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_win.exe" - mode = "file" - destination = "local/filegen_win.exe" - } - } - - - } - #windows - - group "filegen-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_linux" - args = [ - "1", - "10M", - "10000", - "120", - "/run/user/data/file_lin"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_linux" - mode = "file" - destination = "local/filegen_linux" - } - } - - } - - - group "consumer-linux1" { - - restart { - attempts = 0 - } - - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test1/asapo_test1", - "asapo_test1", - "16", - "oTsKsj8i6WcW_gVzeIFvZCtSfMErjDELJEyAI23n7Ik=", - "30000", - "${CONSUMER_READ_META_ONLY}"] - } - -# resources { -# cpu = 5000 -# memory = 128 -# network { -# mbits = 10000 -# } -# } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer-linux1 - - - group "consumer-linux2" { - - restart { - attempts = 0 - } - - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test2/asapo_test2", - "asapo_test2", - "16", - "yzgAcLmijSLWIm8dBiGNCbc0i42u5HSm-zR6FRqo__Y=", - "30000", - "${CONSUMER_READ_META_ONLY}"] - } -# resources { -# cpu = 5000 -# memory = 128 -# network { -# mbits = 10000 -# } -# } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer-linux2 - -} diff --git a/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_1M.nomad.in b/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_1M.nomad.in deleted file mode 100644 index 6763020d64a5ae5642472f22f2fddbdfa45fbb2b..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_1M.nomad.in +++ /dev/null @@ -1,197 +0,0 @@ -job "asapo-test" { - datacenters = [ - "dc1"] - - type = "batch" - - group "filegen-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_win.exe" - args = [ - "1", - "1M", - "100000", - "1100", - "u:/asapo/test_folder/file_win"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_win.exe" - mode = "file" - destination = "local/filegen_win.exe" - } - } - - - } - #windows - - group "filegen-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_linux" - args = [ - "1", - "1M", - "100000", - "1200", - "/run/user/data/file_lin"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_linux" - mode = "file" - destination = "local/filegen_linux" - } - } - - } - - - group "consumer-linux1" { - - restart { - attempts = 0 - } - - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test1/asapo_test1", - "asapo_test1", - "16", - "oTsKsj8i6WcW_gVzeIFvZCtSfMErjDELJEyAI23n7Ik=", - "30000", - "${CONSUMER_READ_META_ONLY}"] - } - -# resources { -# cpu = 5000 -# memory = 128 -# network { -# mbits = 10000 -# } -# } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer-linux1 - - - group "consumer-linux2" { - - restart { - attempts = 0 - } - - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test2/asapo_test2", - "asapo_test2", - "16", - "yzgAcLmijSLWIm8dBiGNCbc0i42u5HSm-zR6FRqo__Y=", - "30000", - "${CONSUMER_READ_META_ONLY}"] - } -# resources { -# cpu = 5000 -# memory = 128 -# network { -# mbits = 10000 -# } -# } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer-linux2 - -} diff --git a/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_1M_batch.nomad.in b/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_1M_batch.nomad.in deleted file mode 100644 index 9312daeabc7d35f94a0cf3c9f5dc1a6b2a5b6070..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_1M_batch.nomad.in +++ /dev/null @@ -1,199 +0,0 @@ -job "asapo-test" { - datacenters = [ - "dc1"] - - type = "batch" - - group "filegen-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_win.exe" - args = [ - "1", - "1M", - "100000", - "1100", - "u:/asapo/test_folder/file_win"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_win.exe" - mode = "file" - destination = "local/filegen_win.exe" - } - } - - - } - #windows - - group "filegen-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_linux" - args = [ - "1", - "1M", - "100000", - "1200", - "/run/user/data/file_lin"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_linux" - mode = "file" - destination = "local/filegen_linux" - } - } - - } - - - group "consumer-linux1" { - - restart { - attempts = 0 - } - - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test1/asapo_test1", - "asapo_test1", - "16", - "oTsKsj8i6WcW_gVzeIFvZCtSfMErjDELJEyAI23n7Ik=", - "30000", - "${CONSUMER_READ_META_ONLY}", - "1"] - } - -# resources { -# cpu = 5000 -# memory = 128 -# network { -# mbits = 10000 -# } -# } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer-linux1 - - - group "consumer-linux2" { - - restart { - attempts = 0 - } - - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test2/asapo_test2", - "asapo_test2", - "16", - "yzgAcLmijSLWIm8dBiGNCbc0i42u5HSm-zR6FRqo__Y=", - "30000", - "${CONSUMER_READ_META_ONLY}", - "1"] - } -# resources { -# cpu = 5000 -# memory = 128 -# network { -# mbits = 10000 -# } -# } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer-linux2 - -} diff --git a/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_1M_multisource.nomad.in b/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_1M_multisource.nomad.in deleted file mode 100644 index c24dd1068694439be21ab9f40151210b106d7a60..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_1M_multisource.nomad.in +++ /dev/null @@ -1,138 +0,0 @@ -job "asapo-test" { - datacenters = [ - "dc1"] - - type = "batch" - - group "filegen-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_win.exe" - args = [ - "1", - "1M", - "100000", - "1100", - "u:/asapo/test_folder/file_win"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_win.exe" - mode = "file" - destination = "local/filegen_win.exe" - } - } - - - } - #windows - - group "filegen-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_linux" - args = [ - "1", - "1M", - "100000", - "1200", - "/run/user/data/file_lin"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_linux" - mode = "file" - destination = "local/filegen_linux" - } - } - - } - - - group "consumer" { - - restart { - attempts = 0 - } - - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test1/asapo_test1", - "asapo_test", - "16", - "KmUDdacgBzaOD3NIJvN1NmKGqWKtx0DK-NyPjdpeWkc=", - "30000", - "${CONSUMER_READ_META_ONLY}", - "1"] - } - -# resources { -# cpu = 5000 -# memory = 128 -# network { -# mbits = 10000 -# } -# } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer - -} diff --git a/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_batch.nomad.in b/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_batch.nomad.in deleted file mode 100644 index e864ebb59c39c4419c59eb4024eefbb5043552fa..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_filegen_consumer_batch.nomad.in +++ /dev/null @@ -1,199 +0,0 @@ -job "asapo-test" { - datacenters = [ - "dc1"] - - type = "batch" - - group "filegen-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_win.exe" - args = [ - "1", - "10M", - "10000", - "120", - "u:/asapo/test_folder/file_win"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_win.exe" - mode = "file" - destination = "local/filegen_win.exe" - } - } - - - } - #windows - - group "filegen-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_linux" - args = [ - "1", - "10M", - "10000", - "120", - "/run/user/data/file_lin"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_linux" - mode = "file" - destination = "local/filegen_linux" - } - } - - } - - - group "consumer-linux1" { - - restart { - attempts = 0 - } - - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test1/asapo_test1", - "asapo_test1", - "16", - "oTsKsj8i6WcW_gVzeIFvZCtSfMErjDELJEyAI23n7Ik=", - "30000", - "${CONSUMER_READ_META_ONLY}", - "1"] - } - -# resources { -# cpu = 5000 -# memory = 128 -# network { -# mbits = 10000 -# } -# } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer-linux1 - - - group "consumer-linux2" { - - restart { - attempts = 0 - } - - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - # constraint { - # attribute = "${meta.location}" - # operator = "!=" - # value = "petra3" - # } - - count = 1 - - task "consumer-linux" { - driver = "raw_exec" - template { - data = <<EOH - CONSUMER_READ_META_ONLY = "{{ keyOrDefault "consumer_read_meta_only" "1" }}" - EOH - destination = "secrets/file.env" - env = true - } - - config { - command = "local/getnext" - args = [ - "psana002:8400", - "/bldocuments/support/asapo/data/test2/asapo_test2", - "asapo_test2", - "16", - "yzgAcLmijSLWIm8dBiGNCbc0i42u5HSm-zR6FRqo__Y=", - "30000", - "${CONSUMER_READ_META_ONLY}", - "1"] - } -# resources { -# cpu = 5000 -# memory = 128 -# network { -# mbits = 10000 -# } -# } - - artifact { - source = "http://nims.desy.de/extra/asapo/getnext-@ASAPO_VERSION@" - mode = "file" - destination = "local/getnext" - } - } - - } - # consumer-linux2 - -} diff --git a/tests/manual/tests_via_nomad/asapo-test_filegen_only.nomad.in b/tests/manual/tests_via_nomad/asapo-test_filegen_only.nomad.in deleted file mode 100644 index b3fcb094f344b94cf30b6895e2cdc6d5770c5fdc..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_filegen_only.nomad.in +++ /dev/null @@ -1,71 +0,0 @@ -job "asapo-filegen" { - datacenters = [ - "dc1"] - - type = "batch" - - group "windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_win.exe" - args = [ - "1","1M","10","c:/tmp/asapo/test_in/test_folder/file_win"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_win.exe" - mode = "file" - destination = "local/filegen_win.exe" - } - } - - - } - #windows - - group "linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "filegen" { - driver = "raw_exec" - - config { - command = "local/filegen_linux" - args = [ - "1","1M","10","/tmp/asapo/test_in/test_folder/file_lin_"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/filegen_linux" - mode = "file" - destination = "local/filegen_linux" - } - } - - } - #linux -} - - - diff --git a/tests/manual/tests_via_nomad/asapo-test_filemon.nomad.in b/tests/manual/tests_via_nomad/asapo-test_filemon.nomad.in deleted file mode 100644 index be78fb225d36390b0f109a91d0665d9b10417c04..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_filemon.nomad.in +++ /dev/null @@ -1,129 +0,0 @@ -job "asapo-filemon" { - datacenters = [ - "dc1"] - - type = "batch" - - group "producer-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - task "producer" { - driver = "raw_exec" - - config { - command = "local/asapo-eventmon-producer.exe" - args = [ - "local/test.json"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/asapo-eventmon-producer-@ASAPO_VERSION@.exe" - mode = "file" - destination = "local/asapo-eventmon-producer.exe" - } - - template { - data = <<EOH -{ - "AsapoEndpoint":"psana002:8400", - "Tag":"test_tag", - "BeamtimeID":"asapo_test1", - "Mode":"tcp", - "NThreads":8, - "LogLevel":"info", - "RootMonitoredFolder":"u:\\asapo", - "MonitoredSubFolders":["test_folder"], - "IgnoreExtensions":["tmp"], - "WhitelistExtensions":[], - "RemoveAfterSend":true, - "DataSource": "", - "Dataset": { - "Mode":"none" - } -} - EOH - destination = "local/test.json" - } - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - } # producer task - } - #windows - - group "producer-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "producer" { - driver = "raw_exec" - - config { - command = "local/asapo-eventmon-producer" - args = [ - "local/test.json"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/asapo-eventmon-producer-@ASAPO_VERSION@" - mode = "file" - destination = "local/asapo-eventmon-producer" - } - - template { - data = <<EOH -{ - "AsapoEndpoint":"psana002:8400", - "Tag":"test_tag", - "BeamtimeID":"asapo_test2", - "Mode":"tcp", - "NThreads":8, - "LogLevel":"info", - "RootMonitoredFolder":"/run/user", - "MonitoredSubFolders":["data"], - "IgnoreExtensions":["tmp"], - "WhitelistExtensions":[], - "RemoveAfterSend":true, - "DataSource": "", - "Dataset": { - "Mode":"none" - } - -} - EOH - destination = "local/test.json" - } - - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - # } - - } # task producer - } - #linux -} - - - diff --git a/tests/manual/tests_via_nomad/asapo-test_filemon_batch.nomad.in b/tests/manual/tests_via_nomad/asapo-test_filemon_batch.nomad.in deleted file mode 100644 index 07c84daeb5b311ec33d8adad5b468bcadd38c0d5..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_filemon_batch.nomad.in +++ /dev/null @@ -1,131 +0,0 @@ -job "asapo-filemon_batch" { - datacenters = [ - "dc1"] - - type = "batch" - - group "producer-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - task "producer" { - driver = "raw_exec" - - config { - command = "local/asapo-eventmon-producer.exe" - args = [ - "local/test.json"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/asapo-eventmon-producer-@ASAPO_VERSION@.exe" - mode = "file" - destination = "local/asapo-eventmon-producer.exe" - } - - template { - data = <<EOH -{ - "AsapoEndpoint":"psana002:8400", - "Tag":"test_tag", - "BeamtimeID":"asapo_test1", - "Mode":"tcp", - "NThreads":8, - "LogLevel":"info", - "RootMonitoredFolder":"u:\\asapo", - "MonitoredSubFolders":["test_folder"], - "IgnoreExtensions":["tmp"], - "WhitelistExtensions":[], - "RemoveAfterSend":true, - "DataSource": "", - "Dataset": { - "Mode":"batch", - "BatchSize": {{ keyOrDefault "monitor_batch_size" "3" }} - } -} - EOH - destination = "local/test.json" - } - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - } # producer task - } - #windows - - group "producer-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "producer" { - driver = "raw_exec" - - config { - command = "local/asapo-eventmon-producer" - args = [ - "local/test.json"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/asapo-eventmon-producer-@ASAPO_VERSION@" - mode = "file" - destination = "local/asapo-eventmon-producer" - } - - template { - data = <<EOH -{ - "AsapoEndpoint":"psana002:8400", - "Tag":"test_tag", - "BeamtimeID":"asapo_test2", - "Mode":"tcp", - "NThreads":8, - "LogLevel":"info", - "RootMonitoredFolder":"/run/user", - "MonitoredSubFolders":["data"], - "IgnoreExtensions":["tmp"], - "WhitelistExtensions":[], - "RemoveAfterSend":true, - "DataSource": "", - "Dataset": { - "Mode":"batch", - "BatchSize": {{ keyOrDefault "monitor_batch_size" "3" }} - } - -} - EOH - destination = "local/test.json" - } - - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - # } - - } # task producer - } - #linux -} - - - diff --git a/tests/manual/tests_via_nomad/asapo-test_filemon_multisource.nomad.in b/tests/manual/tests_via_nomad/asapo-test_filemon_multisource.nomad.in deleted file mode 100644 index 7f7b07825033ee28c48161c07d2825ffdad7075e..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_filemon_multisource.nomad.in +++ /dev/null @@ -1,133 +0,0 @@ -job "asapo-filemon_multisource" { - datacenters = [ - "dc1"] - - type = "batch" - - group "producer-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - task "producer" { - driver = "raw_exec" - - config { - command = "local/asapo-eventmon-producer.exe" - args = [ - "local/test.json"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/asapo-eventmon-producer-@ASAPO_VERSION@.exe" - mode = "file" - destination = "local/asapo-eventmon-producer.exe" - } - - template { - data = <<EOH -{ - "AsapoEndpoint":"psana002:8400", - "Tag":"test_tag", - "BeamtimeID":"asapo_test", - "Mode":"tcp", - "NThreads":8, - "LogLevel":"info", - "RootMonitoredFolder":"u:\\asapo", - "MonitoredSubFolders":["test_folder"], - "IgnoreExtensions":["tmp"], - "WhitelistExtensions":[], - "RemoveAfterSend":true, - "DataSource": "", - "Dataset": { - "Mode":"multisource", - "SourceId": 1, - "NSources":2 - } -} - EOH - destination = "local/test.json" - } - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - } # producer task - } - #windows - - group "producer-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "producer" { - driver = "raw_exec" - - config { - command = "local/asapo-eventmon-producer" - args = [ - "local/test.json"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/asapo-eventmon-producer-@ASAPO_VERSION@" - mode = "file" - destination = "local/asapo-eventmon-producer" - } - - template { - data = <<EOH -{ - "AsapoEndpoint":"psana002:8400", - "Tag":"test_tag", - "BeamtimeID":"asapo_test", - "Mode":"tcp", - "NThreads":8, - "LogLevel":"info", - "RootMonitoredFolder":"/run/user", - "MonitoredSubFolders":["data"], - "IgnoreExtensions":["tmp"], - "WhitelistExtensions":[], - "RemoveAfterSend":true, - "DataSource": "", - "Dataset": { - "Mode":"multisource", - "SourceId": 2, - "NSources":2 - } - -} - EOH - destination = "local/test.json" - } - - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - # } - - } # task producer - } - #linux -} - - - diff --git a/tests/manual/tests_via_nomad/asapo-test_filemon_producer_tolocal.nomad.in b/tests/manual/tests_via_nomad/asapo-test_filemon_producer_tolocal.nomad.in deleted file mode 100644 index 13c332d532289e50bacf15d355a70a2820b2ac14..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/asapo-test_filemon_producer_tolocal.nomad.in +++ /dev/null @@ -1,129 +0,0 @@ -job "asapo-produceronly" { - datacenters = [ - "dc1"] - - type = "batch" - - group "producer-windows" { - - constraint { - attribute = "${attr.kernel.name}" - value = "windows" - } - - count = 1 - task "producer" { - driver = "raw_exec" - - config { - command = "local/asapo-eventmon-producer.exe" - args = [ - "local/test.json"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/asapo-eventmon-producer-@ASAPO_VERSION@.exe" - mode = "file" - destination = "local/asapo-eventmon-producer.exe" - } - - template { - data = <<EOH -{ - "AsapoEndpoint":"c:\\tmp\\asapo\\test_out", - "Tag":"test_tag", - "BeamtimeID":"asapo_test", - "Mode":"filesystem", - "NThreads":1, - "LogLevel":"debug", - "RootMonitoredFolder":"c:\\tmp\\asapo\\test_in", - "MonitoredSubFolders":["test_folder"], - "IgnoreExtensions":["tmp"], - "WhitelistExtensions":[], - "RemoveAfterSend":true, - "DataSource": "", - "Dataset": { - "Mode":"none" - } -} - EOH - destination = "local/test.json" - } - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - } # producer task - } - #windows - - group "producer-linux" { - - constraint { - attribute = "${attr.kernel.name}" - value = "linux" - } - - constraint { - attribute = "${meta.location}" - value = "petra3" - } - - count = 1 - - task "producer" { - driver = "raw_exec" - - config { - command = "local/asapo-eventmon-producer" - args = [ - "local/test.json"] - } - - artifact { - source = "http://nims.desy.de/extra/asapo/asapo-eventmon-producer-@ASAPO_VERSION@" - mode = "file" - destination = "local/asapo-eventmon-producer" - } - - template { - data = <<EOH -{ - "AsapoEndpoint":"/tmp/asapo/test_out", - "Tag":"test_tag", - "BeamtimeID":"asapo_test", - "Mode":"filesystem", - "NThreads":1, - "LogLevel":"debug", - "RootMonitoredFolder":"/tmp/asapo/test_in", - "MonitoredSubFolders":["test_folder"], - "IgnoreExtensions":["tmp"], - "WhitelistExtensions":[], - "RemoveAfterSend":true, - "DataSource": "", - "Dataset": { - "Mode":"none" - } - -} - EOH - destination = "local/test.json" - } - - # resources { - # cpu = 5000 - # memory = 128 - # network { - # mbits = 10000 - # } - # } - - } # task producer - } - #linux -} - - - diff --git a/tests/manual/tests_via_nomad/auth_secret.key b/tests/manual/tests_via_nomad/auth_secret.key deleted file mode 100644 index a953ac63b05cfa6a16e0fadda59d6622fc3b4920..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/auth_secret.key +++ /dev/null @@ -1 +0,0 @@ -sadhfi334yxan \ No newline at end of file diff --git a/tests/manual/tests_via_nomad/clean_after_tests.sh b/tests/manual/tests_via_nomad/clean_after_tests.sh deleted file mode 100755 index 1eeed43f3c0d977ee30187a782bed7d499f4e3b0..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/clean_after_tests.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -mongoaddr=`dig +short @127.0.0.1 mongo.service.asapo | head -1` - -database="asapo_test" - -cont=$(ssh $mongoaddr bash -c "'docker ps | grep mongo'") - -image=`echo "${cont##* }"` - -rm -rf /bldocuments/support/asapo/data/test/asapo_test -rm -rf /bldocuments/support/asapo/data/test1/asapo_test1 -rm -rf /bldocuments/support/asapo/data/test2/asapo_test2 - -mkdir /bldocuments/support/asapo/data/test/asapo_test -mkdir /bldocuments/support/asapo/data/test1/asapo_test1 -mkdir /bldocuments/support/asapo/data/test2/asapo_test2 -chown asapo: -R /bldocuments/support/asapo/data/test/ - -ssh $mongoaddr docker exec $image bash -c "'echo \"db.dropDatabase()\" | mongo --host $mongoaddr asapo_test'" -ssh $mongoaddr docker exec $image bash -c "'echo \"db.dropDatabase()\" | mongo --host $mongoaddr asapo_test1'" -ssh $mongoaddr docker exec $image bash -c "'echo \"db.dropDatabase()\" | mongo --host $mongoaddr asapo_test2'" - - - -nomad stop asapo-brokers -nomad run asapo-brokers.nmd \ No newline at end of file diff --git a/tests/manual/tests_via_nomad/copy.sh b/tests/manual/tests_via_nomad/copy.sh deleted file mode 100755 index e8f30e43d758e2c5348ed89984e20620119920d4..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/copy.sh +++ /dev/null @@ -1 +0,0 @@ -scp * psana002:/bldocuments/support/asapo/config/nomad_jobs/ diff --git a/tests/manual/tests_via_nomad/run_test_fullchain.sh b/tests/manual/tests_via_nomad/run_test_fullchain.sh deleted file mode 100755 index 3c9149fe211805d4dd029d4921df4f20aaa4c936..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/run_test_fullchain.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -nomad stop asapo-filemon -nomad stop asapo-filemon_batch -nomad stop asapo-filemon_multisource -nomad run asapo-test_filemon_batch.nomad -sleep 1 -nomad stop asapo-test -. ./clean_after_tests.sh - -nomad run asapo-test_filegen_consumer.nomad - diff --git a/tests/manual/tests_via_nomad/run_test_fullchain_batch.sh b/tests/manual/tests_via_nomad/run_test_fullchain_batch.sh deleted file mode 100755 index af34de80967216d94af898bebbbfcd9f7c59f537..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/run_test_fullchain_batch.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -nomad stop asapo-filemon -nomad stop asapo-filemon_batch -nomad stop asapo-filemon_multisource -nomad run asapo-test_filemon_batch.nomad -sleep 1 -nomad stop asapo-test -. ./clean_after_tests.sh - -nomad run asapo-test_filegen_consumer_batch.nomad - diff --git a/tests/manual/tests_via_nomad/run_test_fullchain_multisource.sh b/tests/manual/tests_via_nomad/run_test_fullchain_multisource.sh deleted file mode 100755 index 406ac91cca6f32c8a2acf0ca2733690dec3cf7a4..0000000000000000000000000000000000000000 --- a/tests/manual/tests_via_nomad/run_test_fullchain_multisource.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -nomad stop asapo-filemon -nomad stop asapo-filemon_batch -nomad stop asapo-filemon_multisource -nomad run asapo-test_filemon_multisource.nomad -sleep 1 -nomad stop asapo-test -. ./clean_after_tests.sh - -nomad run asapo-test_filegen_consumer_1M_multisource.nomad -