launching nexus AND sandbox
This commit is contained in:
parent
320c5fd740
commit
f6e1583016
@ -111,6 +111,20 @@ struct TALER_TESTING_DatabaseConnection
|
|||||||
struct TALER_EXCHANGEDB_Session *session;
|
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
|
* Prepare launching an exchange. Checks that the configured
|
||||||
* port is available, runs taler-exchange-keyup,
|
* 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
|
* @return the process, or NULL if the process could not
|
||||||
* be started.
|
* be started.
|
||||||
*/
|
*/
|
||||||
struct GNUNET_OS_Process *
|
struct TALER_TESTING_LibeufinServices
|
||||||
TALER_TESTING_run_nexus (const struct TALER_TESTING_BankConfiguration *bc);
|
TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the Fakebank by guessing / extracting the portnumber
|
* Runs the Fakebank by guessing / extracting the portnumber
|
||||||
|
@ -53,6 +53,15 @@ static struct GNUNET_OS_Process *bankd;
|
|||||||
*/
|
*/
|
||||||
static int with_fakebank;
|
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
|
* Main function that will tell the interpreter what commands to
|
||||||
@ -193,7 +202,8 @@ main (int argc,
|
|||||||
"_with_nexus"))
|
"_with_nexus"))
|
||||||
{
|
{
|
||||||
TALER_LOG_DEBUG ("Running with Nexus.\n");
|
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,
|
if (GNUNET_OK != TALER_TESTING_prepare_nexus (CONFIG_FILE_NEXUS,
|
||||||
GNUNET_YES,
|
GNUNET_YES,
|
||||||
"exchange-account-2",
|
"exchange-account-2",
|
||||||
@ -202,7 +212,8 @@ main (int argc,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return 77;
|
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);
|
GNUNET_break (0);
|
||||||
return 77;
|
return 77;
|
||||||
@ -222,14 +233,32 @@ main (int argc,
|
|||||||
rv = 1;
|
rv = 1;
|
||||||
else
|
else
|
||||||
rv = 0;
|
rv = 0;
|
||||||
|
|
||||||
if (GNUNET_NO == with_fakebank)
|
if (GNUNET_NO == with_fakebank)
|
||||||
{
|
{
|
||||||
|
// -> pybank
|
||||||
|
if (GNUNET_NO == with_libeufin)
|
||||||
|
{
|
||||||
|
|
||||||
GNUNET_OS_process_kill (bankd,
|
GNUNET_OS_process_kill (bankd,
|
||||||
SIGKILL);
|
SIGKILL);
|
||||||
GNUNET_OS_process_wait (bankd);
|
GNUNET_OS_process_wait (bankd);
|
||||||
GNUNET_OS_process_destroy (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 (libeufin_services.sandbox,
|
||||||
|
SIGKILL);
|
||||||
|
GNUNET_OS_process_wait (libeufin_services.sandbox);
|
||||||
|
GNUNET_OS_process_destroy (libeufin_services.sandbox);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,17 +106,19 @@ TALER_TESTING_has_in_name (const char *prog,
|
|||||||
* bank" function to do such tasks. This function is also
|
* bank" function to do such tasks. This function is also
|
||||||
* responsible to create the exchange user at Nexus.
|
* responsible to create the exchange user at Nexus.
|
||||||
*
|
*
|
||||||
* @return the process, or NULL if the process could not
|
* @return the pair of both service handles. In case of
|
||||||
* be started.
|
* errors, each element of the pair will be set to NULL.
|
||||||
*/
|
*/
|
||||||
struct GNUNET_OS_Process *
|
struct TALER_TESTING_LibeufinServices
|
||||||
TALER_TESTING_run_nexus (const struct TALER_TESTING_BankConfiguration *bc)
|
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;
|
unsigned int iter;
|
||||||
char *curl_check_cmd;
|
char *curl_check_cmd;
|
||||||
|
|
||||||
bank_proc = GNUNET_OS_start_process
|
nexus_proc = GNUNET_OS_start_process
|
||||||
(GNUNET_NO,
|
(GNUNET_NO,
|
||||||
GNUNET_OS_INHERIT_STD_NONE,
|
GNUNET_OS_INHERIT_STD_NONE,
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
@ -124,14 +126,14 @@ TALER_TESTING_run_nexus (const struct TALER_TESTING_BankConfiguration *bc)
|
|||||||
"nexus",
|
"nexus",
|
||||||
"serve",
|
"serve",
|
||||||
NULL);
|
NULL);
|
||||||
if (NULL == bank_proc)
|
if (NULL == nexus_proc)
|
||||||
{
|
{
|
||||||
BANK_FAIL ();
|
GNUNET_break (0);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
GNUNET_asprintf (&curl_check_cmd,
|
GNUNET_asprintf (&curl_check_cmd,
|
||||||
"curl -s %s",
|
"curl -s %s",
|
||||||
bc->exchange_auth.wire_gateway_url);
|
bc->exchange_auth.wire_gateway_url);
|
||||||
|
|
||||||
/* give child time to start and bind against the socket */
|
/* give child time to start and bind against the socket */
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Waiting for `nexus' to be ready (via %s)\n", curl_check_cmd);
|
"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 (
|
fprintf (
|
||||||
stderr,
|
stderr,
|
||||||
"Failed to launch `nexus'\n");
|
"Failed to launch `nexus'\n");
|
||||||
GNUNET_OS_process_kill (bank_proc,
|
GNUNET_OS_process_kill (nexus_proc,
|
||||||
SIGTERM);
|
SIGTERM);
|
||||||
GNUNET_OS_process_wait (bank_proc);
|
GNUNET_OS_process_wait (nexus_proc);
|
||||||
GNUNET_OS_process_destroy (bank_proc);
|
GNUNET_OS_process_destroy (nexus_proc);
|
||||||
GNUNET_free (curl_check_cmd);
|
GNUNET_free (curl_check_cmd);
|
||||||
BANK_FAIL ();
|
GNUNET_break (0);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
fprintf (stderr, ".");
|
fprintf (stderr, ".");
|
||||||
sleep (1);
|
sleep (1);
|
||||||
@ -157,15 +160,60 @@ TALER_TESTING_run_nexus (const struct TALER_TESTING_BankConfiguration *bc)
|
|||||||
while (0 != system (curl_check_cmd));
|
while (0 != system (curl_check_cmd));
|
||||||
GNUNET_free (curl_check_cmd);
|
GNUNET_free (curl_check_cmd);
|
||||||
fprintf (stderr, "\n");
|
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.
|
// Creates nexus user + bank loopback connection + Taler facade.
|
||||||
if (0 != system ("taler-nexus-prepare"))
|
if (0 != system ("taler-nexus-prepare"))
|
||||||
{
|
{
|
||||||
GNUNET_OS_process_kill (bank_proc, SIGTERM);
|
GNUNET_OS_process_kill (nexus_proc, SIGTERM);
|
||||||
GNUNET_OS_process_wait (bank_proc);
|
GNUNET_OS_process_wait (nexus_proc);
|
||||||
GNUNET_OS_process_destroy (bank_proc);
|
GNUNET_OS_process_destroy (nexus_proc);
|
||||||
BANK_FAIL ();
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user