enable using python bank with benchmark

This commit is contained in:
Christian Grothoff 2020-03-19 21:44:54 +01:00
parent f76e7c46e6
commit 7a1c6769e4
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
6 changed files with 199 additions and 103 deletions

View File

@ -40,25 +40,33 @@ host = localhost
# Adjust $HOME to match remote target!
dir = $HOME/repos/taler/exchange/src/benchmark
[bank]
HTTP_PORT = 8082
SERVE = http
MAX_DEBT = EUR:100000000000.0
MAX_DEBT_BANK = EUR:1000000000000000.0
[benchmark]
USER_PAYTO_URI = payto://x-taler-bank/localhost:8082/42
[exchange-account-2]
# What is the payto://-URL of the exchange (to generate wire response)
PAYTO_URI = "payto://x-taler-bank/localhost:8082/2"
PAYTO_URI = "payto://x-taler-bank/localhost:8082/Exchange"
# What is the bank account (with the "Taler Bank" demo system)? Must end with "/".
WIRE_GATEWAY_URL = http://localhost:8082/2/
WIRE_GATEWAY_URL = http://localhost:8082/taler-wire-gateway/Exchange/
# This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange.
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-2.json
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-exchange.json
# Authentication information for basic authentication
WIRE_GATEWAY_AUTH_METHOD = "basic"
username = user
password = pass
username = Exchange
password = x
enable_debit = YES
enable_credit = YES
[fees-x-taler-bank]
# Fees for the forseeable future...
# If you see this after 2017, update to match the next 10 years...

View File

@ -110,11 +110,21 @@ static struct GNUNET_TIME_Relative duration;
*/
static struct TALER_TESTING_Command *all_commands;
/**
* Name of our configuration file.
*/
static char *cfg_filename;
/**
* Exit code.
*/
static int result;
/**
* Use the fakebank instead of the Python bank.
*/
static int use_fakebank;
/**
* How many coins we want to create per client and reserve.
*/
@ -135,6 +145,11 @@ static unsigned int refresh_rate = 10;
*/
static unsigned int howmany_clients = 1;
/**
* Bank configuration to use.
*/
static struct TALER_TESTING_BankConfiguration bc;
/**
* Log level used during the run.
*/
@ -475,6 +490,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
pid_t cpids[howmany_clients];
pid_t fakebank = -1;
int wstatus;
struct GNUNET_OS_Process *bankd = NULL;
struct GNUNET_OS_Process *auditord = NULL;
struct GNUNET_OS_Process *exchanged = NULL;
struct GNUNET_OS_Process *wirewatch = NULL;
@ -482,6 +498,8 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
struct GNUNET_DISK_PipeHandle *exchange_slave_pipe;
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
{
if (use_fakebank)
{
/* start fakebank */
fakebank = fork ();
@ -501,6 +519,23 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
return GNUNET_SYSERR;
}
}
else
{
/* start bank */
if (GNUNET_OK !=
TALER_TESTING_prepare_bank (cfg_filename,
GNUNET_NO,
"exchange-account-2",
&bc))
{
return 1;
}
bankd = TALER_TESTING_run_bank (cfg_filename,
"http://localhost:8082/");
if (NULL == bankd)
return 77;
}
}
if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
{
@ -515,12 +550,20 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
NULL);
if ( (NULL == exchanged) && (MODE_BOTH == mode) )
{
GNUNET_assert (-1 != fakebank);
if (-1 != fakebank)
{
kill (fakebank,
SIGTERM);
waitpid (fakebank,
&wstatus,
0);
}
if (NULL != bankd)
{
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_destroy (bankd);
}
return 77;
}
/* start auditor */
@ -537,13 +580,21 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
SIGTERM);
if (MODE_BOTH == mode)
{
GNUNET_assert (-1 != fakebank);
if (-1 != fakebank)
{
kill (fakebank,
SIGTERM);
waitpid (fakebank,
&wstatus,
0);
}
if (NULL != bankd)
{
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_destroy (bankd);
}
}
GNUNET_OS_process_destroy (exchanged);
return 77;
}
@ -563,13 +614,21 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
SIGTERM);
if (MODE_BOTH == mode)
{
GNUNET_assert (-1 != fakebank);
if (-1 != fakebank)
{
kill (fakebank,
SIGTERM);
waitpid (fakebank,
&wstatus,
0);
}
if (NULL != bankd)
{
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_destroy (bankd);
}
}
GNUNET_OS_process_destroy (exchanged);
return 77;
}
@ -618,13 +677,21 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
SIGTERM);
if ( (MODE_BOTH == mode) || (MODE_CLIENT == mode))
{
GNUNET_assert (-1 != fakebank);
if (-1 != fakebank)
{
kill (fakebank,
SIGTERM);
waitpid (fakebank,
&wstatus,
0);
}
if (NULL != bankd)
{
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_destroy (bankd);
}
}
GNUNET_OS_process_wait (exchanged);
GNUNET_OS_process_destroy (exchanged);
if (NULL != wirewatch)
@ -757,11 +824,10 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
{
/* stop fakebank */
GNUNET_assert (-1 != fakebank);
if (0 != kill (fakebank,
SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
"kill");
if (-1 != fakebank)
{
kill (fakebank,
SIGTERM);
waitpid (fakebank,
&wstatus,
0);
@ -772,6 +838,13 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
result = GNUNET_SYSERR;
}
}
if (NULL != bankd)
{
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_destroy (bankd);
}
}
return result;
}
@ -787,7 +860,6 @@ int
main (int argc,
char *const *argv)
{
char *cfg_filename = NULL;
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_mandatory
(GNUNET_GETOPT_option_cfgfile (&cfg_filename)),
@ -824,6 +896,10 @@ main (int argc,
"LF",
"will log to file LF",
&logfile),
GNUNET_GETOPT_option_flag ('f',
"fakebank",
"start a fakebank instead of the Python bank",
&use_fakebank),
GNUNET_GETOPT_option_flag ('K',
"linger",
"linger around until key press",
@ -949,10 +1025,13 @@ main (int argc,
}
GNUNET_OS_process_wait (compute_wire_response);
GNUNET_OS_process_destroy (compute_wire_response);
/* If we use the fakebank, we MUST reset the database as the fakebank
will have forgotten everything... */
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_prepare_exchange (cfg_filename,
GNUNET_NO,
(GNUNET_YES == use_fakebank)
? GNUNET_YES
: GNUNET_NO,
&ec));
}
else

