@@ -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#
0 commit comments