Skip to content

Commit

Permalink
test: transaction ddl
Browse files Browse the repository at this point in the history
Signed-off-by: usamoi <usamoi@outlook.com>
  • Loading branch information
usamoi committed Jan 17, 2024
1 parent 66faf0d commit 025c482
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 30 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,11 @@ jobs:
cargo test --all --no-fail-fast --no-default-features --features "pg${{ matrix.version }} pg_test" --target x86_64-unknown-linux-gnu -- --nocapture
- name: Install release
run: ./scripts/ci_install.sh
- name: Sqllogictest
run: |
psql -f ./tests/init.sql
sqllogictest -u runner -d runner './tests/sqllogictest/*.slt'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Crash Recovery test
run: |
sudo pip install psutil==5.9.7
psql -f ./tests/init.sql
sqllogictest -u runner -d runner './tests/crash/create.slt'
sudo python ./tests/crash/kill.py
sqllogictest -u runner -d runner './tests/crash/restore.slt'
python-version: "3.10"
- name: Test 2
run: ./tests/tests.sh
- uses: actions/cache/save@v3
with:
path: |
Expand Down
7 changes: 7 additions & 0 deletions tests/crash/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e

sudo pip install psutil==5.9.7
sqllogictest -u runner -d runner $(dirname $0)/create.slt
sudo python $(dirname $0)/kill.py
sqllogictest -u runner -d runner $(dirname $0)/restore.slt
2 changes: 0 additions & 2 deletions tests/init.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
DROP EXTENSION IF EXISTS vectors CASCADE;
CREATE EXTENSION vectors;
DROP TABLE IF EXISTS t;
2 changes: 1 addition & 1 deletion tests/sqllogictest/error.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
DROP TABLE IF EXISTS t;
SET search_path TO pg_temp, vectors;

statement ok
CREATE TABLE t (val vector(3));
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictest/flat.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
DROP TABLE IF EXISTS t;
SET search_path TO pg_temp, vectors;

statement ok
CREATE TABLE t (val vector(3));
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictest/fp16.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
DROP TABLE IF EXISTS t;
SET search_path TO pg_temp, vectors;

statement ok
CREATE TABLE t (val vecf16(3));
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictest/hnsw.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
DROP TABLE IF EXISTS t;
SET search_path TO pg_temp, vectors;

statement ok
CREATE TABLE t (val vector(3));
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictest/index.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
DROP TABLE IF EXISTS t;
SET search_path TO pg_temp, vectors;

statement ok
CREATE TABLE t (val vector(3));
Expand Down
8 changes: 2 additions & 6 deletions tests/sqllogictest/ivf.slt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
statement ok
DROP TABLE IF EXISTS t;

# ivf native
statement ok
DROP TABLE IF EXISTS t;
SET search_path TO pg_temp, vectors;

statement ok
CREATE TABLE t (val vector(3));
Expand Down Expand Up @@ -38,7 +34,7 @@ DROP TABLE t;

# ivfpq
statement ok
DROP TABLE IF EXISTS t;
DROP TABLE t;

statement ok
CREATE TABLE t (val vector(3));
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictest/partition.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
DROP TABLE IF EXISTS items;
SET search_path TO pg_temp, vectors;

# partition table
statement ok
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictest/quantization.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
DROP TABLE IF EXISTS t;
SET search_path TO pg_temp, vectors;

# product quantization
statement ok
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictest/reindex.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
DROP TABLE IF EXISTS t;
SET search_path TO pg_temp, vectors;

statement ok
CREATE TABLE t (val vector(3));
Expand Down
4 changes: 4 additions & 0 deletions tests/sqllogictest/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -e

sqllogictest -u runner -d runner $(dirname $0)/*.slt
2 changes: 1 addition & 1 deletion tests/sqllogictest/update.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
DROP TABLE IF EXISTS t;
SET search_path TO pg_temp, vectors;

statement ok
CREATE TABLE t (val vector(3));
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictest/vbase.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
statement ok
DROP TABLE IF EXISTS t;
SET search_path TO pg_temp, vectors;

statement ok
CREATE TABLE t (val vector(3));
Expand Down
8 changes: 8 additions & 0 deletions tests/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e

psql -f $(dirname $0)/init.sql

for x in $(dirname $0)/*/test.sh; do
$x
done
23 changes: 23 additions & 0 deletions tests/transaction/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e

d=$(psql -U postgres -tAqX -c "SELECT CURRENT_SETTING('data_directory')")/pg_vectors/indexes

a=$(sudo ls -l $d | wc -l)

printf "entries = $a\n"

psql -f $(dirname $0)/test.sql

sleep 1

b=$(sudo ls -l $d | wc -l)

printf "entries = $b\n"

if [ "$a" == "$b" ]; then
echo "Transaction test [OK]"
else
echo "Transaction test [FAILED]"
exit 1
fi
7 changes: 7 additions & 0 deletions tests/transaction/test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE tests_transaction_t(val vector(3));

INSERT INTO tests_transaction_t (val) SELECT ARRAY[random(), random(), random()]::real[] FROM generate_series(1, 1000);

BEGIN;
CREATE INDEX ON t USING vectors (val vector_l2_ops);
ABORT;

0 comments on commit 025c482

Please sign in to comment.