From 9e16218a088a7888d8b4c657e157956c28206d5c Mon Sep 17 00:00:00 2001 From: Brian Upton Date: Thu, 5 Dec 2024 18:23:18 -0800 Subject: [PATCH 1/2] CI: rewrite bats test scripts to use relative paths - this removes hard-coded references to `$CI_ROOT/bosh` and `$CI_ROOT/bosh-ci` --- ci/tasks/test-brats-performance.sh | 38 ++++++++++++++++++------------ ci/tasks/test-brats.sh | 30 ++++++++++++++--------- 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/ci/tasks/test-brats-performance.sh b/ci/tasks/test-brats-performance.sh index 816dafe3e9..6b03ed62f2 100755 --- a/ci/tasks/test-brats-performance.sh +++ b/ci/tasks/test-brats-performance.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash +set -eu -o pipefail -set -eu - -script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -src_dir="${script_dir}/../../.." +bosh_repo_dir="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")../../" && pwd)")" +bosh_repo_parent_dir="$(realpath "${bosh_repo_dir}/..")" export BOSH_DEPLOYMENT_PATH="/usr/local/bosh-deployment" -source "${src_dir}/bosh/ci/dockerfiles/docker-cpi/start-bosh.sh" +source "${bosh_repo_dir}/ci/dockerfiles/docker-cpi/start-bosh.sh" source /tmp/local-bosh/director/env bosh int /tmp/local-bosh/director/creds.yml --path /jumpbox_ssh/private_key > /tmp/jumpbox_ssh_key.pem @@ -15,20 +14,24 @@ chmod 400 /tmp/jumpbox_ssh_key.pem export BOSH_DIRECTOR_IP="10.245.0.3" -export BOSH_BINARY_PATH=$(which bosh) -bosh_release_tgz=(${PWD}/bosh-release/*.tgz) -export BOSH_DIRECTOR_TARBALL_PATH=${bosh_release_tgz[0]} +BOSH_BINARY_PATH=$(which bosh) +export BOSH_BINARY_PATH +BOSH_DIRECTOR_TARBALL_PATH="$(find "${bosh_repo_parent_dir}/bosh-release" -maxdepth 1 -path '*.tgz')" +export BOSH_DIRECTOR_TARBALL_PATH export BOSH_DIRECTOR_RELEASE_PATH="$PWD/bosh" export CF_DEPLOYMENT_RELEASE_PATH="$PWD/cf-deployment" -export CANDIDATE_STEMCELL_TARBALL_PATH="$(realpath "${src_dir}"/stemcell/*.tgz)" +CANDIDATE_STEMCELL_TARBALL_PATH="$(find "${bosh_repo_parent_dir}/stemcell" -maxdepth 1 -path '*.tgz')" +export CANDIDATE_STEMCELL_TARBALL_PATH export STEMCELL_OS=ubuntu-jammy -export DOCKER_CERTS="$(bosh int /tmp/local-bosh/director/bosh-director.yml --path /instance_groups/0/properties/docker_cpi/docker/tls)" -export DOCKER_HOST="$(bosh int /tmp/local-bosh/director/bosh-director.yml --path /instance_groups/name=bosh/properties/docker_cpi/docker/host)" +DOCKER_CERTS="$(bosh int /tmp/local-bosh/director/bosh-director.yml --path /instance_groups/0/properties/docker_cpi/docker/tls)" +export DOCKER_CERTS +DOCKER_HOST="$(bosh int /tmp/local-bosh/director/bosh-director.yml --path /instance_groups/name=bosh/properties/docker_cpi/docker/host)" +export DOCKER_HOST bosh -n update-cloud-config \ "${BOSH_DEPLOYMENT_PATH}/docker/cloud-config.yml" \ - -o "${src_dir}/bosh-ci/ci/dockerfiles/docker-cpi/outer-cloud-config-ops.yml" \ + -o "${bosh_repo_dir}/ci/dockerfiles/docker-cpi/outer-cloud-config-ops.yml" \ -v network=director_network bosh -n upload-stemcell "${CANDIDATE_STEMCELL_TARBALL_PATH}" @@ -38,6 +41,11 @@ bosh upload-release "$(bosh int ${BOSH_DEPLOYMENT_PATH}/docker/cpi.yml --path /n bosh upload-release "$(bosh int ${BOSH_DEPLOYMENT_PATH}/jumpbox-user.yml --path /release=os-conf/value/url)" \ --sha1 "$(bosh int ${BOSH_DEPLOYMENT_PATH}/jumpbox-user.yml --path /release=os-conf/value/sha1)" -pushd "${src_dir}/bosh/src/brats" > /dev/null - go run github.com/onsi/ginkgo/v2/ginkgo --timeout=24h -r --race --nodes 1 performance -popd > /dev/null +pushd "${bosh_repo_dir}/src/brats/performance" + go run github.com/onsi/ginkgo/v2/ginkgo \ + -r -v --race \ + --focus="${FOCUS_SPEC:-}" \ + --nodes 1 \ + --timeout=24h \ + . +popd diff --git a/ci/tasks/test-brats.sh b/ci/tasks/test-brats.sh index b3b6a520b1..5bb6f8e139 100755 --- a/ci/tasks/test-brats.sh +++ b/ci/tasks/test-brats.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash set -eu -o pipefail -script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -src_dir="${script_dir}/../../.." +bosh_repo_dir="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")../../" && pwd)")" +bosh_repo_parent_dir="$(realpath "${bosh_repo_dir}/..")" -OVERRIDDEN_BOSH_DEPLOYMENT=$(realpath "$(dirname $0)/../../../bosh-deployment") +OVERRIDDEN_BOSH_DEPLOYMENT="${bosh_repo_parent_dir}/bosh-deployment" if [[ -e "${OVERRIDDEN_BOSH_DEPLOYMENT}/bosh.yml" ]];then BOSH_DEPLOYMENT_PATH=${OVERRIDDEN_BOSH_DEPLOYMENT} @@ -14,7 +14,7 @@ fi export BOSH_DEPLOYMENT_PATH if [ ! -f /tmp/local-bosh/director/env ]; then - source "${src_dir}/bosh/ci/dockerfiles/docker-cpi/start-bosh.sh" + source "${bosh_repo_dir}/ci/dockerfiles/docker-cpi/start-bosh.sh" fi source /tmp/local-bosh/director/env @@ -25,11 +25,11 @@ export BOSH_DIRECTOR_IP="10.245.0.3" BOSH_BINARY_PATH=$(which bosh) export BOSH_BINARY_PATH -export BOSH_RELEASE="${PWD}/bosh/src/spec/assets/dummy-release.tgz" -export BOSH_DIRECTOR_RELEASE_PATH="${PWD}/bosh-release" -DNS_RELEASE_PATH="$(realpath "$(find "${PWD}"/bosh-dns-release -maxdepth 1 -path '*.tgz')")" +export BOSH_RELEASE="${bosh_repo_dir}/src/spec/assets/dummy-release.tgz" +export BOSH_DIRECTOR_RELEASE_PATH="${bosh_repo_parent_dir}/bosh-release" +DNS_RELEASE_PATH="$(find "${bosh_repo_parent_dir}/bosh-dns-release" -maxdepth 1 -path '*.tgz')" export DNS_RELEASE_PATH -CANDIDATE_STEMCELL_TARBALL_PATH="$(realpath "${src_dir}"/stemcell/*.tgz)" +CANDIDATE_STEMCELL_TARBALL_PATH="$(find "${bosh_repo_parent_dir}/stemcell" -maxdepth 1 -path '*.tgz')" export CANDIDATE_STEMCELL_TARBALL_PATH export BOSH_DNS_ADDON_OPS_FILE_PATH="${BOSH_DEPLOYMENT_PATH}/misc/dns-addon.yml" @@ -42,7 +42,7 @@ export DOCKER_HOST bosh -n update-cloud-config \ "${BOSH_DEPLOYMENT_PATH}/docker/cloud-config.yml" \ - -o "${src_dir}/bosh-ci/ci/dockerfiles/docker-cpi/outer-cloud-config-ops.yml" \ + -o "${bosh_repo_dir}/ci/dockerfiles/docker-cpi/outer-cloud-config-ops.yml" \ -v network=director_network bosh -n upload-stemcell "${CANDIDATE_STEMCELL_TARBALL_PATH}" @@ -73,7 +73,7 @@ if [ -d database-metadata ]; then export GCP_POSTGRES_EXTERNAL_DB_CLIENT_PRIVATE_KEY fi -brats_env_file="${PWD}/brats-env.sh" +brats_env_file="${bosh_repo_parent_dir}/brats-env.sh" { echo "export OUTER_BOSH_ENV_PATH=\"${OUTER_BOSH_ENV_PATH}\"" echo "export DOCKER_CERTS=\"${DOCKER_CERTS}\"" @@ -112,4 +112,12 @@ brats_env_file="${PWD}/brats-env.sh" echo "# The required BRATS environment can be loaded by running the following:" echo "# 'source ${brats_env_file}'" -bosh/scripts/test-brats +pushd "${bosh_repo_dir}/src/brats" + go run github.com/onsi/ginkgo/v2/ginkgo \ + -r -v --race \ + --randomize-suites --randomize-all \ + --focus="${FOCUS_SPEC:-}" \ + -nodes 5 \ + --skip-package=performance \ + . +popd From 3ab11e02ff0e77836ce057b5cefe70c6c4821b56 Mon Sep 17 00:00:00 2001 From: aram price Date: Thu, 5 Dec 2024 18:29:36 -0800 Subject: [PATCH 2/2] CI: fix missing `/` --- ci/tasks/test-brats-performance.sh | 2 +- ci/tasks/test-brats.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/tasks/test-brats-performance.sh b/ci/tasks/test-brats-performance.sh index 6b03ed62f2..44fb5c7a02 100755 --- a/ci/tasks/test-brats-performance.sh +++ b/ci/tasks/test-brats-performance.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eu -o pipefail -bosh_repo_dir="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")../../" && pwd)")" +bosh_repo_dir="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")/../../" && pwd)")" bosh_repo_parent_dir="$(realpath "${bosh_repo_dir}/..")" export BOSH_DEPLOYMENT_PATH="/usr/local/bosh-deployment" diff --git a/ci/tasks/test-brats.sh b/ci/tasks/test-brats.sh index 5bb6f8e139..93a2fb919e 100755 --- a/ci/tasks/test-brats.sh +++ b/ci/tasks/test-brats.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eu -o pipefail -bosh_repo_dir="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")../../" && pwd)")" +bosh_repo_dir="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")/../../" && pwd)")" bosh_repo_parent_dir="$(realpath "${bosh_repo_dir}/..")" OVERRIDDEN_BOSH_DEPLOYMENT="${bosh_repo_parent_dir}/bosh-deployment"