gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated (e3e3107 -> 4a06127)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (e3e3107 -> 4a06127)
Date: Tue, 03 Jul 2018 12:07:39 +0200

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

marcello pushed a change to branch master
in repository merchant.

    from e3e3107  kill FIXME
     new 83359f4  renaming generator into taler-merchant-benchmark
     new 68e319e  fix previous renaming
     new 2b3b83d  Distinguish case based on sub-command given.
     new 4a06127  detect --help option under sub-command.

The 4 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/merchant-tools/Makefile.am                     |  29 +--
 ...erate-payments.c => taler-merchant-benchmark.c} | 203 +++++++++++++++++++--
 .../taler-merchant-generate-payments-alt.c         |   9 +-
 3 files changed, 197 insertions(+), 44 deletions(-)
 rename src/merchant-tools/{taler-merchant-generate-payments.c => 
taler-merchant-benchmark.c} (74%)

diff --git a/src/merchant-tools/Makefile.am b/src/merchant-tools/Makefile.am
index 24337c8..bf52f50 100644
--- a/src/merchant-tools/Makefile.am
+++ b/src/merchant-tools/Makefile.am
@@ -3,8 +3,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include
 
 bin_PROGRAMS = \
   taler-merchant-dbinit \
-  taler-merchant-generate-payments \
-  taler-merchant-generate-payments-alt
+  taler-merchant-benchmark
 
 taler_merchant_dbinit_SOURCES = \
   taler-merchant-dbinit.c
@@ -16,30 +15,10 @@ taler_merchant_dbinit_LDADD = \
   -ltalerutil \
   -ltalerpq
 
-taler_merchant_generate_payments_alt_SOURCES = \
-  taler-merchant-generate-payments-alt.c
+taler_merchant_benchmark_SOURCES = \
+  taler-merchant-benchmark.c
 
-taler_merchant_generate_payments_alt_LDADD = \
-  $(top_srcdir)/src/backenddb/libtalermerchantdb.la \
-  $(top_srcdir)/src/lib/libtalermerchant.la \
-  $(top_srcdir)/src/lib/libtalermerchanttesting.la \
-  $(LIBGCRYPT_LIBS) \
-  -ltalertesting \
-  -ltalerfakebank \
-  -ltalerbank \
-  -ltalerbanktesting \
-  -ltalerexchange \
-  -ltalerjson \
-  -ltalerutil \
-  -lgnunetjson \
-  -lgnunetcurl \
-  -lgnunetutil \
-  -ljansson
-
-taler_merchant_generate_payments_SOURCES = \
-  taler-merchant-generate-payments.c
-
-taler_merchant_generate_payments_LDADD = \
+taler_merchant_benchmark_LDADD = \
   $(top_srcdir)/src/backenddb/libtalermerchantdb.la \
   $(top_srcdir)/src/lib/libtalermerchant.la \
   $(top_srcdir)/src/lib/libtalermerchanttesting.la \
diff --git a/src/merchant-tools/taler-merchant-generate-payments.c 
b/src/merchant-tools/taler-merchant-benchmark.c
similarity index 74%
rename from src/merchant-tools/taler-merchant-generate-payments.c
rename to src/merchant-tools/taler-merchant-benchmark.c
index 93cd132..35818f9 100644
--- a/src/merchant-tools/taler-merchant-generate-payments.c
+++ b/src/merchant-tools/taler-merchant-benchmark.c
@@ -69,6 +69,44 @@ enum PaymentGeneratorError {
      USER_LOGIN_NAME, USER_LOGIN_PASS, EXCHANGE_URL)
 
 /**
+ * Help string shown if NO subcommand is given on command line.
+ */
+int root_help;
+
+/**
+ * Witnesses if the ordinary cases payment suite should be run.
+ */
+unsigned int ordinary;
+
+/**
+ * Witnesses if the corner cases payment suite should be run.
+ */
+unsigned int corner;
+
+/**
+ * Root help string.
+ */
+char *root_help_str = \
+  "taler-merchant-benchmark\nPopulates production database"
+  " with fake payments.\nMust be used with either 'ordinary'"
+  " or 'corner' sub-commands.\n";
+
+/**
+ * Alternative non default instance.
+ */
+static char *alt_instance;
+
+/**
+ * How many unaggregated payments we want to generate.
+ */
+static unsigned int unaggregated_number = 1;
+
+/**
+ * How many payments that use two coins we want to generate.
+ */
+static unsigned int twocoins_number = 1;
+
+/**
  * Exit code.
  */
 static unsigned int result;
