gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-exchange] branch master updated (7d2fbc4 -> 40b27a8)


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated (7d2fbc4 -> 40b27a8)
Date: Fri, 04 May 2018 16:19:09 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a change to branch master
in repository exchange.

    from 7d2fbc4  fix path generation.
     new a761baa  Test cases.
     new 5fda477  fix segfault
     new 40b27a8  Tests flexibility.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/bank-lib/bank.conf                 |  2 +
 src/bank-lib/bank_twisted.conf         |  2 +
 src/bank-lib/test_bank_api_new.c       |  2 +-
 src/bank-lib/test_bank_api_twisted.c   |  8 ++--
 src/bank-lib/testing_api_helpers.c     | 67 +++++++++++++++++++++++++++++---
 src/exchange-lib/testing_api_helpers.c | 70 +++++++++++++++++++++++++---------
 src/include/taler_testing_bank_lib.h   |  3 +-
 7 files changed, 126 insertions(+), 28 deletions(-)

diff --git a/src/bank-lib/bank.conf b/src/bank-lib/bank.conf
index 9befeba..906b95f 100644
--- a/src/bank-lib/bank.conf
+++ b/src/bank-lib/bank.conf
@@ -5,7 +5,9 @@ currency = KUDOS
 URL = payto://x-taler-bank/localhost:8081/1
 
 [bank]
+SERVE = http
 HTTP_PORT = 8081
+DATABASE = postgres:///talercheck
 
 [exchange-wire-test]
 bank_url = http://localhost:8081/
diff --git a/src/bank-lib/bank_twisted.conf b/src/bank-lib/bank_twisted.conf
index d20e109..ab006b9 100644
--- a/src/bank-lib/bank_twisted.conf
+++ b/src/bank-lib/bank_twisted.conf
@@ -27,7 +27,9 @@ UNIX_MATCH_GID = YES
 currency = KUDOS
 
 [bank]
+serve = http
 http_port = 8081
+database = postgres:///talercheck
 
 [account-1]
 URL = payto://x-taler-bank/localhost:8081/1
diff --git a/src/bank-lib/test_bank_api_new.c b/src/bank-lib/test_bank_api_new.c
index eade780..513b4aa 100644
--- a/src/bank-lib/test_bank_api_new.c
+++ b/src/bank-lib/test_bank_api_new.c
@@ -164,7 +164,7 @@ main(int argc,
     return 77;
 
   if (NULL == (bankd =
-      TALER_TESTING_run_bank (CONFIG_FILE)))
+      TALER_TESTING_run_bank (CONFIG_FILE, bank_url)))
     return 77;
   
   ret = TALER_TESTING_setup (&run,
diff --git a/src/bank-lib/test_bank_api_twisted.c 
b/src/bank-lib/test_bank_api_twisted.c
index b11ccfd..55064b2 100644
--- a/src/bank-lib/test_bank_api_twisted.c
+++ b/src/bank-lib/test_bank_api_twisted.c
@@ -85,7 +85,7 @@ run (void *cls,
   struct TALER_TESTING_Command commands[] = {
 
     TALER_TESTING_cmd_bank_history ("history-0",
-                                    bank_url,
+                                    twister_url,
                                     EXCHANGE_ACCOUNT_NUMBER,
                                     TALER_BANK_DIRECTION_BOTH,
                                     NULL,
@@ -124,10 +124,12 @@ main (int argc,
   GNUNET_log_setup ("test-bank-api-twisted",
                     "DEBUG", NULL);
 
-  if (NULL == (bank_url = TALER_TESTING_prepare_bank (CONFIG_FILE)))
+  if (NULL == (bank_url = TALER_TESTING_prepare_bank
+      (CONFIG_FILE)))
     return 77;
 
-  if (NULL == (bankd = TALER_TESTING_run_bank (CONFIG_FILE)))
+  if (NULL == (bankd = TALER_TESTING_run_bank
+      (CONFIG_FILE, bank_url)))
     return 77;
 
   if (NULL == (twister_url = TALER_TESTING_prepare_twister
diff --git a/src/bank-lib/testing_api_helpers.c 
b/src/bank-lib/testing_api_helpers.c
index 99b0e8c..d890ea4 100644
--- a/src/bank-lib/testing_api_helpers.c
+++ b/src/bank-lib/testing_api_helpers.c
@@ -57,11 +57,63 @@ struct TALER_BANK_AuthenticationData AUTHS[] = {
  *         be started.
  */
 struct GNUNET_OS_Process *
-TALER_TESTING_run_bank (const char *config_filename)
+TALER_TESTING_run_bank (const char *config_filename,
+                        const char *bank_url)
 {
 
+  /* to fetch: dbname+serving_method+base_url */
+
+
   struct GNUNET_OS_Process *bank_proc;
   unsigned int iter;
+  char *wget_cmd;
+  char *database;
+  char *serve_cfg;
+  char *serve_arg;
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+
+
+  cfg = GNUNET_CONFIGURATION_create ();
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_load (cfg,
+                                 config_filename))
+  {
+    GNUNET_break (0);
+    GNUNET_CONFIGURATION_destroy (cfg);
+    exit (77);
+  }
+
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "bank",
+                                             "database",
+                                             &database))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+                               "bank",
+                               "database");
+    GNUNET_break (0);
+    GNUNET_CONFIGURATION_destroy (cfg);
+    exit (77);
+  }
+
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "bank",
+                                             "serve",
+                                             &serve_cfg))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+                               "bank",
+                               "serve");
+    GNUNET_break (0);
+    GNUNET_CONFIGURATION_destroy (cfg);
+    exit (77);
+  }
+
+  serve_arg = "serve-http";
+  if (0 != strcmp ("http", serve_cfg))
+    serve_arg = "serve-uwsgi";
 
   bank_proc = GNUNET_OS_start_process
     (GNUNET_NO,
@@ -70,11 +122,16 @@ TALER_TESTING_run_bank (const char *config_filename)
      "taler-bank-manage",
      "taler-bank-manage",
      "-c", config_filename,
-     "--with-db=postgres:///talercheck",
-     "serve-http", NULL);
+     "--with-db", database,
+     serve_arg, NULL);
   if (NULL == bank_proc)
     BANK_FAIL ();
 
