From f17ad4de768e297879a6ace43f7be723ddff6b6f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 9 Aug 2018 10:33:21 +0200 Subject: in parallel tests, only launch one exchange -- still broken: code attempts to launch multiple fakebanks --- .../.config/taler/account-2.json | 4 +- src/benchmark/taler-exchange-benchmark.c | 47 +++++++++----- src/exchange-lib/testing_api_helpers.c | 74 +++++++++++++--------- src/exchange-lib/testing_api_loop.c | 7 +- src/include/taler_testing_lib.h | 16 ++++- 5 files changed, 95 insertions(+), 53 deletions(-) diff --git a/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json b/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json index dabd5092f..b320bd946 100644 --- a/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json +++ b/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json @@ -1,5 +1,5 @@ { "url": "payto://x-taler-bank/localhost:8082/2", - "salt": "V7S6Y75HPSFGKXET03NHS3SDEST5Q0XNX9WYCXRRRNRHPBVSD86Y1A7ZR5KR7105JN3XDBTKWDD3WQZ9XA2MJKD020APECA0P61FFBG", - "master_sig": "H61WAQKG8F9W25SZNVF1JPNYG0BFYXPN65D936TT44ZC0JT849R8YNC0CFPJBQX77EW51DCR0864DC82A4J2AF7H55DSVVMWVYEZR1R" + "salt": "NYZ2WR8CPT5PB58X10EZDJDY3MSWHAHTD0M99JJH54Z0A916NTX4P4AF5Y3KPGRYEVX3TV7J2ZG6PKZSKFYMSKMHCN83ZT3V2216YP8", + "master_sig": "0RF7GBGKGJQ0ZQVP0HJ516CC882RV6HVJZABN5S1YMF6WD94QJJRZSTFB669QTNW63DPRP0YYJ0RGCNXA3AHQ1HGYDGAMZX0S983020" } \ No newline at end of file diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index 5039a96f5..a5528fff5 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -327,7 +327,6 @@ run (void *cls, struct TALER_Amount total_reserve_amount; struct TALER_Amount withdraw_fee; char *withdraw_fee_str; - struct TALER_TESTING_Command all_commands [1 + /* Withdraw block */ howmany_coins + /* All units */ @@ -353,19 +352,14 @@ run (void *cls, TALER_amount_add (&total_reserve_amount, &total_reserve_amount, &withdraw_fee); - struct TALER_TESTING_Command make_reserve[] = { - CMD_TRANSFER_TO_EXCHANGE ("create-reserve", TALER_amount_to_string (&total_reserve_amount)), - TALER_TESTING_cmd_exec_wirewatch ("wirewatch", cfg_filename), - TALER_TESTING_cmd_end () - }; all_commands[0] = TALER_TESTING_cmd_batch ("make-reserve", @@ -379,18 +373,15 @@ run (void *cls, GNUNET_asprintf (&withdraw_label, "withdraw-%u", i); - GNUNET_asprintf (&order_enc, "{\"nonce\": %u}", i); - unit[0] = TALER_TESTING_cmd_withdraw_amount (withdraw_label, is->exchange, "create-reserve", AMOUNT_5, MHD_HTTP_OK); - unit[1] = TALER_TESTING_cmd_deposit ("deposit", is->exchange, @@ -424,22 +415,20 @@ run (void *cls, AMOUNT_4, withdraw_label, MHD_HTTP_OK); - unit[3] = TALER_TESTING_cmd_refresh_reveal (reveal_label, is->exchange, melt_label, MHD_HTTP_OK); - unit[4] = TALER_TESTING_cmd_refresh_link ("refresh-link", is->exchange, reveal_label, MHD_HTTP_OK); - unit[5] = TALER_TESTING_cmd_end (); } - else unit[2] = TALER_TESTING_cmd_end (); + else + unit[2] = TALER_TESTING_cmd_end (); all_commands[1 + i] = TALER_TESTING_cmd_batch ("unit", unit); @@ -473,17 +462,37 @@ parallel_benchmark (TALER_TESTING_Main main_cb, int result; pid_t cpids[howmany_clients]; int wstatus; - + struct GNUNET_OS_Process *exchanged; + + exchanged = GNUNET_OS_start_process (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-httpd", + "taler-exchange-httpd", + "-c", config_file, + "-i", + NULL); + if (NULL == exchanged) + return GNUNET_SYSERR; + if (0 != TALER_TESTING_wait_exchange_ready (exchange_url)) + { + GNUNET_OS_process_kill (exchanged, + SIGTERM); + GNUNET_OS_process_wait (exchanged); + GNUNET_OS_process_destroy (exchanged); + return 77; + } result = GNUNET_OK; for (unsigned int i=0;ilabel; - i++) + i++) { if ( (NULL != cmd->label) && (0 == strcmp (cmd->label, @@ -181,7 +181,7 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is) GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_cmd (cmd, CURRENT_BATCH_SUBCMD_INDEX, &sub_cmd)); - + if (NULL == sub_cmd->label) is->ip++; } @@ -520,7 +520,7 @@ sighandler_child_death () * @param keys the exchange's keys. * @param compat protocol compatibility information. */ -void +static void cert_cb (void *cls, const struct TALER_EXCHANGE_Keys *keys, enum TALER_EXCHANGE_VersionCompatibility compat) @@ -562,6 +562,7 @@ cert_cb (void *cls, main_ctx->is); } + /** * Initialize scheduler loop and curl context for the testcase, * and responsible to run the "run" method. diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 694db70fe..708d73405 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -113,6 +113,18 @@ TALER_TESTING_prepare_exchange (const char *config_filename, char **base_url); +/** + * Wait for the exchange to have started. Waits for at + * most 10s, after that returns 77 to indicate an error. + * + * @param base_url what URL should we expect the exchange + * to be running at + * @return 0 on success + */ +int +TALER_TESTING_wait_exchange_ready (const char *base_url); + + /** * Remove files from previous runs */ @@ -1241,7 +1253,7 @@ TALER_TESTING_get_trait_process /** * Offer location where a command stores a pointer to a process. - * + * * @param index offered location index number, in case there are * multiple on offer. * @param processp process location to offer. @@ -1501,7 +1513,7 @@ TALER_TESTING_get_trait_contract_terms * * @param index contract terms index number. * @param contract_terms contract terms to offer. - * + * * @return the trait. */ struct TALER_TESTING_Trait -- cgit v1.2.3