Skip to content
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
20 changes: 14 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Builds SqlJam. Database servers are not available here: the ci environment runs the integration tests of H2,
# SQLite and DuckDB only, the others are skipped.
# Builds SqlJam. The ci environment runs the integration tests of H2, SQLite, DuckDB and Access, and of the main
# database servers where they run in Docker (.github/workflows/databases.sh), the others are skipped.
#
# check pull requests: one Linux build with all tests, the check of merging
# check pull requests: one Linux build with all tests against PostgreSQL, MySQL, Oracle, SQL Server, Qdrant
# and Weaviate in Docker, the check of merging
# platforms tags v* and manual runs (Actions > build > Run workflow): Windows, macOS and Linux build, start the
# runnable jar and take screenshots, packages for download (src/packaging/package.sh)
# release tags v*: a GitHub release with the packages of every platform and their SHA-256 checksums
Expand All @@ -28,7 +29,7 @@ jobs:
check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 45
steps:
- uses: actions/checkout@v4

Expand All @@ -38,8 +39,15 @@ jobs:
java-version: '17'
cache: maven

- name: Build and test (UI tests run headless)
run: ./mvnw -B -ntp verify -Dit.env=ci -Djacoco.haltOnFailure=false
# The databases start while SqlJam is compiled
- name: Build and test against the main databases (UI tests run headless)
run: |
bash .github/workflows/databases.sh > databases.log 2>&1 &
DATABASES=$!
./mvnw -B -ntp test-compile
wait $DATABASES || { cat databases.log; exit 1; }
cat databases.log
./mvnw -B -ntp verify -Dit.env=ci -Djacoco.haltOnFailure=false

platforms:
if: github.event_name != 'pull_request'
Expand Down
117 changes: 117 additions & 0 deletions .github/workflows/databases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash
#
# Starts the main database servers of the integration tests in Docker, set up like those of 192.168.0.63, for
# the ci environment (mvn verify -Dit.env=ci, it-databases-ci.properties and it-vdb-ci.properties):
#
# PostgreSQL 17 with pgvector localhost:15432 database demo, schemas sjit_src and sjit_dst, sjit_novector
# MySQL 9 localhost:13306 databases sjit_src and sjit_dst, lower_case_table_names=1
# Oracle 23ai Free localhost:11521 service FREEPDB1, user ADMIN with DBA, vector memory 512 MB
# SQL Server 2025 localhost:11433 database demo (Chinese_PRC_CI_AS) with preview features (float16
# vectors), schemas sjit_src and sjit_dst
# Qdrant 1.19 localhost:16333 api key and read-only key
# Weaviate 1.39 localhost:18080 api key
#
# Every server has the user admin with the password admin123, PostgreSQL, MySQL, Oracle and SQL Server also the
# user sjit_reader with few privileges. Also on a developer machine with Docker:
#
# bash .github/workflows/databases.sh start and set up
# bash .github/workflows/databases.sh stop remove the containers
#
set -e

NAMES="sj-postgresql sj-mysql sj-oracle sj-sqlserver sj-qdrant sj-weaviate"
SA_PASSWORD='Sqljam_ci_2026'

if [ "$1" = stop ]; then
docker rm -f $NAMES >/dev/null 2>&1 || true
echo "Removed $NAMES"
exit 0
fi
docker rm -f $NAMES >/dev/null 2>&1 || true

# Started together, they get ready meanwhile
docker run -d --name sj-postgresql -p 15432:5432 -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admin123 \
-e POSTGRES_DB=demo pgvector/pgvector:pg17 >/dev/null
docker run -d --name sj-mysql -p 13306:3306 -e MYSQL_ROOT_PASSWORD=admin123 -e MYSQL_USER=admin \
-e MYSQL_PASSWORD=admin123 -e MYSQL_DATABASE=sjit_src mysql:9 --lower-case-table-names=1 >/dev/null
docker run -d --name sj-oracle -p 11521:1521 -e ORACLE_PASSWORD=admin123 -e APP_USER=admin \
-e APP_USER_PASSWORD=admin123 gvenzl/oracle-free:23-slim-faststart >/dev/null
docker run -d --name sj-sqlserver -p 11433:1433 -e ACCEPT_EULA=Y -e "MSSQL_SA_PASSWORD=$SA_PASSWORD" \
-e MSSQL_COLLATION=Chinese_PRC_CI_AS mcr.microsoft.com/mssql/server:2025-latest >/dev/null
docker run -d --name sj-qdrant -p 16333:6333 -e QDRANT__SERVICE__API_KEY=admin123 \
-e QDRANT__SERVICE__READ_ONLY_API_KEY=readonly123 qdrant/qdrant:v1.19.2 >/dev/null
docker run -d --name sj-weaviate -p 18080:8080 -e AUTHENTICATION_APIKEY_ENABLED=true \
-e AUTHENTICATION_APIKEY_ALLOWED_KEYS=admin123 -e AUTHENTICATION_APIKEY_USERS=admin \
-e AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=false -e AUTHORIZATION_ADMINLIST_ENABLED=true \
-e AUTHORIZATION_ADMINLIST_USERS=admin -e DEFAULT_VECTORIZER_MODULE=none -e CLUSTER_HOSTNAME=node1 \
-e PERSISTENCE_DATA_PATH=/var/lib/weaviate cr.weaviate.io/semitechnologies/weaviate:1.39.11 >/dev/null

