Skip to content

Commit af9d12c

Browse files
committed
Address review feedback
1 parent fa7ab48 commit af9d12c

3 files changed

Lines changed: 77 additions & 23 deletions

File tree

.github/workflows/cpp_extra.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,12 @@ jobs:
372372
persist-credentials: false
373373
fetch-depth: 0
374374
submodules: recursive
375+
- name: Setup Python on hosted runner
376+
uses: actions/setup-python@v6
377+
with:
378+
python-version: 3
379+
- name: Setup Archery
380+
run: python3 -m pip install -e dev/archery[docker]
375381
- name: Set Up Dremio Instance
376382
run: |
377383
docker compose up -d dremio
@@ -382,12 +388,6 @@ jobs:
382388
path: .docker
383389
key: ubuntu-cpp-odbc-${{ hashFiles('cpp/**') }}
384390
restore-keys: ubuntu-cpp-odbc-
385-
- name: Setup Python on hosted runner
386-
uses: actions/setup-python@v6
387-
with:
388-
python-version: 3
389-
- name: Setup Archery
390-
run: python3 -m pip install -e dev/archery[docker]
391391
- name: Execute Docker Build
392392
env:
393393
ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }}

compose.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,13 @@ services:
374374

375375
dremio:
376376
platform: linux/x86_64
377-
image: dremio/dremio-oss:latest
377+
image: dremio/dremio-oss:26.0.0
378378
ports:
379379
- 9047:9047 # REST API
380380
- 31010:31010 # JDBC/ODBC
381381
- 32010:32010
382-
container_name: dremio_container
383382
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
383+
- "DREMIO_JAVA_SERVER_EXTRA_OPTS=-Dsaffron.default.charset=UTF-8 -Dsaffron.default.nationalcharset=UTF-8 -Dsaffron.default.collation.name=UTF-8$$en_US"
385384
healthcheck:
386385
test: curl --fail http://localhost:9047 || exit 1
387386
interval: 10s
@@ -526,7 +525,7 @@ services:
526525
ARROW_DEPENDENCY_SOURCE: BUNDLED
527526
ARROW_DEPENDENCY_USE_SHARED: "OFF"
528527
ARROW_FLIGHT_SQL_ODBC: "ON"
529-
ARROW_FLIGHT_SQL_ODBC_CONN: "driver={Apache Arrow Flight SQL ODBC Driver};HOST=dremio_container;port=32010;pwd=admin2025;uid=admin;useEncryption=false;UseWideChar=true;"
528+
ARROW_FLIGHT_SQL_ODBC_CONN: "driver={Apache Arrow Flight SQL ODBC Driver};HOST=dremio;port=32010;pwd=admin2025;uid=admin;useEncryption=false;UseWideChar=true;"
530529
ARROW_GANDIVA: "OFF"
531530
ARROW_GCS: "OFF"
532531
ARROW_HDFS: "OFF"
@@ -536,7 +535,8 @@ services:
536535
ARROW_SUBSTRAIT: "OFF"
537536
# Register ODBC before running tests
538537
depends_on:
539-
- dremio
538+
dremio:
539+
condition: service_healthy
540540
command: >
541541
/bin/bash -c "
542542
/arrow/ci/scripts/cpp_build.sh /arrow /build &&

cpp/src/arrow/flight/sql/odbc/tests/dremio/set_up_dremio_instance.sh

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20-
set -e
20+
set -euo pipefail
2121

2222
HOST_URL="http://localhost:9047"
2323
NEW_USER_URL="$HOST_URL/apiv2/bootstrap/firstuser"
@@ -27,28 +27,80 @@ SQL_URL="$HOST_URL/api/v3/sql"
2727
ADMIN_USER="admin"
2828
ADMIN_PASSWORD="admin2025"
2929