@@ -281,7 +319,7 @@ run (void *cls,
     (GNUNET_OK == GNUNET_CURL_append_header
       (is->ctx, APIKEY_SANDBOX));
 
-  struct TALER_TESTING_Command commands[] = {
+  struct TALER_TESTING_Command corner_commands[] = {
 
     CMD_TRANSFER_TO_EXCHANGE
       ("create-reserve-1",
@@ -380,8 +418,16 @@ run (void *cls,
     TALER_TESTING_cmd_end ()
   };
 
-  TALER_TESTING_run (is,
-                     commands);
+  if (GNUNET_OK == ordinary)
+    TALER_TESTING_run (is,
+                       ordinary_commands);
+
+  if (GNUNET_OK == corner)
+    TALER_TESTING_run (is,
+                       corner_commands);
+  TALER_LOG_ERROR ("Neither ordinary or corner payments"
+                   " were specified to be run.\n");
+  return 1;
 }
 
 /**
@@ -413,7 +459,12 @@ main (int argc,
   default_config_file = GNUNET_OS_project_data_get
     ()->user_config_file;
 
-  struct GNUNET_GETOPT_CommandLineOption options[] = {
+  loglev = NULL;
+  GNUNET_log_setup ("taler-merchant-benchmark",
+                    loglev,
+                    logfile);
+
+  struct GNUNET_GETOPT_CommandLineOption root[] = {
 
     GNUNET_GETOPT_option_cfgfile
       (&cfg_filename),
@@ -421,8 +472,93 @@ main (int argc,
     GNUNET_GETOPT_option_version
       (PACKAGE_VERSION " " VCS_VERSION),
 
+    GNUNET_GETOPT_option_flag
+      ('h',
+       "help",
+       NULL,
+       &root_help),
+
+    GNUNET_GETOPT_OPTION_END
+  };
+
+  struct GNUNET_GETOPT_CommandLineOption corner_options[] = {
+
     GNUNET_GETOPT_option_help
-      ("Generate Taler payments to populate the database(s)"),
+      ("Populate databases with corner case payments"),
+
+    GNUNET_GETOPT_option_loglevel
+      (&loglev),
+
+    GNUNET_GETOPT_option_uint
+      ('u',
+       "unaggregated-number",
+       "UN",
+       "will generate UN unaggregated payments, defaults to 1",
+       &unaggregated_number),
+
+    GNUNET_GETOPT_option_uint
+      ('t',
+       "two-coins",
+       "TC",
+       "will perform TC 2-coins payments, defaults to 1",
+       &twocoins_number),
+
+    /**
+     * NOTE: useful when the setup serves merchant
+     * backends via unix domain sockets, since there
+     * is no way - yet? - to get the merchant base url.
+     * Clearly, we could introduce a merchant_base_url
+     * value into the configuration.
+     */
+    GNUNET_GETOPT_option_string
+      ('m',
+       "merchant-url",
+       "MU",
+       "merchant base url, mandatory",
+       &merchant_url),
+
+    GNUNET_GETOPT_option_string
+      ('i',
+       "alt-instance",
+       "AI",
+       "alternative (non default) instance,"
+       " used to provide fresh wire details to"
+       " make unaggregated transactions stay so."
+       " Note, this instance will be given far"
+       " future wire deadline, and so it should"
+       " never author now-deadlined transactions,"
+       " as they would get those far future ones"
+       " aggregated too.",
+       &alt_instance),
+
+    GNUNET_GETOPT_option_string
+      ('b',
+       "bank-url",
+       "BU",
+       "bank base url, mandatory",
+       &bank_url),
+
+    GNUNET_GETOPT_option_string
+      ('l',
+       "logfile",
+       "LF",
+       "will log to file LF",
+       &logfile),
+
+    GNUNET_GETOPT_OPTION_END
+  };
+
+  struct GNUNET_GETOPT_CommandLineOption ordinary_options[] = {
+
+    GNUNET_GETOPT_option_cfgfile
+      (&cfg_filename),
+
+    GNUNET_GETOPT_option_version
+      (PACKAGE_VERSION " " VCS_VERSION),
+
+    GNUNET_GETOPT_option_help
+      ("Generate Taler ordinary payments"
+       " to populate the databases"),
 
     GNUNET_GETOPT_option_loglevel
       (&loglev),
@@ -473,22 +609,63 @@ main (int argc,
   };
 
   result = GNUNET_GETOPT_run
-    ("taler-merchant-generate-payments",
-     options,
+    ("taler-merchant-benchmark",
+     root,
      argc,
      argv);
 
+  GNUNET_assert (GNUNET_SYSERR != result);
+
+  if (GNUNET_OK == root_help && (NULL == argv[result]))
+  {
+    fprintf (stderr, root_help_str); 
+    return 0; 
+  }
+
   if (GNUNET_NO == result)
   {
-    /* --help or --version were given, just return.  */ 
+    /* --version was given, just return.  */ 
     return 0;
   }
 
-  GNUNET_assert (GNUNET_SYSERR != result);
-  loglev = NULL;
-  GNUNET_log_setup ("taler-merchant-generate-payments",
-                    loglev,
-                    logfile);
+  /* extract subcommand.  */
+  if (0 == strcmp ("ordinary", argv[result]))
+  {
+    TALER_LOG_DEBUG ("'ordinary' subcommand found\n"); 
+
+    ordinary = GNUNET_OK;
+    result = GNUNET_GETOPT_run
+      ("taler-merchant-benchmark",
+       ordinary_options,
+       argc,
+       argv);
+    GNUNET_assert (GNUNET_SYSERR != result);
+    if (GNUNET_NO == result)
+      /* --help was given.  */
+      return 0;
+  }
+  else if (0 == strcmp ("corner", argv[result]))
+  {
+    TALER_LOG_DEBUG ("'corner' subcommand found\n"); 
+
+    corner = GNUNET_OK;
+    result = GNUNET_GETOPT_run
+      ("taler-merchant-benchmark",
+       corner_options,
+       argc,
+       argv);
+    GNUNET_assert (GNUNET_SYSERR != result);
+    if (GNUNET_NO == result)
+      /* --help was given.  */
+      return 0;
+  }
+  else
+  {
+    TALER_LOG_ERROR ("Unknown subcommand given.\n"); 
+    return 1;  
+  }
+
+  return 0;
 
   if (NULL == cfg_filename)
     cfg_filename = (char *) default_config_file;
diff --git a/src/merchant-tools/taler-merchant-generate-payments-alt.c 
b/src/merchant-tools/taler-merchant-generate-payments-alt.c
index 0ff9976..d8184a8 100644
--- a/src/merchant-tools/taler-merchant-generate-payments-alt.c
+++ b/src/merchant-tools/taler-merchant-generate-payments-alt.c
@@ -451,15 +451,12 @@ main (int argc,
 
   result = GNUNET_GETOPT_run
     ("taler-merchant-generate-payments-alt",
-     options,
+     root,
      argc,
      argv);
 
-  if (GNUNET_NO == result)
-  {
-    /* --help or --version were given, just return.  */ 
-    return 0;
-  }
+
+  return 0;
 
   GNUNET_assert (GNUNET_SYSERR != result);
   loglev = NULL;

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



reply via email to

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