-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathintegration-production-bq-driver-dm.sh
More file actions
executable file
·123 lines (100 loc) · 3.92 KB
/
Copy pathintegration-production-bq-driver-dm.sh
File metadata and controls
executable file
·123 lines (100 loc) · 3.92 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
#!/bin/bash
#
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
source "$(dirname "$0")/../../lib/init.sh"
source module ci/install-dependencies.sh
source module ci/cloudbuild/builds/lib/cmake.sh
source module ci/cloudbuild/builds/lib/bazel.sh
source module ci/cloudbuild/builds/lib/secrets.sh
source module ci/cloudbuild/builds/lib/unit-tests.sh
source module ci/lib/io.sh
WORKSPACE_DIR=$(pwd)
# Export as env variable
VCPKG_VERSION=$(cat /tmp/vcpkg-version.txt)
export VCPKG_VERSION
echo "Using VCPKG_VERSION=$VCPKG_VERSION"
# Vcpkg install and configure
export VCPKG_ROOT=/vcpkg
git clone --branch "$VCPKG_VERSION" https://github.com/microsoft/vcpkg.git "$VCPKG_ROOT"
cd "$VCPKG_ROOT"
git checkout "$VCPKG_VERSION"
# Bootstrap
./bootstrap-vcpkg.sh -disableMetrics
cd "$WORKSPACE_DIR"
# This runs all the unit tests
mapfile -t args < <(bazel::common_args)
mapfile -t unit_tests_args < <(unit_tests::bazel_args)
mapfile -t secrets_bazel < <(secrets::bazel_args)
io::run bazel test "${args[@]}" "${secrets_bazel[@]}" "${unit_tests_args[@]}" --test_tag_filters=unit-tests ...
# Run the integration tests
mapfile -t cmake_args < <(cmake::common_args)
BUILD_DIR="/opt/odbc-driver"
# This is the name of DSN set in odbc.ini
export ODBC_TESTS_DSN="SampleDSNGoogleDriver"
export CPP_BIGQUERY_ODBC_TEST_TABLE_PREFIX=${TRIGGER_NAME//[-:;.,?]/_}_${BRANCH_NAME//[-:;.,?]/_}
# Check if unixODBC is installed
if command -v odbcinst &>/dev/null; then
# unixODBC is installed, export environment variable
export UNIXODBC_INSTALLED=true
echo "unixODBC is installed."
else
# unixODBC is not installed
export UNIXODBC_INSTALLED=false
export ODBCINSTINI=/opt/odbc-driver/odbcinst.ini
echo "unixODBC is not installed."
fi
io::run cmake -B "$BUILD_DIR" \
"${cmake_args[@]}" \
-DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=Release \
-DODBC_INTEGRATION_TESTING=ON \
-DBQ_DRIVER_INTEGRATION_TESTS=ON \
-DODBC_DEMO_TESTING=ON \
-DODBC_EXAMPLES=ON \
-DODBC_UNIT_TESTING=OFF \
-DCLIENT_LIBRARY_INTEGRATION_TESTING=OFF
io::run cmake --build cmake-out
# ---------------------------------------------------------------------------
# Publish Google driver .so for performance benchmarks
# ---------------------------------------------------------------------------
if [[ "${UNIXODBC_INSTALLED}" == "false" ]]; then
DRIVER_SO="cmake-out/google/cloud/odbc/libgoogle_cloud_odbc_bq_driver.so"
if [[ ! -f "$DRIVER_SO" ]]; then
echo "ERROR: Google ODBC driver .so was not found:"
echo " $DRIVER_SO"
exit 1
fi
echo "Google driver found:"
ls -lh "$DRIVER_SO"
# Sanitize branch name for use in GCS path.
SANITIZED_BRANCH=$(
echo "${BRANCH_NAME}" |
sed -E 's/[^a-zA-Z0-9._-]/_/g'
)
PERF_DRIVER_BUCKET="gs://bq-dev-tools-testing-drivers/odbc-perf"
echo "Uploading Google driver artifact..."
echo "Branch: ${SANITIZED_BRANCH}"
gcloud storage cp \
"$DRIVER_SO" \
"${PERF_DRIVER_BUCKET}/${SANITIZED_BRANCH}/linux/libgoogle_cloud_odbc_bq_driver.so"
echo "Google driver benchmark artifact uploaded:"
echo "${PERF_DRIVER_BUCKET}/${SANITIZED_BRANCH}/linux/libgoogle_cloud_odbc_bq_driver.so"
fi
# Copy the roots.pem file to the .so directory to run test cases.
cp /opt/odbc-driver/roots.pem "cmake-out/google/cloud/odbc/roots.pem"
mapfile -t ctest_args < <(ctest::common_args)
io::run env -C cmake-out ctest "${ctest_args[@]}"