Skip to content

Commit 2d83a1c

Browse files
committed
add ADBC tests for Go, C#, Java, Kotlin, Python, Clojure
1 parent 3e67c8e commit 2d83a1c

49 files changed

Lines changed: 2283 additions & 189 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 127 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -12,110 +12,141 @@ jobs:
1212
runs-on: ubuntu-latest
1313
timeout-minutes: 30
1414

15-
services:
16-
xtdb:
17-
image: ghcr.io/xtdb/xtdb:edge
18-
ports:
19-
- 5432:5432
20-
- 8080:8080
21-
options: >-
22-
--health-cmd "curl --silent --fail http://localhost:8080/healthz/alive || exit 1"
23-
--health-interval 10s
24-
--health-timeout 5s
25-
--health-retries 5
26-
27-
container:
28-
image: archlinux:base
29-
options: --user root
30-
3115
steps:
3216
- name: Checkout Repository
3317
uses: actions/checkout@v4
3418

35-
- name: Install Essential System Dependencies
36-
run: |
37-
chmod +x $GITHUB_WORKSPACE/.devcontainer/install-system-deps.sh
38-
$GITHUB_WORKSPACE/.devcontainer/install-system-deps.sh essential
39-
40-
- name: Create Test User
41-
run: |
42-
useradd -m -s /bin/bash -u 1001 runner
43-
echo "runner ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
44-
45-
- name: Install and configure mise
46-
run: |
47-
cp $GITHUB_WORKSPACE/.devcontainer/setup-mise.sh /tmp/setup-mise.sh
48-
chmod +x /tmp/setup-mise.sh
49-
su - runner -c "/tmp/setup-mise.sh runner $GITHUB_WORKSPACE"
50-
rm /tmp/setup-mise.sh
51-
52-
- name: Install Language Runtimes
53-
run: |
54-
chown -R runner:runner $GITHUB_WORKSPACE
55-
su - runner -c "cd $GITHUB_WORKSPACE && ~/.local/bin/mise install"
56-
57-
- name: Install Language-Specific Tools
58-
run: |
59-
su - runner -c "cd $GITHUB_WORKSPACE && for dir in python csharp babashka; do
60-
if [ -d \"\$dir\" ] && [ -f \"\$dir/.mise.toml\" ]; then
61-
echo \"Installing mise tools for \$dir...\"
62-
(cd \"\$dir\" && ~/.local/bin/mise install) || echo \"Warning: Failed to install tools for \$dir\"
63-
fi
64-
done"
65-
66-
- name: Setup Language Runtime Packages
67-
run: |
68-
# Install system packages for Ruby, Elixir, PHP
69-
$GITHUB_WORKSPACE/.devcontainer/install-system-deps.sh languages
70-
71-
- name: Setup Language Tools (Clojure, Elixir, PHP)
72-
run: |
73-
cp $GITHUB_WORKSPACE/.devcontainer/setup-language-tools.sh /tmp/setup-language-tools.sh
74-
chmod +x /tmp/setup-language-tools.sh
75-
su - runner -c "/tmp/setup-language-tools.sh all"
76-
rm /tmp/setup-language-tools.sh
77-
78-
- name: Install Language Dependencies
79-
run: |
80-
su - runner -c "cd $GITHUB_WORKSPACE && \
81-
eval \"\$(~/.local/bin/mise activate bash)\" && \
82-
for dir in python node ruby go elixir php; do
83-
if [ -d \"\$dir\" ]; then
84-
echo \"Installing dependencies for \$dir...\"
85-
(cd \"\$dir\" && ~/.local/bin/mise run deps 2>&1) || echo \"Warning: Failed to install deps for \$dir\"
86-
fi
87-
done"
88-
89-
- name: Wait for XTDB to be Ready
19+
- name: Start XTDB with Flight SQL
9020
run: |
21+
# Create XTDB config with Flight SQL enabled
22+
# Write directly to avoid mount issues
23+
cat > /tmp/xtdb.yaml << 'EOF'
24+
server:
25+
host: '*'
26+
port: 5432
27+
28+
log: !Local
29+
path: "/var/lib/xtdb/log"
30+
31+
storage: !Local
32+
path: "/var/lib/xtdb/buffers"
33+
34+
healthz:
35+
host: '*'
36+
port: 8080
37+
38+
flightSql:
39+
host: '*'
40+
port: 9833
41+
EOF
42+
43+
# Remove leading whitespace from heredoc (caused by YAML indentation)
44+
sed -i 's/^ //' /tmp/xtdb.yaml
45+
46+
# Verify config
47+
echo "XTDB config:"
48+
cat /tmp/xtdb.yaml
49+
50+
# Start XTDB container with custom config that enables Flight SQL
51+
docker run -d --name xtdb \
52+
-p 5432:5432 -p 8080:8080 -p 9833:9833 \
53+
-v "/tmp/xtdb.yaml:/config/xtdb.yaml:ro" \
54+
ghcr.io/xtdb/xtdb:edge \
55+
-f /config/xtdb.yaml
56+
57+
# Wait for XTDB to be ready
9158
for i in {1..60}; do
92-
if curl --silent --fail http://xtdb:8080/healthz/alive; then
59+
if curl --silent --fail http://localhost:8080/healthz/alive 2>/dev/null; then
9360
echo "XTDB is ready"
94-
exit 0
61+
break
9562
fi
63+
echo "Waiting for XTDB... ($i/60)"
9664
sleep 2
9765
done
98-
echo "XTDB did not start in time" && exit 1
9966
100-
- name: Verify XTDB Connection
101-
run: |
102-
$GITHUB_WORKSPACE/.devcontainer/install-system-deps.sh postgres
103-
su - runner -c "psql -h xtdb -U xtdb -d xtdb -c 'SELECT 1'" || echo "PostgreSQL connection test failed"
104-
env:
105-
PGPASSWORD: xtdb
106-
107-
- name: Run All Tests
108-
env:
109-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
# Verify it started
68+
if ! curl --silent --fail http://localhost:8080/healthz/alive; then
69+
echo "XTDB did not start in time"
70+
docker logs xtdb
71+
exit 1
72+
fi
73+
74+
- name: Pull Archlinux container
75+
run: docker pull archlinux:base
76+
77+
- name: Run tests in Archlinux container
11078
run: |
111-
su - runner -c "cd $GITHUB_WORKSPACE && \
112-
export XTDB_HOST=xtdb && \
113-
export XTDB_PORT=5432 && \
114-
export XTDB_USER=xtdb && \
115-
export XTDB_PASSWORD=xtdb && \
116-
export XTDB_DATABASE=xtdb && \
117-
eval \"\$(~/.local/bin/mise activate bash)\" && \
118-
~/.local/bin/mise run test:all"
79+
docker run --rm \
80+
--network host \
81+
-v ${{ github.workspace }}:/workspace \
82+
-w /workspace \
83+
-e XTDB_HOST=localhost \
84+
-e XTDB_PORT=5432 \
85+
-e XTDB_USER=xtdb \
86+
-e XTDB_PASSWORD=xtdb \
87+
-e XTDB_DATABASE=xtdb \
88+
-e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
89+
archlinux:base \
90+
bash -c '
91+
set -e
92+
93+
# Install essential deps
94+
chmod +x /workspace/.devcontainer/install-system-deps.sh
95+
/workspace/.devcontainer/install-system-deps.sh essential
96+
97+
# Create test user
98+
useradd -m -s /bin/bash -u 1001 runner
99+
echo "runner ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
100+
101+
# Install mise
102+
cp /workspace/.devcontainer/setup-mise.sh /tmp/setup-mise.sh
103+
chmod +x /tmp/setup-mise.sh
104+
su - runner -c "/tmp/setup-mise.sh runner /workspace"
105+
106+
# Install language runtimes
107+
chown -R runner:runner /workspace
108+
su - runner -c "cd /workspace && ~/.local/bin/mise install"
109+
110+
# Install language-specific tools
111+
su - runner -c "cd /workspace && for dir in python csharp babashka; do
112+
if [ -d \"\$dir\" ] && [ -f \"\$dir/.mise.toml\" ]; then
113+
echo \"Installing mise tools for \$dir...\"
114+
(cd \"\$dir\" && ~/.local/bin/mise install) || echo \"Warning: Failed to install tools for \$dir\"
115+
fi
116+
done"
117+
118+
# Install system packages for Ruby, Elixir, PHP
119+
/workspace/.devcontainer/install-system-deps.sh languages
120+
121+
# Setup Clojure, Elixir, PHP
122+
cp /workspace/.devcontainer/setup-language-tools.sh /tmp/setup-language-tools.sh
123+
chmod +x /tmp/setup-language-tools.sh
124+
su - runner -c "/tmp/setup-language-tools.sh all"
125+
126+
# Install language dependencies
127+
su - runner -c "cd /workspace && \
128+
eval \"\$(~/.local/bin/mise activate bash)\" && \
129+
for dir in python node ruby go elixir php; do
130+
if [ -d \"\$dir\" ]; then
131+
echo \"Installing dependencies for \$dir...\"
132+
(cd \"\$dir\" && ~/.local/bin/mise run deps 2>&1) || echo \"Warning: Failed to install deps for \$dir\"
133+
fi
134+
done"
135+
136+
# Verify XTDB connection
137+
/workspace/.devcontainer/install-system-deps.sh postgres
138+
PGPASSWORD=xtdb su - runner -c "psql -h localhost -U xtdb -d xtdb -c \"SELECT 1\"" || echo "PostgreSQL connection test failed"
139+
140+
# Run all tests
141+
su - runner -c "cd /workspace && \
142+
export XTDB_HOST=localhost && \
143+
export XTDB_PORT=5432 && \
144+
export XTDB_USER=xtdb && \
145+
export XTDB_PASSWORD=xtdb && \
146+
export XTDB_DATABASE=xtdb && \
147+
eval \"\$(~/.local/bin/mise activate bash)\" && \
148+
~/.local/bin/mise run test:all"
149+
'
119150
120151
- name: Upload Test Results
121152
if: always()
@@ -126,3 +157,7 @@ jobs:
126157
**/test-results/
127158
**/coverage/
128159
retention-days: 7
160+
161+
- name: Show XTDB logs on failure
162+
if: failure()
163+
run: docker logs xtdb

README.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,24 @@ Feel free to hack on the examples - your Codespace is your own to explore!
3636

3737
## Language Feature Compatibility Matrix
3838

39-
The following matrix shows features that are not supported in some languages:
40-
41-
| Language | Transit-JSON (COPY) | Transit-Msgpack (COPY) | Transit-JSON (Parameters) |
42-
|----------|---------------------|------------------------|---------------------------|
43-
| **Python** ||||
44-
| **Node.js** ||||
45-
| **Go** ||||
46-
| **Ruby** ||||
47-
| **Java** ||||
48-
| **Kotlin** ||||
49-
| **C** ||||
50-
| **C#** ||||
51-
| **Clojure** ||||
52-
| **Elixir** ||||
53-
| **Babashka** ||||
54-
| **PHP** ||||
39+
The following matrix shows features that are not yet tested as working in some languages (i.e. no confirmed support, PRs welcome):
40+
41+
| Language | Transit-JSON (COPY) | Transit-Msgpack (COPY) | Transit-JSON (Params) | ADBC |
42+
|----------|---------------------|------------------------|-----------------------|------|
43+
| **Python** |||||
44+
| **Node.js** |||||
45+
| **Go** |||||
46+
| **Ruby** |||||
47+
| **Java** |||||
48+
| **Kotlin** |||||
49+
| **C** |||||
50+
| **C#** |||||
51+
| **Clojure** |||||
52+
| **Elixir** |||||
53+
| **Babashka** |||||
54+
| **PHP** |||||
55+
56+
[Apache Arrow ADBC](https://arrow.apache.org/adbc/) drivers connect via gRPC (port 9833) using Arrow Flight SQL for high-performance columnar data transfer. In-process ADBC usage on the JVM is also supported.
5557

5658
### Updating the Matrix
5759

@@ -61,7 +63,7 @@ The compatibility matrix is automatically generated from test output. To regener
6163
python3 scripts/generate-feature-matrix.py
6264
```
6365

64-
Languages report only **unsupported** features. All features are assumed supported by default, minimizing maintenance burden.
66+
Languages report only **unsupported** features. All features are assumed supported by default.
6567

6668
### Testing
6769

babashka/bb/my_project/main.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
(defn -main [& _args]
55
(def db {:dbtype "postgresql"
6-
:host "xtdb"
6+
:host (or (System/getenv "XTDB_HOST") "xtdb")
77
:dbname "xtdb"
88
:port 5432})
99

babashka/test/xtdb/xtdb_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[cheshire.core :as json]))
55

66
(def db-config {:dbtype "postgresql"
7-
:host "xtdb"
7+
:host (or (System/getenv "XTDB_HOST") "xtdb")
88
:dbname "xtdb"
99
:port 5432})
1010

c/trades.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
/* Configuration */
1515
#define MAX_INT_STR_LEN 32
1616
#define MAX_QUERY_LEN 1024
17-
#define DEFAULT_DB_PARAMS "host=localhost port=5432 dbname=xtdb"
17+
/* Note: Default uses XTDB_HOST env var if set, otherwise "xtdb" */
18+
#define DEFAULT_DB_HOST "xtdb"
19+
#define DEFAULT_DB_PORT "5432"
20+
#define DEFAULT_DB_NAME "xtdb"
1821
#define LOG_BUF_SIZE 2048
1922

2023
/* Exit codes */
@@ -567,8 +570,11 @@ int main(int argc, char *argv[])
567570

568571
if (pos == 0)
569572
{
570-
strncpy(connection_string, DEFAULT_DB_PARAMS, sizeof(connection_string) - 1);
571-
connection_string[sizeof(connection_string) - 1] = '\0';
573+
/* Use XTDB_HOST env var if set, otherwise default to "xtdb" */
574+
const char *env_host = getenv("XTDB_HOST");
575+
const char *default_host = (env_host && *env_host) ? env_host : DEFAULT_DB_HOST;
576+
snprintf(connection_string, sizeof(connection_string),
577+
"host=%s port=%s dbname=%s", default_host, DEFAULT_DB_PORT, DEFAULT_DB_NAME);
572578
}
573579

574580
if (!connect_db(connection_string))

c/xtdb_test.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,15 @@ TEST(transit_json_copy_from) {
791791
int main(void) {
792792
srand(time(NULL));
793793

794-
PGconn *conn = PQconnectdb("host=xtdb port=5432 dbname=xtdb user=xtdb password=");
794+
const char *host = getenv("XTDB_HOST");
795+
if (!host || *host == '\0') {
796+
host = "xtdb";
797+
}
798+
799+
char conn_str[256];
800+
snprintf(conn_str, sizeof(conn_str), "host=%s port=5432 dbname=xtdb user=xtdb password=", host);
801+
802+
PGconn *conn = PQconnectdb(conn_str);
795803

796804
if (PQstatus(conn) != CONNECTION_OK) {
797805
fprintf(stderr, "Connection failed: %s\n", PQerrorMessage(conn));

clojure/.mise.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ run = "clojure -M:dev:repl"
3232
description = "Run Clojure tests"
3333
run = """
3434
mise run setup
35-
clojure -M:test 2>&1 | grep -v 'Downloading:'
35+
clojure -J--add-opens=java.base/java.nio=ALL-UNNAMED -M:test 2>&1 | grep -v 'Downloading:'
3636
"""

clojure/deps.edn

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
;; JSON processing
1313
org.clojure/data.json {:mvn/version "2.5.0"}
1414

15+
;; Arrow ADBC Flight SQL (same versions as XTDB)
16+
org.apache.arrow.adbc/adbc-driver-flight-sql {:mvn/version "0.20.0"}
17+
org.apache.arrow/arrow-memory-netty {:mvn/version "18.3.0"}
18+
1519
;; helpful for debugging the loading data script
1620
org.clojure/tools.logging {:mvn/version "1.2.4"}
1721
org.slf4j/slf4j-simple {:mvn/version "2.0.9"}}

clojure/dev/user.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
(ns user
22
(:require [xtdb.api :as xt]))
33

4+
(def xtdb-host (or (System/getenv "XTDB_HOST") "xtdb"))
5+
46
(defn get-client []
5-
(xt/client {:host "xtdb"
7+
(xt/client {:host xtdb-host
68
:port 5432
79
:user "xtdb"}))
810

@@ -82,7 +84,7 @@
8284

8385
;; To explore the Sakila dataset using datafy/nav tooling with next.jdbc
8486
(defn get-jdbc-conn []
85-
(jdbc/get-connection "jdbc:xtdb://xtdb:5432/xtdb?options=-c%20TimeZone=UTC"))
87+
(jdbc/get-connection (str "jdbc:xtdb://" xtdb-host ":5432/xtdb?options=-c%20TimeZone=UTC")))
8688

8789
(tap> (jdbc/execute! (get-jdbc-conn) ["select * from inventory"]
8890
{:schema-opts {:pk "_id"}}))

0 commit comments

Comments
 (0)