+  GNUNET_asprintf (&wget_cmd,
+                   "wget -q -t 1 -T 1 %s"
+                   " -o /dev/null -O /dev/null",
+                   bank_url);
+
   /* give child time to start and bind against the socket */
   fprintf (stderr,
            "Waiting for `taler-bank-manage' to be ready");
@@ -96,9 +153,7 @@ TALER_TESTING_run_bank (const char *config_filename)
       sleep (1);
       iter++;
     }
-                                   /*FIXME: no hardcode port*/
-  while (0 != system ("wget -q -t 1 -T 1 http://127.0.0.1:8081/"; \
-                      " -o /dev/null -O /dev/null"));
+  while (0 != system (wget_cmd));
   fprintf (stderr, "\n");
 
   return bank_proc;
diff --git a/src/exchange-lib/testing_api_helpers.c 
b/src/exchange-lib/testing_api_helpers.c
index 31f28d0..c6459a5 100644
--- a/src/exchange-lib/testing_api_helpers.c
+++ b/src/exchange-lib/testing_api_helpers.c
@@ -16,6 +16,7 @@
   License along with TALER; see the file COPYING.  If not, see
   <http://www.gnu.org/licenses/>
 */
+
 /**
  * @file exchange-lib/testing_api_helpers.c
  * @brief helper functions
@@ -355,39 +356,56 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main 
main_cb,
   int result;
   unsigned int iter;
   struct GNUNET_OS_Process *exchanged;
-
   struct GNUNET_CONFIGURATION_Handle *cfg;
   unsigned long long port;
+  char *serve;
+  char *wget_cmd;
+  char *base_url;
 
   cfg = GNUNET_CONFIGURATION_create ();
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_load (cfg,
                                  config_filename))
     return GNUNET_NO;
+
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (cfg,
+      GNUNET_CONFIGURATION_get_value_string (cfg,
                                              "exchange",
-                                             "PORT",
-                                             &port))
+                                             "SERVE",
+                                             &serve))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                "exchange",
-                               "PORT");
+                               "SERVE");
     GNUNET_CONFIGURATION_destroy (cfg);
     return GNUNET_NO;
   }
 
-  GNUNET_CONFIGURATION_destroy (cfg);
-  if (GNUNET_OK !=
-      GNUNET_NETWORK_test_port_free (IPPROTO_TCP,
-                                    (uint16_t) port))
+  if (0 == strcmp ("tcp", serve))
   {
-    fprintf (stderr,
-             "Required port %llu not available, skipping.\n",
-            port);
-    return GNUNET_NO;
+    if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_number (cfg,
+                                               "exchange",
+                                               "PORT",
+                                               &port))
+    {
+      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                                 "exchange",
+                                 "PORT");
+      GNUNET_CONFIGURATION_destroy (cfg);
+      return GNUNET_NO;
+    }
+  
+    if (GNUNET_OK !=
+        GNUNET_NETWORK_test_port_free (IPPROTO_TCP,
+                                    (uint16_t) port))
+    {
+      fprintf (stderr,
+               "Required port %llu not available, skipping.\n",
+            port);
+      return GNUNET_NO;
+    }
   }
-
   exchanged = GNUNET_OS_start_process (GNUNET_NO,
                                        GNUNET_OS_INHERIT_STD_ALL,
                                        NULL, NULL, NULL,
@@ -396,6 +414,26 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main 
main_cb,
                                        "-c", config_filename,
                                        "-i",
                                        NULL);
+
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "exchange",
+                                             "BASE_URL",
+                                             &base_url))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                               "exchange",
+                               "BASE_URL");
+    GNUNET_CONFIGURATION_destroy (cfg);
+    return GNUNET_NO;
+  }
+  GNUNET_CONFIGURATION_destroy (cfg);
+
+  GNUNET_asprintf (&wget_cmd,
+                   "wget -q -t 1 -T 1 %skeys"
+                   " -o /dev/null -O /dev/null",
+                   base_url); // make sure ends with '/'
+
   /* give child time to start and bind against the socket */
   fprintf (stderr,
            "Waiting for `taler-exchange-httpd' to be ready\n");
@@ -417,9 +455,7 @@ TALER_TESTING_setup_with_exchange (TALER_TESTING_Main 
main_cb,
       sleep (1);
       iter++;
     }
-  while (0 != system
-    ("wget -q -t 1 -T 1 http://127.0.0.1:8081/keys";
-     " -o /dev/null -O /dev/null"));
+  while (0 != system (wget_cmd));
 
   result = TALER_TESTING_setup (main_cb,
                                 main_cb_cls,
diff --git a/src/include/taler_testing_bank_lib.h 
b/src/include/taler_testing_bank_lib.h
index 87187a7..1461d7a 100644
--- a/src/include/taler_testing_bank_lib.h
+++ b/src/include/taler_testing_bank_lib.h
@@ -62,7 +62,8 @@
  *         be started.
  */
 struct GNUNET_OS_Process *
-TALER_TESTING_run_bank (const char *config_filename);
+TALER_TESTING_run_bank (const char *config_filename,
+                        const char *bank_url);
 
 /**
  * Prepare the bank execution.  Check if the port is available

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]