This commit is contained in:
Christian Grothoff 2016-05-02 01:30:13 +02:00
parent d1c83c5dda
commit d34c6401b4
6 changed files with 82 additions and 63 deletions

View File

@ -56,7 +56,7 @@ libtalerexchangedb_la_LDFLAGS = \
check_PROGRAMS = \ check_PROGRAMS = \
test-exchangedb-deposits \ test-exchangedb-deposits-postgres \
test-exchangedb-keyio \ test-exchangedb-keyio \
test-exchangedb-postgres \ test-exchangedb-postgres \
test-perf-taler-exchangedb \ test-perf-taler-exchangedb \
@ -65,17 +65,18 @@ check_PROGRAMS = \
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
TESTS = \ TESTS = \
test-exchangedb-postgres \ test-exchangedb-postgres \
test-perf-taler-exchangedb test-perf-taler-exchangedb \
test-exchangedb-keyio \
test-exchangedb-deposits-postgres
test_exchangedb_deposits_SOURCES = \ test_exchangedb_deposits_postgres_SOURCES = \
test_exchangedb_deposits.c test_exchangedb_deposits.c
test_exchangedb_deposits_LDADD = \ test_exchangedb_deposits_postgres_LDADD = \
libtalerexchangedb.la \ libtalerexchangedb.la \
$(top_srcdir)/src/util/libtalerutil.la \ $(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \ $(top_srcdir)/src/pq/libtalerpq.la \
-lgnunetutil \ -lgnunetutil \
-ljansson \ -ljansson
-lpq
test_exchangedb_keyio_SOURCES = \ test_exchangedb_keyio_SOURCES = \
test_exchangedb_keyio.c test_exchangedb_keyio.c

View File

@ -1833,7 +1833,8 @@ PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin,
* @param init the commands to use for the database initialisation, * @param init the commands to use for the database initialisation,
* if #NULL the standard initialization is used * if #NULL the standard initialization is used
* @param benchmark the commands for the benchmark * @param benchmark the commands for the benchmark
* @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure, #GNUNET_NO
* if we failed to init the database
*/ */
int int
PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
@ -1940,7 +1941,7 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error connectiong to the database\n"); "Error connectiong to the database\n");
return ret; return GNUNET_NO;
} }
ret = plugin->create_tables (plugin->cls, ret = plugin->create_tables (plugin->cls,
GNUNET_YES); GNUNET_YES);
@ -1948,7 +1949,7 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error while creating the database architecture\n"); "Error while creating the database architecture\n");
return ret; return GNUNET_NO;
} }
/* /*
* Running the initialization * Running the initialization

View File

@ -1283,7 +1283,8 @@ struct PERF_TALER_EXCHANGEDB_Cmd
* @param init the commands to use for the database initialisation, * @param init the commands to use for the database initialisation,
* if #NULL the standard initialization is used * if #NULL the standard initialization is used
* @param benchmark the commands for the benchmark * @param benchmark the commands for the benchmark
* @return GNUNET_OK upon success; GNUNET_SYSERR upon failure * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure,
* #GNUNET_NO if we failed to init the database
*/ */
int int
PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
@ -1300,8 +1301,7 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
* @param cmd the commands to run * @param cmd the commands to run
*/ */
int int
PERF_TALER_EXCHANGEDB_interpret( PERF_TALER_EXCHANGEDB_interpret(struct TALER_EXCHANGEDB_Plugin *db_plugin,
struct TALER_EXCHANGEDB_Plugin *db_plugin,
struct PERF_TALER_EXCHANGEDB_Cmd cmd[]); struct PERF_TALER_EXCHANGEDB_Cmd cmd[]);

View File

