1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-07 03:22:57 +03:00

MCOL-5784 Add test to MTR test suite.

This commit is contained in:
Denis Khalikov
2024-08-19 11:36:14 +00:00
committed by Leonid Fedorov
parent c22409760f
commit 90023272dd
7 changed files with 61 additions and 11 deletions

View File

@@ -52,6 +52,7 @@ usr/bin/smps
usr/bin/smput
usr/bin/smrm
usr/bin/testS3Connection
usr/bin/test_fdb_api
usr/bin/viewtablelock
usr/bin/workernode
usr/lib/*/libbatchloader.so
@@ -89,6 +90,7 @@ usr/lib/*/libwriteengine.so
usr/lib/*/libwriteengineclient.so
usr/lib/*/libwriteengineredistribute.so
usr/lib/*/libdatatypes.so
usr/lib/*/libfdbcs.so
usr/lib/mysql/plugin/ha_columnstore.so
usr/lib/mysql/plugin/libregr_mysql.so
usr/lib/mysql/plugin/libudf_mysql.so

View File

@@ -0,0 +1 @@
ok

View File

@@ -0,0 +1,7 @@
# Test fdb API
-- source ../include/have_columnstore.inc
#
exec test_fdb_api;
# Have to print any output for MTR tests.
exec echo "ok";

View File

@@ -180,3 +180,8 @@ install(TARGETS fdbcs
LIBRARY DESTINATION ${ENGINE_LIBDIR}
COMPONENT columnstore-engine
)
install(TARGETS test_fdb_api
RUNTIME DESTINATION ${ENGINE_BINDIR}
COMPONENT columnstore-engine
)

View File

@@ -79,9 +79,11 @@ class FDBDataBase
~FDBDataBase();
std::unique_ptr<Transaction> createTransaction() const;
bool isDataBaseReady() const;
private:
FDBDatabase* database_;
const uint32_t secondsToWait_ = 3;
};
class DataBaseCreator

View File

@@ -15,10 +15,10 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include <string>
#include <iostream>
#include <thread>
#include <chrono>
#include "../include/fdbcs.hpp"
namespace FDBCS
@@ -161,6 +161,30 @@ std::unique_ptr<Transaction> FDBDataBase::createTransaction() const
return std::make_unique<Transaction>(tnx);
}
bool FDBDataBase::isDataBaseReady() const
{
FDBTransaction* tnx;
auto err = fdb_database_create_transaction(database_, &tnx);
if (err)
{
std::cerr << "fdb_database_create_transaction error, code: " << (int)err << std::endl;
return false;
}
ByteArray emptyKey{""};
FDBFuture* future = fdb_transaction_get(tnx, (uint8_t*)emptyKey.c_str(), emptyKey.length(), 0);
uint32_t count = 0;
while (!fdb_future_is_ready(future) && count < secondsToWait_)
{
std::this_thread::sleep_for(std::chrono::seconds(1));
++count;
}
bool ready = fdb_future_is_ready(future);
fdb_future_destroy(future);
fdb_transaction_destroy(tnx);
return ready;
}
std::unique_ptr<FDBDataBase> DataBaseCreator::createDataBase(const std::string clusterFilePath)
{
FDBDatabase* database;

View File

@@ -17,46 +17,55 @@
#include "../fdb_wrapper_cpp/include/fdbcs.hpp"
// FIXME: Use GOOGLE test.
#include <cassert>
using namespace std;
using namespace FDBCS;
int main() {
template <typename T>
void assert_internal(const T& value)
{
if (!value)
abort();
}
int main()
{
std::string path = "/etc/foundationdb/fdb.cluster";
setAPIVersion();
assert_internal(setAPIVersion());
FDBNetwork netWork;
// Create and run network.
assert(netWork.setUpAndRunNetwork() == true);
assert_internal(netWork.setUpAndRunNetwork());
// Create database.
std::unique_ptr<FDBDataBase> db = DataBaseCreator::createDataBase(path);
assert_internal(db);
assert_internal(db->isDataBaseReady());
std::string key1 = "fajsdlkfjaskljfewiower39423fds";
std::string value1 = "gfdgjksdflfdsjkslkdrewuior39243";
// Set a key/value.
{
auto tnx = db->createTransaction();
tnx->set(key1, value1);
assert(tnx->commit() == true);
assert_internal(tnx->commit());
}
// Get a value by a key.
{
auto tnx = db->createTransaction();
auto p = tnx->get(key1);
assert(p.first == true);
assert(p.second == value1);
assert_internal(p.first);
assert_internal(p.second == value1);
}
// Remove a key.
{
auto tnx = db->createTransaction();
tnx->remove(key1);
assert(tnx->commit() == true);
assert_internal(tnx->commit());
}
// Check that key is not presetnt anymore.
{
auto tnx = db->createTransaction();
auto p = tnx->get(key1);
assert(p.first == false);
assert_internal(!p.first);
}
return 0;