gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] 12/22: Double twister instance plus first


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] 12/22: Double twister instance plus first coverage effort
Date: Sat, 17 Mar 2018 01:58:37 +0100

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

marcello pushed a commit to branch master
in repository merchant.

commit b55506b39509657aba64be1a4e22c5bf32c934f9
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Mar 15 08:02:20 2018 +0100

    Double twister instance plus first coverage effort
    
    The twisted tests now use two twister processes: one
    to proxy the exchange, the other to proxy the merchant.
    
    Additionally, it is now tested the reaction of /history
    lib to a unexpected HTTP response code returned by the
    merchant.
---
 src/backend/taler-merchant-httpd_history.c    |  2 +
 src/lib/test_merchant_api_proxy_exchange.conf | 29 +++++++++
 src/lib/test_merchant_api_proxy_merchant.conf | 30 ++++++++++
 src/lib/test_merchant_api_twisted.c           | 84 +++++++++++++++++++--------
 src/lib/test_merchant_api_twisted.conf        | 31 ----------
 src/lib/testing_api_cmd_history.c             | 14 ++++-
 src/lib/testing_api_helpers.c                 |  4 +-
 7 files changed, 134 insertions(+), 60 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_history.c 
b/src/backend/taler-merchant-httpd_history.c
index 207ddca..ef0d3e6 100644
--- a/src/backend/taler-merchant-httpd_history.c
+++ b/src/backend/taler-merchant-httpd_history.c
@@ -132,6 +132,7 @@ MH_handler_history (struct TMH_RequestHandler *rh,
   enum GNUNET_DB_QueryStatus qs;
   struct ProcessContractClosure pcc;
 
+  LOG_INFO ("Serving /history\n");
   response = json_array ();
   str = MHD_lookup_connection_value (connection,
                                      MHD_GET_ARGUMENT_KIND,
@@ -280,6 +281,7 @@ MH_handler_history (struct TMH_RequestHandler *rh,
   ret = TMH_RESPONSE_reply_json (connection,
                                  response,
                                  MHD_HTTP_OK);
+  LOG_INFO ("/history, http code: %d\n", MHD_HTTP_OK);
   json_decref (response);
   return ret;
 }
diff --git a/src/lib/test_merchant_api_proxy_exchange.conf 
b/src/lib/test_merchant_api_proxy_exchange.conf
new file mode 100644
index 0000000..6e311cb
--- /dev/null
+++ b/src/lib/test_merchant_api_proxy_exchange.conf
@@ -0,0 +1,29 @@
+# This file is in the public domain.
+
+# Config to set up the twister between the
+# merchant and the exchange.
+
+[twister]
+# HTTP listen port for twister (the merchant
+# will transparently use this URL as the "exchange")
+HTTP_PORT = 8888
+
+# HTTP Destination for twister, so the real exchange
+# URL.  Note: no trailing '/'!
+DESTINATION_BASE_URL = "http://localhost:8081";
+
+# Control port for TCP
+# PORT = 8889
+HOSTNAME = localhost
+ACCEPT_FROM = 127.0.0.1;
+ACCEPT_FROM6 = ::1;
+
+# Control port for UNIX
+UNIXPATH = /tmp/taler-service-twister-exchange.sock
+UNIX_MATCH_UID = NO
+UNIX_MATCH_GID = YES
+
+# Launching of twister by ARM
+# BINARY = taler-service-twister
+# AUTOSTART = NO
+# FORCESTART = NO
diff --git a/src/lib/test_merchant_api_proxy_merchant.conf 
b/src/lib/test_merchant_api_proxy_merchant.conf
new file mode 100644
index 0000000..706ac29
--- /dev/null
+++ b/src/lib/test_merchant_api_proxy_merchant.conf
@@ -0,0 +1,30 @@
+# This file is in the public domain.
+
+# Config to set up the twister between the
+# HTTP client (= the "lib" code) and the
+# merchant service.
+
+[twister]
+# HTTP listen port for twister ("lib" code will
+# transparently use this URL as the "merchant")
+HTTP_PORT = 8889
+
+# HTTP Destination for twister, so the real
+# merchant URL.  Note: no trailing '/'!
+DESTINATION_BASE_URL = "http://localhost:8082";
+
+# Control port for TCP
+# PORT = 8889
+HOSTNAME = localhost
+ACCEPT_FROM = 127.0.0.1;
+ACCEPT_FROM6 = ::1;
+
+# Control port for UNIX
+UNIXPATH = /tmp/taler-service-twister-merchant.sock
+UNIX_MATCH_UID = NO
+UNIX_MATCH_GID = YES
+
+# Launching of twister by ARM
+# BINARY = taler-service-twister
+# AUTOSTART = NO
+# FORCESTART = NO
diff --git a/src/lib/test_merchant_api_twisted.c 
b/src/lib/test_merchant_api_twisted.c
index c70c5fc..1d3ee19 100644
--- a/src/lib/test_merchant_api_twisted.c
+++ b/src/lib/test_merchant_api_twisted.c
@@ -46,14 +46,33 @@
 #define CONFIG_FILE "test_merchant_api_twisted.conf"
 
 /**
+ * Configuration file for the proxy between merchant and
+ * exchange.  Not used directly here in the code (instead
+ * used in the merchant config), but kept around for consistency.
+ */
+#define PROXY_EXCHANGE_CONFIG_FILE \
+  "test_merchant_api_proxy_exchange.conf"
+
+/**
+ * Configuration file for the proxy between "lib" and merchant.
+ */
+#define PROXY_MERCHANT_CONFIG_FILE \
+  "test_merchant_api_proxy_merchant.conf"
+
+/**
  * Exchange base URL.  Could also be taken from config.
  */
 #define EXCHANGE_URL "http://localhost:8081/";
 
 /**
- * (real) Twister URL.  Used at startup time to check if it runs.
+ * Twister URL that proxies the exchange.
  */
-static char *twister_url;
+static char *twister_exchange_url;
+
+/**
+ * Twister URL that proxies the merchant.
+ */
+static char *twister_merchant_url;
 
 /**
  * URL of the fakebank.  Obtained from CONFIG_FILE's
@@ -77,9 +96,14 @@ static char *exchange_url;
 static struct GNUNET_OS_Process *merchantd;
 
 /**
- * Twister process.
+ * Twister process that proxies the exchange.
+ */
+static struct GNUNET_OS_Process *twisterexchanged;
+
+/**
+ * Twister process that proxies the merchant.
  */
-static struct GNUNET_OS_Process *twisterd;
+static struct GNUNET_OS_Process *twistermerchantd;
 
 /**
  * Account number of the exchange at the bank.
@@ -158,6 +182,7 @@ run (void *cls,
 
   struct TALER_TESTING_Command commands[] = {
 
+    #ifdef TEST_FAILED_DEPENDENCY
     /**
      * Move money to the exchange's bank account.
      */
@@ -269,17 +294,21 @@ run (void *cls,
        "deposit-simple",
        "EUR:0.01"), // ignored
 
-
-    #if 0
-    TALER_TESTING_cmd_merchant_track_transfer
-      ("track-transfer-1",
-       merchant_url,
-       is->ctx,
-       MHD_HTTP_OK,
-       "check_bank_transfer-1",
-       "deposit-simple"),
     #endif
-
+    
+    TALER_TESTING_cmd_hack_response_code
+      ("twist-history",
+       PROXY_MERCHANT_CONFIG_FILE,
+       MHD_HTTP_GONE),
+
+    TALER_TESTING_cmd_history ("history-0",
+                               twister_merchant_url,
+                               is->ctx,
+                               MHD_HTTP_GONE,
+                               GNUNET_TIME_UNIT_ZERO_ABS,
+                               1, // nresult
+                               10, // start
+                               10), // nrows
     /**
      * End the suite.  Fixme: better to have a label for this
      * too, as it shows a "(null)" token on logs.
@@ -324,8 +353,12 @@ main (int argc,
       (CONFIG_FILE)))
     return 77;
 
-  if (NULL == (twister_url = TALER_TESTING_prepare_twister
-      (CONFIG_FILE)))
+  if (NULL == (twister_exchange_url = TALER_TESTING_prepare_twister
+      (PROXY_EXCHANGE_CONFIG_FILE)))
+    return 77;
+
+  if (NULL == (twister_merchant_url = TALER_TESTING_prepare_twister
+      (PROXY_MERCHANT_CONFIG_FILE)))
     return 77;
 
   TALER_TESTING_cleanup_files (CONFIG_FILE);
@@ -343,21 +376,22 @@ main (int argc,
 
     if (NULL == (merchantd = TALER_TESTING_run_merchant
         (CONFIG_FILE)))
-    {
-      purge_process (twisterd);
-      return 1; // 1 is fine; after all is merchant test cases.
-    }
+      // 1 is fine; after all this is merchant test cases.
+      return 1;
 
-    if (NULL == (twisterd = TALER_TESTING_run_twister
-        (CONFIG_FILE)))
+    if (NULL == (twisterexchanged = TALER_TESTING_run_twister
+        (PROXY_EXCHANGE_CONFIG_FILE)))
+      return 77;
+
+    if (NULL == (twistermerchantd = TALER_TESTING_run_twister
+        (PROXY_MERCHANT_CONFIG_FILE)))
       return 77;
 
     ret = TALER_TESTING_setup_with_exchange (&run, NULL,
                                              CONFIG_FILE);
     purge_process (merchantd);
-    purge_process (twisterd);
-    GNUNET_free (merchant_url);
-    GNUNET_free (twister_url);
+    purge_process (twisterexchanged);
+    purge_process (twistermerchantd);
 
     if (GNUNET_OK != ret)
       return 1;
diff --git a/src/lib/test_merchant_api_twisted.conf 
b/src/lib/test_merchant_api_twisted.conf
index ea298df..3bd9cea 100644
--- a/src/lib/test_merchant_api_twisted.conf
+++ b/src/lib/test_merchant_api_twisted.conf
@@ -1,34 +1,5 @@
 # This file is in the public domain.
 
-#########################
-# Twister configuration #
-#########################
-
-[twister]
-# HTTP listen port for twister
-HTTP_PORT = 8888
-
-# HTTP Destination for twister.  The test-Webserver needs
-# to listen on the port used here.  Note: no trailing '/'!
-DESTINATION_BASE_URL = "http://localhost:8081";
-
-# Control port for TCP
-# PORT = 8889
-HOSTNAME = localhost
-ACCEPT_FROM = 127.0.0.1;
-ACCEPT_FROM6 = ::1;
-
-# Control port for UNIX
-UNIXPATH = /tmp/taler-service-twister.sock
-UNIX_MATCH_UID = NO
-UNIX_MATCH_GID = YES
-
-# Launching of twister by ARM
-# BINARY = taler-service-twister
-# AUTOSTART = NO
-# FORCESTART = NO
-
-#
 [PATHS]
 # Persistant data storage for the testcase
 TALER_TEST_HOME = test_merchant_api_home/
@@ -127,7 +98,6 @@ TIP_EXCHANGE = http://localhost:8088/
 TIP_RESERVE_PRIV_FILENAME = reserve_dkey.priv
 NAME = Test Tipping Merchant 2
 
-
 [merchant-instance-wireformat-tor]
 TEST_RESPONSE_FILE = ${TALER_CONFIG_HOME}/merchant/wire/test.json
 
@@ -163,7 +133,6 @@ BIC = GENODEF1SRL
 SALT = 17919252168512238964
 ADDRESS = "Garching"
 
-
 ##########################
 # Exchange configuration #
 ##########################
diff --git a/src/lib/testing_api_cmd_history.c 
b/src/lib/testing_api_cmd_history.c
index 3667d34..b9763cf 100644
--- a/src/lib/testing_api_cmd_history.c
+++ b/src/lib/testing_api_cmd_history.c
@@ -157,8 +157,18 @@ history_cb (void *cls,
   struct GNUNET_TIME_Absolute entry_timestamp;
 
   hs->ho = NULL;
-  if (hs->http_status != http_status)
-    TALER_TESTING_FAIL (hs->is);
+
+  /* 410 is a convenience status that is used to
+   * trigger the "unexpected response code" in the
+   * lib, that should then result in a 0 status code
+   * passed here to the callback. */
+  if (MHD_HTTP_GONE == hs->http_status)
+  {
+    if (0 != http_status)
+      TALER_TESTING_FAIL (hs->is);
+    
+    TALER_TESTING_interpreter_next (hs->is);
+  }
 
   nresult = json_array_size (json);
   if (hs->nresult != nresult)
diff --git a/src/lib/testing_api_helpers.c b/src/lib/testing_api_helpers.c
index e445856..bca193c 100644
--- a/src/lib/testing_api_helpers.c
+++ b/src/lib/testing_api_helpers.c
@@ -59,7 +59,7 @@ TALER_TESTING_run_merchant (const char *config_filename)
 
   /* give child time to start and bind against the socket */
   fprintf (stderr,
-           "Waiting for `taler-merchant-httpd' to be ready");
+           "Waiting for `taler-merchant-httpd' to be ready\n");
   iter = 0;
   do
     {
@@ -74,7 +74,7 @@ TALER_TESTING_run_merchant (const char *config_filename)
        GNUNET_OS_process_destroy (merchant_proc);
        MERCHANT_FAIL ();
       }
-      fprintf (stderr, ".");
+      fprintf (stderr, ".\n");
       sleep (1);
       iter++;
     }

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



reply via email to

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