Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proto tests #595

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 15 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 "spqr-console"; 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,20 @@ 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 role xproto SUPERUSER LOGIN" -d xproto_db >> $SETUP_LOG 2>&1 || {
echo "ERROR: users creation failed, examine the log"
cat "$SETUP_LOG"
cat "$PG_LOG"
exit 1
}

psql -h localhost -p 5432 -U postgres -c "create user \"spqr-console\"" -d "spqr-console" >> $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
5 changes: 5 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ cd /test_dir/test && /usr/bin/odyssey_test

setup

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

# odyssey rule-address test
/rule-address/test.sh
if [ $? -eq 1 ]
Expand Down
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=odyssey -e POSTGRES_PORT=6432 -e POSTGRES_DB=xproto_db -e POSTGRES_USER=xproto --network=odyssey_od_net xproto-tests
Loading