Skip to content

Commit fd73bee

Browse files
authored
ci: isolate storage emulator tests (#16143)
1 parent 4a93fde commit fd73bee

28 files changed

Lines changed: 496 additions & 41 deletions

ci/cloudbuild/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ if [[ "${DOCKER_FLAG}" = "true" ]]; then
373373
"--env=VERBOSE_FLAG=${VERBOSE_FLAG:-}"
374374
"--env=USE_BAZEL_VERSION=${USE_BAZEL_VERSION:-}"
375375
"--env=LIBRARIES=${LIBRARIES:-}"
376+
"--env=INTEGRATION_LIBRARIES=${INTEGRATION_LIBRARIES:-}"
376377
"--env=SHARD=${SHARD:-}"
377378
# Mounts an empty volume over "build-out" to isolate builds from each
378379
# other. Doesn't affect GCB builds, but it helps our local docker builds.

ci/cloudbuild/builds/asan.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ args+=(--config=asan)
2727
io::run bazel test "${args[@]}" --test_tag_filters=-integration-test "${BAZEL_TARGETS[@]}"
2828

2929
mapfile -t integration_args < <(integration::bazel_args)
30-
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
30+
if [[ "${INTEGRATION_LIBRARIES:-}" == "storage" ]]; then
31+
integration::bazel_storage_with_emulators test "${args[@]}" "${integration_args[@]}"
32+
else
33+
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
34+
fi

ci/cloudbuild/builds/lib/integration.sh

Lines changed: 163 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -166,79 +166,133 @@ function integration::bazel_args() {
166166
# mapfile -t integration_args < <(integration::bazel_args)
167167
# integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
168168
#
169-
function integration::bazel_with_emulators() {
170-
readonly EMULATOR_SCRIPT="run_integration_tests_emulator_bazel.sh"
169+
# Runs Pub/Sub integration tests (including Pub/Sub Lite if BAZEL_TARGETS is default).
170+
function integration::bazel_pubsub_with_emulators() {
171+
local EMULATOR_SCRIPT="run_integration_tests_emulator_bazel.sh"
171172
if [[ $# == 0 ]]; then
172173
io::log_red "error: bazel verb required"
173174
return 1
174175
fi
175-
176176
local verb="$1"
177177
local args=("${@:2}")
178178

179-
production_integration_tests=(
180-
# gRPC Utils integration tests
181-
"google/cloud:internal_grpc_impersonate_service_account_integration_test"
182-
# Generator integration tests
183-
"generator/..."
184-
# BigQuery integration tests
185-
"google/cloud/bigquery/..."
186-
# Compute integration tests
187-
"google/cloud/compute/..."
188-
# IAM and IAM Credentials integration tests
189-
"google/cloud/iam/..."
190-
# Logging integration tests
191-
"google/cloud/logging/..."
192-
# Pub/Sub Lite integration tests
193-
"google/cloud/pubsublite/..."
194-
# Cloud Sql Admin integration tests
195-
"google/cloud/sql/integration_tests/..."
196-
# Unified Rest Credentials test
197-
"google/cloud:internal_unified_rest_credentials_integration_test"
198-
)
179+
io::log_h2 "Running Pub/Sub integration tests (with emulator)"
180+
"google/cloud/pubsub/ci/${EMULATOR_SCRIPT}" \
181+
bazel "${verb}" "${args[@]}" --test_tag_filters="integration-test,-ud-only"
182+
183+
if [[ "${BAZEL_TARGETS[*]}" != "..." ]]; then
184+
return 0
185+
fi
199186

200187
production_tests_tag_filters="integration-test,-ud-only"
201188
if echo "${args[@]}" | grep -w -q -- "--config=msan"; then
202189
production_tests_tag_filters="integration-test,-no-msan,-ud-only"
203190
fi
204191

205-
io::log_h2 "Running Pub/Sub integration tests (with emulator)"
206-
"google/cloud/pubsub/ci/${EMULATOR_SCRIPT}" \
207-
bazel "${verb}" "${args[@]}" --test_tag_filters="integration-test,-ud-only"
192+
io::log_h2 "Running Pub/Sub production integration tests"
193+
bazel "${verb}" "${args[@]}" \
194+
--test_tag_filters="${production_tests_tag_filters}" \
195+
"google/cloud/pubsublite/..."
196+
}
197+
198+
# Runs Storage integration tests.
199+
function integration::bazel_storage_with_emulators() {
200+
local EMULATOR_SCRIPT="run_integration_tests_emulator_bazel.sh"
201+
if [[ $# == 0 ]]; then
202+
io::log_red "error: bazel verb required"
203+
return 1
204+
fi
205+
local verb="$1"
206+
local args=("${@:2}")
208207

209208
io::log_h2 "Running Storage integration tests (with emulator)"
210209
"google/cloud/storage/ci/${EMULATOR_SCRIPT}" \
211210
bazel "${verb}" "${args[@]}" --test_tag_filters="integration-test,-ud-only"
211+
}
212+
213+
# Runs Spanner integration tests.
214+
function integration::bazel_spanner_with_emulators() {
215+
local EMULATOR_SCRIPT="run_integration_tests_emulator_bazel.sh"
216+
if [[ $# == 0 ]]; then
217+
io::log_red "error: bazel verb required"
218+
return 1
219+
fi
220+
local verb="$1"
221+
local args=("${@:2}")
212222

213223
io::log_h2 "Running Spanner integration tests (with emulator)"
214224
"google/cloud/spanner/ci/${EMULATOR_SCRIPT}" \
215225
bazel "${verb}" "${args[@]}" --test_tag_filters="integration-test,-ud-only"
226+
}
227+
228+
# Runs Bigtable integration tests.
229+
function integration::bazel_bigtable_with_emulators() {
230+
local EMULATOR_SCRIPT="run_integration_tests_emulator_bazel.sh"
231+
if [[ $# == 0 ]]; then
232+
io::log_red "error: bazel verb required"
233+
return 1
234+
fi
235+
local verb="$1"
236+
local args=("${@:2}")
216237

217238
io::log_h2 "Running Bigtable integration tests (with emulator)"
218239
"google/cloud/bigtable/ci/${EMULATOR_SCRIPT}" \
219240
bazel "${verb}" "${args[@]}" --test_tag_filters="integration-test,-ud-only"
220241

221-
io::log_h2 "Running REST integration tests (with emulator)"
222-
"google/cloud/internal/ci/${EMULATOR_SCRIPT}" \
223-
bazel "${verb}" "${args[@]}" --test_tag_filters="integration-test,-ud-only"
224-
225242
if [[ "${BAZEL_TARGETS[*]}" != "..." ]]; then
226-
io::log_h2 "Skipping some integration tests because BAZEL_TARGETS is not the default"
227243
return 0
228244
fi
229245

230-
io::log_h2 "Running integration tests that require production access"
231-
bazel "${verb}" "${args[@]}" \
232-
--test_tag_filters="${production_tests_tag_filters}" \
233-
"${production_integration_tests[@]}"
234-
235246
# This test is run separately because the access token changes every time and
236247
# that would mess up bazel's test cache for all the other tests.
237248
io::log_h2 "Running Bigtable gRPC credential examples"
238249
access_token="$(gcloud auth print-access-token)"
239250
bazel "${verb}" "${args[@]}" \
240251
"--test_env=GOOGLE_CLOUD_CPP_BIGTABLE_TEST_ACCESS_TOKEN=${access_token}" \
241252
//google/cloud/bigtable/examples:bigtable_grpc_credentials
253+
}
254+
255+
# Runs REST integration tests.
256+
function integration::bazel_rest_with_emulators() {
257+
local EMULATOR_SCRIPT="run_integration_tests_emulator_bazel.sh"
258+
if [[ $# == 0 ]]; then
259+
io::log_red "error: bazel verb required"
260+
return 1
261+
fi
262+
local verb="$1"
263+
local args=("${@:2}")
264+
265+
io::log_h2 "Running REST integration tests (with emulator)"
266+
"google/cloud/internal/ci/${EMULATOR_SCRIPT}" \
267+
bazel "${verb}" "${args[@]}" --test_tag_filters="integration-test,-ud-only"
268+
269+
if [[ "${BAZEL_TARGETS[*]}" != "..." ]]; then
270+
return 0
271+
fi
272+
273+
production_tests_tag_filters="integration-test,-ud-only"
274+
if echo "${args[@]}" | grep -w -q -- "--config=msan"; then
275+
production_tests_tag_filters="integration-test,-no-msan,-ud-only"
276+
fi
277+
278+
io::log_h2 "Running REST production integration tests"
279+
bazel "${verb}" "${args[@]}" \
280+
--test_tag_filters="${production_tests_tag_filters}" \
281+
"google/cloud:internal_unified_rest_credentials_integration_test"
282+
}
283+
284+
# Runs combined examples integration tests.
285+
function integration::bazel_examples_with_emulators() {
286+
if [[ $# == 0 ]]; then
287+
io::log_red "error: bazel verb required"
288+
return 1
289+
fi
290+
local verb="$1"
291+
local args=("${@:2}")
292+
293+
if [[ "${BAZEL_TARGETS[*]}" != "..." ]]; then
294+
return 0
295+
fi
242296

243297
# This test is run separately because the URL may change and that would mess
244298
# up Bazel's test cache for all the other tests.
@@ -260,6 +314,30 @@ function integration::bazel_with_emulators() {
260314
"--test_env=GOOGLE_CLOUD_CPP_TEST_HELLO_WORLD_GRPC_URL=${hello_world_grpc}" \
261315
"--test_env=GOOGLE_CLOUD_CPP_TEST_HELLO_WORLD_SERVICE_ACCOUNT=${GOOGLE_CLOUD_CPP_TEST_HELLO_WORLD_SERVICE_ACCOUNT}" \
262316
//examples/...
317+
}
318+
319+
# Runs generator integration tests.
320+
function integration::bazel_generator_with_emulators() {
321+
if [[ $# == 0 ]]; then
322+
io::log_red "error: bazel verb required"
323+
return 1
324+
fi
325+
local verb="$1"
326+
local args=("${@:2}")
327+
328+
if [[ "${BAZEL_TARGETS[*]}" != "..." ]]; then
329+
return 0
330+
fi
331+
332+
production_tests_tag_filters="integration-test,-ud-only"
333+
if echo "${args[@]}" | grep -w -q -- "--config=msan"; then
334+
production_tests_tag_filters="integration-test,-no-msan,-ud-only"
335+
fi
336+
337+
io::log_h2 "Running generator production integration tests"
338+
bazel "${verb}" "${args[@]}" \
339+
--test_tag_filters="${production_tests_tag_filters}" \
340+
"generator/..."
263341

264342
local bazel_output_base
265343
if echo "${args[@]}" | grep -w -q -- "--config=msan"; then
@@ -293,6 +371,55 @@ function integration::bazel_with_emulators() {
293371
fi
294372
}
295373

374+
# Runs all integration tests with bazel using emulators when possible.
375+
function integration::bazel_with_emulators() {
376+
if [[ $# == 0 ]]; then
377+
io::log_red "error: bazel verb required"
378+
return 1
379+
fi
380+
381+
local verb="$1"
382+
local args=("${@:2}")
383+
384+
integration::bazel_pubsub_with_emulators "${verb}" "${args[@]}"
385+
integration::bazel_spanner_with_emulators "${verb}" "${args[@]}"
386+
integration::bazel_bigtable_with_emulators "${verb}" "${args[@]}"
387+
integration::bazel_rest_with_emulators "${verb}" "${args[@]}"
388+
389+
if [[ "${BAZEL_TARGETS[*]}" != "..." ]]; then
390+
io::log_h2 "Skipping some integration tests because BAZEL_TARGETS is not the default"
391+
return 0
392+
fi
393+
394+
production_integration_tests=(
395+
# gRPC Utils integration tests
396+
"google/cloud:internal_grpc_impersonate_service_account_integration_test"
397+
# BigQuery integration tests
398+
"google/cloud/bigquery/..."
399+
# Compute integration tests
400+
"google/cloud/compute/..."
401+
# IAM and IAM Credentials integration tests
402+
"google/cloud/iam/..."
403+
# Logging integration tests
404+
"google/cloud/logging/..."
405+
# Cloud Sql Admin integration tests
406+
"google/cloud/sql/integration_tests/..."
407+
)
408+
409+
production_tests_tag_filters="integration-test,-ud-only"
410+
if echo "${args[@]}" | grep -w -q -- "--config=msan"; then
411+
production_tests_tag_filters="integration-test,-no-msan,-ud-only"
412+
fi
413+
414+
io::log_h2 "Running production integration tests for other libraries"
415+
bazel "${verb}" "${args[@]}" \
416+
--test_tag_filters="${production_tests_tag_filters}" \
417+
"${production_integration_tests[@]}"
418+
419+
integration::bazel_examples_with_emulators "${verb}" "${args[@]}"
420+
integration::bazel_generator_with_emulators "${verb}" "${args[@]}"
421+
}
422+
296423
# Runs integration tests with CTest using emulators. This function requires a
297424
# first argument that is the "cmake-out" directory where the tests live.
298425
#

ci/cloudbuild/builds/msan.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ args+=("--config=msan")
3030
io::run bazel test "${args[@]}" --test_tag_filters=-integration-test,-no-msan "${BAZEL_TARGETS[@]}"
3131

3232
mapfile -t integration_args < <(integration::bazel_args)
33-
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
33+
if [[ "${INTEGRATION_LIBRARIES:-}" == "storage" ]]; then
34+
integration::bazel_storage_with_emulators test "${args[@]}" "${integration_args[@]}"
35+
else
36+
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
37+
fi

ci/cloudbuild/builds/tsan.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ args+=("--test_env=TSAN_OPTIONS=suppressions=${PROJECT_ROOT}/ci/tsan_suppression
3232
io::run bazel test "${args[@]}" --test_tag_filters=-integration-test "${BAZEL_TARGETS[@]}"
3333

3434
mapfile -t integration_args < <(integration::bazel_args)
35-
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
35+
if [[ "${INTEGRATION_LIBRARIES:-}" == "storage" ]]; then
36+
integration::bazel_storage_with_emulators test "${args[@]}" "${integration_args[@]}"
37+
else
38+
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
39+
fi

ci/cloudbuild/builds/ubsan.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ args+=("--deleted_packages=${deleted_packages:1}")
3535
io::run bazel test "${args[@]}" --test_tag_filters=-integration-test "${BAZEL_TARGETS[@]}"
3636

3737
mapfile -t integration_args < <(integration::bazel_args)
38-
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
38+
if [[ "${INTEGRATION_LIBRARIES:-}" == "storage" ]]; then
39+
integration::bazel_storage_with_emulators test "${args[@]}" "${integration_args[@]}"
40+
else
41+
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
42+
fi

ci/cloudbuild/builds/xsan.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ args+=("--config=xsan")
3030
io::run bazel test "${args[@]}" --test_tag_filters=-integration-test "${BAZEL_TARGETS[@]}"
3131

3232
mapfile -t integration_args < <(integration::bazel_args)
33-
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
33+
if [[ "${INTEGRATION_LIBRARIES:-}" == "storage" ]]; then
34+
integration::bazel_storage_with_emulators test "${args[@]}" "${integration_args[@]}"
35+
else
36+
integration::bazel_with_emulators test "${args[@]}" "${integration_args[@]}"
37+
fi

ci/cloudbuild/cloudbuild.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ substitutions:
5050
_TAG1: 'team-only'
5151
_LIBRARIES: 'all_bar_compute'
5252
_SHARD: '__default__'
53+
_INTEGRATION_LIBRARIES: 'all'
5354

5455
timeout: 36000s
5556
tags: [
@@ -126,6 +127,7 @@ steps:
126127
env: [
127128
'BAZEL_REMOTE_CACHE=https://storage.googleapis.com/${_CACHE_BUCKET}/bazel-cache/${_DISTRO}-${_BUILD_NAME}',
128129
'LIBRARIES=${_LIBRARIES}',
130+
'INTEGRATION_LIBRARIES=${_INTEGRATION_LIBRARIES}',
129131
'SHARD=${_SHARD}',
130132
'SCCACHE_GCS_BUCKET=${_CACHE_BUCKET}',
131133
'SCCACHE_GCS_KEY_PREFIX=sccache/${_DISTRO}-${_BUILD_NAME}',

ci/cloudbuild/triggers/asan-ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ name: asan-ci
2323
substitutions:
2424
_BUILD_NAME: asan
2525
_DISTRO: fedora-latest-bazel
26+
_INTEGRATION_LIBRARIES: all_bar_storage
2627
_TRIGGER_TYPE: ci
2728
tags:
2829
- ci

ci/cloudbuild/triggers/asan-pr.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ name: asan-pr
2424
substitutions:
2525
_BUILD_NAME: asan
2626
_DISTRO: fedora-latest-bazel
27+
_INTEGRATION_LIBRARIES: all_bar_storage
2728
_TRIGGER_TYPE: pr
2829
tags:
2930
- pr

0 commit comments

Comments
 (0)