Merge branch 'master' into age-withdraw
This commit is contained in:
commit
7837015692
@ -12,9 +12,8 @@ endif
|
|||||||
|
|
||||||
bin_PROGRAMS = \
|
bin_PROGRAMS = \
|
||||||
taler-aggregator-benchmark \
|
taler-aggregator-benchmark \
|
||||||
taler-bank-benchmark
|
taler-bank-benchmark \
|
||||||
|
taler-exchange-benchmark
|
||||||
# taler-exchange-benchmark
|
|
||||||
|
|
||||||
|
|
||||||
taler_aggregator_benchmark_SOURCES = \
|
taler_aggregator_benchmark_SOURCES = \
|
||||||
|
@ -58,20 +58,15 @@ MAX_DEBT_BANK=EUR:1000000000000000.0
|
|||||||
DATABASE=bank-db.sqlite3
|
DATABASE=bank-db.sqlite3
|
||||||
|
|
||||||
[libeufin-nexus]
|
[libeufin-nexus]
|
||||||
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
|
DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
|
||||||
DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
|
#DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
|
||||||
|
|
||||||
[libeufin-sandbox]
|
[libeufin-sandbox]
|
||||||
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
|
DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
|
||||||
DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"
|
#DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"
|
||||||
|
|
||||||
[auditor]
|
[auditor]
|
||||||
BASE_URL="http://localhost:8083/"
|
BASE_URL="http://localhost:8083/"
|
||||||
|
|
||||||
[benchmark-remote-exchange]
|
|
||||||
HOST=localhost
|
|
||||||
# Adjust $HOME to match remote target!
|
|
||||||
DIR=$HOME/repos/taler/exchange/src/benchmark
|
|
||||||
|
|
||||||
[benchmark]
|
[benchmark]
|
||||||
USER_PAYTO_URI="payto://x-taler-bank/localhost:8082/42?receiver-name=user42"
|
USER_PAYTO_URI="payto://x-taler-bank/localhost:8082/42?receiver-name=user42"
|
||||||
|
@ -28,25 +28,7 @@
|
|||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include "taler_util.h"
|
#include "taler_util.h"
|
||||||
#include "taler_signatures.h"
|
|
||||||
#include "taler_exchangedb_lib.h"
|
|
||||||
#include "taler_exchange_service.h"
|
|
||||||
#include "taler_json_lib.h"
|
|
||||||
#include "taler_bank_service.h"
|
|
||||||
#include "taler_fakebank_lib.h"
|
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_error_codes.h"
|
|
||||||
|
|
||||||
/* Error codes. */
|
|
||||||
enum BenchmarkError
|
|
||||||
{
|
|
||||||
MISSING_BANK_URL,
|
|
||||||
FAILED_TO_LAUNCH_BANK,
|
|
||||||
BAD_CLI_ARG,
|
|
||||||
BAD_CONFIG_FILE,
|
|
||||||
NO_CONFIG_FILE_GIVEN
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The whole benchmark is a repetition of a "unit". Each
|
* The whole benchmark is a repetition of a "unit". Each
|
||||||
@ -55,51 +37,11 @@ enum BenchmarkError
|
|||||||
*/
|
*/
|
||||||
#define UNITY_SIZE 6
|
#define UNITY_SIZE 6
|
||||||
|
|
||||||
#define FIRST_INSTRUCTION -1
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What mode should the benchmark run in?
|
* Credentials to use for the benchmark.
|
||||||
*/
|
*/
|
||||||
enum BenchmarkMode
|
static struct TALER_TESTING_Credentials cred;
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run as client (with fakebank), also starts a remote exchange.
|
|
||||||
*/
|
|
||||||
MODE_CLIENT = 1,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the the exchange.
|
|
||||||
*/
|
|
||||||
MODE_EXCHANGE = 2,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run both, for a local benchmark.
|
|
||||||
*/
|
|
||||||
MODE_BOTH = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hold information regarding which bank has the exchange account.
|
|
||||||
*/
|
|
||||||
static const struct TALER_EXCHANGEDB_AccountInfo *exchange_bank_account;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hold information about a user at the bank.
|
|
||||||
*/
|
|
||||||
static char *user_payto_uri;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Time snapshot taken right before executing the CMDs.
|
|
||||||
*/
|
|
||||||
static struct GNUNET_TIME_Absolute start_time;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Benchmark duration time taken right after the CMD interpreter
|
|
||||||
* returns.
|
|
||||||
*/
|
|
||||||
static struct GNUNET_TIME_Relative duration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of all the commands the benchmark is running.
|
* Array of all the commands the benchmark is running.
|
||||||
@ -111,16 +53,6 @@ static struct TALER_TESTING_Command *all_commands;
|
|||||||
*/
|
*/
|
||||||
static char *cfg_filename;
|
static char *cfg_filename;
|
||||||
|
|
||||||
/**
|
|
||||||
* Exit code.
|
|
||||||
*/
|
|
||||||
static enum GNUNET_GenericReturnValue result;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use the fakebank instead of the Python bank.
|
|
||||||
*/
|
|
||||||
static int use_fakebank;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How many coins we want to create per client and reserve.
|
* How many coins we want to create per client and reserve.
|
||||||
*/
|
*/
|
||||||
@ -151,16 +83,6 @@ static char *loglev;
|
|||||||
*/
|
*/
|
||||||
static char *logfile;
|
static char *logfile;
|
||||||
|
|
||||||
/**
|
|
||||||
* Benchmarking mode (run as client, exchange, both) as string.
|
|
||||||
*/
|
|
||||||
static char *mode_str;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Benchmarking mode (run as client, exchange, both).
|
|
||||||
*/
|
|
||||||
static enum BenchmarkMode mode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration.
|
* Configuration.
|
||||||
*/
|
*/
|
||||||
@ -171,21 +93,22 @@ static struct GNUNET_CONFIGURATION_Handle *cfg;
|
|||||||
*/
|
*/
|
||||||
static int reserves_first;
|
static int reserves_first;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Are we running against 'fakebank'?
|
||||||
|
*/
|
||||||
|
static int use_fakebank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Section with the configuration data for the exchange
|
||||||
|
* bank account.
|
||||||
|
*/
|
||||||
|
static char *exchange_bank_section = "exchange-account-1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currency used.
|
* Currency used.
|
||||||
*/
|
*/
|
||||||
static char *currency;
|
static char *currency;
|
||||||
|
|
||||||
/**
|
|
||||||
* Remote host that runs the exchange.
|
|
||||||
*/
|
|
||||||
static char *remote_host;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remote benchmarking directory.
|
|
||||||
*/
|
|
||||||
static char *remote_dir;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of command labels.
|
* Array of command labels.
|
||||||
*/
|
*/
|
||||||
@ -202,8 +125,7 @@ static unsigned int label_len;
|
|||||||
static unsigned int label_off;
|
static unsigned int label_off;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Don't kill exchange/fakebank/wirewatch until
|
* Linger around until stop is requested by the user explicitly by key stroke.
|
||||||
* requested by the user explicitly.
|
|
||||||
*/
|
*/
|
||||||
static int linger;
|
static int linger;
|
||||||
|
|
||||||
@ -246,8 +168,8 @@ cmd_transfer_to_exchange (const char *label,
|
|||||||
return TALER_TESTING_cmd_admin_add_incoming_retry (
|
return TALER_TESTING_cmd_admin_add_incoming_retry (
|
||||||
TALER_TESTING_cmd_admin_add_incoming (label,
|
TALER_TESTING_cmd_admin_add_incoming (label,
|
||||||
amount,
|
amount,
|
||||||
exchange_bank_account->auth,
|
&cred.ba,
|
||||||
user_payto_uri));
|
cred.user42_payto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -288,11 +210,12 @@ run (void *cls,
|
|||||||
char *amount_1;
|
char *amount_1;
|
||||||
|
|
||||||
(void) cls;
|
(void) cls;
|
||||||
all_commands = GNUNET_new_array (howmany_reserves * (1 /* Withdraw block */
|
all_commands = GNUNET_new_array (
|
||||||
+ howmany_coins) /* All units */
|
howmany_reserves * (1 /* Withdraw block */
|
||||||
+ 1 /* stat CMD */
|
+ howmany_coins) /* All units */
|
||||||
+ 1 /* End CMD */,
|
+ 1 /* stat CMD */
|
||||||
struct TALER_TESTING_Command);
|
+ 1 /* End CMD */,
|
||||||
|
struct TALER_TESTING_Command);
|
||||||
GNUNET_asprintf (&amount_5, "%s:5", currency);
|
GNUNET_asprintf (&amount_5, "%s:5", currency);
|
||||||
GNUNET_asprintf (&amount_4, "%s:4", currency);
|
GNUNET_asprintf (&amount_4, "%s:4", currency);
|
||||||
GNUNET_asprintf (&amount_1, "%s:1", currency);
|
GNUNET_asprintf (&amount_1, "%s:1", currency);
|
||||||
@ -350,25 +273,25 @@ run (void *cls,
|
|||||||
wl = add_label (withdraw_label);
|
wl = add_label (withdraw_label);
|
||||||
GNUNET_asprintf (&order_enc,
|
GNUNET_asprintf (&order_enc,
|
||||||
"{\"nonce\": %llu}",
|
"{\"nonce\": %llu}",
|
||||||
((unsigned long long) i) + (howmany_coins
|
((unsigned long long) i)
|
||||||
* (unsigned long long) j));
|
+ (howmany_coins * (unsigned long long) j));
|
||||||
unit[0] =
|
unit[0] =
|
||||||
TALER_TESTING_cmd_withdraw_with_retry
|
TALER_TESTING_cmd_withdraw_with_retry (
|
||||||
(TALER_TESTING_cmd_withdraw_amount (wl,
|
TALER_TESTING_cmd_withdraw_amount (wl,
|
||||||
create_reserve_label,
|
create_reserve_label,
|
||||||
amount_5,
|
amount_5,
|
||||||
0, /* age restriction off */
|
0, /* age restriction off */
|
||||||
MHD_HTTP_OK));
|
MHD_HTTP_OK));
|
||||||
unit[1] =
|
unit[1] =
|
||||||
TALER_TESTING_cmd_deposit_with_retry
|
TALER_TESTING_cmd_deposit_with_retry (
|
||||||
(TALER_TESTING_cmd_deposit ("deposit",
|
TALER_TESTING_cmd_deposit ("deposit",
|
||||||
wl,
|
wl,
|
||||||
0, /* Index of the one withdrawn coin in the traits. */
|
0, /* Index of the one withdrawn coin in the traits. */
|
||||||
user_payto_uri,
|
cred.user43_payto,
|
||||||
add_label (order_enc),
|
add_label (order_enc),
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
amount_1,
|
amount_1,
|
||||||
MHD_HTTP_OK));
|
MHD_HTTP_OK));
|
||||||
if (eval_probability (refresh_rate / 100.0))
|
if (eval_probability (refresh_rate / 100.0))
|
||||||
{
|
{
|
||||||
char *melt_label;
|
char *melt_label;
|
||||||
@ -387,21 +310,21 @@ run (void *cls,
|
|||||||
j);
|
j);
|
||||||
rl = add_label (reveal_label);
|
rl = add_label (reveal_label);
|
||||||
unit[2] =
|
unit[2] =
|
||||||
TALER_TESTING_cmd_melt_with_retry
|
TALER_TESTING_cmd_melt_with_retry (
|
||||||
(TALER_TESTING_cmd_melt (ml,
|
TALER_TESTING_cmd_melt (ml,
|
||||||
wl,
|
wl,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
NULL));
|
NULL));
|
||||||
unit[3] =
|
unit[3] =
|
||||||
TALER_TESTING_cmd_refresh_reveal_with_retry
|
TALER_TESTING_cmd_refresh_reveal_with_retry (
|
||||||
(TALER_TESTING_cmd_refresh_reveal (rl,
|
TALER_TESTING_cmd_refresh_reveal (rl,
|
||||||
ml,
|
ml,
|
||||||
MHD_HTTP_OK));
|
MHD_HTTP_OK));
|
||||||
unit[4] =
|
unit[4] =
|
||||||
TALER_TESTING_cmd_refresh_link_with_retry
|
TALER_TESTING_cmd_refresh_link_with_retry (
|
||||||
(TALER_TESTING_cmd_refresh_link ("link",
|
TALER_TESTING_cmd_refresh_link ("link",
|
||||||
rl,
|
rl,
|
||||||
MHD_HTTP_OK));
|
MHD_HTTP_OK));
|
||||||
unit[5] = TALER_TESTING_cmd_end ();
|
unit[5] = TALER_TESTING_cmd_end ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -429,7 +352,6 @@ run (void *cls,
|
|||||||
GNUNET_free (amount_4);
|
GNUNET_free (amount_4);
|
||||||
GNUNET_free (amount_5);
|
GNUNET_free (amount_5);
|
||||||
GNUNET_free (withdraw_fee_str);
|
GNUNET_free (withdraw_fee_str);
|
||||||
result = GNUNET_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -446,10 +368,10 @@ print_stats (void)
|
|||||||
|
|
||||||
total = GNUNET_strdup (
|
total = GNUNET_strdup (
|
||||||
GNUNET_STRINGS_relative_time_to_string (timings[i].total_duration,
|
GNUNET_STRINGS_relative_time_to_string (timings[i].total_duration,
|
||||||
GNUNET_YES));
|
true));
|
||||||
latency = GNUNET_strdup (
|
latency = GNUNET_strdup (
|
||||||
GNUNET_STRINGS_relative_time_to_string (timings[i].success_latency,
|
GNUNET_STRINGS_relative_time_to_string (timings[i].success_latency,
|
||||||
GNUNET_YES));
|
true));
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"%s-%d took %s in total with %s for latency for %u executions (%u repeats)\n",
|
"%s-%d took %s in total with %s for latency for %u executions (%u repeats)\n",
|
||||||
timings[i].prefix,
|
timings[i].prefix,
|
||||||
@ -480,135 +402,66 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
|
|||||||
{
|
{
|
||||||
enum GNUNET_GenericReturnValue result = GNUNET_OK;
|
enum GNUNET_GenericReturnValue result = GNUNET_OK;
|
||||||
pid_t cpids[howmany_clients];
|
pid_t cpids[howmany_clients];
|
||||||
pid_t fakebank = -1;
|
|
||||||
int wstatus;
|
|
||||||
|
|
||||||
if (MODE_CLIENT == mode)
|
if (1 == howmany_clients)
|
||||||
{
|
{
|
||||||
char *remote_cmd;
|
result = TALER_TESTING_loop (main_cb,
|
||||||
|
main_cb_cls);
|
||||||
GNUNET_asprintf (&remote_cmd,
|
print_stats ();
|
||||||
("cd '%s'; "
|
|
||||||
"taler-exchange-benchmark --mode=exchange -c '%s'"),
|
|
||||||
remote_dir,
|
|
||||||
config_file);
|
|
||||||
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
|
||||||
"remote command: %s\n",
|
|
||||||
remote_cmd);
|
|
||||||
|
|
||||||
GNUNET_assert (NULL != (exchange_slave_pipe =
|
|
||||||
GNUNET_DISK_pipe (GNUNET_DISK_PF_BLOCKING_RW)));
|
|
||||||
|
|
||||||
exchange_slave = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
|
|
||||||
exchange_slave_pipe, NULL, NULL,
|
|
||||||
"ssh",
|
|
||||||
"ssh",
|
|
||||||
/* Don't ask for pw/passphrase, rather fail */
|
|
||||||
"-oBatchMode=yes",
|
|
||||||
remote_host,
|
|
||||||
remote_cmd,
|
|
||||||
NULL);
|
|
||||||
GNUNET_free (remote_cmd);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* We always wait for the exchange, no matter if it's running locally or
|
|
||||||
remotely */
|
|
||||||
if (0 != TALER_TESTING_wait_httpd_ready (ec.exchange_url))
|
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
for (unsigned int i = 0; i<howmany_clients; i++)
|
||||||
"Failed to detect running exchange at `%s'\n",
|
|
||||||
ec.exchange_url);
|
|
||||||
return 77;
|
|
||||||
}
|
|
||||||
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
|
|
||||||
{
|
|
||||||
start_time = GNUNET_TIME_absolute_get ();
|
|
||||||
result = GNUNET_OK;
|
|
||||||
if (1 == howmany_clients)
|
|
||||||
{
|
{
|
||||||
result = TALER_TESTING_run (main_cb,
|
if (0 == (cpids[i] = fork ()))
|
||||||
main_cb_cls);
|
|
||||||
print_stats ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i<howmany_clients; i++)
|
|
||||||
{
|
{
|
||||||
if (0 == (cpids[i] = fork ()))
|
/* I am the child, do the work! */
|
||||||
{
|
GNUNET_log_setup ("benchmark-worker",
|
||||||
/* I am the child, do the work! */
|
NULL == loglev ? "INFO" : loglev,
|
||||||
GNUNET_log_setup ("benchmark-worker",
|
logfile);
|
||||||
NULL == loglev ? "INFO" : loglev,
|
result = TALER_TESTING_loop (main_cb,
|
||||||
logfile);
|
main_cb_cls);
|
||||||
|
print_stats ();
|
||||||
result = TALER_TESTING_run (main_cb,
|
if (GNUNET_OK != result)
|
||||||
main_cb_cls);
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
print_stats ();
|
"Failure in child process %u test suite!\n",
|
||||||
if (GNUNET_OK != result)
|
i);
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
if (GNUNET_OK == result)
|
||||||
"Failure in child process test suite!\n");
|
exit (0);
|
||||||
if (GNUNET_OK == result)
|
else
|
||||||
exit (0);
|
exit (1);
|
||||||
else
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
if (-1 == cpids[i])
|
|
||||||
{
|
|
||||||
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"fork");
|
|
||||||
howmany_clients = i;
|
|
||||||
result = GNUNET_SYSERR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* fork() success, continue starting more processes! */
|
|
||||||
}
|
}
|
||||||
/* collect all children */
|
if (-1 == cpids[i])
|
||||||
for (unsigned int i = 0; i<howmany_clients; i++)
|
|
||||||
{
|
{
|
||||||
waitpid (cpids[i],
|
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
|
||||||
&wstatus,
|
"fork");
|
||||||
0);
|
howmany_clients = i;
|
||||||
if ( (! WIFEXITED (wstatus)) ||
|
result = GNUNET_SYSERR;
|
||||||
(0 != WEXITSTATUS (wstatus)) )
|
break;
|
||||||
{
|
}
|
||||||
GNUNET_break (0);
|
/* fork() success, continue starting more processes! */
|
||||||
result = GNUNET_SYSERR;
|
}
|
||||||
}
|
/* collect all children */
|
||||||
|
for (unsigned int i = 0; i<howmany_clients; i++)
|
||||||
|
{
|
||||||
|
int wstatus;
|
||||||
|
|
||||||
|
waitpid (cpids[i],
|
||||||
|
&wstatus,
|
||||||
|
0);
|
||||||
|
if ( (! WIFEXITED (wstatus)) ||
|
||||||
|
(0 != WEXITSTATUS (wstatus)) )
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
result = GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (GNUNET_YES == linger)
|
||||||
/* Wait for our master to die or to tell us to die */
|
|
||||||
if (MODE_EXCHANGE == mode)
|
|
||||||
(void) getchar ();
|
|
||||||
|
|
||||||
if ( (GNUNET_YES == linger) &&
|
|
||||||
( ((mode == MODE_BOTH) ||
|
|
||||||
(mode == MODE_CLIENT) ) ) )
|
|
||||||
{
|
{
|
||||||
printf ("press ENTER to stop\n");
|
printf ("press ENTER to stop\n");
|
||||||
(void) getchar ();
|
(void) getchar ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MODE_CLIENT == mode)
|
|
||||||
{
|
|
||||||
char c = 'q';
|
|
||||||
|
|
||||||
GNUNET_assert (NULL != exchange_slave);
|
|
||||||
|
|
||||||
/* Write a character to the pipe to end the exchange slave.
|
|
||||||
* We can't send a signal here, as it would just kill SSH and
|
|
||||||
* not necessarily the process on the other machine. */
|
|
||||||
GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle
|
|
||||||
(exchange_slave_pipe, GNUNET_DISK_PIPE_END_WRITE),
|
|
||||||
&c, sizeof (c));
|
|
||||||
|
|
||||||
GNUNET_break (GNUNET_OK ==
|
|
||||||
GNUNET_OS_process_wait (exchange_slave));
|
|
||||||
GNUNET_OS_process_destroy (exchange_slave);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,55 +478,70 @@ main (int argc,
|
|||||||
char *const *argv)
|
char *const *argv)
|
||||||
{
|
{
|
||||||
struct GNUNET_GETOPT_CommandLineOption options[] = {
|
struct GNUNET_GETOPT_CommandLineOption options[] = {
|
||||||
GNUNET_GETOPT_option_mandatory
|
GNUNET_GETOPT_option_mandatory (
|
||||||
(GNUNET_GETOPT_option_cfgfile (&cfg_filename)),
|
GNUNET_GETOPT_option_cfgfile (
|
||||||
GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
|
&cfg_filename)),
|
||||||
GNUNET_GETOPT_option_help ("Exchange benchmark"),
|
GNUNET_GETOPT_option_version (
|
||||||
GNUNET_GETOPT_option_loglevel (&loglev),
|
PACKAGE_VERSION " " VCS_VERSION),
|
||||||
GNUNET_GETOPT_option_uint ('n',
|
GNUNET_GETOPT_option_help (
|
||||||
"coins-number",
|
"Exchange benchmark"),
|
||||||
"CN",
|
GNUNET_GETOPT_option_loglevel (
|
||||||
"How many coins we should instantiate per reserve",
|
&loglev),
|
||||||
&howmany_coins),
|
GNUNET_GETOPT_option_uint (
|
||||||
GNUNET_GETOPT_option_uint ('p',
|
'n',
|
||||||
"parallelism",
|
"coins-number",
|
||||||
"NPROCS",
|
"CN",
|
||||||
"How many client processes we should run",
|
"How many coins we should instantiate per reserve",
|
||||||
&howmany_clients),
|
&howmany_coins),
|
||||||
GNUNET_GETOPT_option_uint ('r',
|
GNUNET_GETOPT_option_uint (
|
||||||
"reserves",
|
'p',
|
||||||
"NRESERVES",
|
"parallelism",
|
||||||
"How many reserves per client we should create",
|
"NPROCS",
|
||||||
&howmany_reserves),
|
"How many client processes we should run",
|
||||||
GNUNET_GETOPT_option_uint ('R',
|
&howmany_clients),
|
||||||
"refresh-rate",
|
GNUNET_GETOPT_option_uint (
|
||||||
"RATE",
|
'r',
|
||||||
"Probability of refresh per coin (0-100)",
|
"reserves",
|
||||||
&refresh_rate),
|
"NRESERVES",
|
||||||
GNUNET_GETOPT_option_string ('m',
|
"How many reserves per client we should create",
|
||||||
"mode",
|
&howmany_reserves),
|
||||||
"MODE",
|
GNUNET_GETOPT_option_uint (
|
||||||
"run as exchange, clients or both",
|
'R',
|
||||||
&mode_str),
|
"refresh-rate",
|
||||||
GNUNET_GETOPT_option_string ('l',
|
"RATE",
|
||||||
"logfile",
|
"Probability of refresh per coin (0-100)",
|
||||||
"LF",
|
&refresh_rate),
|
||||||
"will log to file LF",
|
GNUNET_GETOPT_option_string (
|
||||||
&logfile),
|
'l',
|
||||||
GNUNET_GETOPT_option_flag ('f',
|
"logfile",
|
||||||
"fakebank",
|
"LF",
|
||||||
"start a fakebank instead of the Python bank",
|
"will log to file LF",
|
||||||
&use_fakebank),
|
&logfile),
|
||||||
GNUNET_GETOPT_option_flag ('F',
|
GNUNET_GETOPT_option_string (
|
||||||
"reserves-first",
|
'u',
|
||||||
"should all reserves be created first, before starting normal operations",
|
"exchange-account-section",
|
||||||
&reserves_first),
|
"SECTION",
|
||||||
GNUNET_GETOPT_option_flag ('K',
|
"use exchange bank account configuration from the given SECTION",
|
||||||
"linger",
|
&exchange_bank_section),
|
||||||
"linger around until key press",
|
GNUNET_GETOPT_option_flag (
|
||||||
&linger),
|
'f',
|
||||||
|
"fakebank",
|
||||||
|
"use fakebank for the banking system",
|
||||||
|
&use_fakebank),
|
||||||
|
GNUNET_GETOPT_option_flag (
|
||||||
|
'F',
|
||||||
|
"reserves-first",
|
||||||
|
"should all reserves be created first, before starting normal operations",
|
||||||
|
&reserves_first),
|
||||||
|
GNUNET_GETOPT_option_flag (
|
||||||
|
'K',
|
||||||
|
"linger",
|
||||||
|
"linger around until key press",
|
||||||
|
&linger),
|
||||||
GNUNET_GETOPT_OPTION_END
|
GNUNET_GETOPT_OPTION_END
|
||||||
};
|
};
|
||||||
|
enum GNUNET_GenericReturnValue result;
|
||||||
|
struct GNUNET_TIME_Relative duration;
|
||||||
|
|
||||||
unsetenv ("XDG_DATA_HOME");
|
unsetenv ("XDG_DATA_HOME");
|
||||||
unsetenv ("XDG_CONFIG_HOME");
|
unsetenv ("XDG_CONFIG_HOME");
|
||||||
@ -686,29 +554,13 @@ main (int argc,
|
|||||||
GNUNET_free (cfg_filename);
|
GNUNET_free (cfg_filename);
|
||||||
if (GNUNET_NO == result)
|
if (GNUNET_NO == result)
|
||||||
return 0;
|
return 0;
|
||||||
return BAD_CLI_ARG;
|
return EXIT_INVALIDARGUMENT;
|
||||||
}
|
}
|
||||||
GNUNET_log_setup ("taler-exchange-benchmark",
|
GNUNET_log_setup ("taler-exchange-benchmark",
|
||||||
NULL == loglev ? "INFO" : loglev,
|
NULL == loglev
|
||||||
|
? "INFO"
|
||||||
|
: loglev,
|
||||||
logfile);
|
logfile);
|
||||||
if (NULL == mode_str)
|
|
||||||
mode = MODE_BOTH;
|
|
||||||
else if (0 == strcmp (mode_str,
|
|
||||||
"exchange"))
|
|
||||||
mode = MODE_EXCHANGE;
|
|
||||||
else if (0 == strcmp (mode_str,
|
|
||||||
"client"))
|
|
||||||
mode = MODE_CLIENT;
|
|
||||||
else if (0 == strcmp (mode_str,
|
|
||||||
"both"))
|
|
||||||
mode = MODE_BOTH;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TALER_LOG_ERROR ("Unknown mode given: '%s'\n",
|
|
||||||
mode_str);
|
|
||||||
GNUNET_free (cfg_filename);
|
|
||||||
return BAD_CONFIG_FILE;
|
|
||||||
}
|
|
||||||
if (NULL == cfg_filename)
|
if (NULL == cfg_filename)
|
||||||
cfg_filename = GNUNET_CONFIGURATION_default_filename ();
|
cfg_filename = GNUNET_CONFIGURATION_default_filename ();
|
||||||
if (NULL == cfg_filename)
|
if (NULL == cfg_filename)
|
||||||
@ -724,7 +576,7 @@ main (int argc,
|
|||||||
{
|
{
|
||||||
TALER_LOG_ERROR ("Could not parse configuration\n");
|
TALER_LOG_ERROR ("Could not parse configuration\n");
|
||||||
GNUNET_free (cfg_filename);
|
GNUNET_free (cfg_filename);
|
||||||
return BAD_CONFIG_FILE;
|
return EXIT_NOTCONFIGURED;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_config_get_currency (cfg,
|
TALER_config_get_currency (cfg,
|
||||||
@ -732,96 +584,45 @@ main (int argc,
|
|||||||
{
|
{
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
GNUNET_free (cfg_filename);
|
GNUNET_free (cfg_filename);
|
||||||
return BAD_CONFIG_FILE;
|
return EXIT_NOTCONFIGURED;
|
||||||
}
|
}
|
||||||
if (howmany_clients > 10240)
|
if (howmany_clients > 10240)
|
||||||
{
|
{
|
||||||
TALER_LOG_ERROR ("-p option value given is too large\n");
|
TALER_LOG_ERROR ("-p option value given is too large\n");
|
||||||
return BAD_CLI_ARG;
|
return EXIT_INVALIDARGUMENT;
|
||||||
}
|
}
|
||||||
if (0 == howmany_clients)
|
if (0 == howmany_clients)
|
||||||
{
|
{
|
||||||
TALER_LOG_ERROR ("-p option value must not be zero\n");
|
TALER_LOG_ERROR ("-p option value must not be zero\n");
|
||||||
GNUNET_free (cfg_filename);
|
GNUNET_free (cfg_filename);
|
||||||
return BAD_CLI_ARG;
|
return EXIT_INVALIDARGUMENT;
|
||||||
}
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
||||||
"benchmark",
|
|
||||||
"USER_PAYTO_URI",
|
|
||||||
&user_payto_uri))
|
|
||||||
{
|
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"benchmark",
|
|
||||||
"USER_PAYTO_URI");
|
|
||||||
GNUNET_free (cfg_filename);
|
|
||||||
return BAD_CONFIG_FILE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_EXCHANGEDB_load_accounts (cfg,
|
TALER_TESTING_get_credentials (
|
||||||
TALER_EXCHANGEDB_ALO_AUTHDATA
|
cfg_filename,
|
||||||
| TALER_EXCHANGEDB_ALO_CREDIT))
|
exchange_bank_section,
|
||||||
|
use_fakebank
|
||||||
|
? TALER_TESTING_BS_FAKEBANK
|
||||||
|
: TALER_TESTING_BS_IBAN,
|
||||||
|
&cred))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Configuration fails to provide exchange bank details\n");
|
"Required bank credentials not given in configuration\n");
|
||||||
GNUNET_free (cfg_filename);
|
GNUNET_free (cfg_filename);
|
||||||
return BAD_CONFIG_FILE;
|
return EXIT_NOTCONFIGURED;
|
||||||
}
|
|
||||||
|
|
||||||
exchange_bank_account
|
|
||||||
= TALER_EXCHANGEDB_find_account_by_method ("x-taler-bank");
|
|
||||||
if (NULL == exchange_bank_account)
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"No bank account for `x-taler-bank` given in configuration\n");
|
|
||||||
GNUNET_free (cfg_filename);
|
|
||||||
return BAD_CONFIG_FILE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
struct GNUNET_TIME_Absolute start_time;
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
||||||
"benchmark-remote-exchange",
|
|
||||||
"host",
|
|
||||||
&remote_host))
|
|
||||||
{
|
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"benchmark-remote-exchange",
|
|
||||||
"host");
|
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
|
||||||
GNUNET_free (cfg_filename);
|
|
||||||
return BAD_CONFIG_FILE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
start_time = GNUNET_TIME_absolute_get ();
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
result = parallel_benchmark (&run,
|
||||||
"benchmark-remote-exchange",
|
NULL,
|
||||||
"dir",
|
cfg_filename);
|
||||||
&remote_dir))
|
duration = GNUNET_TIME_absolute_get_duration (start_time);
|
||||||
{
|
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"benchmark-remote-exchange",
|
|
||||||
"dir");
|
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
|
||||||
GNUNET_free (cfg_filename);
|
|
||||||
return BAD_CONFIG_FILE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = parallel_benchmark (&run,
|
|
||||||
NULL,
|
|
||||||
cfg_filename);
|
|
||||||
TALER_EXCHANGEDB_unload_accounts ();
|
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
|
||||||
GNUNET_free (cfg_filename);
|
|
||||||
|
|
||||||
/* If we're the exchange worker, we're done now. No need to print results */
|
|
||||||
if (MODE_EXCHANGE == mode)
|
|
||||||
{
|
|
||||||
return (GNUNET_OK == result) ? 0 : result;
|
|
||||||
}
|
|
||||||
duration = GNUNET_TIME_absolute_get_duration (start_time);
|
|
||||||
if (GNUNET_OK == result)
|
if (GNUNET_OK == result)
|
||||||
{
|
{
|
||||||
struct rusage usage;
|
struct rusage usage;
|
||||||
@ -829,39 +630,45 @@ main (int argc,
|
|||||||
GNUNET_assert (0 == getrusage (RUSAGE_CHILDREN,
|
GNUNET_assert (0 == getrusage (RUSAGE_CHILDREN,
|
||||||
&usage));
|
&usage));
|
||||||
fprintf (stdout,
|
fprintf (stdout,
|
||||||
"Executed (Withdraw=%u, Deposit=%u, Refresh~=%5.2f) * Reserve=%u * Parallel=%u, operations in %s\n",
|
"Executed (Withdraw=%u, Deposit=%u, Refresh~=%5.2f)"
|
||||||
|
" * Reserve=%u * Parallel=%u, operations in %s\n",
|
||||||
howmany_coins,
|
howmany_coins,
|
||||||
howmany_coins,
|
howmany_coins,
|
||||||
(float) howmany_coins * (refresh_rate / 100.0),
|
(float) howmany_coins * (refresh_rate / 100.0),
|
||||||
howmany_reserves,
|
howmany_reserves,
|
||||||
howmany_clients,
|
howmany_clients,
|
||||||
GNUNET_STRINGS_relative_time_to_string
|
GNUNET_STRINGS_relative_time_to_string (
|
||||||
(duration,
|
duration,
|
||||||
GNUNET_NO));
|
false));
|
||||||
fprintf (stdout,
|
fprintf (stdout,
|
||||||
"(approximately %s/coin)\n",
|
"(approximately %s/coin)\n",
|
||||||
GNUNET_STRINGS_relative_time_to_string
|
GNUNET_STRINGS_relative_time_to_string (
|
||||||
(GNUNET_TIME_relative_divide (duration,
|
GNUNET_TIME_relative_divide (
|
||||||
(unsigned long long) howmany_coins
|
duration,
|
||||||
* howmany_reserves
|
(unsigned long long) howmany_coins
|
||||||
* howmany_clients),
|
* howmany_reserves
|
||||||
GNUNET_YES));
|
* howmany_clients),
|
||||||
|
true));
|
||||||
fprintf (stdout,
|
fprintf (stdout,
|
||||||
"RAW: %04u %04u %04u %16llu\n",
|
"RAW: %04u %04u %04u %16llu\n",
|
||||||
howmany_coins,
|
howmany_coins,
|
||||||
howmany_reserves,
|
howmany_reserves,
|
||||||
howmany_clients,
|
howmany_clients,
|
||||||
(unsigned long long) duration.rel_value_us);
|
(unsigned long long) duration.rel_value_us);
|
||||||
fprintf (stdout, "cpu time: sys %llu user %llu\n", \
|
fprintf (stdout,
|
||||||
|
"cpu time: sys %llu user %llu\n",
|
||||||
(unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000
|
(unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000
|
||||||
+ usage.ru_stime.tv_usec),
|
+ usage.ru_stime.tv_usec),
|
||||||
(unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000
|
(unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000
|
||||||
+ usage.ru_utime.tv_usec));
|
+ usage.ru_utime.tv_usec));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i<label_off; i++)
|
for (unsigned int i = 0; i<label_off; i++)
|
||||||
GNUNET_free (labels[i]);
|
GNUNET_free (labels[i]);
|
||||||
GNUNET_array_grow (labels,
|
GNUNET_array_grow (labels,
|
||||||
label_len,
|
label_len,
|
||||||
0);
|
0);
|
||||||
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
|
GNUNET_free (cfg_filename);
|
||||||
return (GNUNET_OK == result) ? 0 : result;
|
return (GNUNET_OK == result) ? 0 : result;
|
||||||
}
|
}
|
||||||
|
@ -2318,6 +2318,7 @@ add_denom_key_cb (void *cls,
|
|||||||
* Add the headers we want to set for every /keys response.
|
* Add the headers we want to set for every /keys response.
|
||||||
*
|
*
|
||||||
* @param ksh the key state to use
|
* @param ksh the key state to use
|
||||||
|
* @param wsh wire state to use
|
||||||
* @param[in,out] response the response to modify
|
* @param[in,out] response the response to modify
|
||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user