Skip to content

Commit 1e29550

Browse files
alinaliBQjusting-bq
authored andcommitted
Configure Dremio instance to allow remote testing
Authored by Justin Co-authored-by: justing-bq <justin.gossett@improving.com> ^ Conflicts: ^ .github/workflows/cpp_extra.yml
1 parent 16fe342 commit 1e29550

4 files changed

Lines changed: 164 additions & 5 deletions

File tree

.github/workflows/cpp_extra.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,17 +394,21 @@ jobs:
394394
persist-credentials: false
395395
fetch-depth: 0
396396
submodules: recursive
397-
- name: Restore Docker Volumes
398-
uses: apache/infrastructure-actions/stash/restore@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
399-
with:
400-
path: .docker
401-
key: ubuntu-cpp-odbc
402397
- name: Setup Python on hosted runner
403398
uses: actions/setup-python@v6
404399
with:
405400
python-version: 3
406401
- name: Setup Archery
407402
run: python3 -m pip install -e dev/archery[docker]
403+
- name: Set Up Dremio Instance
404+
run: |
405+
docker compose up -d dremio
406+
cpp/src/arrow/flight/sql/odbc/tests/dremio/set_up_dremio_instance.sh
407+
- name: Restore Docker Volumes
408+
uses: apache/infrastructure-actions/stash/restore@0ba14156c9f4c3cfbe4b0c9f36339ab0f8d81e53
409+
with:
410+
path: .docker
411+
key: ubuntu-cpp-odbc
408412
- name: Execute Docker Build
409413
env:
410414
ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }}

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ repos:
350350
?^cpp/src/arrow/flight/sql/odbc/install/mac/postinstall$|
351351
?^cpp/src/arrow/flight/sql/odbc/install/unix/install_odbc\.sh$|
352352
?^cpp/src/arrow/flight/sql/odbc/install/unix/install_odbc_ini\.sh$|
353+
?^cpp/src/arrow/flight/sql/odbc/tests/dremio/set_up_dremio_instance\.sh$|
353354
?^dev/release/05-binary-upload\.sh$|
354355
?^dev/release/07-flightsqlodbc-upload\.sh$|
355356
?^dev/release/09-binary-verify\.sh$|

compose.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ x-hierarchy:
135135
- debian-ruby
136136
- debian-python:
137137
- debian-docs
138+
- dremio
138139
- fedora-cpp:
139140
- fedora-python
140141
- fedora-r-clang
@@ -372,6 +373,21 @@ services:
372373
/arrow/ci/scripts/cpp_build.sh /arrow /build &&
373374
/arrow/ci/scripts/cpp_test.sh /arrow /build"
374375

