From 0bfb5b25091a1cbdd9911ae124ae6da35cd2b916 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 13 Jan 2017 14:44:51 +0100 Subject: Add option to initialized db, fixes 4858 Additionally remove the TESTRUN option, since the name is confusing and doesn't match the original semantics (temp tables). Test cases should now invoke the exchange httpd with the "-i" option. --- src/exchange/exchange.conf | 3 --- src/exchange/taler-exchange-httpd.c | 15 ++++++++++----- src/exchange/test_taler_exchange_httpd.conf | 5 ----- src/exchange/test_taler_exchange_httpd.sh | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) (limited to 'src/exchange') diff --git a/src/exchange/exchange.conf b/src/exchange/exchange.conf index 333e9a58a..39151ea67 100644 --- a/src/exchange/exchange.conf +++ b/src/exchange/exchange.conf @@ -17,9 +17,6 @@ KEYDIR = ${TALER_DATA_HOME}/exchange/live-keys/ # How to access our database DB = postgres -# Is this is a testcase, use transient DB actions? -# TESTRUN = YES - # Where do we store the offline master private key of the exchange? MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index d6dfb0358..f1661b003 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -100,6 +100,11 @@ static struct MHD_Daemon *mhd_admin; */ static int no_admin; +/** + * Initialize the database by creating tables and indices. + */ +static int init_db; + /** * Port to run the daemon on. */ @@ -656,13 +661,10 @@ exchange_serve_process_config () TEH_VALIDATION_done (); return GNUNET_SYSERR; } - if (GNUNET_YES == - GNUNET_CONFIGURATION_get_value_yesno (cfg, - "exchange", - "TESTRUN")) + if (0 != init_db) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Running in TEST mode! Database contents will not persist!\n"); + "Ensuring that tables and indices are created!\n"); TEH_plugin->create_tables (TEH_plugin->cls); } @@ -938,6 +940,9 @@ main (int argc, {'D', "disable-admin", NULL, "do not run the /admin-HTTP server", 0, &GNUNET_GETOPT_set_one, &no_admin}, + {'i', "init-db", NULL, + "create database tables and indicies if necessary", 0, + &GNUNET_GETOPT_set_one, &init_db}, {'t', "timeout", "SECONDS", "after how long do connections timeout by default (in seconds)", 1, &GNUNET_GETOPT_set_uint, &connection_timeout}, diff --git a/src/exchange/test_taler_exchange_httpd.conf b/src/exchange/test_taler_exchange_httpd.conf index 19f448f3b..e1c30615b 100644 --- a/src/exchange/test_taler_exchange_httpd.conf +++ b/src/exchange/test_taler_exchange_httpd.conf @@ -23,11 +23,6 @@ MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG # How to access our database DB = postgres -# Is this is a testcase, use transient DB actions? -TESTRUN = YES - - - [exchangedb-postgres] DB_CONN_STR = "postgres:///talercheck" diff --git a/src/exchange/test_taler_exchange_httpd.sh b/src/exchange/test_taler_exchange_httpd.sh index 6e51e06c1..7cd2e2762 100755 --- a/src/exchange/test_taler_exchange_httpd.sh +++ b/src/exchange/test_taler_exchange_httpd.sh @@ -27,7 +27,7 @@ unset XDG_CONFIG_HOME # Setup keys. taler-exchange-keyup -c test_taler_exchange_httpd.conf # Run Exchange HTTPD (in background) -taler-exchange-httpd -c test_taler_exchange_httpd.conf & +taler-exchange-httpd -c test_taler_exchange_httpd.conf -i & # Give HTTP time to start sleep 5 # Finally run test... -- cgit v1.2.3