diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-03-19 21:44:54 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-03-19 21:44:54 +0100 |
commit | 7a1c6769e428f6f8bb413fb74383c82e16871d2c (patch) | |
tree | 049947c0cac5cc5a70996683df7bd88b4e51c593 /src/benchmark/taler-exchange-benchmark.c | |
parent | f76e7c46e6609d39d5b28cb489a946833ca58bfb (diff) | |
download | exchange-7a1c6769e428f6f8bb413fb74383c82e16871d2c.tar.xz |
enable using python bank with benchmark
Diffstat (limited to 'src/benchmark/taler-exchange-benchmark.c')
-rw-r--r-- | src/benchmark/taler-exchange-benchmark.c | 183 |
1 files changed, 131 insertions, 52 deletions
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 |