Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate running VPC e2e tests with Boskos #1026

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions hack/boskos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ set -o pipefail
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..

USER="cluster-api-provider-ibmcloud"
RESOURCE_TYPE="${RESOURCE_TYPE:-"powervs-service"}"

release_account(){
url="http://${BOSKOS_HOST}/release?name=${BOSKOS_RESOURCE_NAME}&dest=dirty&owner=${USER}"
Expand All @@ -34,14 +33,19 @@ release_account(){
}

checkout_account(){
url="http://${BOSKOS_HOST}/acquire?type=${RESOURCE_TYPE}&state=free&dest=busy&owner=${USER}"
resource_type=$1
url="http://${BOSKOS_HOST}/acquire?type=${resource_type}&state=free&dest=busy&owner=${USER}"
output=$(curl -X POST ${url})
[ $? = 0 ] && status_code=200

if [[ ${status_code} == 200 ]]; then
echo "export BOSKOS_RESOURCE_NAME=$(echo ${output} | jq -r '.name')"
echo "export BOSKOS_RESOURCE_ID=$(echo ${output} | jq -r '.userdata["service-instance-id"]')"
echo "export IBMCLOUD_API_KEY=$(echo ${output} | jq -r '.userdata["api-key"]')"
echo "export BOSKOS_RESOURCE_GROUP=$(echo ${output} | jq -r '.userdata["resource-group"]')"
echo "export BOSKOS_REGION=$(echo ${output} | jq -r '.userdata["region"]')"
if [[ ${resource_type} == "powervs-service" ]]; then
echo "export BOSKOS_RESOURCE_ID=$(echo ${output} | jq -r '.userdata["service-instance-id"]')"
fi
else
echo "Got invalid response- ${status_code}"
exit 1
Expand Down
18 changes: 11 additions & 7 deletions scripts/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
cd "${REPO_ROOT}" || exit 1
GOPATH_BIN="$(go env GOPATH)/bin/"
export PATH="${GOPATH_BIN}:${PATH}"
RESOURCE_TYPE="${RESOURCE_TYPE:-"powervs-service"}"

# shellcheck source=../hack/ensure-go.sh
source "${REPO_ROOT}/hack/ensure-go.sh"
Expand All @@ -35,8 +36,8 @@ mkdir -p "${ARTIFACTS}/logs/"

ARCH=$(uname -m)
OS=$(uname -s)
IBMCLOUD_CLI_VERSION=${IBMCLOUD_CLI_VERSION:-"2.12.0"}
PVSADM_VERSION=${PVSADM_VERSION:-"v0.1.7"}
IBMCLOUD_CLI_VERSION=${IBMCLOUD_CLI_VERSION:-"2.13.0"}
PVSADM_VERSION=${PVSADM_VERSION:-"v0.1.9"}
E2E_FLAVOR=${E2E_FLAVOR:-}
REGION=${REGION:-"us-south"}

Expand Down Expand Up @@ -113,10 +114,10 @@ prerequisites_powervs(){

prerequisites_vpc(){
# Assigning VPC variables
export IBMVPC_REGION=${REGION}
export IBMVPC_ZONE="${REGION}-1"
export IBMVPC_RESOURCEGROUP=${IBMVPC_RESOURCEGROUP:-"fa5405a58226402f9a5818cb9b8a5a8a"}
export IBMVPC_NAME="capi-vpc-$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head --bytes 5)"
export IBMVPC_REGION=${BOSKOS_REGION:-"jp-tok"}
export IBMVPC_ZONE="${BOSKOS_REGION:-}-1"
export IBMVPC_RESOURCEGROUP=${BOSKOS_RESOURCE_GROUP:-"fa5405a58226402f9a5818cb9b8a5a8a"}
export IBMVPC_NAME=${BOSKOS_RESOURCE_NAME:-"capi-vpc-e2e"}
export IBMVPC_IMAGE_NAME=${IBMVPC_IMAGE_NAME:-"capibm-vpc-ubuntu-2004-kube-v1-25-2"}
export IBMVPC_PROFILE=${IBMVPC_PROFILE:-"bx2-4x16"}
export IBMVPC_SSHKEY_NAME=${IBMVPC_SSHKEY_NAME:-"vpc-cloud-bot-key"}
Expand All @@ -125,12 +126,15 @@ prerequisites_vpc(){
}

main(){

[ "${E2E_FLAVOR}" = "vpc" ] && RESOURCE_TYPE="vpc-service"

# If BOSKOS_HOST is set then acquire an IBM Cloud resource from Boskos.
if [ -n "${BOSKOS_HOST:-}" ]; then
# Check out the resource from Boskos and store the produced environment
# variables in a temporary file.
account_env_var_file="$(mktemp)"
checkout_account 1> "${account_env_var_file}"
checkout_account ${RESOURCE_TYPE} 1> "${account_env_var_file}"
checkout_account_status="${?}"

# If the checkout process was a success then load the
Expand Down