# Runs the command until it succeeds, 5 minutes at most
wait_for() {
local name=$1
shift
for i in $(seq 1 150); do
if "$@" >/dev/null 2>&1; then
echo "$name is ready"
return 0
fi
sleep 2
done
echo "$name is not ready" >&2
docker logs --tail 50 "sj-$name" >&2 || true
return 1
}

wait_for postgresql docker exec sj-postgresql psql -U admin -d demo -c 'SELECT 1'
docker exec sj-postgresql psql -q -U admin -d demo -c 'CREATE EXTENSION IF NOT EXISTS vector' \
-c 'CREATE SCHEMA IF NOT EXISTS sjit_src' -c 'CREATE SCHEMA IF NOT EXISTS sjit_dst'
docker exec sj-postgresql psql -q -U admin -d demo -c 'CREATE DATABASE sjit_novector' \
-c "CREATE ROLE sjit_reader LOGIN PASSWORD 'sjit_reader123'"

wait_for mysql docker exec sj-mysql mysql -uroot -padmin123 -e 'SELECT 1'
docker exec sj-mysql mysql -uroot -padmin123 -e "CREATE DATABASE IF NOT EXISTS sjit_dst;
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
CREATE USER 'sjit_reader'@'%' IDENTIFIED BY 'sjit_reader123'; GRANT SELECT ON sjit_src.* TO 'sjit_reader'@'%';
FLUSH PRIVILEGES;"

wait_for qdrant curl -sf http://localhost:16333/collections -H 'api-key: admin123'
wait_for weaviate curl -sf http://localhost:18080/v1/meta -H 'Authorization: Bearer admin123'

SQLCMD="/opt/mssql-tools18/bin/sqlcmd -C -b -S localhost -U sa -P $SA_PASSWORD"
wait_for sqlserver docker exec sj-sqlserver $SQLCMD -Q 'SELECT 1'
# SQL Server answers before it finished its own start, its statements may be chosen as victims of deadlocks
# meanwhile (Msg 1205): the setup may run again, it is retried
sqlserver_setup() {
docker exec sj-sqlserver $SQLCMD -Q "
IF SUSER_ID('admin') IS NULL CREATE LOGIN admin WITH PASSWORD = 'admin123', CHECK_POLICY = OFF;
ALTER SERVER ROLE sysadmin ADD MEMBER admin;
IF SUSER_ID('sjit_reader') IS NULL
CREATE LOGIN sjit_reader WITH PASSWORD = 'Ro#Vector2026x', CHECK_POLICY = OFF;
IF DB_ID('demo') IS NULL CREATE DATABASE demo;" \
&& docker exec sj-sqlserver $SQLCMD -d demo -Q "
IF SCHEMA_ID('sjit_src') IS NULL EXEC('CREATE SCHEMA sjit_src');
IF SCHEMA_ID('sjit_dst') IS NULL EXEC('CREATE SCHEMA sjit_dst');
ALTER DATABASE SCOPED CONFIGURATION SET PREVIEW_FEATURES = ON;
IF USER_ID('sjit_reader') IS NULL CREATE USER sjit_reader FOR LOGIN sjit_reader;"
}
for i in 1 2 3 4 5 6; do
if sqlserver_setup; then
break
fi
if [ "$i" = 6 ]; then
echo "sqlserver is not set up" >&2
exit 1
fi
echo "sqlserver setup is retried" >&2
sleep 5
done

wait_for oracle docker exec sj-oracle healthcheck.sh
printf '%s\n' 'GRANT DBA TO admin;' 'CREATE USER sjit_reader IDENTIFIED BY "Sjit_reader123";' \
'GRANT CREATE SESSION, CREATE TABLE TO sjit_reader;' 'ALTER USER sjit_reader QUOTA UNLIMITED ON USERS;' | docker exec -i sj-oracle sqlplus -s 'sys/admin123@//localhost/FREEPDB1 as sysdba'
# Vector indexes need the vector memory, it is given at the start of the instance
echo 'ALTER SYSTEM SET vector_memory_size=512M SCOPE=SPFILE;' | docker exec -i sj-oracle sqlplus -s '/ as sysdba'
docker restart sj-oracle >/dev/null
wait_for oracle docker exec sj-oracle healthcheck.sh

