SysTester: Adding options for testing with external library & multithreaded client
This commit is contained in:
parent
45d0815218
commit
e50c4320f0
|
@ -78,8 +78,24 @@ EmptyFuture Transaction::onError(fdb_error_t err) {
|
|||
return EmptyFuture(fdb_transaction_on_error(tx_, err));
|
||||
}
|
||||
|
||||
void Transaction::reset() {
|
||||
fdb_transaction_reset(tx_);
|
||||
}
|
||||
|
||||
Transaction::~Transaction() {
|
||||
fdb_transaction_destroy(tx_);
|
||||
}
|
||||
|
||||
fdb_error_t FdbApi::setOption(FDBNetworkOption option, std::string_view value) {
|
||||
return fdb_network_set_option(option, reinterpret_cast<const uint8_t*>(value.data()), value.size());
|
||||
}
|
||||
|
||||
fdb_error_t FdbApi::setOption(FDBNetworkOption option, int64_t value) {
|
||||
return fdb_network_set_option(option, reinterpret_cast<const uint8_t*>(&value), sizeof(value));
|
||||
}
|
||||
|
||||
fdb_error_t FdbApi::setOption(FDBNetworkOption option) {
|
||||
return fdb_network_set_option(option, reinterpret_cast<const uint8_t*>(""), 0);
|
||||
}
|
||||
|
||||
} // namespace FDBSystemTester
|
|
@ -40,6 +40,9 @@ public:
|
|||
virtual ~Future();
|
||||
|
||||
Future& operator=(Future&& other) {
|
||||
if (future_) {
|
||||
reset();
|
||||
}
|
||||
future_ = other.future_;
|
||||
other.future_ = nullptr;
|
||||
return *this;
|
||||
|
@ -77,11 +80,19 @@ public:
|
|||
void set(std::string_view key, std::string_view value);
|
||||
EmptyFuture commit();
|
||||
EmptyFuture onError(fdb_error_t err);
|
||||
void reset();
|
||||
|
||||
private:
|
||||
FDBTransaction* tx_;
|
||||
};
|
||||
|
||||
class FdbApi {
|
||||
public:
|
||||
static fdb_error_t setOption(FDBNetworkOption option, std::string_view value);
|
||||
static fdb_error_t setOption(FDBNetworkOption option, int64_t value);
|
||||
static fdb_error_t setOption(FDBNetworkOption option);
|
||||
};
|
||||
|
||||
} // namespace FDBSystemTester
|
||||
|
||||
#endif
|
|
@ -47,6 +47,8 @@ public:
|
|||
bool blockOnFutures = false;
|
||||
int numClientThreads = 1;
|
||||
int numDatabases = 1;
|
||||
std::string externalClientLibrary;
|
||||
int numFdbThreads = 1;
|
||||
|
||||
bool parseArgs(int argc, char** argv);
|
||||
|
||||
|
|
|
@ -46,7 +46,9 @@ enum TesterOptionId {
|
|||
OPT_API_VERSION,
|
||||
OPT_BLOCK_ON_FUTURES,
|
||||
OPT_NUM_CLIENT_THREADS,
|
||||
OPT_NUM_DATABASES
|
||||
OPT_NUM_DATABASES,
|
||||
OPT_EXTERNAL_CLIENT_LIBRARY,
|
||||
OPT_NUM_FDB_THREADS
|
||||
};
|
||||
|
||||
CSimpleOpt::SOption TesterOptionDefs[] = //
|
||||
|
@ -62,7 +64,9 @@ CSimpleOpt::SOption TesterOptionDefs[] = //
|
|||
{ OPT_API_VERSION, "--api-version", SO_REQ_SEP },
|
||||
{ OPT_BLOCK_ON_FUTURES, "--block-on-futures", SO_NONE },
|
||||
{ OPT_NUM_CLIENT_THREADS, "--num-client-threads", SO_REQ_SEP },
|
||||
{ OPT_NUM_DATABASES, "--num-databases", SO_REQ_SEP } };
|
||||
{ OPT_NUM_DATABASES, "--num-databases", SO_REQ_SEP },
|
||||
{ OPT_EXTERNAL_CLIENT_LIBRARY, "--external-client-library", SO_REQ_SEP },
|
||||
{ OPT_NUM_FDB_THREADS, "--num-fdb-threads", SO_REQ_SEP } };
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -91,10 +95,14 @@ void TesterOptions::printProgramUsage(const char* execName) {
|
|||
" Changes a knob option. KNOBNAME should be lowercase.\n"
|
||||
" --block-on-futures\n"
|
||||
" Use blocking waits on futures instead of scheduling callbacks.\n"
|
||||
" --num-client-threads NUM_THREADS\n"
|
||||
" --num-client-threads NUMBER\n"
|
||||
" Number of threads to be used for execution of client workloads.\n"
|
||||
" --num-databases NUM_DB\n"
|
||||
" --num-databases NUMBER\n"
|
||||
" Number of database connections to be used concurrently.\n"
|
||||
" --external-client-library FILE_PATH\n"
|
||||
" Path to the external client library.\n"
|
||||
" --num-fdb-threads NUMBER\n"
|
||||
" Number of FDB client threads to be created.\n"
|
||||
" -h, --help Display this help and exit.\n");
|
||||
}
|
||||
|
||||
|
@ -185,6 +193,14 @@ bool TesterOptions::processArg(const CSimpleOpt& args) {
|
|||
case OPT_NUM_DATABASES:
|
||||
processIntArg(args, numDatabases, 1, 1000);
|
||||
break;
|
||||
|
||||
case OPT_EXTERNAL_CLIENT_LIBRARY:
|
||||
externalClientLibrary = args.OptionArg();
|
||||
break;
|
||||
|
||||
case OPT_NUM_FDB_THREADS:
|
||||
processIntArg(args, numFdbThreads, 1, 1000);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -204,6 +220,19 @@ IWorkload* createApiCorrectnessWorkload();
|
|||
|
||||
using namespace FDBSystemTester;
|
||||
|
||||
void applyNetworkOptions(TesterOptions& options) {
|
||||
if (!options.externalClientLibrary.empty()) {
|
||||
fdb_check(FdbApi::setOption(FDBNetworkOption::FDB_NET_OPTION_DISABLE_LOCAL_CLIENT));
|
||||
fdb_check(
|
||||
FdbApi::setOption(FDBNetworkOption::FDB_NET_OPTION_EXTERNAL_CLIENT_LIBRARY, options.externalClientLibrary));
|
||||
}
|
||||
|
||||
if (options.numFdbThreads > 1) {
|
||||
fdb_check(
|
||||
FdbApi::setOption(FDBNetworkOption::FDB_NET_OPTION_CLIENT_THREADS_PER_VERSION, options.numFdbThreads));
|
||||
}
|
||||
}
|
||||
|
||||
void runApiCorrectness(TesterOptions& options) {
|
||||
TransactionExecutorOptions txExecOptions;
|
||||
txExecOptions.blockOnFutures = options.blockOnFutures;
|
||||
|
@ -230,6 +259,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
fdb_check(fdb_select_api_version(options.api_version));
|
||||
applyNetworkOptions(options);
|
||||
fdb_check(fdb_setup_network());
|
||||
|
||||
std::thread network_thread{ &fdb_run_network };
|
||||
|
|
Loading…
Reference in New Issue