summaryrefslogtreecommitdiffstats
path: root/tests/helpers
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2014-10-29 10:22:36 -0400
committerPatrick Uiterwijk <puiterwijk@redhat.com>2014-11-12 23:46:47 +0100
commit0087ad1e0824b4b1c49ce1468bfbb2e492ac7992 (patch)
tree3f66e46800ed4e4735a1094174e9ca9952e7a1a9 /tests/helpers
parent0167e69a38734586c1a1f45786313efb3b5f73c3 (diff)
downloadipsilon-0087ad1e0824b4b1c49ce1468bfbb2e492ac7992.tar.gz
ipsilon-0087ad1e0824b4b1c49ce1468bfbb2e492ac7992.tar.xz
ipsilon-0087ad1e0824b4b1c49ce1468bfbb2e492ac7992.zip
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 <simo@redhat.com> Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Diffstat (limited to 'tests/helpers')
-rwxr-xr-xtests/helpers/common.py20
1 files changed, 20 insertions, 0 deletions
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)