Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8e729f5

Browse files
committed
2 parents c917e4d + c616219 commit 8e729f5

File tree

4 files changed

+75
-83
lines changed

4 files changed

+75
-83
lines changed

contrib/raftable/tests/Dockerfile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,25 @@ RUN apt-get update && apt-get install -y \
2626

2727
RUN mkdir /pg
2828
RUN chown postgres:postgres /pg
29-
3029
USER postgres
3130
WORKDIR /pg
31+
3232
ENV CFLAGS -O0
3333
RUN git clone https://github.com/postgrespro/postgres_cluster.git --depth 1
3434
WORKDIR /pg/postgres_cluster
35-
RUN ./configure --enable-cassert --enable-debug --prefix=/usr/local/
35+
RUN ./configure --enable-cassert --enable-debug --prefix=/pg/install
3636
RUN make -j 4
37-
38-
USER root
3937
RUN make install
4038
RUN cd /pg/postgres_cluster/contrib/pg_tsdtm && make install
4139
RUN cd /pg/postgres_cluster/contrib/raftable && make install
4240
RUN cd /pg/postgres_cluster/contrib/mmts && make install
4341
RUN cd /pg/postgres_cluster/contrib/postgres_fdw && make install
44-
RUN mkdir -p /var/lib/postgresql/data && chown -R postgres /var/lib/postgresql/data
45-
RUN mkdir -p /run/postgresql && chown -R postgres /run/postgresql
42+
4643

4744
USER postgres
48-
ENV PATH /usr/local/bin:$PATH
49-
ENV PGDATA /var/lib/postgresql/data
50-
VOLUME /var/lib/postgresql/data
45+
ENV PATH /pg/install/bin:$PATH
46+
ENV PGDATA /pg/data
47+
#VOLUME /pg/data
5148

5249
COPY docker-entrypoint.sh /
5350

contrib/raftable/tests/blockade.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ containers:
2929
ports:
3030
5434: 5432
3131

32+
network:
33+
driver: udn
3234

contrib/raftable/tests/docker-entrypoint.sh

Lines changed: 66 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,80 @@
11
#!/bin/bash
22
set -e
33

4-
# wtf is that?
5-
if [ "${1:0:1}" = '-' ]; then
6-
set -- postgres "$@"
7-
fi
4+
mkdir -p "$PGDATA"
5+
chmod 700 "$PGDATA"
6+
chown -R postgres "$PGDATA"
7+
8+
# look specifically for PG_VERSION, as it is expected in the DB dir
9+
if [ ! -s "$PGDATA/PG_VERSION" ]; then
10+
initdb
11+
12+
if [ "$POSTGRES_PASSWORD" ]; then
13+
pass="PASSWORD '$POSTGRES_PASSWORD'"
14+
authMethod=md5
15+
else
16+
pass=
17+
authMethod=trust
18+
fi
819

