Proto tests (#595)

* add spqr proto tests

* fix
This commit is contained in:
NikitaUnisikhin 2024-03-18 16:54:25 +05:00 committed by GitHub
parent ddbbb698b7
commit b8b0651026
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 42 additions and 2 deletions

View File

@ -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

View File

@ -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
@ -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

View File

@ -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"
@ -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 || {

View File

@ -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 ]

9
docker/xproto/Dockerfile Normal file
View File

@ -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
docker/xproto/test.sh Executable file
View File

@ -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