Fix up the docker tests

This commit is contained in:
Derry Hamilton 2019-07-12 13:03:23 +01:00
parent e71832f57a
commit f669b1af9d
4 changed files with 81 additions and 3 deletions

View file

@ -5,13 +5,13 @@
<blockSize>1000</blockSize> <blockSize>1000</blockSize>
<pollTimeout>500</pollTimeout> <pollTimeout>500</pollTimeout>
<source> <source>
<dsn>jdbc:postgresql://localhost:5432/test</dsn> <dsn>jdbc:postgresql://testdb:5432/test</dsn>
<username>test</username> <username>test</username>
<password>test</password> <password>test</password>
<networkTimeout>600000</networkTimeout> <networkTimeout>600000</networkTimeout>
</source> </source>
<dest> <dest>
<dsn>jdbc:postgresql://localhost:5432/test</dsn> <dsn>jdbc:postgresql://testdb:5432/test</dsn>
<username>test</username> <username>test</username>
<password>test</password> <password>test</password>
</dest> </dest>
@ -49,10 +49,43 @@
OR dest.test_ts = EXCLUDED.test_ts OR dest.test_ts = EXCLUDED.test_ts
</insert> </insert>
</job> </job>
<job>
<name>test upsert</name>
<key>select -1 as key</key>
<select>
select
id,
test_int,
test_text,
test_ts
from
public.source where id > ?::bigint</select>
<insert>
insert into public.dest(
id,
test_int,
test_text,
test_ts
)values(
?::bigint,
?::integer,
?::text,
?::timestamp with time zone
)ON CONFLICT(id) DO UPDATE
set
test_int = EXCLUDED.test_int,
test_text = EXCLUDED.test_text,
test_ts = EXCLUDED.test_ts
WHERE
dest.test_int IS DISTINCT FROM EXCLUDED.test_int
OR dest.test_text IS DISTINCT FROM EXCLUDED.test_text
OR dest.test_ts IS DISTINCT FROM EXCLUDED.test_ts
</insert>
</job>
<job> <job>
<name>denormalise</name> <name>denormalise</name>
<key>select -1 as key</key> <key>select -1 as key</key>
<select>select person_id,fname,lname from normalised_personalia p join normalised_first_names f using(fid) join normalised_last_names l using(lid);</select> <select>select person_id,fname,lname from normalised_personalia p join normalised_first_names f using(fid) join normalised_last_names l using(lid) where ?::integer is not null;</select>
<insert> <insert>
INSERT INTO denormalised_personalia(person_id,fname,lname) INSERT INTO denormalised_personalia(person_id,fname,lname)
values(?::integer,?::text,?::text) values(?::integer,?::text,?::text)

View file

@ -8,5 +8,14 @@ until PGPASSWORD=test psql -h "testdb" -U "test" -c 'SELECT 1 FROM public.contai
sleep 1 sleep 1
done done
>&2 echo "Postgres is up - Waiting for the reboot"
sleep 3 # Wait for the Postgres reboot at the end of setup
until PGPASSWORD=test psql -h "testdb" -U "test" -c 'SELECT 1 FROM public.container_ready' postgres; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
>&2 echo "Postgres is up - executing command" >&2 echo "Postgres is up - executing command"
exec $cmd exec $cmd

View file

@ -44,6 +44,9 @@ CREATE TABLE denormalised_personalia(
lname text lname text
); );
GRANT SELECT ON ALL TABLES IN SCHEMA public TO test;
GRANT SELECT,INSERT,UPDATE ON denormalised_personalia TO test;
\c postgres \c postgres
CREATE TABLE public.container_ready AS SELECT 1 FROM(VALUES(1)) AS a(a); CREATE TABLE public.container_ready AS SELECT 1 FROM(VALUES(1)) AS a(a);

View file

@ -49,6 +49,39 @@
OR dest.test_ts = EXCLUDED.test_ts OR dest.test_ts = EXCLUDED.test_ts
</insert> </insert>
</job> </job>
<job>
<name>test upsert</name>
<key>select -1 as key</key>
<select>
select
id,
test_int,
test_text,
test_ts
from
public.source where id > ?::bigint</select>
<insert>
insert into public.dest(
id,
test_int,
test_text,
test_ts
)values(
?::bigint,
?::integer,
?::text,
?::timestamp with time zone
)ON CONFLICT(id) DO UPDATE
set
test_int = EXCLUDED.test_int,
test_text = EXCLUDED.test_text,
test_ts = EXCLUDED.test_ts
WHERE
dest.test_int IS DISTINCT FROM EXCLUDED.test_int
OR dest.test_text IS DISTINCT FROM EXCLUDED.test_text
OR dest.test_ts IS DISTINCT FROM EXCLUDED.test_ts
</insert>
</job>
<job> <job>
<name>denormalise</name> <name>denormalise</name>
<key>select -1 as key</key> <key>select -1 as key</key>