30+
MAX_WAIT_ATTEMPTS=60
31+
WAIT_INTERVAL_SECONDS=5
32+
3033
# Wait for Dremio to be available.
31-
until curl -s "$NEW_USER_URL"; do
32-
echo 'Waiting for Dremio to start...'
33-
sleep 5
34+
attempt=1
35+
until curl --fail --silent --show-error \
36+
--output /dev/null \
37+
--max-time 5 \
38+
"$NEW_USER_URL"; do
39+
40+
if [[ "$attempt" -ge "$MAX_WAIT_ATTEMPTS" ]]; then
41+
echo "Timed out waiting for Dremio to start." >&2
42+
exit 1
43+
fi
44+
45+
echo "Waiting for Dremio to start... ($attempt/$MAX_WAIT_ATTEMPTS)"
46+
attempt=$((attempt + 1))
47+
sleep "$WAIT_INTERVAL_SECONDS"
3448
done
3549

3650
echo ""
37-
echo 'Creating admin user...'
51+
echo "Creating admin user..."
3852

3953
# Create new admin account.
40-
curl -X PUT "$NEW_USER_URL" \
54+
curl --fail --silent --show-error \
55+
-X PUT "$NEW_USER_URL" \
4156
-H "Content-Type: application/json" \
42-
-d "{ \"userName\": \"$ADMIN_USER\", \"password\": \"$ADMIN_PASSWORD\" }"
57+
-d "$(python3 - <<EOF
58+
import json
59+
print(json.dumps({
60+
"userName": "$ADMIN_USER",
61+
"password": "$ADMIN_PASSWORD"
62+
}))
63+
EOF
64+
)"
4365

4466
echo ""
4567
echo "Created admin user."
4668

47-
# Use admin account to login and acquire a token.
48-
TOKEN=$(curl -s -X POST "$LOGIN_URL" \
69+
echo "Logging in as admin user..."
70+
71+
# Login and capture response body.
72+
LOGIN_RESPONSE="$(curl --fail --silent --show-error \
73+
-X POST "$LOGIN_URL" \
4974
-H "Content-Type: application/json" \
50-
-d "{ \"userName\": \"$ADMIN_USER\", \"password\": \"$ADMIN_PASSWORD\" }" \
51-
| grep -oP '(?<="token":")[^"]+')
75+
-d "$(python3 - <<EOF
76+
import json
77+
print(json.dumps({
78+
"userName": "$ADMIN_USER",
79+
"password": "$ADMIN_PASSWORD"
80+
}))
81+
EOF
82+
)")"
83+
84+
# Extract token safely using Python JSON parsing.
85+
TOKEN="$(python3 - <<EOF
86+
import json
87+
import sys
88+
89+
try:
90+
response = json.loads("""$LOGIN_RESPONSE""")
91+
except json.JSONDecodeError as exc:
92+
print(f"Failed to parse login response JSON: {exc}", file=sys.stderr)
93+
sys.exit(1)
94+
95+
token = response.get("token")
96+
97+
if not token:
98+
print("Login response did not contain a token.", file=sys.stderr)
99+
sys.exit(1)
100+
101+
print(token)
102+
EOF
103+
)"
52104

53105
SQL_QUERY="
54106
Create Table \$scratch.ODBCTest As
@@ -62,10 +114,12 @@ Create Table \$scratch.ODBCTest As
62114
CAST(TIME '23:59:59' AS TIME) AS time_max,
63115
CAST(TIMESTAMP '9999-12-31 23:59:59' AS TIMESTAMP) AS timestamp_max;
64116
"
117+
65118
echo "Creating \$scratch.ODBCTest table."
66119

67120
# Create a new table by sending a SQL query.
68-
curl -i -X POST "$SQL_URL" \
121+
curl --fail --silent --show-error \
122+
-X POST "$SQL_URL" \
69123
-H "Authorization: _dremio$TOKEN" \
70124
-H "Content-Type: application/json" \
71125
-d "$(python3 - <<EOF

0 commit comments

Comments
 (0)