Skip to content

Commit

Permalink
Merge 8db8ebc into 892d691
Browse files Browse the repository at this point in the history
  • Loading branch information
rekby authored Aug 21, 2024
2 parents 892d691 + 8db8ebc commit bbe4af7
Show file tree
Hide file tree
Showing 23 changed files with 1,190 additions and 0 deletions.
1 change: 1 addition & 0 deletions ydb/tests/library/harness/kikimr_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def __make_run_command(self):
"--grpc-port=%s" % self.grpc_port,
"--mon-port=%d" % self.mon_port,
"--ic-port=%d" % self.ic_port,
"--pgwire-port=%d" % self.pgwire_port,
]
)

Expand Down
6 changes: 6 additions & 0 deletions ydb/tests/postgres_integrations/go-libpq/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ydb.tests.postgres_integrations.library
import pytest


def pytest_collection_finish(session: pytest.Session):
ydb.tests.postgres_integrations.library.pytest_collection_finish(session)
3 changes: 3 additions & 0 deletions ydb/tests/postgres_integrations/go-libpq/data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/exchange/
/sources/
/test-result/
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -eu

ONE_TEST_TIMEOUT=5s
TEST_BINARY=./test.binary

echo "Get test list"
TESTS=$($TEST_BINARY --test.list "^Test" | sort)


echo "Shell $SHELL"

rm -f /test-result/raw/result.txt
for TEST_NAME in $TESTS; do
echo -n "Test: $TEST_NAME "
if echo "$TEST_NAME" | grep -Eq "$YDB_PG_TESTFILTER"; then
echo start
else
echo skip
continue
fi
CMD="$TEST_BINARY --test.run '^$TEST_NAME\$' --test.v --test.timeout='$ONE_TEST_TIMEOUT'"
echo "$CMD"
bash -c "$CMD" >> /test-result/raw/result.txt 2>&1 || true
done

go-junit-report < /test-result/raw/result.txt > /test-result/raw/result.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "3"
services:
project:
network_mode: host

image: ydb-test/go-pqlib
build:
context: ../../..
dockerfile: languages/go/libpq/Dockerfile
network: host
environment:
- PGUSER=${YDB_PG_USER:-root}
- PGPASSWORD=${YDB_PG_PASSWORD:-1234}
- PGHOST=${YDB_PG_HOST:-ydb}
- PGPORT=${YDB_PG_PORT:-5432}
- PGDATABASE=${YDB_PG_DATABASE:-local}
- PQGOSSLTESTS=0
- PQSSLCERTTEST_PATH=certs
- YDB_PG_TESTNAME=${YDB_PG_TESTNAME:-}
volumes:
- ./exchange:/exchange
- ./test-result/:/test-result
40 changes: 40 additions & 0 deletions ydb/tests/postgres_integrations/go-libpq/data/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3"
services:
ydb:
image: ghcr.io/ydb-platform/local-ydb:nightly
environment:
- "YDB_DEFAULT_LOG_LEVEL=DEBUG"
- "GRPC_TLS_PORT=2135"
- "GRPC_PORT=2136"
- "MON_PORT=8765"
- "YDB_USE_IN_MEMORY_PDISKS=true"
- "POSTGRES_USER=${YDB_PG_USER:-root}"
- "POSTGRES_PASSWORD=${YDB_PG_PASSWORD:-1234}"
- "YDB_FEATURE_FLAGS=enable_temp_tables"
- "YDB_TABLE_ENABLE_PREPARED_DDL=true"
healthcheck:
test: "/bin/sh /health_check"
interval: 1s
start_period: 1m
project:
depends_on:
ydb:
condition: service_healthy

image: ydb-test/go-pqlib
build:
context: ../../..
dockerfile: languages/go/libpq/Dockerfile
network: host
environment:
- PGUSER=${YDB_PG_USER:-root}
- PGPASSWORD=${YDB_PG_PASSWORD:-1234}
- PGHOST=${YDB_PG_HOST:-ydb}
- PGPORT=${YDB_PG_PORT:-5432}
- PGDATABASE=${YDB_PG_DATABASE:-/local}
- PQGOSSLTESTS=0
- PQSSLCERTTEST_PATH=certs
- YDB_PG_TESTNAME=${YDB_PG_TESTNAME:-}
volumes:
- ./exchange:/exchange
- ./test-result/:/test-result
24 changes: 24 additions & 0 deletions ydb/tests/postgres_integrations/go-libpq/data/docker-init.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -eu

apt-get update && apt-get install -y patch

go install github.com/jstemmer/go-junit-report/[email protected]

mkdir -p /original-sources
cd /original-sources

wget https://github.com/lib/pq/archive/refs/tags/v1.10.9.tar.gz -O libpq.tar.gz
tar --strip-components=1 -zxvf libpq.tar.gz
rm -f libpq.tar.gz

mkdir -p /project/sources/
cp -R /original-sources/. /project/sources/

cd /project/sources/
[ -e /patch.diff ] && patch -s -p0 < /patch.diff

# cache binary
echo "Build test binary"
go test -c -o ./test.binary
38 changes: 38 additions & 0 deletions ydb/tests/postgres_integrations/go-libpq/data/docker-start.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -eu

echo "Start script"

rm -rf /test-result 2> /dev/null || true

mkdir -p /exchange
mkdir -p /test-result/raw

if [ -e /exchange/sources ]; then
echo "Skip prepare sources, because it is exist"
else
echo "Copy sources"
mkdir -p /exchange/sources
cp -R /project/sources/. /exchange/sources
chmod -R a+rw /exchange/sources
fi

cd /project/sources/

export YDB_PG_TESTFILTER="${YDB_PG_TESTFILTER:-}" # set YDB_PG_TESTNAME to empty string if it not set

echo "Run tests: '$YDB_PG_TESTFILTER'"

echo "Start test"

mkdir -p /test-result/raw
PQTEST_BINARY_PARAMETERS=no /go-run-separate-tests.bash

sed -e 's|classname=""|classname="golang-lib-pq"|' -i /test-result/raw/result.xml

if [ -n "${YDB_PG_TESTFILTER:-}" ]; then
cat /test-result/raw/result.txt
fi

chmod -R a+rw /test-result
Loading

0 comments on commit bbe4af7

Please sign in to comment.