echo "Databases are ready"
9 changes: 3 additions & 6 deletions src/main/java/com/github/sqljam/vdb/client/QdrantClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,17 @@ public Map<String, Double> getMetrics() {
Map<String, Double> metrics = super.getMetrics();
try {
Map<String, Double> values = VdbInfo.prometheus(rest.get("/metrics").asText());
// Newer servers count the requests in their histograms of durations
// Newer servers count the requests in their histograms of durations. A new server has no lines of them
// before its first request, it served none
double requests = 0;
boolean counted = false;
for (String name : new String[]{"rest_responses_total", "grpc_responses_total",
"rest_responses_duration_seconds_count", "grpc_responses_duration_seconds_count"}) {
if (values.containsKey(name) && !(name.endsWith("_count") && values.containsKey(name.replace(
"_duration_seconds_count", "_total")))) {
requests += values.get(name);
counted = true;
}
}
if (counted) {
metrics.put("requests", requests);
}
metrics.put("requests", requests);
putIfPresent(metrics, "cpu.cores", values.get("cpu_cores_used"));
putIfPresent(metrics, "memory.resident", values.get("memory_resident_bytes"));
putIfPresent(metrics, "memory.allocated", values.get("memory_allocated_bytes"));
Expand Down
5 changes: 4 additions & 1 deletion src/test/java/com/github/sqljam/it/VectorIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -811,7 +812,7 @@ private static List<String> indexDefinitions(String schema) throws SQLException
private static List<String> indexDefinitions(Connection connection, String schema) throws SQLException {
List<String> definitions = new ArrayList<>();
try (PreparedStatement ps = connection.prepareStatement("SELECT indexdef FROM pg_indexes WHERE schemaname = ?"
+ " AND tablename = ? AND indexname NOT LIKE '%pkey' ORDER BY indexdef")) {
+ " AND tablename = ? AND indexname NOT LIKE '%pkey'")) {
ps.setString(1, schema);
ps.setString(2, TABLE);
try (ResultSet rs = ps.executeQuery()) {
Expand All @@ -821,6 +822,8 @@ private static List<String> indexDefinitions(Connection connection, String schem
}
}
}
// Sorted without the index names, their order depends on the collation of the database
Collections.sort(definitions);
return definitions;
}
}
41 changes: 39 additions & 2 deletions src/test/resources/it-databases-ci.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Environment of GitHub Actions: no database servers, only the file databases run (mvn verify -Dit.env=ci).
# H2, SQLite, DuckDB and Access are files in target/it-data, every database server is skipped.
# Environment of GitHub Actions (mvn verify -Dit.env=ci): the main database servers run in Docker on localhost,
# started by .github/workflows/databases.sh. H2, SQLite, DuckDB and Access are files in target/it-data, the other
# database servers are skipped.

h2.username=sa
h2.password=
Expand All @@ -8,3 +9,39 @@ h2.targetSchema=PUBLIC

duckdb.sourceSchema=main
duckdb.targetSchema=main

mysql.host=localhost
mysql.port=13306
mysql.username=admin
mysql.password=admin123
mysql.database=sjit_src
mysql.sourceCatalog=sjit_src
mysql.targetCatalog=sjit_dst

postgresql.host=localhost
postgresql.port=15432
postgresql.username=admin
postgresql.password=admin123
postgresql.database=demo
postgresql.sourceCatalog=demo
postgresql.sourceSchema=sjit_src
postgresql.targetCatalog=demo
postgresql.targetSchema=sjit_dst

oracle.host=localhost
oracle.port=11521
oracle.username=admin
oracle.password=admin123
oracle.database=FREEPDB1
oracle.sourceSchema=ADMIN
oracle.targetSchema=ADMIN

sqlserver.host=localhost
sqlserver.port=11433
sqlserver.username=admin
sqlserver.password=admin123
sqlserver.database=demo
sqlserver.sourceCatalog=demo
sqlserver.sourceSchema=dbo
sqlserver.targetCatalog=demo
sqlserver.targetSchema=sjit_dst
9 changes: 9 additions & 0 deletions src/test/resources/it-vdb-ci.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Vector databases of GitHub Actions (mvn verify -Dit.env=ci), Docker containers on localhost started by
# .github/workflows/databases.sh. The others are skipped.

qdrant.url=http://localhost:16333
qdrant.apiKey=admin123
qdrant.readonlyKey=readonly123

weaviate.url=http://localhost:18080
weaviate.apiKey=admin123
Loading