9-
if [ "$1" = 'postgres' ]; then
10-
mkdir -p "$PGDATA"
11-
chmod 700 "$PGDATA"
12-
chown -R postgres "$PGDATA"
13-
14-
# look specifically for PG_VERSION, as it is expected in the DB dir
15-
if [ ! -s "$PGDATA/PG_VERSION" ]; then
16-
initdb
17-
18-
if [ "$POSTGRES_PASSWORD" ]; then
19-
pass="PASSWORD '$POSTGRES_PASSWORD'"
20-
authMethod=md5
21-
else
22-
pass=
23-
authMethod=trust
24-
fi
25-
26-
{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA/pg_hba.conf"
27-
{ echo; echo "host replication all 0.0.0.0/0 $authMethod"; } >> "$PGDATA/pg_hba.conf"
28-
29-
############################################################################
30-
31-
# internal start of server in order to allow set-up using psql-client
32-
# does not listen on TCP/IP and waits until start finishes
33-
pg_ctl -D "$PGDATA" \
34-
-o "-c listen_addresses=''" \
35-
-w start
36-
37-
: ${POSTGRES_USER:=postgres}
38-
: ${POSTGRES_DB:=$POSTGRES_USER}
39-
export POSTGRES_USER POSTGRES_DB
40-
41-
psql=( psql -v ON_ERROR_STOP=1 )
42-
43-
if [ "$POSTGRES_DB" != 'postgres' ]; then
44-
"${psql[@]}" --username postgres <<-EOSQL
45-
CREATE DATABASE "$POSTGRES_DB" ;
46-
EOSQL
47-
echo
48-
fi
49-
50-
if [ "$POSTGRES_USER" = 'postgres' ]; then
51-
op='ALTER'
52-
else
53-
op='CREATE'
54-
fi
55-
"${psql[@]}" --username postgres <<-EOSQL
56-
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
57-
EOSQL
58-
echo
20+
{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA/pg_hba.conf"
21+
{ echo; echo "host replication all 0.0.0.0/0 $authMethod"; } >> "$PGDATA/pg_hba.conf"
5922

60-
############################################################################
61-
62-
RAFT_PEERS='1:172.18.0.2:6666, 2:172.18.0.4:6666, 3:172.18.0.3:6666'
23+
############################################################################
6324

64-
cat <<-EOF >> $PGDATA/postgresql.conf
65-
listen_addresses='*'
66-
max_prepared_transactions = 100
67-
synchronous_commit = off
68-
wal_level = logical
69-
max_worker_processes = 15
70-
max_replication_slots = 10
71-
max_wal_senders = 10
72-
shared_preload_libraries = 'raftable'
73-
raftable.id = $NODE_ID
74-
raftable.peers = '$RAFT_PEERS'
75-
EOF
25+
# internal start of server in order to allow set-up using psql-client
26+
# does not listen on TCP/IP and waits until start finishes
27+
pg_ctl -D "$PGDATA" \
28+
-o "-c listen_addresses=''" \
29+
-w start
7630

77-
tail -n 20 $PGDATA/postgresql.conf
31+
: ${POSTGRES_USER:=postgres}
32+
: ${POSTGRES_DB:=$POSTGRES_USER}
33+
export POSTGRES_USER POSTGRES_DB
7834

79-
pg_ctl -D "$PGDATA" -m fast -w stop
35+
psql=( psql -v ON_ERROR_STOP=1 )
8036

37+
if [ "$POSTGRES_DB" != 'postgres' ]; then
38+
"${psql[@]}" --username postgres <<-EOSQL
39+
CREATE DATABASE "$POSTGRES_DB" ;
40+
EOSQL
8141
echo
82-
echo 'PostgreSQL init process complete; ready for start up.'
83-
echo
8442
fi
43+
44+
if [ "$POSTGRES_USER" = 'postgres' ]; then
45+
op='ALTER'
46+
else
47+
op='CREATE'
48+
fi
49+
"${psql[@]}" --username postgres <<-EOSQL
50+
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
51+
EOSQL
52+
echo
53+
54+
############################################################################
55+
56+
RAFT_PEERS='1:172.18.0.2:6666, 2:172.18.0.4:6666, 3:172.18.0.3:6666'
57+
58+
cat <<-EOF >> $PGDATA/postgresql.conf
59+
listen_addresses='*'
60+
max_prepared_transactions = 100
61+
synchronous_commit = off
62+
wal_level = logical
63+
max_worker_processes = 15
64+
max_replication_slots = 10
65+
max_wal_senders = 10
66+
shared_preload_libraries = 'raftable'
67+
raftable.id = $NODE_ID
68+
raftable.peers = '$RAFT_PEERS'
69+
EOF
70+
71+
tail -n 20 $PGDATA/postgresql.conf
72+
73+
pg_ctl -D "$PGDATA" -m fast -w stop
74+
75+
echo
76+
echo 'PostgreSQL init process complete; ready for start up.'
77+
echo
8578
fi
8679

8780
exec "$@"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
git+https://github.com/kelvich/blockade.git
1+
git+https://github.com/kelvich/blockade.git@user-defined-network
22
psycopg2

0 commit comments

Comments
 (0)