View File

@ -805,11 +805,13 @@ TALER_TESTING_run_fakebank (const char *bank_url,
* and reset database.
*
* @param config_filename configuration file name.
* @param reset_db should we reset the bank's database
* @param[out] bc set to the bank's configuration data
* @return #GNUNET_OK on success
*/
int
TALER_TESTING_prepare_bank (const char *config_filename,
int reset_db,
const char *config_section,
struct TALER_TESTING_BankConfiguration *bc);

View File

@ -171,6 +171,7 @@ main (int argc,
cfgfilename = CONFIG_FILE_PYBANK;
if (GNUNET_OK !=
TALER_TESTING_prepare_bank (CONFIG_FILE_PYBANK,
GNUNET_YES,
"exchange-account-2",
&bc))
{

View File

@ -177,6 +177,7 @@ main (int argc,
TALER_LOG_DEBUG ("Running against the Pybank.\n");
if (GNUNET_OK !=
TALER_TESTING_prepare_bank (cfgfilename,
GNUNET_YES,
"exchange-account-2",
&bc))
{

View File

@ -169,7 +169,7 @@ TALER_TESTING_run_bank (const char *config_filename,
GNUNET_free (serve_cfg);
bank_proc = GNUNET_OS_start_process
(GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
GNUNET_OS_INHERIT_STD_NONE,
NULL, NULL, NULL,
"taler-bank-manage-testing",
"taler-bank-manage-testing",
@ -222,6 +222,7 @@ TALER_TESTING_run_bank (const char *config_filename,
* and reset database.
*
* @param config_filename configuration file name.
* @param reset_db should we reset the bank's database
* @param config_section section of the configuration with the exchange's account
* @param[out] bc set to the bank's configuration data
* @return the base url, or NULL upon errors. Must be freed
@ -229,6 +230,7 @@ TALER_TESTING_run_bank (const char *config_filename,
*/
int
TALER_TESTING_prepare_bank (const char *config_filename,
int reset_db,
const char *config_section,
struct TALER_TESTING_BankConfiguration *bc)
{
@ -305,10 +307,12 @@ TALER_TESTING_prepare_bank (const char *config_filename,
}
/* DB preparation */
if (GNUNET_YES == reset_db)
{
if (NULL ==
(dbreset_proc = GNUNET_OS_start_process (
GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
GNUNET_OS_INHERIT_STD_NONE,
NULL, NULL, NULL,
"taler-bank-manage",
"taler-bank-manage",
@ -355,6 +359,7 @@ TALER_TESTING_prepare_bank (const char *config_filename,
return GNUNET_SYSERR;
}
GNUNET_OS_process_destroy (dbreset_proc);
}
if (GNUNET_OK !=
TALER_BANK_auth_parse_cfg (cfg,
config_section,