debian experimental exim-daemon-heavy config
[exim.git] / test / scripts / 2620-Postgresql / 2620
1 # pgsql lookups
2 # The pgsql-devel (or equivalent) package will be need for Exim to build, and
3 # the postgresql-server (or equivalent) package for this test to run.
4 #
5 # first, populate a DB to test against
6 sudo rm -fr DIR/pgsql
7 echo Starting DB server
8 perl
9 system 'DIR/bin.sys/initdb -D DIR/pgsql/data';
10 ****
11 sudo rm test-stdout
12 background
13 DIR/bin.sys/postgres -D DIR/pgsql/data -p PORT_N -k DIR/pgsql
14 ****
15 sleep 1
16 echo Waiting for DB server
17 perl
18 system 'DIR/bin.sys/pg_ctl -w -D DIR/pgsql/data status';
19 system 'createdb -h localhost -p PORT_N test';
20 system 'psql -h localhost -p PORT_N -d test \
21 -c "CREATE TABLE them ( name text, id text ); \
22 INSERT INTO them VALUES ( \'Philip Hazel\', \'ph10\' ); \
23 INSERT INTO them VALUES ( \'Aristotle\', \'aaaa\' ); \
24 INSERT INTO them VALUES ( \'\', \'nothing\' ); \
25 INSERT INTO them VALUES ( \'\"stquot\', \'quote2\' ); \
26 INSERT INTO them VALUES ( \'before\' || CHR(13) || CHR(10) || \'after\', \'newline\' ); \
27 INSERT INTO them VALUES ( \'x\' || CHR(9) || \'x\', \'tab\' ); \
28 INSERT INTO them VALUES ( CHR(39) || \'stquot\', \'quote1\' );" \
29 ';
30 ****
31 echo Populated DB server
32 #
33 # now, the tests
34 exim -d-all+lookup -be
35 ${lookup pgsql {select name from them where id='ph10';}}
36 ${lookup pgsql {select name from them where id='ph10';}}
37 ${lookup pgsql {select name from them where id='xxxx';}}
38 ${lookup pgsql {select name from them where id='nothing';}}
39 ${lookup pgsql {select id,name from them where id='nothing';}}
40 ${lookup pgsql {delete from them where id='nonexist';}}
41 ${lookup pgsql {select * from them where id='quote2';}}
42 ${lookup pgsql {select * from them where id='newline';}}
43 ${lookup pgsql {select * from them where id='tab';}}
44 ${lookup pgsql {select * from them where name='${quote_pgsql:'stquot}';}}
45 ${lookup pgsql {servers=x:localhost; select name from them where id='ph10';}}
46 ${lookup pgsql {servers=localhost::PORT_N:x; select name from them where id='ph10';}}
47 ${lookup pgsql {servers=localhost::PORT_N/test/CALLER/:x; select name from them where id='ph10';}}
48 ${lookup pgsql {servers=(DIR/pgsql/.s.PGSQL.PORT_N)/test/CALLER/:x; select name from them where id='ph10';}}
49 x
50 ${lookup pgsql {SELECT name FROM them WHERE id IN ('ph10', 'aaaa');}}
51 ${lookup pgsql {SELECT * FROM them WHERE id IN ('ph10', 'aaaa');}}
52 ${lookup pgsql {delete from them where id='aaaa'}}
53 ****
54 exim -d -bh 10.0.0.0
55 mail from:<a@b>
56 rcpt to:<c@d>
57 rcpt to:<c@d>
58 quit
59 ****
60 exim -odi -d CALLER
61 Test message
62 .
63 ****
64 exim -DSERVERS=\(DIR/pgsql/.s.PGSQL.PORT_N\)/test/CALLER/ -d-all+lookup -be
65 ${lookup pgsql {select name from them where id='ph10';}}
66 ****
67 #
68 perl
69 system 'DIR/bin.sys/pg_ctl stop -D DIR/pgsql/data -m immediate';
70 ****
71 sleep 2
72 killdaemon
73 sudo rm -fr DIR/pgsql