From 4acf845a358a627d3fcaade100e82767df392772 Mon Sep 17 00:00:00 2001 From: Moreno Ambrosin Date: Mon, 27 Nov 2023 03:49:37 -0800 Subject: [PATCH] Test examples in kokoro/gcp_ubuntu/bazel/run_tests.sh Remove the unused test script PiperOrigin-RevId: 585602443 Change-Id: Ic1fb002d15b7ee76dcdcb63dc83757b553918e13 --- kokoro/gcp_ubuntu/bazel/run_tests.sh | 29 +++++-- kokoro/gcp_ubuntu/examples/bazel/run_tests.sh | 81 ------------------- 2 files changed, 22 insertions(+), 88 deletions(-) delete mode 100644 kokoro/gcp_ubuntu/examples/bazel/run_tests.sh diff --git a/kokoro/gcp_ubuntu/bazel/run_tests.sh b/kokoro/gcp_ubuntu/bazel/run_tests.sh index eb6beba..f8a9ed2 100644 --- a/kokoro/gcp_ubuntu/bazel/run_tests.sh +++ b/kokoro/gcp_ubuntu/bazel/run_tests.sh @@ -59,23 +59,38 @@ readonly GITHUB_ORG="https://github.com/tink-crypto" "${GITHUB_ORG}/tink-cc" ./kokoro/testutils/copy_credentials.sh "testdata" "gcp" - -MANUAL_TARGETS=() -if [[ "${IS_KOKORO}" == "true" ]]; then - MANUAL_TARGETS+=("//tink/integration/gcpkms:gcp_kms_aead_integration_test") -fi -readonly MANUAL_TARGETS +./kokoro/testutils/copy_credentials.sh "examples/testdata" "gcp" cp "WORKSPACE" "WORKSPACE.bak" ./kokoro/testutils/replace_http_archive_with_local_repository.py \ -f "WORKSPACE" -t .. +cp "examples/WORKSPACE" "examples/WORKSPACE.bak" +./kokoro/testutils/replace_http_archive_with_local_repository.py \ + -f "examples/WORKSPACE" -t ../.. + trap cleanup EXIT cleanup() { - # Restore the original WORKSPACE on exit (moslty useful for local testing). mv "WORKSPACE.bak" "WORKSPACE" + mv "examples/WORKSPACE.bak" "examples/WORKSPACE" } +MANUAL_TARGETS=() +if [[ "${IS_KOKORO}" == "true" ]]; then + MANUAL_TARGETS+=("//tink/integration/gcpkms:gcp_kms_aead_integration_test") +fi +readonly MANUAL_TARGETS + ./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \ ./kokoro/testutils/run_bazel_tests.sh . "${MANUAL_TARGETS[@]}" + +# Test examples. +EXAMPLES_MANUAL_TARGETS=() +if [[ "${IS_KOKORO}" == "true" ]]; then + EXAMPLES_MANUAL_TARGETS+=( "//envelopeaead:envelopeaead_cli_test" ) +fi +readonly EXAMPLES_MANUAL_TARGETS + +./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \ + ./kokoro/testutils/run_bazel_tests.sh examples "${EXAMPLES_MANUAL_TARGETS[@]}" diff --git a/kokoro/gcp_ubuntu/examples/bazel/run_tests.sh b/kokoro/gcp_ubuntu/examples/bazel/run_tests.sh deleted file mode 100644 index 76191f3..0000000 --- a/kokoro/gcp_ubuntu/examples/bazel/run_tests.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# Copyright 2023 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 -# -# http://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. -################################################################################ - -# By default when run locally this script runs the command below directly on the -# host. The CONTAINER_IMAGE variable can be set to run on a custom container -# image for local testing. E.g.: -# -# CONTAINER_IMAGE="gcr.io/tink-test-infrastructure/linux-tink-cc-base:latest" \ -# sh ./kokoro/gcp_ubuntu/examples/bazel/run_tests.sh -# -# The user may specify TINK_BASE_DIR as the folder where to look for -# tink-cc-gcpkms and its dependencies. That is: -# ${TINK_BASE_DIR}/tink_cc -# ${TINK_BASE_DIR}/tink_cc_gcpkms -# NOTE: tink_cc is fetched from GitHub if not found. -set -eEuo pipefail - -IS_KOKORO="false" -if [[ -n "${KOKORO_ARTIFACTS_DIR:-}" ]]; then - IS_KOKORO="true" -fi -readonly IS_KOKORO - -RUN_COMMAND_ARGS=() -if [[ "${IS_KOKORO}" == "true" ]]; then - TINK_BASE_DIR="$(echo "${KOKORO_ARTIFACTS_DIR}"/git*)" - source \ - "${TINK_BASE_DIR}/tink_cc_gcpkms/kokoro/testutils/cc_test_container_images.sh" - CONTAINER_IMAGE="${TINK_CC_BASE_IMAGE}" - RUN_COMMAND_ARGS+=( -k "${TINK_GCR_SERVICE_KEY}" ) -fi -: "${TINK_BASE_DIR:=$(cd .. && pwd)}" -readonly TINK_BASE_DIR -readonly CONTAINER_IMAGE - -if [[ -n "${CONTAINER_IMAGE:-}" ]]; then - RUN_COMMAND_ARGS+=( -c "${CONTAINER_IMAGE}" ) -fi - -cd "${TINK_BASE_DIR}/tink_cc_gcpkms" - -# Check for dependencies in TINK_BASE_DIR. Any that aren't present will be -# downloaded. -readonly GITHUB_ORG="https://github.com/tink-crypto" -./kokoro/testutils/fetch_git_repo_if_not_present.sh "${TINK_BASE_DIR}" \ - "${GITHUB_ORG}/tink-cc" - -./kokoro/testutils/copy_credentials.sh "examples/testdata" "gcp" - -cp "examples/WORKSPACE" "examples/WORKSPACE.bak" -./kokoro/testutils/replace_http_archive_with_local_repository.py \ - -f "examples/WORKSPACE" -t ../.. - -trap cleanup EXIT - -cleanup() { - # Restore the original WORKSPACE on exit (moslty useful for local testing). - mv "examples/WORKSPACE.bak" "examples/WORKSPACE" -} - -MANUAL_TARGETS=() -if [[ "${IS_KOKORO}" == "true" ]]; then - MANUAL_TARGETS+=( "//envelopeaead:envelopeaead_cli_test" ) -fi -readonly MANUAL_TARGETS - -./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \ - ./kokoro/testutils/run_bazel_tests.sh examples "${MANUAL_TARGETS[@]}"