summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMS <ms@taler.net>2020-06-02 11:36:51 +0200
committerMS <ms@taler.net>2020-06-02 11:36:51 +0200
commitf6e1583016de3f54e437c49ef31f19a052b3a0c8 (patch)
tree67be5bb176e9afde535a73c0f01296e262aa8260
parent320c5fd74091cbcbd06b8246f7817f259077080c (diff)
downloadexchange-f6e1583016de3f54e437c49ef31f19a052b3a0c8.tar.gz
exchange-f6e1583016de3f54e437c49ef31f19a052b3a0c8.tar.bz2
exchange-f6e1583016de3f54e437c49ef31f19a052b3a0c8.zip
launching nexus AND sandbox
-rw-r--r--src/include/taler_testing_lib.h18
-rw-r--r--src/testing/test_bank_api.c41
-rw-r--r--src/testing/testing_api_helpers_bank.c84
3 files changed, 117 insertions, 26 deletions
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 1194cb4b4..0696573ea 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -111,6 +111,20 @@ struct TALER_TESTING_DatabaseConnection
struct TALER_EXCHANGEDB_Session *session;
};
+struct TALER_TESTING_LibeufinServices
+{
+ /**
+ * Nexus
+ */
+ struct GNUNET_OS_Process *nexus;
+
+ /**
+ * Sandbox
+ */
+ struct GNUNET_OS_Process *sandbox;
+
+};
+
/**
* Prepare launching an exchange. Checks that the configured
* port is available, runs taler-exchange-keyup,
@@ -822,8 +836,8 @@ TALER_TESTING_run_bank (const char *config_filename,
* @return the process, or NULL if the process could not
* be started.
*/
-struct GNUNET_OS_Process *
-TALER_TESTING_run_nexus (const struct TALER_TESTING_BankConfiguration *bc);
+struct TALER_TESTING_LibeufinServices
+TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc);
/**
* Runs the Fakebank by guessing / extracting the portnumber
diff --git a/src/testing/test_bank_api.c b/src/testing/test_bank_api.c
index c4055c516..ffce3503f 100644
--- a/src/testing/test_bank_api.c
+++ b/src/testing/test_bank_api.c
@@ -53,6 +53,15 @@ static struct GNUNET_OS_Process *bankd;
*/
static int with_fakebank;
+/**
+ * Handles to the libeufin services.
+ */
+static struct TALER_TESTING_LibeufinServices libeufin_services;
+
+/**
+ * Needed to shutdown differently.
+ */
+static int with_libeufin;
/**
* Main function that will tell the interpreter what commands to
@@ -193,7 +202,8 @@ main (int argc,
"_with_nexus"))
{
TALER_LOG_DEBUG ("Running with Nexus.\n");
- cfgfile = CONFIG_FILE_FAKEBANK;
+ with_libeufin = GNUNET_YES;
+ cfgfile = CONFIG_FILE_NEXUS;
if (GNUNET_OK != TALER_TESTING_prepare_nexus (CONFIG_FILE_NEXUS,
GNUNET_YES,
"exchange-account-2",
@@ -202,7 +212,8 @@ main (int argc,
GNUNET_break (0);
return 77;
}
- if (NULL == (bankd = TALER_TESTING_run_nexus (&bc)))
+ libeufin_services = TALER_TESTING_run_libeufin (&bc);
+ if ( (NULL == libeufin_services.nexus) || (NULL == libeufin_services.sandbox) )
{
GNUNET_break (0);
return 77;
@@ -222,14 +233,32 @@ main (int argc,
rv = 1;
else
rv = 0;
+
if (GNUNET_NO == with_fakebank)
{
+ // -> pybank
+ if (GNUNET_NO == with_libeufin)
+ {
+
+ GNUNET_OS_process_kill (bankd,
+ SIGKILL);
+ GNUNET_OS_process_wait (bankd);
+ GNUNET_OS_process_destroy (bankd);
+ }
+ else // -> libeufin
+ {
+ GNUNET_OS_process_kill (libeufin_services.nexus,
+ SIGKILL);
+ GNUNET_OS_process_wait (libeufin_services.nexus);
+ GNUNET_OS_process_destroy (libeufin_services.nexus);
- GNUNET_OS_process_kill (bankd,
- SIGKILL);
- GNUNET_OS_process_wait (bankd);
- GNUNET_OS_process_destroy (bankd);
+ GNUNET_OS_process_kill (libeufin_services.sandbox,
+ SIGKILL);
+ GNUNET_OS_process_wait (libeufin_services.sandbox);
+ GNUNET_OS_process_destroy (libeufin_services.sandbox);
+ }
}
+
return rv;
}
diff --git a/src/testing/testing_api_helpers_bank.c b/src/testing/testing_api_helpers_bank.c
index a6a97edd5..b887bfc04 100644
--- a/src/testing/testing_api_helpers_bank.c
+++ b/src/testing/testing_api_helpers_bank.c
@@ -106,17 +106,19 @@ TALER_TESTING_has_in_name (const char *prog,
* bank" function to do such tasks. This function is also
* responsible to create the exchange user at Nexus.
*
- * @return the process, or NULL if the process could not
- * be started.
+ * @return the pair of both service handles. In case of
+ * errors, each element of the pair will be set to NULL.
*/
-struct GNUNET_OS_Process *
-TALER_TESTING_run_nexus (const struct TALER_TESTING_BankConfiguration *bc)
+struct TALER_TESTING_LibeufinServices
+TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc)
{
- struct GNUNET_OS_Process *bank_proc;
+ struct GNUNET_OS_Process *nexus_proc;
+ struct GNUNET_OS_Process *sandbox_proc;
+ struct TALER_TESTING_LibeufinServices ret;
unsigned int iter;
char *curl_check_cmd;
- bank_proc = GNUNET_OS_start_process
+ nexus_proc = GNUNET_OS_start_process
(GNUNET_NO,
GNUNET_OS_INHERIT_STD_NONE,
NULL, NULL, NULL,
@@ -124,14 +126,14 @@ TALER_TESTING_run_nexus (const struct TALER_TESTING_BankConfiguration *bc)
"nexus",
"serve",
NULL);
- if (NULL == bank_proc)
+ if (NULL == nexus_proc)
{
- BANK_FAIL ();
+ GNUNET_break (0);
+ return ret;
}
GNUNET_asprintf (&curl_check_cmd,
"curl -s %s",
bc->exchange_auth.wire_gateway_url);
-
/* give child time to start and bind against the socket */
fprintf (stderr,
"Waiting for `nexus' to be ready (via %s)\n", curl_check_cmd);
@@ -143,12 +145,13 @@ TALER_TESTING_run_nexus (const struct TALER_TESTING_BankConfiguration *bc)
fprintf (
stderr,
"Failed to launch `nexus'\n");
- GNUNET_OS_process_kill (bank_proc,
+ GNUNET_OS_process_kill (nexus_proc,
SIGTERM);
- GNUNET_OS_process_wait (bank_proc);
- GNUNET_OS_process_destroy (bank_proc);
+ GNUNET_OS_process_wait (nexus_proc);
+ GNUNET_OS_process_destroy (nexus_proc);
GNUNET_free (curl_check_cmd);
- BANK_FAIL ();
+ GNUNET_break (0);
+ return ret;
}
fprintf (stderr, ".");
sleep (1);
@@ -157,15 +160,60 @@ TALER_TESTING_run_nexus (const struct TALER_TESTING_BankConfiguration *bc)
while (0 != system (curl_check_cmd));
GNUNET_free (curl_check_cmd);
fprintf (stderr, "\n");
+
+ sandbox_proc = GNUNET_OS_start_process
+ (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_NONE,
+ NULL, NULL, NULL,
+ "sandbox",
+ "sandbox",
+ NULL);
+ if (NULL == sandbox_proc)
+ {
+ GNUNET_break (0);
+ return ret;
+ }
+
+ /* give child time to start and bind against the socket */
+ fprintf (stderr,
+ "Waiting for `sandbox' to be ready..\n");
+ iter = 0;
+ do
+ {
+ if (10 == iter)
+ {
+ fprintf (
+ stderr,
+ "Failed to launch `sandbox'\n");
+ GNUNET_OS_process_kill (sandbox_proc,
+ SIGTERM);
+ GNUNET_OS_process_wait (sandbox_proc);
+ GNUNET_OS_process_destroy (sandbox_proc);
+ GNUNET_break (0);
+ return ret;
+ }
+ fprintf (stderr, ".");
+ sleep (1);
+ iter++;
+ }
+ while (0 != system ("curl http://localhost:5001/"));
+ fprintf (stderr, "\n");
+
// Creates nexus user + bank loopback connection + Taler facade.
if (0 != system ("taler-nexus-prepare"))
{
- GNUNET_OS_process_kill (bank_proc, SIGTERM);
- GNUNET_OS_process_wait (bank_proc);
- GNUNET_OS_process_destroy (bank_proc);
- BANK_FAIL ();
+ GNUNET_OS_process_kill (nexus_proc, SIGTERM);
+ GNUNET_OS_process_wait (nexus_proc);
+ GNUNET_OS_process_destroy (nexus_proc);
+ GNUNET_OS_process_kill (sandbox_proc, SIGTERM);
+ GNUNET_OS_process_wait (sandbox_proc);
+ GNUNET_OS_process_destroy (sandbox_proc);
+ GNUNET_break (0);
+ return ret;
}
- return bank_proc;
+ ret.nexus = nexus_proc;
+ ret.sandbox = sandbox_proc;
+ return ret;
}
/**