Skip to content

Commit

Permalink
add spqr proto tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaUnisikhin committed Mar 17, 2024
1 parent ff5b656 commit a1759fd
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
context: .
environment:
CMAKE_BUILD_TYPE: "${CMAKE_BUILD_TYPE:-Debug}"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
od_net:
ipv4_address: 192.168.233.15
Expand Down
7 changes: 6 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev \
vim \
postgresql-common \
postgresql-server-dev-14
postgresql-server-dev-14 \
git

RUN curl -fsSL https://get.docker.com -o get-docker.sh && \
sudo sh get-docker.sh

COPY ./docker/pg/pg_hba-test.conf /etc/postgresql/14/main/pg_hba.conf

Expand All @@ -75,6 +79,7 @@ COPY ./docker/ldap /ldap
COPY ./docker/lagpolling /lagpolling
COPY ./docker/shell-test /shell-test
COPY ./docker/tsa /tsa
COPY ./docker/xproto /xproto

COPY ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh

Expand Down
9 changes: 8 additions & 1 deletion docker/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ sudo -u postgres /usr/bin/pg_basebackup -D /var/lib/postgresql/14/repl -R -h loc
sudo -u postgres /usr/lib/postgresql/14/bin/pg_ctl -D /var/lib/postgresql/14/repl/ -o '-p 5433' start

# Create databases
for database_name in db scram_db ldap_db auth_query_db db1 hba_db tsa_db addr_db; do
for database_name in db scram_db ldap_db auth_query_db db1 hba_db tsa_db addr_db xproto_db; do
sudo -u postgres createdb $database_name >> "$SETUP_LOG" 2>&1 || {
echo "ERROR: 'createdb $database_name' failed, examine the log"
cat "$SETUP_LOG"
Expand Down Expand Up @@ -171,6 +171,13 @@ psql -h localhost -p 5432 -U postgres -c "set password_encryption TO 'md5'; crea
exit 1
}

psql -h localhost -p 5432 -U postgres -c "create user xproto" -d xproto_db >> $SETUP_LOG 2>&1 || {
echo "ERROR: users creation failed, examine the log"
cat "$SETUP_LOG"
cat "$PG_LOG"
exit 1
}

# Grant access for ldap_storage_credentials

psql -h localhost -p 5432 -U postgres -c "GRANT ALL ON DATABASE ldap_db1 TO ldap_readonly" -d postgres >> $SETUP_LOG 2>&1 || {
Expand Down
8 changes: 8 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ cd /test_dir/test && /usr/bin/odyssey_test

setup

ody-start
/xproto/test.sh
ody-stop

# odyssey rule-address test
/rule-address/test.sh
if [ $? -eq 1 ]
Expand Down Expand Up @@ -81,4 +85,8 @@ ody-start
/ody-integration-test
ody-stop

# ody-start
# /xproto/test.sh
# ody-stop

teardown
9 changes: 9 additions & 0 deletions docker/xproto/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.21

WORKDIR /root
COPY . /root

RUN go mod init prep_stmt_test && \
go mod tidy

ENTRYPOINT go test .
5 changes: 5 additions & 0 deletions docker/xproto/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
git clone https://github.com/pg-sharding/spqr.git /xproto/spqr
cp /xproto/spqr/test/xproto/proto_test.go /xproto/proto_test.go
rm -rf /xproto/spqr
docker build -t xproto-tests /xproto
docker run -e POSTGRES_HOST=localhost -e POSTGRES_PORT=6432 -e POSTGRES_DB=xproto_db -e POSTGRES_USER=xproto --network=host xproto-tests

0 comments on commit a1759fd

Please sign in to comment.