aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-03-19 21:44:54 +0100
committerChristian Grothoff <christian@grothoff.org>2020-03-19 21:44:54 +0100
commit7a1c6769e428f6f8bb413fb74383c82e16871d2c (patch)
tree049947c0cac5cc5a70996683df7bd88b4e51c593 /src
parentf76e7c46e6609d39d5b28cb489a946833ca58bfb (diff)
enable using python bank with benchmark
Diffstat (limited to 'src')
-rw-r--r--src/benchmark/benchmark.conf18
-rw-r--r--src/benchmark/taler-exchange-benchmark.c183
-rw-r--r--src/include/taler_testing_lib.h2
-rw-r--r--src/testing/test_bank_api.c1
-rw-r--r--src/testing/test_bank_api_twisted.c1
-rw-r--r--src/testing/testing_api_helpers_bank.c97
6 files changed, 199 insertions, 103 deletions
diff --git a/src/benchmark/benchmark.conf b/src/benchmark/benchmark.conf
index 418b2a677..a7be9f0d3 100644
--- a/src/benchmark/benchmark.conf
+++ b/src/benchmark/benchmark.conf
@@ -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...
diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c
index f5a1649b2..22b71948e 100644
--- a/src/benchmark/taler-exchange-benchmark.c
+++ b/src/benchmark/taler-exchange-benchmark.c
@@ -111,11 +111,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.
*/
static unsigned int howmany_coins = 1;
@@ -136,6 +146,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.
*/
static char *loglev;
@@ -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;
@@ -483,22 +499,41 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
{
- /* start fakebank */
- fakebank = fork ();
- if (0 == fakebank)
+ if (use_fakebank)
{
- GNUNET_log_setup ("benchmark-fakebank",
- NULL == loglev ? "INFO" : loglev,
- logfile);
- GNUNET_SCHEDULER_run (&launch_fakebank,
- NULL);
- exit (0);
+ /* start fakebank */
+ fakebank = fork ();
+ if (0 == fakebank)
+ {
+ GNUNET_log_setup ("benchmark-fakebank",
+ NULL == loglev ? "INFO" : loglev,
+ logfile);
+ GNUNET_SCHEDULER_run (&launch_fakebank,
+ NULL);
+ exit (0);
+ }
+ if (-1 == fakebank)
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
+ "fork");
+ return GNUNET_SYSERR;
+ }
}
- if (-1 == fakebank)
+ else
{
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "fork");
- return GNUNET_SYSERR;
+ /* 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;
}
}
@@ -515,12 +550,20 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
NULL);
if ( (NULL == exchanged) && (MODE_BOTH == mode) )
{
- GNUNET_assert (-1 != fakebank);
- kill (fakebank,
- SIGTERM);
- waitpid (fakebank,
- &wstatus,
- 0);
+ 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,12 +580,20 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
SIGTERM);
if (MODE_BOTH == mode)
{
- GNUNET_assert (-1 != fakebank);
- kill (fakebank,
- SIGTERM);
- waitpid (fakebank,
- &wstatus,
- 0);
+ 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,12 +614,20 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
SIGTERM);
if (MODE_BOTH == mode)
{
- GNUNET_assert (-1 != fakebank);
- kill (fakebank,
- SIGTERM);
- waitpid (fakebank,
- &wstatus,
- 0);
+ 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,12 +677,20 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
SIGTERM);
if ( (MODE_BOTH == mode) || (MODE_CLIENT == mode))
{
- GNUNET_assert (-1 != fakebank);
- kill (fakebank,
- SIGTERM);
- waitpid (fakebank,
- &wstatus,
- 0);
+ 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);
@@ -757,19 +824,25 @@ 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");
- waitpid (fakebank,
- &wstatus,
- 0);
- if ( (! WIFEXITED (wstatus)) ||
- (0 != WEXITSTATUS (wstatus)) )
+ if (-1 != fakebank)
+ {
+ kill (fakebank,
+ SIGTERM);
+ waitpid (fakebank,
+ &wstatus,
+ 0);
+ if ( (! WIFEXITED (wstatus)) ||
+ (0 != WEXITSTATUS (wstatus)) )
+ {
+ GNUNET_break (0);
+ result = GNUNET_SYSERR;
+ }
+ }
+ if (NULL != bankd)
{
- GNUNET_break (0);
- result = GNUNET_SYSERR;
+ 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
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index b91057973..7e392f09b 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -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);
diff --git a/src/testing/test_bank_api.c b/src/testing/test_bank_api.c
index 75e22b59e..b0b61a166 100644
--- a/src/testing/test_bank_api.c
+++ b/src/testing/test_bank_api.c
@@ -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))
{
diff --git a/src/testing/test_bank_api_twisted.c b/src/testing/test_bank_api_twisted.c
index 4ec4a1b9e..c2382db96 100644
--- a/src/testing/test_bank_api_twisted.c
+++ b/src/testing/test_bank_api_twisted.c
@@ -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))
{
diff --git a/src/testing/testing_api_helpers_bank.c b/src/testing/testing_api_helpers_bank.c
index 3cfb693ae..30813da71 100644
--- a/src/testing/testing_api_helpers_bank.c
+++ b/src/testing/testing_api_helpers_bank.c
@@ -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,56 +307,59 @@ TALER_TESTING_prepare_bank (const char *config_filename,
}
/* DB preparation */
- if (NULL ==
- (dbreset_proc = GNUNET_OS_start_process (
- GNUNET_NO,
- GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-bank-manage",
- "taler-bank-manage",
- "-c", config_filename,
- "--with-db", database,
- "django",
- "flush",
- "--no-input", NULL)))
+ if (GNUNET_YES == reset_db)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to flush the bank db.\n");
+ if (NULL ==
+ (dbreset_proc = GNUNET_OS_start_process (
+ GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_NONE,
+ NULL, NULL, NULL,
+ "taler-bank-manage",
+ "taler-bank-manage",
+ "-c", config_filename,
+ "--with-db", database,
+ "django",
+ "flush",
+ "--no-input", NULL)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to flush the bank db.\n");
+ GNUNET_free (database);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return GNUNET_SYSERR;
+ }
GNUNET_free (database);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
- GNUNET_free (database);
- if (GNUNET_SYSERR ==
- GNUNET_OS_process_wait_status (dbreset_proc,
- &type,
- &code))
- {
+ if (GNUNET_SYSERR ==
+ GNUNET_OS_process_wait_status (dbreset_proc,
+ &type,
+ &code))
+ {
+ GNUNET_OS_process_destroy (dbreset_proc);
+ GNUNET_break (0);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return GNUNET_SYSERR;
+ }
+ if ( (type == GNUNET_OS_PROCESS_EXITED) &&
+ (0 != code) )
+ {
+ fprintf (stderr,
+ "Failed to setup database\n");
+ GNUNET_break (0);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return GNUNET_SYSERR;
+ }
+ if ( (type != GNUNET_OS_PROCESS_EXITED) ||
+ (0 != code) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected error running `taler-bank-manage django flush'!\n");
+ GNUNET_break (0);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ return GNUNET_SYSERR;
+ }
GNUNET_OS_process_destroy (dbreset_proc);
- GNUNET_break (0);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
- if ( (type == GNUNET_OS_PROCESS_EXITED) &&
- (0 != code) )
- {
- fprintf (stderr,
- "Failed to setup database\n");
- GNUNET_break (0);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
- if ( (type != GNUNET_OS_PROCESS_EXITED) ||
- (0 != code) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected error running `taler-bank-manage django flush'!\n");
- GNUNET_break (0);
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
}
- GNUNET_OS_process_destroy (dbreset_proc);
if (GNUNET_OK !=
TALER_BANK_auth_parse_cfg (cfg,
config_section,