Skip to content

Commit ee00774

Browse files
committed
Add test suite for pgvector called run_pgvector_test
example pgvector added to 'examples' directory Signed-off-by: Petr "Stone" Hracek <[email protected]>
1 parent f47eb93 commit ee00774

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

examples/pgvector/README

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The PostgreSQL Audit Extension (or pgaudit) provides detailed session and/or object
2+
audit logging via the standard logging facility provided by PostgreSQL.
3+
4+
Bind-mount this directory under /opt/app-root/src in the container, and all the
5+
*.conf files from postgresql-cfg/ files will be included to postgresql.conf.
6+
7+
This config file enables the pgaudit extensions that is available in the container
8+
image, but needs to be enabled.
9+
10+
More about pgaudit extension at https://www.pgaudit.org.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shared_preload_libraries = 'vector'

test/run_test

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ run_s2i_enable_ssl_test
2727
run_upgrade_test
2828
run_migration_test
2929
run_pgaudit_test
30+
run_pgvector_test
3031
run_env_extension_load_test
3132
run_logging_test
3233
"
@@ -1039,6 +1040,60 @@ EOSQL" || ret=3
10391040
return $ret
10401041
}
10411042

1043+
# run_pgvector_test
1044+
# --------------------
1045+
# Configure container to include pgvector. Check
1046+
# that pgvector is loaded.
1047+
run_pgvector_test()
1048+
{
1049+
local ret=0
1050+
# extension pgvector is not available for older versions
1051+
case ${VERSION} in
1052+
11|12|15) echo "pgvector not expected, test skipped."; return ;;
1053+
*) ;;
1054+
esac
1055+
case ${OS} in
1056+
fedora)
1057+
echo "pgvector not expected, test skipped."; return ;;
1058+
*) ;;
1059+
esac
1060+
1061+
local config_dir data_dir name=test-pgvector
1062+
1063+
# create a dir for config
1064+
config_dir=$(mktemp -d --tmpdir vector-hook-volume.XXXXX)
1065+
add_cleanup_command /bin/rm -rf "$config_dir"
1066+
test -n "$DOCKER_EXTRA_ARGS" || cp -r "$test_dir"/examples/pgvector/* "$config_dir"
1067+
setfacl -R -m u:26:rwx "$config_dir"
1068+
1069+
# create a dir for data
1070+
create_volume_dir
1071+
data_dir="${volume_dir}"
1072+
1073+
DOCKER_ARGS="
1074+
-e POSTGRESQL_ADMIN_PASSWORD=password
1075+
$DOCKER_EXTRA_ARGS
1076+
-v ${config_dir}:/opt/app-root/src:Z
1077+
-v ${data_dir}:/var/lib/pgsql/data:Z
1078+
" create_container "$name"
1079+
1080+
assert_runtime_option "$name" shared_preload_libraries vector || ret=1
1081+
wait_ready "$name" || \
1082+
false "FAIL: Container did not start up properly."
1083+
1084+
# enable the pgvector extension
1085+
docker exec -i $(get_cid "$name") bash -c "psql <<EOSQL
1086+
CREATE EXTENSION vector;
1087+
CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));
1088+
EOSQL" || ret=2
1089+
1090+
1091+
if [ $ret -eq 0 ]; then
1092+
echo " Success!"
1093+
fi
1094+
return $ret
1095+
}
1096+
10421097
# run_env_extension_load_test
10431098
# --------------------
10441099
# Tries to load pgaudit extension using environment variables

0 commit comments

Comments
 (0)