@@ -250,27 +250,21 @@ psm::csm::run_test() {
250
250
# Provisions necessary software, configures the test driver, and executes the test suite.
251
251
#
252
252
# Globals:
253
- # KOKORO_ARTIFACTS_DIR
254
- # GITHUB_REPOSITORY_NAME
255
- # GRPC_LANGUAGE
256
- # SRC_DIR: Populated with absolute path to the source repo
257
- # TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
258
- # the test driver
259
- # TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
260
- # TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
261
- # TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
262
- # GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
263
- # GIT_COMMIT: Populated with the SHA-1 of git commit being built
264
- # GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
265
- # KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
253
+ # GRPC_LANGUAGE: The name of gRPC languages under test
254
+ # BUILD_SCRIPT_DIR: Absolute path to the directory with lang-specific buildscript
255
+ # in the source repo.
266
256
# Arguments:
267
- # Test suite name, one of (lb, security, url_map)
257
+ # Test suite name, one of (lb, security, url_map, csm )
268
258
# Outputs:
269
259
# Writes the output of test execution to stdout, stderr
270
260
# ######################################
271
261
psm::run () {
272
262
local test_suite=" ${1:? ${FUNCNAME[0]} missing the test suite argument} "
273
263
psm::tools::log " Starting PSM Interop tests: ${test_suite} "
264
+ if [[ $( type -t psm::lang::build_docker_images) != function ]]; then
265
+ psm::tools::log " Method psm::lang::build_docker_images must be defined by the buildscript."
266
+ exit 1
267
+ fi
274
268
275
269
psm::setup::docker_image_names " ${GRPC_LANGUAGE} " " ${test_suite} "
276
270
@@ -467,20 +461,69 @@ psm::setup::docker_image_names() {
467
461
}
468
462
469
463
psm::setup::test_driver () {
470
- local build_docker_script=" ${BUILD_SCRIPT_DIR} /psm-interop-build-${GRPC_LANGUAGE} .sh"
471
- psm::tools::log " Looking for docker image build script ${build_docker_script} "
472
- if [[ -f " ${build_docker_script} " ]]; then
473
- psm::tools::log " Sourcing docker image build script: ${build_docker_script} "
474
- source " ${build_docker_script} "
475
- fi
476
-
477
464
if [[ -n " ${KOKORO_ARTIFACTS_DIR} " ]]; then
478
- kokoro_setup_test_driver " ${GITHUB_REPOSITORY_NAME } "
465
+ psm::setup::kokoro " ${BUILD_SCRIPT_DIR } "
479
466
else
480
467
local_setup_test_driver " ${BUILD_SCRIPT_DIR} "
481
468
fi
482
469
}
483
470
471
+ # ######################################
472
+ # Installs and configures the test driver for testing build script locally.
473
+ # Globals:
474
+ # TEST_DRIVER_REPO_NAME The repository name of the test driver directory
475
+ # TEST_DRIVER_REPO_DIR: The path to the test driver directory (optional)
476
+ # SRC_DIR: Populated with absolute path to the source repo
477
+ # KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
478
+ # SECONDARY_KUBE_CONTEXT: Populated with name of kubectl context with secondary GKE cluster
479
+ # access, if any
480
+ # TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
481
+ # TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
482
+ # GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
483
+ # GIT_COMMIT: Populated with the SHA-1 of git commit being built
484
+ # GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
485
+ # Arguments:
486
+ # Absolute path to the directory with lang-specific buildscript, must be in the source repo.
487
+ # Outputs:
488
+ # Writes the output to stdout, stderr, files
489
+ # ######################################
490
+ psm::setup::kokoro () {
491
+ local script_dir=" ${1:? ${FUNCNAME[0]} missing the build script dir argument} "
492
+
493
+ psm::tools::log " Starting Kokoro provisioning"
494
+ # Capture Kokoro VM version info in the log.
495
+ kokoro_print_version
496
+ # Get testing version from the job name.
497
+ kokoro_get_testing_version
498
+
499
+ # Absolute path to the root of the source git repo.
500
+ readonly SRC_DIR=" $( git -C " ${script_dir} " rev-parse --show-toplevel) "
501
+
502
+ # Test artifacts dir: xml reports, logs, etc.
503
+ local artifacts_dir=" ${KOKORO_ARTIFACTS_DIR} /artifacts"
504
+ # Folders after $artifacts_dir reported as target name
505
+ readonly TEST_XML_OUTPUT_DIR=" ${artifacts_dir} /${KOKORO_JOB_NAME} "
506
+ readonly BUILD_LOGS_ROOT=" ${TEST_XML_OUTPUT_DIR} "
507
+
508
+ mkdir -p " ${artifacts_dir} " " ${TEST_XML_OUTPUT_DIR} " " ${BUILD_LOGS_ROOT} "
509
+ parse_src_repo_git_info SRC_DIR
510
+ kokoro_write_sponge_properties
511
+
512
+ psm::tools::log " Installing packages with apt, see install-apt.log"
513
+ kokoro_install_dependencies & > " ${BUILD_LOGS_ROOT} /install-apt.log"
514
+
515
+ # Get kubectl cluster credentials.
516
+ psm::tools::log " Fetching GKE cluster credentials"
517
+ gcloud_get_cluster_credentials
518
+
519
+ # Install the driver.
520
+ local test_driver_repo_dir
521
+ test_driver_repo_dir=" ${TEST_DRIVER_REPO_DIR:- $(mktemp -d)/ ${TEST_DRIVER_REPO_NAME} } "
522
+ test_driver_install " ${test_driver_repo_dir} "
523
+ # shellcheck disable=SC2034 # Used in the main script
524
+ readonly TEST_DRIVER_FLAGFILE=" config/grpc-testing.cfg"
525
+ }
526
+
484
527
# --- Common test build logic -----------
485
528
486
529
# ######################################
@@ -514,6 +557,7 @@ psm::build::docker_images_if_needed() {
514
557
{
515
558
psm::tools::log " Building xDS interop test app Docker images"
516
559
gcloud -q auth configure-docker " ${DOCKER_REGISTRY} "
560
+ # This method must be defined in the language-specific buildscript.
517
561
psm::lang::build_docker_images
518
562
psm::tools::log " Finished xDS interop test app Docker images"
519
563
} | tee -a " ${BUILD_LOGS_ROOT} /build-docker.log"
@@ -1015,6 +1059,9 @@ kokoro_get_testing_version() {
1015
1059
1016
1060
# ######################################
1017
1061
# Installs and configures the test driver on Kokoro VM.
1062
+ #
1063
+ # Deprecated. Use psm::setup::kokoro
1064
+ #
1018
1065
# Globals:
1019
1066
# KOKORO_ARTIFACTS_DIR
1020
1067
# KOKORO_JOB_NAME
@@ -1037,6 +1084,7 @@ kokoro_get_testing_version() {
1037
1084
# Writes the output to stdout, stderr, files
1038
1085
# ######################################
1039
1086
kokoro_setup_test_driver () {
1087
+ # TODO(sergiitk): Remove after per-lang buildscripts are backported.
1040
1088
# Unset noisy verbose mode often set in the parent scripts.
1041
1089
set +x
1042
1090
0 commit comments