@ -172,8 +172,9 @@ static struct TALER_Amount fee_refresh;
static struct TALER_Amount fee_refund; static struct TALER_Amount fee_refund;
static struct TALER_Amount amount_with_fee; static struct TALER_Amount amount_with_fee;
static void static void
free_refresh_commit_coins_array(struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins, free_refresh_commit_coins_array (struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins,
unsigned int size) unsigned int size)
{ {
unsigned int cnt; unsigned int cnt;
@ -282,6 +283,7 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session,
return ret; return ret;
} }
/** /**
* Function to test melting of coins as part of a refresh session * Function to test melting of coins as part of a refresh session
* *
@ -658,14 +660,14 @@ run (void *cls)
if (NULL == if (NULL ==
(plugin = TALER_EXCHANGEDB_plugin_load (cfg))) (plugin = TALER_EXCHANGEDB_plugin_load (cfg)))
{ {
result = 1; result = 77;
return; return;
} }
if (GNUNET_OK != if (GNUNET_OK !=
plugin->create_tables (plugin->cls, plugin->create_tables (plugin->cls,
GNUNET_YES)) GNUNET_YES))
{ {
result = 2; result = 77;
goto drop; goto drop;
} }
if (NULL == if (NULL ==

View File

@ -19,7 +19,6 @@
* @author Sree Harsha Totakura <sreeharsha@totakura.in> * @author Sree Harsha Totakura <sreeharsha@totakura.in>
*/ */
#include "platform.h" #include "platform.h"
#include <libpq-fe.h>
#include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_util_lib.h>
#include "taler_pq_lib.h" #include "taler_pq_lib.h"
#include "taler_exchangedb_lib.h" #include "taler_exchangedb_lib.h"
@ -43,11 +42,6 @@
} while (0) } while (0)
/**
* Should we not interact with a temporary table?
*/
static int persistent;
/** /**
* Testcase result * Testcase result
*/ */
@ -58,20 +52,16 @@ static int result;
*/ */
static struct TALER_EXCHANGEDB_Plugin *plugin; static struct TALER_EXCHANGEDB_Plugin *plugin;
/** /**
* Main function that will be run by the scheduler. * Main function that will be run by the scheduler.
* *
* @param cls closure * @param cls configuration
* @param args remaining command-line arguments
* @param cfgfile name of the configuration file used (for saving, can be NULL!)
* @param cfg configuration
*/ */
static void static void
run (void *cls, run (void *cls)
char *const *args,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{ {
const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
static const char wire[] = "{" static const char wire[] = "{"
"\"type\":\"SEPA\"," "\"type\":\"SEPA\","
"\"IBAN\":\"DE67830654080004822650\"," "\"IBAN\":\"DE67830654080004822650\","
@ -84,11 +74,15 @@ run (void *cls,
deposit = NULL; deposit = NULL;
EXITIF (NULL == (plugin = TALER_EXCHANGEDB_plugin_load (cfg))); EXITIF (NULL == (plugin = TALER_EXCHANGEDB_plugin_load (cfg)));
EXITIF (GNUNET_OK != if (GNUNET_OK !=
plugin->create_tables (plugin->cls, plugin->create_tables (plugin->cls,
! persistent)); GNUNET_YES))
{
result = 77;
goto EXITIF_exit;
}
session = plugin->get_session (plugin->cls, session = plugin->get_session (plugin->cls,
! persistent); GNUNET_YES);
EXITIF (NULL == session); EXITIF (NULL == session);
deposit = GNUNET_malloc (sizeof (struct TALER_EXCHANGEDB_Deposit) + sizeof (wire)); deposit = GNUNET_malloc (sizeof (struct TALER_EXCHANGEDB_Deposit) + sizeof (wire));
/* Makeup a random coin public key */ /* Makeup a random coin public key */
@ -117,7 +111,6 @@ run (void *cls,
session, session,
deposit)); deposit));
result = GNUNET_OK; result = GNUNET_OK;
EXITIF_exit: EXITIF_exit:
GNUNET_free_non_null (deposit); GNUNET_free_non_null (deposit);
if (NULL != plugin) if (NULL != plugin)
@ -132,21 +125,38 @@ int
main (int argc, main (int argc,
char *const argv[]) char *const argv[])
{ {
static const struct GNUNET_GETOPT_CommandLineOption options[] = { const char *plugin_name;
{'T', "persist", NULL, char *config_filename;
gettext_noop ("Use a persistent database table instead of a temporary one"), char *testname;
GNUNET_NO, &GNUNET_GETOPT_set_one, &persistent}, struct GNUNET_CONFIGURATION_Handle *cfg;
GNUNET_GETOPT_OPTION_END
};
result = -1;
persistent = GNUNET_NO; if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
result = GNUNET_SYSERR; {
GNUNET_break (0);
return -1;
}
GNUNET_log_setup (argv[0],
"WARNING",
NULL);
plugin_name++;
(void) GNUNET_asprintf (&testname,
"test-exchange-db-%s", plugin_name);
(void) GNUNET_asprintf (&config_filename,
"%s.conf", testname);
cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, argv, GNUNET_CONFIGURATION_parse (cfg,
"test-exchange-deposits", config_filename))
"testcase for exchange deposits", {
options, &run, NULL)) GNUNET_break (0);
return 3; GNUNET_free (config_filename);
return (GNUNET_OK == result) ? 0 : 1; GNUNET_free (testname);
return 2;
}
GNUNET_SCHEDULER_run (&run, cfg);
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free (config_filename);
GNUNET_free (testname);
return result;
} }

View File

@ -35,6 +35,7 @@
#define NB_WITHDRAW_INIT 1 #define NB_WITHDRAW_INIT 1
#define NB_WITHDRAW_SAVE 1 #define NB_WITHDRAW_SAVE 1
/** /**
* Allocate, copies and free all the data used in the interpreter * Allocate, copies and free all the data used in the interpreter
* Used to check for memory leaks * Used to check for memory leaks
@ -42,7 +43,8 @@
static void static void
test_allocate () test_allocate ()
{ {
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki, *dki_copy; struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki_copy;
struct PERF_TALER_EXCHANGEDB_Reserve *reserve, *reserve_copy; struct PERF_TALER_EXCHANGEDB_Reserve *reserve, *reserve_copy;
struct PERF_TALER_EXCHANGEDB_Coin *coin, *coin_copy; struct PERF_TALER_EXCHANGEDB_Coin *coin, *coin_copy;
struct TALER_EXCHANGEDB_Deposit *deposit, *deposit_copy; struct TALER_EXCHANGEDB_Deposit *deposit, *deposit_copy;
@ -68,6 +70,7 @@ test_allocate ()
PERF_TALER_EXCHANGEDB_deposit_free (deposit_copy); PERF_TALER_EXCHANGEDB_deposit_free (deposit_copy);
} }
/** /**
* Runs the performances tests for the exchange database * Runs the performances tests for the exchange database
* and logs the results using Gauger * and logs the results using Gauger
@ -178,5 +181,7 @@ main (int argc, char ** argv)
benchmark); benchmark);
if (GNUNET_SYSERR == ret) if (GNUNET_SYSERR == ret)
return 1; return 1;
if (GNUNET_NO == ret)
return 77; /* testcase skipped */
return 0; return 0;
} }