1 #ifndef __TEST_UTILS_H__
2 #define __TEST_UTILS_H__
8 #include <log4cplus/logger.h>
9 #include <log4cplus/loggingmacros.h>
15 extern log4cplus::Logger
logger;
22 #define KINETICA_STREAM_TO_STRING(...) ( static_cast<const std::ostringstream&> (std::ostringstream() << __VA_ARGS__).str() )
27 #define KINETICA_STREAM_TO_CSTRING(...) ( KINETICA_STREAM_TO_STRING(__VA_ARGS__).c_str() )
30 #define LOG_KINETICA_INFO(logger, logEvent) do { LOG4CPLUS_INFO(logger, logEvent); } while(0)
33 #define LOG_KINETICA_DEBUG(logger, logEvent) do { LOG4CPLUS_DEBUG(logger, logEvent); } while(0)
36 #define LOG_KINETICA_WARN(logger, logEvent) do { LOG4CPLUS_WARN(logger, logEvent); } while(0)
39 #define LOG_KINETICA_ERROR(logger, logEvent) do { LOG4CPLUS_ERROR(logger, logEvent); } while(0)
47 #define NORMALIZER 100
48 #define USE_NULL_VALUE(null_percentage) \
49 ((std::rand() % NORMALIZER) < null_percentage)
51 #define PERFORM_ACTION( percentage ) \
52 ((std::rand() % NORMALIZER) < percentage)
54 #define GENERATE_INT8() \
55 ( (std::rand() % 256) - 128)
57 #define GENERATE_INT16() \
58 ( (std::rand() % 65536) - 32768)
60 #define GENERATE_FLOAT() \
61 ( ((float)std::rand()) / std::rand() * std::pow(-1, (std::rand() % 2)) )
63 #define GENERATE_DOUBLE() \
64 ( ((double)std::rand()) / std::rand() * std::pow(-1, (std::rand() % 2)) )
66 #define GENERATE_UNSIGNED_INT16() \
67 ( std::rand() % 65536 )
70 #define GENERATE_UNSIGNED_LONG_LONG() \
71 ( ( (unsigned long long)GENERATE_UNSIGNED_INT16() << 48 ) | \
72 ( (unsigned long long)GENERATE_UNSIGNED_INT16() << 32 ) | \
73 ( (unsigned long long)GENERATE_UNSIGNED_INT16() << 16 ) | \
74 ( (unsigned long long)GENERATE_UNSIGNED_INT16() ) )
79 #define GENERATE_UNSIGNED_LONG_LONG_STRING() \
80 ( std::to_string( GENERATE_UNSIGNED_LONG_LONG() ) )
83 #define GENERATE_TIMESTAMP() \
84 ( std::rand() - std::rand() ) // Range is actually [-30610239758979, 29379542399999]
88 static const char alphanum[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
89 static const char numeric[] =
"0123456789";
139 #define GENERATE_IPV4() \
140 ( std::to_string(std::rand() % 256) + "." \
141 + std::to_string(std::rand() % 256) + "." \
142 + std::to_string(std::rand() % 256) + "." \
143 + std::to_string(std::rand() % 256) )
156 std::string
generate_datetime(
int chance_percentage_has_time,
int chance_percentage_has_ms );
169 std::string
generate_decimal(
int frac_only_percentage,
int has_frac_percentage,
int negative_percentage,
int positive_percentage );
185 const std::vector<gpudb::Type::Column>& columns);
196 #endif // __TEST_UTILS_H__
std::string generate_unsigned_long_long_str()
static const char numeric[]
static const char alphanum[]
std::string generate_unsigned_long_long_str_no_leading_zero()
std::string generate_date()
size_t get_table_size(const gpudb::GPUdb &db, const std::string table_name)
Get a given table's size.
std::string generate_table_name(const std::string &prefix)
Generate a table name with the given prefix.
static const int alphabet_size
std::string generate_datetime(int chance_percentage_has_time, int chance_percentage_has_ms)
std::string generate_time(int chance_percentage_has_ms)
void clear_table(const gpudb::GPUdb &db, const std::string table_name)
Clear a given table.
void create_table(const gpudb::GPUdb &db, const std::string table_name, const gpudb::Type &type)
Create a table given a DB hancle, table name, and a type.
std::string generate_random_string()
std::string generate_decimal(int frac_only_percentage, int has_frac_percentage, int negative_percentage, int positive_percentage)
std::string generate_charN(size_t N)