376+
dremio:
377+
platform: linux/x86_64
378+
image: dremio/dremio-oss:26.0.0
379+
ports:
380+
- 9047:9047 # REST API
381+
- 31010:31010 # JDBC/ODBC
382+
- 32010:32010
383+
environment:
384+
- "DREMIO_JAVA_SERVER_EXTRA_OPTS=-Dsaffron.default.charset=UTF-8 -Dsaffron.default.nationalcharset=UTF-8 -Dsaffron.default.collation.name=UTF-8$$en_US"
385+
healthcheck:
386+
test: curl --fail http://localhost:9047 || exit 1
387+
interval: 10s
388+
timeout: 5s
389+
retries: 30
390+
375391
ubuntu-cpp: &ubuntu-cpp-base
376392
# Usage:
377393
# docker compose build ubuntu-cpp
@@ -510,6 +526,7 @@ services:
510526
ARROW_DEPENDENCY_SOURCE: BUNDLED
511527
ARROW_DEPENDENCY_USE_SHARED: "OFF"
512528
ARROW_FLIGHT_SQL_ODBC: "ON"
529+
ARROW_FLIGHT_SQL_ODBC_CONN: "driver={Apache Arrow Flight SQL ODBC Driver};HOST=dremio;port=32010;pwd=admin2025;uid=admin;useEncryption=false;UseWideChar=true;"
513530
ARROW_GANDIVA: "OFF"
514531
ARROW_GCS: "OFF"
515532
ARROW_HDFS: "OFF"
@@ -518,6 +535,9 @@ services:
518535
ARROW_S3: "OFF"
519536
ARROW_SUBSTRAIT: "OFF"
520537
# Register ODBC before running tests
538+
depends_on:
539+
dremio:
540+
condition: service_healthy
521541
command: >
522542
/bin/bash -c "
523543
/arrow/ci/scripts/cpp_build.sh /arrow /build &&
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
set -euo pipefail
21+
22+
HOST_URL="http://localhost:9047"
23+
NEW_USER_URL="$HOST_URL/apiv2/bootstrap/firstuser"
24+
LOGIN_URL="$HOST_URL/apiv2/login"
25+
SQL_URL="$HOST_URL/api/v3/sql"
26+
27+
ADMIN_USER="admin"
28+
ADMIN_PASSWORD="admin2025"
29+
30+
MAX_WAIT_ATTEMPTS=60
31+
WAIT_INTERVAL_SECONDS=5
32+
33+
# Wait for Dremio to be available.
34+
attempt=1
35+
until status_code="$(
36+
curl --silent \
37+
--output /dev/null \
38+
--write-out '%{http_code}' \
39+
"$NEW_USER_URL"
40+
)"; [[ "$status_code" == "200" || "$status_code" == "404" || "$status_code" == "405" ]]; do
41+
42+
if [[ "$attempt" -ge "$MAX_WAIT_ATTEMPTS" ]]; then
43+
echo "Timed out waiting for Dremio to start." >&2
44+
exit 1
45+
fi
46+
47+
echo "Waiting for Dremio to start... HTTP $status_code"
48+
attempt=$((attempt + 1))
49+
sleep "$WAIT_INTERVAL_SECONDS"
50+
done
51+
52+
echo ""
53+
echo "Creating admin user..."
54+
55+
# Create new admin account.
56+
curl --fail --silent --show-error \
57+
-X PUT "$NEW_USER_URL" \
58+
-H "Content-Type: application/json" \
59+
-d "$(python3 - <<EOF
60+
import json
61+
print(json.dumps({
62+
"userName": "$ADMIN_USER",
63+
"password": "$ADMIN_PASSWORD"
64+
}))
65+
EOF
66+
)"
67+
68+
echo ""
69+
echo "Created admin user."
70+
71+
echo "Logging in as admin user..."
72+
73+
# Login and capture response body.
74+
LOGIN_RESPONSE="$(curl --fail --silent --show-error \
75+
-X POST "$LOGIN_URL" \
76+
-H "Content-Type: application/json" \
77+
-d "$(python3 - <<EOF
78+
import json
79+
print(json.dumps({
80+
"userName": "$ADMIN_USER",
81+
"password": "$ADMIN_PASSWORD"
82+
}))
83+
EOF
84+
)")"
85+
86+
# Extract token safely using Python JSON parsing.
87+
TOKEN="$(python3 - <<EOF
88+
import json
89+
import sys
90+
91+
try:
92+
response = json.loads("""$LOGIN_RESPONSE""")
93+
except json.JSONDecodeError as exc:
94+
print(f"Failed to parse login response JSON: {exc}", file=sys.stderr)
95+
sys.exit(1)
96+
97+
token = response.get("token")
98+
99+
if not token:
100+
print("Login response did not contain a token.", file=sys.stderr)
101+
sys.exit(1)
102+
103+
print(token)
104+
EOF
105+
)"
106+
107+
SQL_QUERY="
108+
Create Table \$scratch.ODBCTest As
109+
SELECT CAST(2147483647 AS INTEGER) AS sinteger_max,
110+
CAST(9223372036854775807 AS BIGINT) AS sbigint_max,
111+
CAST(999999999 AS DECIMAL(38,0)) AS decimal_positive,
112+
CAST(3.40282347E38 AS FLOAT) AS float_max,
113+
CAST(1.7976931348623157E308 AS DOUBLE) AS double_max,
114+
CAST(true AS BOOLEAN) AS bit_true,
115+
CAST(DATE '9999-12-31' AS DATE) AS date_max,
116+
CAST(TIME '23:59:59' AS TIME) AS time_max,
117+
CAST(TIMESTAMP '9999-12-31 23:59:59' AS TIMESTAMP) AS timestamp_max;
118+
"
119+
120+
echo "Creating \$scratch.ODBCTest table."
121+
122+
# Create a new table by sending a SQL query.
123+
curl --fail --silent --show-error \
124+
-X POST "$SQL_URL" \
125+
-H "Authorization: _dremio$TOKEN" \
126+
-H "Content-Type: application/json" \
127+
-d "$(python3 - <<EOF
128+
import json
129+
print(json.dumps({"sql": """$SQL_QUERY"""}))
130+
EOF
131+
)"
132+
133+
echo ""
134+
echo "Finished setting up dremio docker instance."

0 commit comments

Comments
 (0)