summaryrefslogtreecommitdiff
path: root/src/benchmark
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/benchmark
parentf76e7c46e6609d39d5b28cb489a946833ca58bfb (diff)
downloadexchange-7a1c6769e428f6f8bb413fb74383c82e16871d2c.tar.gz
exchange-7a1c6769e428f6f8bb413fb74383c82e16871d2c.tar.bz2
exchange-7a1c6769e428f6f8bb413fb74383c82e16871d2c.zip
enable using python bank with benchmark
Diffstat (limited to 'src/benchmark')
-rw-r--r--src/benchmark/benchmark.conf18
-rw-r--r--src/benchmark/taler-exchange-benchmark.c183
2 files changed, 144 insertions, 57 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