From 80ac69d667612341b2fcb8087e5d6faa1f0aec7c Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 15 Dec 2016 17:21:31 +0200 Subject: [PATCH] Cache: Add TesterRawStorage class A class dedicated for performing tests for raw storages. --- .../filter/cache/test/testerrawstorage.cc | 37 +++++++++++++++ .../filter/cache/test/testerrawstorage.hh | 45 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 server/modules/filter/cache/test/testerrawstorage.cc create mode 100644 server/modules/filter/cache/test/testerrawstorage.hh diff --git a/server/modules/filter/cache/test/testerrawstorage.cc b/server/modules/filter/cache/test/testerrawstorage.cc new file mode 100644 index 000000000..b72dca04d --- /dev/null +++ b/server/modules/filter/cache/test/testerrawstorage.cc @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl. + * + * Change Date: 2019-07-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include +#include "storagefactory.hh" +#include "testerrawstorage.hh" + + +TesterRawStorage::TesterRawStorage(std::ostream* pOut, StorageFactory* pFactory) + : TesterStorage(pOut, pFactory) +{ +} + +Storage* TesterRawStorage::get_storage() +{ + return m_factory.createRawStorage(CACHE_THREAD_MODEL_MT, + "unspecified", + 0, // No TTL + 0, // No max count + 0, // No max size + 0, NULL); +} + +size_t TesterRawStorage::get_n_items(size_t n_threads, size_t n_seconds) +{ + return n_threads * n_seconds * 10; // From the sleeve... +} diff --git a/server/modules/filter/cache/test/testerrawstorage.hh b/server/modules/filter/cache/test/testerrawstorage.hh new file mode 100644 index 000000000..1ea6e87bf --- /dev/null +++ b/server/modules/filter/cache/test/testerrawstorage.hh @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl. + * + * Change Date: 2019-07-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include +#include "testerstorage.hh" + + +class TesterRawStorage : public TesterStorage +{ +public: + /** + * Constructor + * + * @param pOut Pointer to the stream to be used for (user) output. + * @param pFactory Pointer to factory to be used. + */ + TesterRawStorage(std::ostream* pOut, StorageFactory* pFactory); + +protected: + /** + * Returns a raw storage. + * + * @return A storage instance or NULL. + */ + Storage* get_storage(); + + /** + * @see TesterStorage::get_n_items + */ + size_t get_n_items(size_t n_threads, size_t n_seconds); + +private: + TesterRawStorage(const TesterRawStorage&); + TesterRawStorage& operator = (const TesterRawStorage&); +};