From 0087ad1e0824b4b1c49ce1468bfbb2e492ac7992 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 29 Oct 2014 10:22:36 -0400 Subject: Add test to check a real database (pgsql) works Change config template to e able to set up ipsilon with an extrenal database. For the easy install the database server must have 3 datbases configured, and named exactly: admincondif, userprefs, transactions If different names are required manual instalation will be necessary. Database URLs (including credentials) can be set using the new option named --database-url Signed-off-by: Simo Sorce Reviewed-by: Patrick Uiterwijk --- tests/helpers/common.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/helpers') diff --git a/tests/helpers/common.py b/tests/helpers/common.py index 00e2a35..a0adfae 100755 --- a/tests/helpers/common.py +++ b/tests/helpers/common.py @@ -117,11 +117,31 @@ class IpsilonTestBase(object): return http_conf_file + def setup_pgdb(self, datadir, env): + cmd = ['/usr/bin/pg_ctl', 'initdb', '-D', datadir] + subprocess.check_call(cmd, env=env) + auth = 'host all all 127.0.0.1/24 trust\n' + filename = os.path.join(datadir, 'pg_hba.conf') + with open(filename, 'a') as f: + f.write(auth) + def start_http_server(self, conf, env): p = subprocess.Popen(['/usr/sbin/httpd', '-DFOREGROUND', '-f', conf], env=env, preexec_fn=os.setsid) self.processes.append(p) + def start_pgdb_server(self, datadir, rundir, log, addr, port, env): + p = subprocess.Popen(['/usr/bin/pg_ctl', 'start', '-D', datadir, '-o', + '-c unix_socket_directories=%s -c port=%s -c \ + listen_addresses=%s' % (rundir, port, addr), + '-l', log, '-w'], + env=env, preexec_fn=os.setsid) + self.processes.append(p) + p.wait() + for d in ['adminconfig', 'userprefs', 'transactions']: + cmd = ['/usr/bin/createdb', '-h', addr, '-p', port, d] + subprocess.check_call(cmd, env=env) + def wait(self): for p in self.processes: os.killpg(p.pid, signal.SIGTERM) -- cgit