-
Notifications
You must be signed in to change notification settings - Fork 39
206 lines (174 loc) · 7.35 KB
/
loggingTesting.yml
File metadata and controls
206 lines (174 loc) · 7.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Test JDBC Logging
on:
push:
branches:
- main
workflow_dispatch:
inputs:
branch:
description: 'Branch to checkout'
required: false
default: 'main'
permissions:
id-token: write
contents: read
jobs:
test-logging:
strategy:
fail-fast: false
matrix:
github-runner: [linux-ubuntu-latest, windows-server-latest]
thrift-client: [0, 1]
runs-on:
group: databricks-protected-runner-group
labels: ${{ matrix.github-runner }}
steps:
- name: Enable long paths
if: runner.os == 'Windows'
run: git config --system core.longpaths true
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ inputs.branch || github.ref }}
- name: Set up Java
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
with:
distribution: 'adopt'
java-version: '21'
- name: Get JFrog OIDC token
run: |
set -euo pipefail
# Get GitHub OIDC ID token
ID_TOKEN=$(curl -sLS \
-H "User-Agent: actions/oidc-client" \
-H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=jfrog-github" | jq .value | tr -d '"')
echo "::add-mask::${ID_TOKEN}"
# Exchange for JFrog access token
ACCESS_TOKEN=$(curl -sLS -XPOST -H "Content-Type: application/json" \
"https://databricks.jfrog.io/access/api/v1/oidc/token" \
-d "{\"grant_type\": \"urn:ietf:params:oauth:grant-type:token-exchange\", \"subject_token_type\":\"urn:ietf:params:oauth:token-type:id_token\", \"subject_token\": \"${ID_TOKEN}\", \"provider_name\": \"github-actions\"}" | jq .access_token | tr -d '"')
echo "::add-mask::${ACCESS_TOKEN}"
if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" = "null" ]; then
echo "FAIL: Could not extract JFrog access token"
exit 1
fi
echo "JFROG_ACCESS_TOKEN=${ACCESS_TOKEN}" >> "$GITHUB_ENV"
echo "JFrog OIDC token obtained successfully"
- name: Configure maven
run: |
set -euo pipefail
mkdir -p ~/.m2
cat > ~/.m2/settings.xml << EOF
<settings>
<mirrors>
<mirror>
<id>jfrog-central</id>
<mirrorOf>*</mirrorOf>
<url>https://databricks.jfrog.io/artifactory/db-maven/</url>
</mirror>
</mirrors>
<servers>
<server>
<id>jfrog-central</id>
<username>gha-service-account</username>
<password>${JFROG_ACCESS_TOKEN}</password>
</server>
</servers>
</settings>
EOF
echo "Maven configured to use JFrog registry"
- name: Build JDBC driver
run: mvn clean package -DskipTests
- name: Find JAR file
shell: bash
run: |
# Find the main JAR file dynamically (uber JAR from assembly-uber module)
MAIN_JAR=$(find assembly-uber/target -maxdepth 1 -name "databricks-jdbc-*.jar" \
-not -name "*-thin.jar" \
-not -name "*-tests.jar" | head -1)
if [ -z "$MAIN_JAR" ]; then
echo "ERROR: Could not find main JAR file in assembly-uber/target directory"
ls -la assembly-uber/target/
exit 1
fi
echo "Using JAR file: $MAIN_JAR"
echo "MAIN_JAR=$MAIN_JAR" >> $GITHUB_ENV
- name: Set Environment Variables
if: runner.os != 'Windows'
shell: bash
env:
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
DATABRICKS_HTTP_PATH: ${{ secrets.DATABRICKS_HTTP_PATH }}
USE_THRIFT_CLIENT: ${{ matrix.thrift-client }}
run: |
echo "DATABRICKS_TOKEN=${DATABRICKS_TOKEN}" >> $GITHUB_ENV
echo "DATABRICKS_HOST=${DATABRICKS_HOST}" >> $GITHUB_ENV
echo "DATABRICKS_HTTP_PATH=${DATABRICKS_HTTP_PATH}" >> $GITHUB_ENV
echo "USE_THRIFT_CLIENT=${USE_THRIFT_CLIENT}" >> $GITHUB_ENV
- name: Set Environment Variables (Windows)
if: runner.os == 'Windows'
shell: powershell
env:
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
DATABRICKS_HTTP_PATH: ${{ secrets.DATABRICKS_HTTP_PATH }}
USE_THRIFT_CLIENT: ${{ matrix.thrift-client }}
run: |
"DATABRICKS_TOKEN=$env:DATABRICKS_TOKEN" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"DATABRICKS_HOST=$env:DATABRICKS_HOST" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"DATABRICKS_HTTP_PATH=$env:DATABRICKS_HTTP_PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"USE_THRIFT_CLIENT=$env:USE_THRIFT_CLIENT" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Clean & Compile LoggingTest
shell: bash
run: |
rm -rf jdbc-core/target/test-classes
mkdir -p jdbc-core/target/test-classes
echo "Using JAR file: $MAIN_JAR"
javac \
-cp "$MAIN_JAR" \
-d jdbc-core/target/test-classes \
jdbc-core/src/test/java/com/databricks/client/jdbc/LoggingTest.java
echo "==== Checking compiled classes ===="
find jdbc-core/target/test-classes -type f
- name: Run LoggingTest
shell: bash
run: |
echo "==== Running LoggingTest with usethriftclient=${{ matrix.thrift-client }} ===="
OS_TYPE=$(uname | tr '[:upper:]' '[:lower:]')
if [[ "$OS_TYPE" == "linux" ]]; then SEP=":"; else SEP=";"; fi
echo "Using classpath separator: '$SEP'"
echo "Using JAR file: $MAIN_JAR"
CP="jdbc-core/target/test-classes${SEP}$MAIN_JAR"
java \
--add-opens=java.base/java.nio=ALL-UNNAMED \
-cp "$CP" \
com.databricks.client.jdbc.LoggingTest
- name: Verify log file contents
shell: bash
run: |
LOG_DIR="${HOME}/logstest"
LOG_FILE="${LOG_DIR}/databricks_jdbc.log.0"
echo "Verifying log file contents in ${LOG_FILE}..."
if [ -f "$LOG_FILE" ]; then
echo "Log file found. Checking contents..."
REQUIRED_STRINGS=("sql = SELECT 1",
"Result retrieved successfully"
"Closing global async HTTP client"
"Global async HTTP client has been shut down")
for STRING in "${REQUIRED_STRINGS[@]}"; do
if ! grep -qF "$STRING" "$LOG_FILE"; then
echo "ERROR: Required log string not found: $STRING"
echo "Showing last 100 lines of log file:"
tail -n 100 "$LOG_FILE"
exit 1
fi
done
echo "All required log strings were found."
else
echo "Log file directory contents:"
ls -la "${LOG_DIR}" || echo "Directory does not exist"
echo "Log file ${LOG_FILE} does not exist. Failing the build."
exit 1
fi