summaryrefslogtreecommitdiff
path: root/src/benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'src/benchmark')
-rw-r--r--src/benchmark/.gitignore1
-rw-r--r--src/benchmark/Makefile.am7
-rw-r--r--src/benchmark/bank-benchmark-cs.conf12
-rw-r--r--src/benchmark/bank-benchmark-rsa.conf14
-rw-r--r--src/benchmark/benchmark-common.conf73
-rw-r--r--src/benchmark/benchmark-cs.conf2
-rw-r--r--src/benchmark/benchmark-rsa.conf2
-rw-r--r--src/benchmark/exchange_benchmark_home/.local/share/taler/exchange/offline-keys/master.priv1
-rw-r--r--src/benchmark/taler-aggregator-benchmark.c91
-rw-r--r--src/benchmark/taler-bank-benchmark.c677
-rwxr-xr-xsrc/benchmark/taler-benchmark-setup.sh655
-rw-r--r--src/benchmark/taler-exchange-benchmark.c910
12 files changed, 449 insertions, 1996 deletions
diff --git a/src/benchmark/.gitignore b/src/benchmark/.gitignore
index 45e150087..a1b4711e7 100644
--- a/src/benchmark/.gitignore
+++ b/src/benchmark/.gitignore
@@ -1,2 +1,3 @@
taler-bank-benchmark
taler-aggregator-benchmark
+*.edited
diff --git a/src/benchmark/Makefile.am b/src/benchmark/Makefile.am
index de93cc748..c82584626 100644
--- a/src/benchmark/Makefile.am
+++ b/src/benchmark/Makefile.am
@@ -15,9 +15,6 @@ bin_PROGRAMS = \
taler-bank-benchmark \
taler-exchange-benchmark
-bin_SCRIPTS = \
- taler-benchmark-setup.sh
-
taler_aggregator_benchmark_SOURCES = \
taler-aggregator-benchmark.c
@@ -74,6 +71,4 @@ EXTRA_DIST = \
bank-benchmark-cs.conf \
bank-benchmark-rsa.conf \
coins-cs.conf \
- coins-rsa.conf \
- $(bin_SCRIPTS) \
- exchange_benchmark_home/.local/share/taler/exchange/offline-keys/master.priv
+ coins-rsa.conf
diff --git a/src/benchmark/bank-benchmark-cs.conf b/src/benchmark/bank-benchmark-cs.conf
index d1d75d740..39c82a3fe 100644
--- a/src/benchmark/bank-benchmark-cs.conf
+++ b/src/benchmark/bank-benchmark-cs.conf
@@ -2,16 +2,4 @@
@INLINE@ benchmark-common.conf
@INLINE@ coins-cs.conf
-[exchange-account-2]
-# What is the payto://-URL of the exchange (to generate wire response)
-PAYTO_URI = "payto://x-taler-bank/localhost:8082/Exchange?receiver-name=Exchange"
-ENABLE_DEBIT = YES
-ENABLE_CREDIT = YES
-[exchange-accountcredentials-2]
-# What is the bank account (with the "Taler Bank" demo system)? Must end with "/".
-WIRE_GATEWAY_URL = http://localhost:8082/Exchange/
-# Authentication information for basic authentication
-WIRE_GATEWAY_AUTH_METHOD = "basic"
-USERNAME = Exchange
-PASSWORD = x
diff --git a/src/benchmark/bank-benchmark-rsa.conf b/src/benchmark/bank-benchmark-rsa.conf
index d1d75d740..ca5d6b0da 100644
--- a/src/benchmark/bank-benchmark-rsa.conf
+++ b/src/benchmark/bank-benchmark-rsa.conf
@@ -1,17 +1,5 @@
# This file is in the public domain.
@INLINE@ benchmark-common.conf
-@INLINE@ coins-cs.conf
+@INLINE@ coins-rsa.conf
-[exchange-account-2]
-# What is the payto://-URL of the exchange (to generate wire response)
-PAYTO_URI = "payto://x-taler-bank/localhost:8082/Exchange?receiver-name=Exchange"
-ENABLE_DEBIT = YES
-ENABLE_CREDIT = YES
-[exchange-accountcredentials-2]
-# What is the bank account (with the "Taler Bank" demo system)? Must end with "/".
-WIRE_GATEWAY_URL = http://localhost:8082/Exchange/
-# Authentication information for basic authentication
-WIRE_GATEWAY_AUTH_METHOD = "basic"
-USERNAME = Exchange
-PASSWORD = x
diff --git a/src/benchmark/benchmark-common.conf b/src/benchmark/benchmark-common.conf
index 5ac4a3974..e47115a2b 100644
--- a/src/benchmark/benchmark-common.conf
+++ b/src/benchmark/benchmark-common.conf
@@ -13,9 +13,17 @@ PORT=8081
MASTER_PUBLIC_KEY=98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
DB=postgres
BASE_URL="http://localhost:8081/"
-AGGREGATOR_SHARD_SIZE=67108864
+# Only set this option if you are actually running
+# multiple aggregators!
+# AGGREGATOR_SHARD_SIZE=67108864
WIREWATCH_IDLE_SLEEP_INTERVAL=5 ms
+[exchangedb-postgres]
+CONFIG="postgres:///talercheck"
+
+[exchange-offline]
+MASTER_PRIV_FILE=${TALER_TEST_HOME}/.local/share/taler/exchange/offline-keys/master.priv
+
[taler-exchange-secmod-rsa]
LOOKAHEAD_SIGN="1 d"
@@ -26,6 +34,39 @@ LOOKAHEAD_SIGN="1 d"
DURATION="2 d"
LOOKAHEAD_SIGN="1 d"
+# account-2 is suitable for fakebank
+[exchange-account-1]
+PAYTO_URI = "payto://x-taler-bank/localhost/exchange?receiver-name=exchange"
+ENABLE_DEBIT = YES
+ENABLE_CREDIT = YES
+
+[exchange-accountcredentials-1]
+WIRE_GATEWAY_AUTH_METHOD = none
+WIRE_GATEWAY_URL = "http://localhost:8080/accounts/exchange/taler-wire-gateway/"
+
+[admin-accountcredentials-1]
+WIRE_GATEWAY_AUTH_METHOD = none
+WIRE_GATEWAY_URL = "http://localhost:8080/accounts/exchange/taler-wire-gateway/"
+
+# account-2 is suitable for libeufin
+[exchange-account-2]
+ENABLE_DEBIT = YES
+ENABLE_CREDIT = YES
+PAYTO_URI = payto://iban/SANDBOXX/DE033310?receiver-name=Exchange+Company
+
+[exchange-accountcredentials-2]
+WIRE_GATEWAY_AUTH_METHOD = basic
+USERNAME = exchange
+PASSWORD = x
+WIRE_GATEWAY_URL = "http://localhost:8080/accounts/exchange/taler-wire-gateway/"
+
+[admin-accountcredentials-2]
+WIRE_GATEWAY_AUTH_METHOD = basic
+USERNAME = admin
+PASSWORD = secret
+WIRE_GATEWAY_URL = "http://localhost:8080/accounts/exchange/taler-wire-gateway/"
+
+
# Trust local exchange for "EUR" currency
[merchant-exchange-benchmark]
EXCHANGE_BASE_URL = http://localhost:8081/
@@ -35,9 +76,6 @@ MASTER_KEY=98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
CURRENCY = EUR
-[exchangedb-postgres]
-CONFIG="postgres:///talercheck"
-
[merchantdb-postgres]
CONFIG="postgres:///talercheck"
@@ -47,31 +85,22 @@ CONFIG="postgres:///talercheck"
[syncdb-postgres]
CONFIG="postgres:///talercheck"
-[exchange-offline]
-MASTER_PRIV_FILE=${TALER_DATA_HOME}/exchange/offline-keys/master.priv
+[exchange]
+WIREWATCH_IDLE_SLEEP_INTERVAL = 5000 ms
[bank]
-HTTP_PORT=8082
+HTTP_PORT=8080
SERVE=http
-MAX_DEBT=EUR:100000000000.0
-MAX_DEBT_BANK=EUR:1000000000000000.0
-DATABASE=bank-db.sqlite3
+RAM_LIMIT=10000000
+
+[libeufin-bank]
+CURRENCY = EUR
[libeufin-nexus]
-#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix."
-DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
+DB_CONNECTION="postgresql:///talercheck"
[libeufin-sandbox]
-#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix."
-DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"
+DB_CONNECTION="postgresql:///talercheck"
[auditor]
BASE_URL="http://localhost:8083/"
-
-[benchmark-remote-exchange]
-HOST=localhost
-# Adjust $HOME to match remote target!
-DIR=$HOME/repos/taler/exchange/src/benchmark
-
-[benchmark]
-USER_PAYTO_URI="payto://x-taler-bank/localhost:8082/42?receiver-name=user42"
diff --git a/src/benchmark/benchmark-cs.conf b/src/benchmark/benchmark-cs.conf
index db44e4d1b..7f660ad31 100644
--- a/src/benchmark/benchmark-cs.conf
+++ b/src/benchmark/benchmark-cs.conf
@@ -10,7 +10,7 @@ ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
[exchange-accountcredentials-test]
-WIRE_GATEWAY_URL = http://localhost:8082/Exchange/
+WIRE_GATEWAY_URL = http://localhost:8082/accounts/Exchange/taler-wire-gateway/
WIRE_GATEWAY_AUTH_METHOD = "basic"
USERNAME = Exchange
PASSWORD = x
diff --git a/src/benchmark/benchmark-rsa.conf b/src/benchmark/benchmark-rsa.conf
index bd4a90cf3..a6c1512ee 100644
--- a/src/benchmark/benchmark-rsa.conf
+++ b/src/benchmark/benchmark-rsa.conf
@@ -10,7 +10,7 @@ ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
[exchange-accountcredentials-test]
-WIRE_GATEWAY_URL = http://localhost:8082/Exchange/
+WIRE_GATEWAY_URL = http://localhost:8082/accounts/Exchange/taler-wire-gateway/
WIRE_GATEWAY_AUTH_METHOD = "basic"
USERNAME = Exchange
PASSWORD = x
diff --git a/src/benchmark/exchange_benchmark_home/.local/share/taler/exchange/offline-keys/master.priv b/src/benchmark/exchange_benchmark_home/.local/share/taler/exchange/offline-keys/master.priv
deleted file mode 100644
index 394926938..000000000
--- a/src/benchmark/exchange_benchmark_home/.local/share/taler/exchange/offline-keys/master.priv
+++ /dev/null
@@ -1 +0,0 @@
-p^-33XX!\0qmU_ \ No newline at end of file
diff --git a/src/benchmark/taler-aggregator-benchmark.c b/src/benchmark/taler-aggregator-benchmark.c
index bf9a3f3ec..228d050e4 100644
--- a/src/benchmark/taler-aggregator-benchmark.c
+++ b/src/benchmark/taler-aggregator-benchmark.c
@@ -251,7 +251,7 @@ add_refund (const struct Merchant *m,
r.details.rtransaction_id = 42;
make_amount (0, 5000000, &r.details.refund_amount);
make_amount (0, 5, &r.details.refund_fee);
- if (0 <=
+ if (0 >=
plugin->insert_refund (plugin->cls,
&r))
{
@@ -274,7 +274,11 @@ static bool
add_deposit (const struct Merchant *m)
{
struct Deposit d;
- struct TALER_EXCHANGEDB_Deposit deposit;
+ struct TALER_EXCHANGEDB_CoinDepositInformation deposit;
+ struct TALER_EXCHANGEDB_BatchDeposit bd = {
+ .cdis = &deposit,
+ .num_cdis = 1
+ };
uint64_t known_coin_id;
struct TALER_DenominationHashP dph;
struct TALER_AgeCommitmentHash agh;
@@ -302,24 +306,40 @@ add_deposit (const struct Merchant *m)
}
deposit.coin = d.coin;
RANDOMIZE (&deposit.csig);
- deposit.merchant_pub = m->merchant_pub;
- deposit.h_contract_terms = d.h_contract_terms;
- deposit.wire_salt = m->wire_salt;
- deposit.receiver_wire_account = m->payto_uri;
- deposit.timestamp = random_time ();
- deposit.refund_deadline = random_time ();
- deposit.wire_deadline = random_time ();
+ bd.merchant_pub = m->merchant_pub;
+ bd.h_contract_terms = d.h_contract_terms;
+ bd.wire_salt = m->wire_salt;
+ bd.receiver_wire_account = m->payto_uri;
+ bd.wallet_timestamp = random_time ();
+ do {
+ bd.refund_deadline = random_time ();
+ bd.wire_deadline = random_time ();
+ } while (GNUNET_TIME_timestamp_cmp (bd.wire_deadline,
+ <,
+ bd.refund_deadline));
+
make_amount (1, 0, &deposit.amount_with_fee);
- make_amount (0, 5, &deposit.deposit_fee);
- if (0 >=
- plugin->insert_deposit (plugin->cls,
- random_time (),
- &deposit))
+
{
- GNUNET_break (0);
- global_ret = EXIT_FAILURE;
- GNUNET_SCHEDULER_shutdown ();
- return false;
+ struct GNUNET_TIME_Timestamp now;
+ bool balance_ok;
+ uint32_t bad_idx;
+ bool conflict;
+
+ now = random_time ();
+ if (0 >=
+ plugin->do_deposit (plugin->cls,
+ &bd,
+ &now,
+ &balance_ok,
+ &bad_idx,
+ &conflict))
+ {
+ GNUNET_break (0);
+ global_ret = EXIT_FAILURE;
+ GNUNET_SCHEDULER_shutdown ();
+ return false;
+ }
}
if (GNUNET_YES ==
eval_probability (((float) refund_rate) / 100.0))
@@ -446,6 +466,9 @@ run (void *cls,
}
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
+ memset (&issue,
+ 0,
+ sizeof (issue));
RANDOMIZE (&issue.signature);
issue.start
= start;
@@ -466,18 +489,19 @@ run (void *cls,
struct TALER_PlanchetDetail pd;
struct TALER_BlindedDenominationSignature bds;
struct TALER_PlanchetMasterSecretP ps;
- struct TALER_ExchangeWithdrawValues alg_values;
struct TALER_CoinSpendPublicKeyP coin_pub;
struct TALER_AgeCommitmentHash hac;
- union TALER_DenominationBlindingKeyP bks;
+ union GNUNET_CRYPTO_BlindingSecretP bks;
+ const struct TALER_ExchangeWithdrawValues *alg_values;
RANDOMIZE (&coin_pub);
GNUNET_assert (GNUNET_OK ==
TALER_denom_priv_create (&pk,
&denom_pub,
- TALER_DENOMINATION_RSA,
+ GNUNET_CRYPTO_BSA_RSA,
1024));
- alg_values.cipher = TALER_DENOMINATION_RSA;
+ alg_values = TALER_denom_ewv_rsa_singleton ();
+ denom_pub.age_mask = issue.age_mask;
TALER_denom_pub_hash (&denom_pub,
&h_denom_pub);
make_amount (2, 0, &issue.value);
@@ -497,9 +521,8 @@ run (void *cls,
return;
}
-
TALER_planchet_blinding_secret_create (&ps,
- &alg_values,
+ TALER_denom_ewv_rsa_singleton (),
&bks);
{
@@ -512,23 +535,21 @@ run (void *cls,
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
&seed,
sizeof(seed));
-
- GNUNET_assert (GNUNET_OK ==
- TALER_age_restriction_commit (
- &mask,
- 13,
- &seed,
- &acp));
-
- TALER_age_commitment_hash (&acp.commitment, &hac);
+ TALER_age_restriction_commit (&mask,
+ 13,
+ &seed,
+ &acp);
+ TALER_age_commitment_hash (&acp.commitment,
+ &hac);
}
GNUNET_assert (GNUNET_OK ==
TALER_denom_blind (&denom_pub,
&bks,
+ NULL,
&hac,
&coin_pub,
- &alg_values,
+ alg_values,
&c_hash,
&pd.blinded_planchet));
GNUNET_assert (GNUNET_OK ==
@@ -542,7 +563,7 @@ run (void *cls,
&bds,
&bks,
&c_hash,
- &alg_values,
+ alg_values,
&denom_pub));
TALER_blinded_denom_sig_free (&bds);
TALER_denom_pub_free (&denom_pub);
diff --git a/src/benchmark/taler-bank-benchmark.c b/src/benchmark/taler-bank-benchmark.c
index 584df4896..528798424 100644
--- a/src/benchmark/taler-bank-benchmark.c
+++ b/src/benchmark/taler-bank-benchmark.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2014-2021 Taler Systems SA
+ (C) 2014-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as
@@ -38,55 +38,12 @@
#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
-};
-
-
-/**
- * What mode should the benchmark run in?
- */
-enum BenchmarkMode
-{
- /**
- * Run as client against the bank.
- */
- MODE_CLIENT = 1,
-
- /**
- * Run the bank.
- */
- MODE_BANK = 2,
-
- /**
- * Run both, for a local benchmark.
- */
- MODE_BOTH = 3,
-};
-
+#define SHARD_SIZE "1024"
/**
- * Hold information regarding which bank has the exchange account.
+ * Credentials to use for the benchmark.
*/
-static const struct TALER_EXCHANGEDB_AccountInfo *exchange_bank_account;
-
-/**
- * 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;
+static struct TALER_TESTING_Credentials cred;
/**
* Array of all the commands the benchmark is running.
@@ -94,26 +51,14 @@ static struct GNUNET_TIME_Relative duration;
static struct TALER_TESTING_Command *all_commands;
/**
- * Dummy keepalive task.
- */
-static struct GNUNET_SCHEDULER_Task *keepalive;
-
-/**
* Name of our configuration file.
*/
static char *cfg_filename;
/**
* Use the fakebank instead of LibEuFin.
- * NOTE: LibEuFin not yet supported! Set
- * to 0 once we do support it!
*/
-static int use_fakebank = 1;
-
-/**
- * Number of taler-exchange-wirewatchers to launch.
- */
-static unsigned int start_wirewatch;
+static int use_fakebank;
/**
* Verbosity level.
@@ -121,12 +66,6 @@ static unsigned int start_wirewatch;
static unsigned int verbose;
/**
- * Size of the transaction history the fakebank
- * should keep in RAM.
- */
-static unsigned long long history_size = 65536;
-
-/**
* How many reserves we want to create per client.
*/
static unsigned int howmany_reserves = 1;
@@ -137,9 +76,9 @@ static unsigned int howmany_reserves = 1;
static unsigned int howmany_clients = 1;
/**
- * How many bank worker threads do we want to create.
+ * How many wirewatch processes do we want to create.
*/
-static unsigned int howmany_threads;
+static unsigned int start_wirewatch;
/**
* Log level used during the run.
@@ -152,30 +91,15 @@ static char *loglev;
static char *logfile;
/**
- * Benchmarking mode (run as client, exchange, both) as string.
- */
-static char *mode_str;
-
-/**
- * Benchmarking mode (run as client, bank, both).
- */
-static enum BenchmarkMode mode;
-
-/**
- * Don't kill exchange/fakebank/wirewatch until
- * requested by the user explicitly.
- */
-static int linger;
-
-/**
- * Do not initialize or reset the database.
+ * Configuration.
*/
-static int incremental;
+static struct GNUNET_CONFIGURATION_Handle *cfg;
/**
- * Configuration.
+ * Section with the configuration data for the exchange
+ * bank account.
*/
-static struct GNUNET_CONFIGURATION_Handle *cfg;
+static char *exchange_bank_section;
/**
* Currency used.
@@ -237,10 +161,10 @@ print_stats (void)
total = GNUNET_strdup (
GNUNET_STRINGS_relative_time_to_string (timings[i].total_duration,
- GNUNET_YES));
+ true));
latency = GNUNET_strdup (
GNUNET_STRINGS_relative_time_to_string (timings[i].success_latency,
- GNUNET_YES));
+ true));
fprintf (stderr,
"%s-%d took %s in total with %s for latency for %u executions (%u repeats)\n",
timings[i].prefix,
@@ -270,38 +194,39 @@ run (void *cls,
(void) cls;
len = howmany_reserves + 2;
- all_commands = GNUNET_malloc_large (len
+ all_commands = GNUNET_malloc_large ((1 + len)
* sizeof (struct TALER_TESTING_Command));
GNUNET_assert (NULL != all_commands);
+ all_commands[0]
+ = TALER_TESTING_cmd_get_exchange ("get-exchange",
+ cred.cfg,
+ NULL,
+ true,
+ true);
+
GNUNET_asprintf (&total_reserve_amount,
"%s:5",
currency);
for (unsigned int j = 0; j < howmany_reserves; j++)
{
char *create_reserve_label;
- char *user_payto_uri;
-
- // FIXME: vary user accounts more...
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "benchmark",
- "USER_PAYTO_URI",
- &user_payto_uri));
+
GNUNET_asprintf (&create_reserve_label,
"createreserve-%u",
j);
- all_commands[j]
+ // TODO: vary user accounts more...
+ all_commands[1 + j]
= TALER_TESTING_cmd_admin_add_incoming_retry (
TALER_TESTING_cmd_admin_add_incoming (add_label (
create_reserve_label),
total_reserve_amount,
- exchange_bank_account->auth,
- add_label (user_payto_uri)));
+ &cred.ba_admin,
+ cred.user42_payto));
}
GNUNET_free (total_reserve_amount);
- all_commands[howmany_reserves]
+ all_commands[1 + howmany_reserves]
= TALER_TESTING_cmd_stat (timings);
- all_commands[howmany_reserves + 1]
+ all_commands[1 + howmany_reserves + 1]
= TALER_TESTING_cmd_end ();
TALER_TESTING_run2 (is,
all_commands,
@@ -318,15 +243,11 @@ launch_clients (void)
enum GNUNET_GenericReturnValue result = GNUNET_OK;
pid_t cpids[howmany_clients];
- start_time = GNUNET_TIME_absolute_get ();
if (1 == howmany_clients)
{
/* do everything in this process */
- result = TALER_TESTING_setup (&run,
- NULL,
- cfg,
- NULL,
- GNUNET_NO);
+ result = TALER_TESTING_loop (&run,
+ NULL);
if (verbose)
print_stats ();
return result;
@@ -340,11 +261,8 @@ launch_clients (void)
GNUNET_log_setup ("benchmark-worker",
NULL == loglev ? "INFO" : loglev,
logfile);
- result = TALER_TESTING_setup (&run,
- NULL,
- cfg,
- NULL,
- GNUNET_NO);
+ result = TALER_TESTING_loop (&run,
+ NULL);
if (verbose)
print_stats ();
if (GNUNET_OK != result)
@@ -394,78 +312,6 @@ again:
/**
- * Stop the fakebank.
- *
- * @param cls fakebank handle
- */
-static void
-stop_fakebank (void *cls)
-{
- struct TALER_FAKEBANK_Handle *fakebank = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Stopping fakebank\n");
- TALER_FAKEBANK_stop (fakebank);
- GNUNET_SCHEDULER_cancel (keepalive);
- keepalive = NULL;
-}
-
-
-/**
- * Dummy task that is never run.
- */
-static void
-never_task (void *cls)
-{
- (void) cls;
- GNUNET_assert (0);
-}
-
-
-/**
- * Start the fakebank.
- *
- * @param cls NULL
- */
-static void
-launch_fakebank (void *cls)
-{
- struct TALER_FAKEBANK_Handle *fakebank;
- unsigned long long pnum;
-
- (void) cls;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg,
- "bank",
- "HTTP_PORT",
- &pnum))
- {
- GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
- "bank",
- "HTTP_PORT",
- "must be valid port number");
- return;
- }
- fakebank
- = TALER_FAKEBANK_start2 ((uint16_t) pnum,
- currency,
- history_size,
- howmany_threads);
- if (NULL == fakebank)
- {
- GNUNET_break (0);
- return;
- }
- keepalive
- = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &never_task,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (&stop_fakebank,
- fakebank);
-}
-
-
-/**
* Run the benchmark in parallel in many (client) processes
* and summarize result.
*
@@ -475,278 +321,100 @@ static enum GNUNET_GenericReturnValue
parallel_benchmark (void)
{
enum GNUNET_GenericReturnValue result = GNUNET_OK;
- pid_t fakebank = -1;
- struct GNUNET_OS_Process *bankd = NULL;
struct GNUNET_OS_Process *wirewatch[GNUNET_NZL (start_wirewatch)];
memset (wirewatch,
0,
sizeof (wirewatch));
- if ( (MODE_BANK == mode) ||
- (MODE_BOTH == mode) )
+ /* start exchange wirewatch */
+ for (unsigned int w = 0; w<start_wirewatch; w++)
{
- if (use_fakebank)
- {
- unsigned long long pnum;
-
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg,
- "bank",
- "HTTP_PORT",
- &pnum))
- {
- GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
- "bank",
- "HTTP_PORT",
- "must be valid port number");
- return GNUNET_SYSERR;
- }
- /* 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;
- }
- /* wait for fakebank to be ready */
- {
- char *bank_url;
- int ret;
-
- GNUNET_asprintf (&bank_url,
- "http://localhost:%u/",
- (unsigned int) (uint16_t) pnum);
- ret = TALER_TESTING_wait_httpd_ready (bank_url);
- GNUNET_free (bank_url);
- if (0 != ret)
- {
- int wstatus;
-
- kill (fakebank,
- SIGTERM);
- if (fakebank !=
- waitpid (fakebank,
- &wstatus,
- 0))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "waitpid");
- }
- fakebank = -1;
- exit (ret);
- }
- }
- }
- else
+ wirewatch[w] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-exchange-wirewatch",
+ "taler-exchange-wirewatch",
+ "-c", cfg_filename,
+ "-a", exchange_bank_section,
+ "-S", SHARD_SIZE,
+ (NULL != loglev) ? "-L" : NULL,
+ loglev,
+ NULL);
+ if (NULL == wirewatch[w])
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "FIXME #7273: launching LibEuFin not yet supported\n");
- bankd = NULL; // FIXME #7273
- return GNUNET_SYSERR;
- }
-
- if (0 == incremental)
- {
- struct GNUNET_OS_Process *dbinit;
-
- dbinit = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-exchange-dbinit",
- "taler-exchange-dbinit",
- "-c", cfg_filename,
- "-r",
- (NULL != loglev) ? "-L" : NULL,
- loglev,
- NULL);
- if (NULL == dbinit)
- {
- if (NULL != bankd)
- {
- GNUNET_OS_process_kill (bankd,
- SIGTERM);
- GNUNET_OS_process_destroy (bankd);
- bankd = NULL;
- }
- return GNUNET_SYSERR;
- }
- GNUNET_break (GNUNET_OK ==
- GNUNET_OS_process_wait (dbinit));
- GNUNET_OS_process_destroy (dbinit);
- }
- /* start exchange wirewatch */
- for (unsigned int w = 0; w<start_wirewatch; w++)
- {
- wirewatch[w] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-exchange-wirewatch",
- "taler-exchange-wirewatch",
- "-c", cfg_filename,
- (NULL != loglev) ? "-L" : NULL,
- loglev,
- NULL);
- if (NULL == wirewatch[w])
+ "Failed to launch wirewatch, aborting benchmark\n");
+ for (unsigned int x = 0; x<w; x++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to launch wirewatch, aborting benchmark\n");
- for (unsigned int x = 0; x<w; x++)
- {
- GNUNET_break (0 ==
- GNUNET_OS_process_kill (wirewatch[x],
- SIGTERM));
- GNUNET_break (GNUNET_OK ==
- GNUNET_OS_process_wait (wirewatch[x]));
- GNUNET_OS_process_destroy (wirewatch[x]);
- wirewatch[x] = NULL;
- }
- if (-1 != fakebank)
- {
- int wstatus;
-
- kill (fakebank,
- SIGTERM);
- if (fakebank !=
- waitpid (fakebank,
- &wstatus,
- 0))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "waitpid");
- }
- fakebank = -1;
- }
- if (NULL != bankd)
- {
- GNUNET_OS_process_kill (bankd,
- SIGTERM);
- GNUNET_OS_process_destroy (bankd);
- bankd = NULL;
- }
- return GNUNET_SYSERR;
+ GNUNET_break (0 ==
+ GNUNET_OS_process_kill (wirewatch[x],
+ SIGTERM));
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_OS_process_wait (wirewatch[x]));
+ GNUNET_OS_process_destroy (wirewatch[x]);
+ wirewatch[x] = NULL;
}
+ return GNUNET_SYSERR;
}
}
-
- if ( (MODE_CLIENT == mode) ||
- (MODE_BOTH == mode) )
- result = launch_clients ();
- if ( (GNUNET_YES == linger) ||
- (MODE_BANK == mode) )
+ result = launch_clients ();
+ /* Ensure wirewatch runs to completion! */
+ if (0 != start_wirewatch)
{
- printf ("Press ENTER to stop!\n");
- if (MODE_BANK != mode)
- duration = GNUNET_TIME_absolute_get_duration (start_time);
- (void) getchar ();
- if (MODE_BANK == mode)
- duration = GNUNET_TIME_absolute_get_duration (start_time);
- }
-
- if ( (MODE_BANK == mode) ||
- (MODE_BOTH == mode) )
- {
- /* Ensure wirewatch runs to completion! */
- if (0 != start_wirewatch)
+ /* replace ONE of the wirewatchers with one that is in test-mode */
+ GNUNET_break (0 ==
+ GNUNET_OS_process_kill (wirewatch[0],
+ SIGTERM));
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_OS_process_wait (wirewatch[0]));
+ GNUNET_OS_process_destroy (wirewatch[0]);
+ wirewatch[0] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-exchange-wirewatch",
+ "taler-exchange-wirewatch",
+ "-c", cfg_filename,
+ "-a", exchange_bank_section,
+ "-S", SHARD_SIZE,
+ "-t",
+ (NULL != loglev) ? "-L" : NULL,
+ loglev,
+ NULL);
+ /* wait for it to finish! */
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_OS_process_wait (wirewatch[0]));
+ GNUNET_OS_process_destroy (wirewatch[0]);
+ wirewatch[0] = NULL;
+ /* Then stop the rest, which should basically also be finished */
+ for (unsigned int w = 1; w<start_wirewatch; w++)
{
- /* replace ONE of the wirewatchers with one that is in test-mode */
GNUNET_break (0 ==
- GNUNET_OS_process_kill (wirewatch[0],
+ GNUNET_OS_process_kill (wirewatch[w],
SIGTERM));
GNUNET_break (GNUNET_OK ==
- GNUNET_OS_process_wait (wirewatch[0]));
- GNUNET_OS_process_destroy (wirewatch[0]);
- wirewatch[0] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-exchange-wirewatch",
- "taler-exchange-wirewatch",
- "-c", cfg_filename,
- "-t",
- (NULL != loglev) ? "-L" : NULL,
- loglev,
- NULL);
- /* wait for it to finish! */
- GNUNET_break (GNUNET_OK ==
- GNUNET_OS_process_wait (wirewatch[0]));
- GNUNET_OS_process_destroy (wirewatch[0]);
- wirewatch[0] = NULL;
- /* Then stop the rest, which should basically also be finished */
- for (unsigned int w = 1; w<start_wirewatch; w++)
- {
- GNUNET_break (0 ==
- GNUNET_OS_process_kill (wirewatch[w],
- SIGTERM));
- GNUNET_break (GNUNET_OK ==
- GNUNET_OS_process_wait (wirewatch[w]));
- GNUNET_OS_process_destroy (wirewatch[w]);
- }
-
- /* But be extra sure we did finish all shards by doing one more */
- GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
- "Shard check phase\n");
- wirewatch[0] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-exchange-wirewatch",
- "taler-exchange-wirewatch",
- "-c", cfg_filename,
- "-t",
- (NULL != loglev) ? "-L" : NULL,
- loglev,
- NULL);
- /* wait for it to finish! */
- GNUNET_break (GNUNET_OK ==
- GNUNET_OS_process_wait (wirewatch[0]));
- GNUNET_OS_process_destroy (wirewatch[0]);
- wirewatch[0] = NULL;
+ GNUNET_OS_process_wait (wirewatch[w]));
+ GNUNET_OS_process_destroy (wirewatch[w]);
}
- /* Now stop the time, if this was the right mode */
- if ( (GNUNET_YES != linger) &&
- (MODE_BANK != mode) )
- duration = GNUNET_TIME_absolute_get_duration (start_time);
-
- /* stop fakebank */
- if (-1 != fakebank)
- {
- int wstatus;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Telling fakebank to shut down\n");
- kill (fakebank,
- SIGTERM);
- if (fakebank !=
- waitpid (fakebank,
- &wstatus,
- 0))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "waitpid");
- }
- else
- {
- if ( (! WIFEXITED (wstatus)) ||
- (0 != WEXITSTATUS (wstatus)) )
- {
- GNUNET_break (0);
- result = GNUNET_SYSERR;
- }
- }
- fakebank = -1;
- }
- if (NULL != bankd)
- {
- GNUNET_OS_process_kill (bankd,
- SIGTERM);
- GNUNET_OS_process_destroy (bankd);
- }
+ /* But be extra sure we did finish all shards by doing one more */
+ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+ "Shard check phase\n");
+ wirewatch[0] = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-exchange-wirewatch",
+ "taler-exchange-wirewatch",
+ "-c", cfg_filename,
+ "-a", exchange_bank_section,
+ "-S", SHARD_SIZE,
+ "-t",
+ (NULL != loglev) ? "-L" : NULL,
+ loglev,
+ NULL);
+ /* wait for it to finish! */
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_OS_process_wait (wirewatch[0]));
+ GNUNET_OS_process_destroy (wirewatch[0]);
+ wirewatch[0] = NULL;
}
+
return result;
}
@@ -766,52 +434,34 @@ main (int argc,
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_mandatory (
GNUNET_GETOPT_option_cfgfile (&cfg_filename)),
-#if FIXME_SUPPORT_LIBEUFIN
GNUNET_GETOPT_option_flag ('f',
"fakebank",
- "start a fakebank instead of the Python bank",
+ "we are using fakebank",
&use_fakebank),
-#endif
GNUNET_GETOPT_option_help ("taler-bank benchmark"),
- GNUNET_GETOPT_option_flag ('K',
- "linger",
- "linger around until key press",
- &linger),
- GNUNET_GETOPT_option_flag ('i',
- "incremental",
- "skip initializing and resetting the database",
- &incremental),
GNUNET_GETOPT_option_string ('l',
"logfile",
"LF",
"will log to file LF",
&logfile),
GNUNET_GETOPT_option_loglevel (&loglev),
- GNUNET_GETOPT_option_string ('m',
- "mode",
- "MODE",
- "run as bank, client or both",
- &mode_str),
GNUNET_GETOPT_option_uint ('p',
"worker-parallelism",
"NPROCS",
"How many client processes we should run",
&howmany_clients),
- GNUNET_GETOPT_option_uint ('P',
- "service-parallelism",
- "NTHREADS",
- "How many service threads we should create",
- &howmany_threads),
GNUNET_GETOPT_option_uint ('r',
"reserves",
"NRESERVES",
"How many reserves per client we should create",
&howmany_reserves),
- GNUNET_GETOPT_option_ulong ('s',
- "size",
- "HISTORY_SIZE",
- "Maximum history size kept in memory by the fakebank",
- &history_size),
+ GNUNET_GETOPT_option_mandatory (
+ GNUNET_GETOPT_option_string (
+ 'u',
+ "exchange-account-section",
+ "SECTION",
+ "use exchange bank account configuration from the given SECTION",
+ &exchange_bank_section)),
GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
GNUNET_GETOPT_option_verbose (&verbose),
GNUNET_GETOPT_option_uint ('w',
@@ -821,6 +471,7 @@ main (int argc,
&start_wirewatch),
GNUNET_GETOPT_OPTION_END
};
+ struct GNUNET_TIME_Relative duration;
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
@@ -833,43 +484,15 @@ main (int argc,
GNUNET_free (cfg_filename);
if (GNUNET_NO == result)
return 0;
- return BAD_CLI_ARG;
+ return EXIT_INVALIDARGUMENT;
}
+ if (NULL == exchange_bank_section)
+ exchange_bank_section = "exchange-account-1";
+ if (NULL == loglev)
+ loglev = "INFO";
GNUNET_log_setup ("taler-bank-benchmark",
- NULL == loglev ? "INFO" : loglev,
+ loglev,
logfile);
- if (history_size < 10)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "History size too small, this can hardly work\n");
- return BAD_CLI_ARG;
- }
- if (NULL == mode_str)
- mode = MODE_BOTH;
- else if (0 == strcasecmp (mode_str,
- "bank"))
- mode = MODE_BANK;
- else if (0 == strcasecmp (mode_str,
- "client"))
- mode = MODE_CLIENT;
- else if (0 == strcasecmp (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)
- cfg_filename = GNUNET_CONFIGURATION_default_filename ();
- if (NULL == cfg_filename)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Can't find default configuration file.\n");
- return EXIT_NOTCONFIGURED;
- }
cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK !=
GNUNET_CONFIGURATION_load (cfg,
@@ -877,7 +500,7 @@ main (int argc,
{
TALER_LOG_ERROR ("Could not parse configuration\n");
GNUNET_free (cfg_filename);
- return BAD_CONFIG_FILE;
+ return EXIT_NOTCONFIGURED;
}
if (GNUNET_OK !=
TALER_config_get_currency (cfg,
@@ -885,52 +508,30 @@ main (int argc,
{
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free (cfg_filename);
- return BAD_CONFIG_FILE;
- }
- if (MODE_BANK != mode)
- {
- if (howmany_clients > 10240)
- {
- TALER_LOG_ERROR ("-p option value given is too large\n");
- return BAD_CLI_ARG;
- }
- if (0 == howmany_clients)
- {
- TALER_LOG_ERROR ("-p option value must not be zero\n");
- GNUNET_free (cfg_filename);
- return BAD_CLI_ARG;
- }
+ return EXIT_NOTCONFIGURED;
}
if (GNUNET_OK !=
- TALER_EXCHANGEDB_load_accounts (cfg,
- TALER_EXCHANGEDB_ALO_AUTHDATA
- | TALER_EXCHANGEDB_ALO_CREDIT))
+ TALER_TESTING_get_credentials (
+ cfg_filename,
+ exchange_bank_section,
+ use_fakebank
+ ? TALER_TESTING_BS_FAKEBANK
+ : TALER_TESTING_BS_IBAN,
+ &cred))
{
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);
- 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;
- }
- result = parallel_benchmark ();
- TALER_EXCHANGEDB_unload_accounts ();
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (cfg_filename);
+ struct GNUNET_TIME_Absolute start_time;
- if (MODE_BANK == mode)
- {
- /* If we're the bank, we're done now. No need to print results. */
- return (GNUNET_OK == result) ? 0 : result;
+ start_time = GNUNET_TIME_absolute_get ();
+ result = parallel_benchmark ();
+ duration = GNUNET_TIME_absolute_get_duration (start_time);
}
if (GNUNET_OK == result)
@@ -958,7 +559,7 @@ main (int argc,
tps);
}
fprintf (stdout,
- "CPU time: sys %llu user %llu\n", \
+ "CPU time: sys %llu user %llu\n",
(unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000
+ usage.ru_stime.tv_usec),
(unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000
@@ -969,5 +570,7 @@ main (int argc,
GNUNET_array_grow (labels,
label_len,
0);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ GNUNET_free (cfg_filename);
return (GNUNET_OK == result) ? 0 : result;
}
diff --git a/src/benchmark/taler-benchmark-setup.sh b/src/benchmark/taler-benchmark-setup.sh
deleted file mode 100755
index 70a7654bf..000000000
--- a/src/benchmark/taler-benchmark-setup.sh
+++ /dev/null
@@ -1,655 +0,0 @@
-#!/bin/bash
-#
-# This file is part of TALER
-# Copyright (C) 2023 Taler Systems SA
-#
-# TALER is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 3, or
-# (at your option) any later version.
-#
-# TALER is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with TALER; see the file COPYING. If not, see
-# <http://www.gnu.org/licenses/>
-#
-# Author: Christian Grothoff
-#
-# This script configures and launches various GNU Taler services.
-# Which ones depend on command-line options. Use "-h" to find out.
-# Prints "<<READY>>" on a separate line once all requested services
-# are running. Close STDIN (or input 'NEWLINE') to stop all started
-# services again.
-#
-set -eu
-
-# Exit, with status code "skip" (no 'real' failure)
-function exit_skip() {
- echo " SKIP: " "$@"
- exit 77
-}
-
-# Exit, with error message (hard failure)
-function exit_fail() {
- echo " FAIL: " "$@"
- exit 1
-}
-
-# Cleanup to run whenever we exit
-function cleanup()
-{
- for n in $(jobs -p)
- do
- kill $n 2> /dev/null || true
- done
- wait
- rm -f libeufin-nexus.pid libeufin-sandbox.pid
-}
-
-# Install cleanup handler (except for kill -9)
-trap cleanup EXIT
-
-START_AUDITOR=0
-START_BACKUP=0
-START_EXCHANGE=0
-START_FAKEBANK=0
-START_AGGREGATOR=0
-START_MERCHANT=0
-START_NEXUS=0
-START_SANDBOX=0
-START_TRANSFER=0
-START_WIREWATCH=0
-USE_VALGRIND=""
-CONF_ORIG="~/.config/taler.conf"
-LOGLEVEL="DEBUG"
-DEFAULT_SLEEP="0.2"
-
-# Parse command-line options
-while getopts ':abc:efghl:mnstvw' OPTION; do
- case "$OPTION" in
- a)
- START_AUDITOR="1"
- ;;
- b)
- START_BACKUP="1"
- ;;
- c)
- CONF_ORIG="$OPTARG"
- ;;
- e)
- START_EXCHANGE="1"
- ;;
- f)
- START_FAKEBANK="1"
- ;;
- h)
- echo 'Supported options:'
- echo ' -a -- start auditor'
- echo ' -b -- start backup/sync'
- echo ' -c $CONF -- set configuration'
- echo ' -e -- start exchange'
- echo ' -f -- start fakebank'
- echo ' -h -- print this help'
- echo ' -l $LOGLEVEL -- set log level'
- echo ' -m -- start merchant'
- echo ' -n -- start nexus'
- echo ' -s -- start sandbox'
- echo ' -t -- start transfer'
- echo ' -v -- use valgrind'
- echo ' -w -- start wirewatch'
- exit 0
- ;;
- g)
- START_AGGREGATOR="1"
- ;;
- l)
- LOGLEVEL="$OPTARG"
- ;;
- m)
- START_MERCHANT="1"
- ;;
- n)
- START_NEXUS="1"
- ;;
- s)
- START_SANDBOX="1"
- ;;
- t)
- START_TRANSFER="1"
- ;;
- v)
- USE_VALGRIND="valgrind --leak-check=yes"
- DEFAULT_SLEEP="2"
- ;;
- w)
- START_WIREWATCH="1"
- ;;
- ?)
- exit_fail "Unrecognized command line option"
- ;;
- esac
-done
-
-echo "Starting with configuration file at: $CONF_ORIG"
-CONF="$CONF_ORIG.edited"
-cp "${CONF_ORIG}" "${CONF}"
-
-echo -n "Testing for jq"
-jq -h > /dev/null || exit_skip " jq required"
-echo " FOUND"
-
-if [ "1" = "$START_EXCHANGE" ]
-then
- echo -n "Testing for Taler exchange"
- taler-exchange-httpd -h > /dev/null || exit_skip " taler-exchange-httpd required"
- echo " FOUND"
-fi
-
-if [ "1" = "$START_MERCHANT" ]
-then
- echo -n "Testing for Taler merchant"
- taler-merchant-httpd -h > /dev/null || exit_skip " taler-merchant-httpd required"
- echo " FOUND"
-fi
-
-if [ "1" = "$START_BACKUP" ]
-then
- echo -n "Testing for sync-httpd"
- sync-httpd -h > /dev/null || exit_skip " sync-httpd required"
- echo " FOUND"
-fi
-
-if [ "1" = "$START_NEXUS" ]
-then
- echo -n "Testing for libeufin-cli"
- libeufin-cli --help >/dev/null </dev/null || exit_skip " MISSING"
- echo " FOUND"
-fi
-
-EXCHANGE_URL=$(taler-config -c "$CONF" -s "EXCHANGE" -o "BASE_URL")
-CURRENCY=$(taler-config -c "$CONF" -s "TALER" -o "CURRENCY")
-
-register_sandbox_account() {
- export LIBEUFIN_SANDBOX_USERNAME="$1"
- export LIBEUFIN_SANDBOX_PASSWORD="$2"
- # FIXME-MS: delete should be removed after we make 'register' idempotent!
- libeufin-cli sandbox \
- demobank \
- delete \
- --bank-account "$1" &> /dev/null || true
- libeufin-cli sandbox \
- demobank \
- register --name "$3"
- unset LIBEUFIN_SANDBOX_USERNAME
- unset LIBEUFIN_SANDBOX_PASSWORD
-}
-
-
-BANK_PORT=$(taler-config -c "$CONF" -s "BANK" -o "HTTP_PORT")
-if [ "1" = "$START_NEXUS" ]
-then
- NEXUS_PORT="$BANK_PORT"
- SANDBOX_PORT="1$BANK_PORT"
-else
- NEXUS_PORT="0"
- SANDBOX_PORT="1$BANK_PORT"
-fi
-
-if [ "1" = "$START_SANDBOX" ]
-then
- export LIBEUFIN_SANDBOX_DB_CONNECTION=$(taler-config -c "$CONF" -s "libeufin-sandbox" -o "DB_CONNECTION")
-
- # Create the default demobank.
- echo -n "Configuring sandbox "
- libeufin-sandbox config --currency "$CURRENCY" default &> libeufin-sandbox-config.log
- echo "DONE"
- echo -n "Launching sandbox "
- export LIBEUFIN_SANDBOX_ADMIN_PASSWORD="secret"
- libeufin-sandbox serve \
- --port "$SANDBOX_PORT" \
- > libeufin-sandbox-stdout.log \
- 2> libeufin-sandbox-stderr.log &
- echo $! > libeufin-sandbox.pid
- echo "DONE"
- export LIBEUFIN_SANDBOX_URL="http://localhost:$SANDBOX_PORT/"
- OK="0"
- echo -n "Waiting for Sandbox ..."
- for n in $(seq 1 100); do
- echo -n "."
- sleep "$DEFAULT_SLEEP"
- wget --timeout=1 \
- --tries=3 \
- --waitretry=0 \
- -o /dev/null \
- -O /dev/null \
- "$LIBEUFIN_SANDBOX_URL" || continue
- OK="1"
- break
- done
- if [ "1" != "$OK" ]
- then
- exit_skip "Failed to launch services (sandbox)"
- fi
- echo "OK"
- echo -n "Register Sandbox users ..."
- register_sandbox_account fortytwo x "Forty Two"
- register_sandbox_account fortythree x "Forty Three"
- register_sandbox_account exchange x "Exchange Company"
- register_sandbox_account tor x "Tor Project"
- register_sandbox_account gnunet x "GNUnet"
- register_sandbox_account tutorial x "Tutorial"
- register_sandbox_account survey x "Survey"
- echo " DONE"
-
- echo -n "Fixing up exchange's PAYTO_URI in the config ..."
- export LIBEUFIN_SANDBOX_USERNAME="exchange"
- export LIBEUFIN_SANDBOX_PASSWORD="x"
- EXCHANGE_PAYTO=$(libeufin-cli sandbox demobank info --bank-account exchange | jq --raw-output '.paytoUri')
- taler-config -c "$CONF" -s exchange-account-1 -o "PAYTO_URI" -V "$EXCHANGE_PAYTO"
- echo " OK"
-
- echo -n "Setting this exchange as the bank's default ..."
- libeufin-sandbox default-exchange "$EXCHANGE_URL" "$EXCHANGE_PAYTO"
- echo " OK"
-
- # Prepare EBICS: create Ebics host and Exchange subscriber.
- # Shortly becoming admin to setup Ebics.
- export LIBEUFIN_SANDBOX_USERNAME="admin"
- export LIBEUFIN_SANDBOX_PASSWORD="secret"
- echo -n "Create EBICS host at Sandbox.."
- # FIXME-MS: || true should be removed after we make 'create' idempotent!
- libeufin-cli sandbox \
- --sandbox-url "$LIBEUFIN_SANDBOX_URL" \
- ebicshost create --host-id talerebics &> libeufin-sandbox-ebicshost-create.log || true
- echo "OK"
- echo -n "Create exchange EBICS subscriber at Sandbox.."
- # FIXME-MS: || true should be removed after we make 'new-ebicssubscriber' idempotent!
- libeufin-cli sandbox \
- demobank new-ebicssubscriber --host-id talerebics \
- --user-id exchangeebics --partner-id talerpartner \
- --bank-account exchange &> libeufin-sandbox-ebicsscubscriber.log || true
- # that's a username _and_ a bank account name
- echo "OK"
- unset LIBEUFIN_SANDBOX_USERNAME
- unset LIBEUFIN_SANDBOX_PASSWORD
-fi
-
-if [ "1" = "$START_NEXUS" ]
-then
- echo "Setting up Nexus ..."
-
- # Prepare Nexus, which is the side actually talking
- # to the exchange.
- export LIBEUFIN_NEXUS_DB_CONNECTION=$(taler-config -c "$CONF" -s "libeufin-nexus" -o "DB_CONNECTION")
-
- # For convenience, username and password are
- # identical to those used at the Sandbox.
- echo -n "Create exchange Nexus user ..."
- libeufin-nexus superuser exchange --password x
- echo "OK"
- libeufin-nexus serve --port "$NEXUS_PORT" \
- 2> libeufin-nexus-stderr.log \
- > libeufin-nexus-stdout.log &
- echo $! > libeufin-nexus.pid
- export LIBEUFIN_NEXUS_URL="http://localhost:$NEXUS_PORT"
- echo -n "Waiting for Nexus ..."
- OK="0"
- for n in $(seq 1 100); do
- echo -n "."
- sleep "$DEFAULT_SLEEP"
- wget --timeout=1 \
- --tries=3 \
- --waitretry=0 \
- -o /dev/null \
- -O /dev/null \
- "$LIBEUFIN_NEXUS_URL" || continue
- OK="1"
- break
- done
- if [ "1" != "$OK" ]
- then
- exit_skip "Failed to launch services (bank)"
- fi
- echo " OK"
-
- export LIBEUFIN_NEXUS_USERNAME=exchange
- export LIBEUFIN_NEXUS_PASSWORD=x
- echo -n "Creating a EBICS connection at Nexus ..."
- libeufin-cli connections new-ebics-connection \
- --ebics-url "http://localhost:$SANDBOX_PORT/ebicsweb" \
- --host-id talerebics \
- --partner-id talerpartner \
- --ebics-user-id exchangeebics \
- talerconn
- echo "OK"
-
- echo -n "Setup EBICS keying ..."
- libeufin-cli connections connect talerconn > /dev/null
- echo "OK"
- echo -n "Download bank account name from Sandbox ..."
- libeufin-cli connections download-bank-accounts talerconn
- echo "OK"
- echo -n "Importing bank account info into Nexus ..."
- libeufin-cli connections import-bank-account \
- --offered-account-id exchange \
- --nexus-bank-account-id exchange-nexus \
- talerconn
- echo "OK"
- echo -n "Setup payments submission task..."
- # Tries every second.
- libeufin-cli accounts task-schedule \
- --task-type submit \
- --task-name exchange-payments \
- --task-cronspec "* * *" \
- exchange-nexus
- echo "OK"
- # Tries every second. Ask C52
- echo -n "Setup history fetch task..."
- libeufin-cli accounts task-schedule \
- --task-type fetch \
- --task-name exchange-history \
- --task-cronspec "* * *" \
- --task-param-level report \
- --task-param-range-type latest \
- exchange-nexus
- echo "OK"
- # create Taler facade.
- echo -n "Create the Taler facade at Nexus..."
- libeufin-cli facades \
- new-taler-wire-gateway-facade \
- --currency TESTKUDOS --facade-name test-facade \
- talerconn exchange-nexus
- echo "OK"
- # Facade schema: http://localhost:$NEXUS_PORT/facades/test-facade/taler-wire-gateway/
- # FIXME: set the above URL automatically in the configuration?
-fi
-
-if [ "1" = "$START_FAKEBANK" ]
-then
- echo "Setting up fakebank ..."
- $USE_VALGRIND taler-fakebank-run -c "$CONF" -L "$LOGLEVEL" 2> taler-fakebank-run.log &
-fi
-
-
-if [ "1" = "$START_EXCHANGE" ]
-then
- echo -n "Starting exchange ..."
- EXCHANGE_PORT=$(taler-config -c "$CONF" -s EXCHANGE -o PORT)
- EXCHANGE_URL="http://localhost:${EXCHANGE_PORT}/"
- MASTER_PRIV_FILE=$(taler-config -f -c "${CONF}" -s "EXCHANGE-OFFLINE" -o "MASTER_PRIV_FILE")
- MASTER_PRIV_DIR=$(dirname "$MASTER_PRIV_FILE")
- mkdir -p "${MASTER_PRIV_DIR}"
- gnunet-ecc -g1 "$MASTER_PRIV_FILE" > /dev/null 2> /dev/null
- MASTER_PUB=$(gnunet-ecc -p "${MASTER_PRIV_FILE}")
- MPUB=$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)
- if [ "$MPUB" != "$MASTER_PUB" ]
- then
- echo -n " patching master_pub ($MASTER_PUB)..."
- taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY -V "$MASTER_PUB"
- fi
- taler-exchange-dbinit -c "$CONF"
- $USE_VALGRIND taler-exchange-secmod-eddsa -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-eddsa.log &
- $USE_VALGRIND taler-exchange-secmod-rsa -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-rsa.log &
- $USE_VALGRIND taler-exchange-secmod-cs -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-cs.log &
- $USE_VALGRIND taler-exchange-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-httpd.log &
- EXCHANGE_HTTPD_PID=$!
- echo " DONE"
-fi
-
-if [ "1" = "$START_WIREWATCH" ]
-then
- echo -n "Starting wirewatch ..."
- $USE_VALGRIND taler-exchange-wirewatch -c "$CONF" 2> taler-exchange-wirewatch.log &
- WIREWATCH_PID=$!
- echo " DONE"
-fi
-
-if [ "1" = "$START_AGGREGATOR" ]
-then
- echo -n "Starting aggregator ..."
- $USE_VALGRIND taler-exchange-aggregator -c "$CONF" 2> taler-exchange-aggregator.log &
- AGGREGATOR_PID=$!
- echo " DONE"
-fi
-
-if [ "1" = "$START_TRANSFER" ]
-then
- echo -n "Starting transfer ..."
- $USE_VALGRIND taler-exchange-transfer -c "$CONF" 2> taler-exchange-transfer.log &
- TRANSFER_PID=$!
- echo " DONE"
-fi
-
-if [ "1" = "$START_MERCHANT" ]
-then
- echo -n "Starting merchant ..."
- MEPUB=$(taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY)
- MXPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)}
- if [ "$MEPUB" != "$MXPUB" ]
- then
- echo -n " patching master_pub ($MXPUB)..."
- taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY -V "$MXPUB"
- fi
- MERCHANT_PORT=$(taler-config -c "$CONF" -s MERCHANT -o PORT)
- MERCHANT_URL="http://localhost:${MERCHANT_PORT}/"
- taler-merchant-dbinit -c "$CONF"
- $USE_VALGRIND taler-merchant-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-httpd.log &
- MERCHANT_HTTPD_PID=$!
- $USE_VALGRIND taler-merchant-webhook -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-webhook.log &
- MERCHANT_WEBHOOK_PID=$!
- echo " DONE"
-fi
-
-if [ "1" = "$START_BACKUP" ]
-then
- echo -n "Starting sync ..."
- SYNC_PORT=$(taler-config -c "$CONF" -s SYNC -o PORT)
- SYNC_URL="http://localhost:${SYNC_PORT}/"
- sync-dbinit -c "$CONF"
- $USE_VALGRIND sync-httpd -c "$CONF" -L "$LOGLEVEL" 2> sync-httpd.log &
- echo " DONE"
-fi
-
-
-if [ "1" = "$START_AUDITOR" ]
-then
- echo -n "Starting auditor ..."
- AUDITOR_URL="http://localhost:8083/"
- AUDITOR_PRIV_FILE=$(taler-config -f -c "$CONF" -s AUDITOR -o AUDITOR_PRIV_FILE)
- AUDITOR_PRIV_DIR=$(dirname "$AUDITOR_PRIV_FILE")
- mkdir -p "$AUDITOR_PRIV_DIR"
- gnunet-ecc -g1 "$AUDITOR_PRIV_FILE" > /dev/null 2> /dev/null
- AUDITOR_PUB=$(gnunet-ecc -p "${AUDITOR_PRIV_FILE}")
- MAPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)}
- taler-auditor-dbinit -c "$CONF"
- taler-auditor-exchange -c "$CONF" -m "$MAPUB" -u "$EXCHANGE_URL"
- $USE_VALGRIND taler-auditor-httpd -L "$LOGLEVEL" -c "$CONF" 2> taler-auditor-httpd.log &
- echo " DONE"
-fi
-
-if [[ "1" = "$START_NEXUS" || "1" = "$START_FAKEBANK" ]]
-then
- echo -n "Waiting for the bank"
- # Wait for bank to be available (usually the slowest)
- OK="0"
- for n in $(seq 1 300)
- do
- echo -n "."
- sleep "$DEFAULT_SLEEP"
- # bank
- wget --tries=1 \
- --waitretry=0 \
- --timeout=1 \
- --user admin \
- --password secret \
- "http://localhost:8082/" \
- -o /dev/null \
- -O /dev/null >/dev/null || continue
- OK="1"
- break
- done
- if [ "1" != "$OK" ]
- then
- exit_skip "Failed to launch services (bank)"
- fi
- echo " OK"
-fi
-
-echo -n "Waiting for Taler services ..."
-# Wait for all other taler services to be available
-for n in $(seq 1 20)
-do
- echo -n "."
- sleep "$DEFAULT_SLEEP"
- OK="0"
- if [ "1" = "$START_EXCHANGE" ]
- then
- wget \
- --tries=1 \
- --timeout=1 \
- "http://localhost:8081/config" \
- -o /dev/null \
- -O /dev/null >/dev/null || continue
- fi
- if [ "1" = "$START_MERCHANT" ]
- then
- wget \
- --tries=1 \
- --timeout=1 \
- "${MERCHANT_URL}config" \
- -o /dev/null \
- -O /dev/null >/dev/null || continue
- fi
- if [ "1" = "$START_BACKUP" ]
- then
- wget \
- --tries=1 \
- --timeout=1 \
- "${SYNC_URL}config" \
- -o /dev/null \
- -O /dev/null >/dev/null || continue
- fi
- if [ "1" = "$START_AUDITOR" ]
- then
- wget \
- --tries=1 \
- --timeout=1 \
- "${AUDITOR_URL}config" \
- -o /dev/null \
- -O /dev/null >/dev/null || continue
- fi
- OK="1"
- break
-done
-if [ 1 != "$OK" ]
-then
- exit_skip "Failed to launch (some) Taler services"
-fi
-echo " OK"
-
-if [ "1" = "$START_EXCHANGE" ]
-then
- echo -n "Wait for exchange /management/keys to be ready "
- OK="0"
- LAST_RESPONSE=$(mktemp tmp-last-response.XXXXXXXX)
- for n in $(seq 1 50)
- do
- echo -n "."
- sleep "$DEFAULT_SLEEP"
- # exchange
- wget \
- --tries=3 \
- --waitretry=0 \
- --timeout=1 \
- "http://localhost:8081/management/keys"\
- -o /dev/null \
- -O "$LAST_RESPONSE" \
- >/dev/null || continue
- OK="1"
- break;
- done
- if [ "1" != "$OK" ]
- then
- cat "$LAST_RESPONSE"
- exit_skip "Failed to setup exchange keys, check secmod logs"
- fi
- rm "$LAST_RESPONSE"
- echo " OK"
-
- echo -n "Setting up exchange keys ..."
- taler-exchange-offline -c "$CONF" \
- download \
- sign \
- wire-fee now iban "$CURRENCY:0.01" "$CURRENCY:0.01" \
- global-fee now "$CURRENCY:0.01" "$CURRENCY:0.01" "$CURRENCY:0.01" 1h 1year 5 \
- upload &> taler-exchange-offline.log
- echo "OK"
- for ASEC in $(taler-config -c "$CONF" -S | grep -i "exchange-account-")
- do
- ENABLED=$(taler-config -c "$CONF" -s "$ASEC" -o "ENABLE_CREDIT")
- if [ "YES" = "$ENABLED" ]
- then
- echo -n "Configuring bank account $ASEC ..."
- EXCHANGE_PAYTO_URI=$(taler-config -c "$CONF" -s "$ASEC" -o "PAYTO_URI")
- taler-exchange-offline -c "$CONF" \
- enable-account "$EXCHANGE_PAYTO_URI" \
- upload &> "taler-exchange-offline-account-$ASEC.log"
- echo " OK"
- fi
- done
- if [ "1" = "$START_AUDITOR" ]
- then
- echo -n "Enabling auditor ..."
- taler-exchange-offline -c "$CONF" \
- enable-auditor $AUDITOR_PUB $AUDITOR_URL "$CURRENCY Auditor" \
- upload &> taler-exchange-offline-auditor.log
- echo "OK"
- fi
-
- echo -n "Checking /keys "
- OK="0"
- LAST_RESPONSE=$(mktemp tmp-last-response.XXXXXXXX)
- for n in $(seq 1 10)
- do
- echo -n "."
- sleep "$DEFAULT_SLEEP"
- wget \
- --tries=1 \
- --timeout=1 \
- "http://localhost:8081/keys" \
- -o /dev/null \
- -O "$LAST_RESPONSE" \
- >/dev/null || continue
- OK="1"
- break
- done
- if [ "1" != "$OK" ]
- then
- cat "$LAST_RESPONSE"
- exit_skip " Failed to setup keys"
- fi
- rm "$LAST_RESPONSE"
- echo " OK"
-fi
-
-if [ "1" = "$START_AUDITOR" ]
-then
- echo -n "Setting up auditor signatures ..."
- timeout 15 taler-auditor-offline -c "$CONF" \
- download \
- sign \
- upload &> taler-auditor-offline.log
- echo " OK"
-fi
-
-# Signal caller that we are ready.
-echo "<<READY>>"
-
-# Wait until caller stops us.
-read
-
-exit 0
diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c
index e29e117de..75424a358 100644
--- a/src/benchmark/taler-exchange-benchmark.c
+++ b/src/benchmark/taler-exchange-benchmark.c
@@ -28,25 +28,7 @@
#include <microhttpd.h>
#include <sys/resource.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_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
@@ -55,56 +37,11 @@ enum BenchmarkError
*/
#define UNITY_SIZE 6
-#define FIRST_INSTRUCTION -1
-
-
-/**
- * What mode should the benchmark run in?
- */
-enum BenchmarkMode
-{
- /**
- * 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;
-
-/**
- * Configuration of our exchange.
- */
-static struct TALER_TESTING_ExchangeConfiguration ec;
-
-/**
- * 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.
+ * Credentials to use for the benchmark.
*/
-static struct GNUNET_TIME_Relative duration;
+static struct TALER_TESTING_Credentials cred;
/**
* Array of all the commands the benchmark is running.
@@ -117,16 +54,6 @@ static struct TALER_TESTING_Command *all_commands;
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.
*/
static unsigned int howmany_coins = 1;
@@ -147,11 +74,6 @@ 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;
@@ -162,16 +84,6 @@ static char *loglev;
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.
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -182,19 +94,20 @@ static struct GNUNET_CONFIGURATION_Handle *cfg;
static int reserves_first;
/**
- * Currency used.
+ * Are we running against 'fakebank'?
*/
-static char *currency;
+static int use_fakebank;
/**
- * Remote host that runs the exchange.
+ * Section with the configuration data for the exchange
+ * bank account.
*/
-static char *remote_host;
+static char *exchange_bank_section;
/**
- * Remote benchmarking directory.
+ * Currency used.
*/
-static char *remote_dir;
+static char *currency;
/**
* Array of command labels.
@@ -212,12 +125,6 @@ static unsigned int label_len;
static unsigned int label_off;
/**
- * Don't kill exchange/fakebank/wirewatch until
- * requested by the user explicitly.
- */
-static int linger;
-
-/**
* Performance counters.
*/
static struct TALER_TESTING_Timer timings[] = {
@@ -256,14 +163,15 @@ cmd_transfer_to_exchange (const char *label,
return TALER_TESTING_cmd_admin_add_incoming_retry (
TALER_TESTING_cmd_admin_add_incoming (label,
amount,
- exchange_bank_account->auth,
- user_payto_uri));
+ &cred.ba_admin,
+ cred.user42_payto));
}
/**
* Throw a weighted coin with @a probability.
*
+ * @param probability weight of the coin flip
* @return #GNUNET_OK with @a probability,
* #GNUNET_NO with 1 - @a probability
*/
@@ -298,11 +206,20 @@ run (void *cls,
char *amount_1;
(void) cls;
- all_commands = GNUNET_new_array (howmany_reserves * (1 /* Withdraw block */
- + howmany_coins) /* All units */
- + 1 /* stat CMD */
- + 1 /* End CMD */,
- struct TALER_TESTING_Command);
+ all_commands = GNUNET_malloc_large (
+ (1 /* exchange CMD */
+ + howmany_reserves
+ * (1 /* Withdraw block */
+ + howmany_coins) /* All units */
+ + 1 /* stat CMD */
+ + 1 /* End CMD */) * sizeof (struct TALER_TESTING_Command));
+ GNUNET_assert (NULL != all_commands);
+ all_commands[0]
+ = TALER_TESTING_cmd_get_exchange ("get-exchange",
+ cred.cfg,
+ NULL,
+ true,
+ true);
GNUNET_asprintf (&amount_5, "%s:5", currency);
GNUNET_asprintf (&amount_4, "%s:4", currency);
GNUNET_asprintf (&amount_1, "%s:1", currency);
@@ -339,9 +256,9 @@ run (void *cls,
GNUNET_asprintf (&batch_label,
"batch-start-%u",
j);
- all_commands[reserves_first
- ? j
- : j * (howmany_coins + 1)]
+ all_commands[1 + (reserves_first
+ ? j
+ : j * (howmany_coins + 1))]
= TALER_TESTING_cmd_batch (add_label (batch_label),
make_reserve);
}
@@ -360,25 +277,25 @@ run (void *cls,
wl = add_label (withdraw_label);
GNUNET_asprintf (&order_enc,
"{\"nonce\": %llu}",
- ((unsigned long long) i) + (howmany_coins
- * (unsigned long long) j));
+ ((unsigned long long) i)
+ + (howmany_coins * (unsigned long long) j));
unit[0] =
- TALER_TESTING_cmd_withdraw_with_retry
- (TALER_TESTING_cmd_withdraw_amount (wl,
- create_reserve_label,
- amount_5,
- 0, /* age restriction off */
- MHD_HTTP_OK));
+ TALER_TESTING_cmd_withdraw_with_retry (
+ TALER_TESTING_cmd_withdraw_amount (wl,
+ create_reserve_label,
+ amount_5,
+ 0, /* age restriction off */
+ MHD_HTTP_OK));
unit[1] =
- TALER_TESTING_cmd_deposit_with_retry
- (TALER_TESTING_cmd_deposit ("deposit",
- wl,
- 0, /* Index of the one withdrawn coin in the traits. */
- user_payto_uri,
- add_label (order_enc),
- GNUNET_TIME_UNIT_ZERO,
- amount_1,
- MHD_HTTP_OK));
+ TALER_TESTING_cmd_deposit_with_retry (
+ TALER_TESTING_cmd_deposit ("deposit",
+ wl,
+ 0, /* Index of the one withdrawn coin in the traits. */
+ cred.user43_payto,
+ add_label (order_enc),
+ GNUNET_TIME_UNIT_ZERO,
+ amount_1,
+ MHD_HTTP_OK));
if (eval_probability (refresh_rate / 100.0))
{
char *melt_label;
@@ -397,21 +314,21 @@ run (void *cls,
j);
rl = add_label (reveal_label);
unit[2] =
- TALER_TESTING_cmd_melt_with_retry
- (TALER_TESTING_cmd_melt (ml,
- wl,
- MHD_HTTP_OK,
- NULL));
+ TALER_TESTING_cmd_melt_with_retry (
+ TALER_TESTING_cmd_melt (ml,
+ wl,
+ MHD_HTTP_OK,
+ NULL));
unit[3] =
- TALER_TESTING_cmd_refresh_reveal_with_retry
- (TALER_TESTING_cmd_refresh_reveal (rl,
- ml,
- MHD_HTTP_OK));
+ TALER_TESTING_cmd_refresh_reveal_with_retry (
+ TALER_TESTING_cmd_refresh_reveal (rl,
+ ml,
+ MHD_HTTP_OK));
unit[4] =
- TALER_TESTING_cmd_refresh_link_with_retry
- (TALER_TESTING_cmd_refresh_link ("link",
- rl,
- MHD_HTTP_OK));
+ TALER_TESTING_cmd_refresh_link_with_retry (
+ TALER_TESTING_cmd_refresh_link ("link",
+ rl,
+ MHD_HTTP_OK));
unit[5] = TALER_TESTING_cmd_end ();
}
else
@@ -421,16 +338,16 @@ run (void *cls,
"unit-%u-%u",
i,
j);
- all_commands[reserves_first
- ? howmany_reserves + j * howmany_coins + i
- : j * (howmany_coins + 1) + (1 + i)]
+ all_commands[1 + (reserves_first
+ ? howmany_reserves + j * howmany_coins + i
+ : j * (howmany_coins + 1) + (1 + i))]
= TALER_TESTING_cmd_batch (add_label (unit_label),
unit);
}
}
- all_commands[howmany_reserves * (1 + howmany_coins)]
+ all_commands[1 + howmany_reserves * (1 + howmany_coins)]
= TALER_TESTING_cmd_stat (timings);
- all_commands[howmany_reserves * (1 + howmany_coins) + 1]
+ all_commands[1 + howmany_reserves * (1 + howmany_coins) + 1]
= TALER_TESTING_cmd_end ();
TALER_TESTING_run2 (is,
all_commands,
@@ -439,7 +356,6 @@ run (void *cls,
GNUNET_free (amount_4);
GNUNET_free (amount_5);
GNUNET_free (withdraw_fee_str);
- result = GNUNET_OK;
}
@@ -456,10 +372,10 @@ print_stats (void)
total = GNUNET_strdup (
GNUNET_STRINGS_relative_time_to_string (timings[i].total_duration,
- GNUNET_YES));
+ true));
latency = GNUNET_strdup (
GNUNET_STRINGS_relative_time_to_string (timings[i].success_latency,
- GNUNET_YES));
+ true));
fprintf (stderr,
"%s-%d took %s in total with %s for latency for %u executions (%u repeats)\n",
timings[i].prefix,
@@ -475,45 +391,6 @@ print_stats (void)
/**
- * Stop the fakebank.
- *
- * @param cls fakebank handle
- */
-static void
-stop_fakebank (void *cls)
-{
- struct TALER_FAKEBANK_Handle *fakebank = cls;
-
- TALER_FAKEBANK_stop (fakebank);
-}
-
-
-/**
- * Start the fakebank.
- *
- * @param cls NULL
- */
-static void
-launch_fakebank (void *cls)
-{
- struct TALER_FAKEBANK_Handle *fakebank;
-
- (void) cls;
- fakebank
- = TALER_TESTING_run_fakebank (
- exchange_bank_account->auth->wire_gateway_url,
- currency);
- if (NULL == fakebank)
- {
- GNUNET_break (0);
- return;
- }
- GNUNET_SCHEDULER_add_shutdown (&stop_fakebank,
- fakebank);
-}
-
-
-/**
* Run the benchmark in parallel in many (client) processes
* and summarize result.
*
@@ -529,358 +406,51 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
{
enum GNUNET_GenericReturnValue result = GNUNET_OK;
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;
- struct GNUNET_OS_Process *exchange_slave = NULL;
- struct GNUNET_DISK_PipeHandle *exchange_slave_pipe;
- if ( (MODE_CLIENT == mode) ||
- (MODE_BOTH == mode) )
+ if (1 == howmany_clients)
+ {
+ result = TALER_TESTING_loop (main_cb,
+ main_cb_cls);
+ print_stats ();
+ }
+ else
{
- if (use_fakebank)
+ for (unsigned int i = 0; i<howmany_clients; i++)
{
- /* start fakebank */
- fakebank = fork ();
- if (0 == fakebank)
+ if (0 == (cpids[i] = fork ()))
{
- GNUNET_log_setup ("benchmark-fakebank",
- NULL == loglev ? "INFO" : loglev,
+ /* I am the child, do the work! */
+ GNUNET_log_setup ("benchmark-worker",
+ loglev,
logfile);
- GNUNET_SCHEDULER_run (&launch_fakebank,
- NULL);
- exit (0);
+ result = TALER_TESTING_loop (main_cb,
+ main_cb_cls);
+ print_stats ();
+ if (GNUNET_OK != result)
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failure in child process %u test suite!\n",
+ i);
+ if (GNUNET_OK == result)
+ exit (0);
+ else
+ exit (1);
}
- if (-1 == fakebank)
+ if (-1 == cpids[i])
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
"fork");
- return GNUNET_SYSERR;
- }
- }
- else
- {
- /* start bank */
- if (GNUNET_OK !=
- TALER_TESTING_prepare_bank (cfg_filename,
- GNUNET_NO,
- "exchange-account-test",
- &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) )
- {
- /* start exchange */
- exchanged = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-exchange-httpd",
- "taler-exchange-httpd",
- "-c", config_file,
- "-C",
- NULL);
- if ( (NULL == exchanged) &&
- (MODE_BOTH == mode) )
- {
- 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 */
- auditord = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-auditor-httpd",
- "taler-auditor-httpd",
- "-c", config_file,
- NULL);
- if (NULL == auditord)
- {
- GNUNET_OS_process_kill (exchanged,
- SIGTERM);
- if (MODE_BOTH == mode)
- {
- 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;
- }
- /* start exchange wirewatch */
- wirewatch = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
- NULL, NULL, NULL,
- "taler-exchange-wirewatch",
- "taler-exchange-wirewatch",
- "-c", config_file,
- NULL);
- if (NULL == wirewatch)
- {
- GNUNET_OS_process_kill (auditord,
- SIGTERM);
- GNUNET_OS_process_kill (exchanged,
- SIGTERM);
- if (MODE_BOTH == mode)
- {
- 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;
- }
- }
-
- if (MODE_CLIENT == mode)
- {
- char *remote_cmd;
-
- GNUNET_asprintf (&remote_cmd,
- ("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);
- }
-
- /* We always wait for the exchange, no matter if it's running locally or
- remotely */
- if (0 != TALER_TESTING_wait_exchange_ready (ec.exchange_url))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to detect running exchange at `%s'\n",
- ec.exchange_url);
- GNUNET_OS_process_kill (exchanged,
- SIGTERM);
- if ( (MODE_BOTH == mode) || (MODE_CLIENT == mode))
- {
- if (-1 != fakebank)
- {
- kill (fakebank,
- SIGTERM);
- waitpid (fakebank,
- &wstatus,
- 0);
- }
- if (NULL != bankd)
- {
- GNUNET_OS_process_kill (bankd,
- SIGTERM);
- GNUNET_OS_process_destroy (bankd);
+ howmany_clients = i;
+ result = GNUNET_SYSERR;
+ break;
}
+ /* fork() success, continue starting more processes! */
}
- GNUNET_OS_process_wait (exchanged);
- GNUNET_OS_process_destroy (exchanged);
- if (NULL != wirewatch)
- {
- GNUNET_OS_process_kill (wirewatch,
- SIGTERM);
- GNUNET_OS_process_wait (wirewatch);
- GNUNET_OS_process_destroy (wirewatch);
- }
- if (NULL != auditord)
- {
- GNUNET_OS_process_kill (auditord,
- SIGTERM);
- GNUNET_OS_process_wait (auditord);
- GNUNET_OS_process_destroy (auditord);
- }
- return 77;
- }
- if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
- {
- if (-1 != fakebank)
- sleep (1); /* make sure fakebank process is ready before continuing */
-
- start_time = GNUNET_TIME_absolute_get ();
- result = GNUNET_OK;
-
- if (1 == howmany_clients)
- {
- result = TALER_TESTING_setup (main_cb,
- main_cb_cls,
- cfg,
- exchanged,
- GNUNET_YES);
- print_stats ();
- }
- else
+ /* collect all children */
+ for (unsigned int i = 0; i<howmany_clients; i++)
{
- 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",
- NULL == loglev ? "INFO" : loglev,
- logfile);
-
- result = TALER_TESTING_setup (main_cb,
- main_cb_cls,
- cfg,
- exchanged,
- GNUNET_YES);
- print_stats ();
- if (GNUNET_OK != result)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failure in child process test suite!\n");
- if (GNUNET_OK == result)
- exit (0);
- 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 */
- for (unsigned int i = 0; i<howmany_clients; i++)
- {
- waitpid (cpids[i],
- &wstatus,
- 0);
- if ( (! WIFEXITED (wstatus)) ||
- (0 != WEXITSTATUS (wstatus)) )
- {
- GNUNET_break (0);
- result = GNUNET_SYSERR;
- }
- }
- }
- }
-
- /* 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");
- (void) getchar ();
- }
-
- if (MODE_CLIENT == mode)
- {
- char c = 'q';
-
- GNUNET_assert (NULL != exchange_slave);
+ int wstatus;
- /* 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);
- }
-
- if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
- {
- GNUNET_assert (NULL != wirewatch);
- GNUNET_assert (NULL != exchanged);
- GNUNET_assert (NULL != auditord);
- /* stop wirewatch */
- GNUNET_break (0 ==
- GNUNET_OS_process_kill (wirewatch,
- SIGTERM));
- GNUNET_break (GNUNET_OK ==
- GNUNET_OS_process_wait (wirewatch));
- GNUNET_OS_process_destroy (wirewatch);
- /* stop auditor */
- GNUNET_break (0 ==
- GNUNET_OS_process_kill (auditord,
- SIGTERM));
- GNUNET_break (GNUNET_OK ==
- GNUNET_OS_process_wait (auditord));
- GNUNET_OS_process_destroy (auditord);
- /* stop exchange */
- GNUNET_break (0 ==
- GNUNET_OS_process_kill (exchanged,
- SIGTERM));
- GNUNET_break (GNUNET_OK ==
- GNUNET_OS_process_wait (exchanged));
- GNUNET_OS_process_destroy (exchanged);
- }
-
- if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
- {
- /* stop fakebank */
- if (-1 != fakebank)
- {
- kill (fakebank,
- SIGTERM);
- waitpid (fakebank,
+ waitpid (cpids[i],
&wstatus,
0);
if ( (! WIFEXITED (wstatus)) ||
@@ -890,12 +460,6 @@ 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;
}
@@ -913,55 +477,65 @@ main (int argc,
char *const *argv)
{
struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_mandatory
- (GNUNET_GETOPT_option_cfgfile (&cfg_filename)),
- GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
- GNUNET_GETOPT_option_help ("Exchange benchmark"),
- GNUNET_GETOPT_option_loglevel (&loglev),
- GNUNET_GETOPT_option_uint ('n',
- "coins-number",
- "CN",
- "How many coins we should instantiate per reserve",
- &howmany_coins),
- GNUNET_GETOPT_option_uint ('p',
- "parallelism",
- "NPROCS",
- "How many client processes we should run",
- &howmany_clients),
- GNUNET_GETOPT_option_uint ('r',
- "reserves",
- "NRESERVES",
- "How many reserves per client we should create",
- &howmany_reserves),
- GNUNET_GETOPT_option_uint ('R',
- "refresh-rate",
- "RATE",
- "Probability of refresh per coin (0-100)",
- &refresh_rate),
- GNUNET_GETOPT_option_string ('m',
- "mode",
- "MODE",
- "run as exchange, clients or both",
- &mode_str),
- GNUNET_GETOPT_option_string ('l',
- "logfile",
- "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 ('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_mandatory (
+ GNUNET_GETOPT_option_cfgfile (
+ &cfg_filename)),
+ GNUNET_GETOPT_option_version (
+ PACKAGE_VERSION " " VCS_VERSION),
+ GNUNET_GETOPT_option_flag (
+ '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_help (
+ "Exchange benchmark"),
+ GNUNET_GETOPT_option_string (
+ 'l',
+ "logfile",
+ "LF",
+ "will log to file LF",
+ &logfile),
+ GNUNET_GETOPT_option_loglevel (
+ &loglev),
+ GNUNET_GETOPT_option_uint (
+ 'n',
+ "coins-number",
+ "CN",
+ "How many coins we should instantiate per reserve",
+ &howmany_coins),
+ GNUNET_GETOPT_option_uint (
+ 'p',
+ "parallelism",
+ "NPROCS",
+ "How many client processes we should run",
+ &howmany_clients),
+ GNUNET_GETOPT_option_uint (
+ 'r',
+ "reserves",
+ "NRESERVES",
+ "How many reserves per client we should create",
+ &howmany_reserves),
+ GNUNET_GETOPT_option_uint (
+ 'R',
+ "refresh-rate",
+ "RATE",
+ "Probability of refresh per coin (0-100)",
+ &refresh_rate),
+ GNUNET_GETOPT_option_string (
+ 'u',
+ "exchange-account-section",
+ "SECTION",
+ "use exchange bank account configuration from the given SECTION",
+ &exchange_bank_section),
GNUNET_GETOPT_OPTION_END
};
+ enum GNUNET_GenericReturnValue result;
+ struct GNUNET_TIME_Relative duration;
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
@@ -974,29 +548,15 @@ main (int argc,
GNUNET_free (cfg_filename);
if (GNUNET_NO == result)
return 0;
- return BAD_CLI_ARG;
+ return EXIT_INVALIDARGUMENT;
}
+ if (NULL == exchange_bank_section)
+ exchange_bank_section = "exchange-account-1";
+ if (NULL == loglev)
+ loglev = "INFO";
GNUNET_log_setup ("taler-exchange-benchmark",
- NULL == loglev ? "INFO" : loglev,
+ loglev,
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)
cfg_filename = GNUNET_CONFIGURATION_default_filename ();
if (NULL == cfg_filename)
@@ -1012,7 +572,7 @@ main (int argc,
{
TALER_LOG_ERROR ("Could not parse configuration\n");
GNUNET_free (cfg_filename);
- return BAD_CONFIG_FILE;
+ return EXIT_NOTCONFIGURED;
}
if (GNUNET_OK !=
TALER_config_get_currency (cfg,
@@ -1020,127 +580,45 @@ main (int argc,
{
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free (cfg_filename);
- return BAD_CONFIG_FILE;
+ return EXIT_NOTCONFIGURED;
}
if (howmany_clients > 10240)
{
TALER_LOG_ERROR ("-p option value given is too large\n");
- return BAD_CLI_ARG;
+ return EXIT_INVALIDARGUMENT;
}
if (0 == howmany_clients)
{
TALER_LOG_ERROR ("-p option value must not be zero\n");
GNUNET_free (cfg_filename);
- return BAD_CLI_ARG;
- }
- 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;
+ return EXIT_INVALIDARGUMENT;
}
if (GNUNET_OK !=
- TALER_EXCHANGEDB_load_accounts (cfg,
- TALER_EXCHANGEDB_ALO_AUTHDATA
- | TALER_EXCHANGEDB_ALO_CREDIT))
+ TALER_TESTING_get_credentials (
+ cfg_filename,
+ exchange_bank_section,
+ use_fakebank
+ ? TALER_TESTING_BS_FAKEBANK
+ : TALER_TESTING_BS_IBAN,
+ &cred))
{
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);
- 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 ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
- {
- /* If we use the fakebank, we MUST reset the database as the fakebank
- will have forgotten everything... */
- if (GNUNET_OK !=
- TALER_TESTING_prepare_exchange (cfg_filename,
- (GNUNET_YES == use_fakebank)
- ? GNUNET_YES
- : GNUNET_NO,
- &ec))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to prepare the exchange for launch\n");
- GNUNET_free (cfg_filename);
- return BAD_CONFIG_FILE;
- }
- }
- else
- {
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "exchange",
- "BASE_URL",
- &ec.exchange_url))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "exchange",
- "base_url");
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (cfg_filename);
- return BAD_CONFIG_FILE;
- }
-
- if (GNUNET_OK !=
- 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;
- }
+ struct GNUNET_TIME_Absolute start_time;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "benchmark-remote-exchange",
- "dir",
- &remote_dir))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "benchmark-remote-exchange",
- "dir");
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_free (cfg_filename);
- return BAD_CONFIG_FILE;
- }
+ start_time = GNUNET_TIME_absolute_get ();
+ result = parallel_benchmark (&run,
+ NULL,
+ cfg_filename);
+ duration = GNUNET_TIME_absolute_get_duration (start_time);
}
- 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)
{
struct rusage usage;
@@ -1148,39 +626,45 @@ main (int argc,
GNUNET_assert (0 == getrusage (RUSAGE_CHILDREN,
&usage));
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,
(float) howmany_coins * (refresh_rate / 100.0),
howmany_reserves,
howmany_clients,
- GNUNET_STRINGS_relative_time_to_string
- (duration,
- GNUNET_NO));
+ GNUNET_STRINGS_relative_time_to_string (
+ duration,
+ false));
fprintf (stdout,
"(approximately %s/coin)\n",
- GNUNET_STRINGS_relative_time_to_string
- (GNUNET_TIME_relative_divide (duration,
- (unsigned long long) howmany_coins
- * howmany_reserves
- * howmany_clients),
- GNUNET_YES));
+ GNUNET_STRINGS_relative_time_to_string (
+ GNUNET_TIME_relative_divide (
+ duration,
+ (unsigned long long) howmany_coins
+ * howmany_reserves
+ * howmany_clients),
+ true));
fprintf (stdout,
"RAW: %04u %04u %04u %16llu\n",
howmany_coins,
howmany_reserves,
howmany_clients,
(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
+ usage.ru_stime.tv_usec),
(unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000
+ usage.ru_utime.tv_usec));
}
+
for (unsigned int i = 0; i<label_off; i++)
GNUNET_free (labels[i]);
GNUNET_array_grow (labels,
label_len,
0);
+ GNUNET_CONFIGURATION_destroy (cfg);
+ GNUNET_free (cfg_filename);
return (GNUNET_OK == result) ? 0 : result;
}