@@ -27,19 +27,26 @@ export PATH="${GOPATH_BIN}:${PATH}"
27
27
source " ${REPO_ROOT} /hack/ensure-go.sh"
28
28
# shellcheck source=../hack/ensure-kubectl.sh
29
29
source " ${REPO_ROOT} /hack/ensure-kubectl.sh"
30
+ # shellcheck source=../hack/boskos.sh
31
+ source ${REPO_ROOT} /hack/boskos.sh
30
32
31
33
ARTIFACTS=" ${ARTIFACTS:- ${PWD} / _artifacts} "
32
34
mkdir -p " ${ARTIFACTS} /logs/"
33
35
34
36
ARCH=$( uname -m)
35
- PVSADM_VERSION=${PVSADM_VERSION:- " v0.1.3" }
37
+ PVSADM_VERSION=${PVSADM_VERSION:- " v0.1.4-alpha. 3" }
36
38
E2E_FLAVOR=${E2E_FLAVOR:- }
39
+ REGION=${REGION:- " us-south" }
40
+ RESOURCE_GROUP=${RESOURCE_GROUP:- " prow-resource-group" }
37
41
38
42
trap cleanup EXIT
39
43
40
44
cleanup (){
41
45
# Delete the created ports for the network instance
42
46
[ -n " ${NEW_PORT} " ] && ./pvsadm delete port --network ${IBMPOWERVS_NETWORK_NAME} --port-id ${PORT_ID} --instance-id ${IBMPOWERVS_SERVICE_INSTANCE_ID}
47
+
48
+ # stop the boskos heartbeat
49
+ [[ -z ${HEART_BEAT_PID:- } ]] || kill -9 " ${HEART_BEAT_PID} " || true
43
50
}
44
51
45
52
install_pvsadm (){
@@ -50,8 +57,26 @@ install_pvsadm(){
50
57
chmod +x ./pvsadm
51
58
}
52
59
60
+ create_powervs_network_instance (){
61
+ # Install ibmcloud CLI tool
62
+ curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
63
+
64
+ # Login to IBM Cloud using the API Key
65
+ ibmcloud login -a cloud.ibm.com -r ${REGION} -g ${RESOURCE_GROUP}
66
+
67
+ # Install power-iaas command-line plug-in and target the required service instance
68
+ ibmcloud plugin install power-iaas
69
+ CRN=$( ibmcloud resource service-instance ${IBMPOWERVS_SERVICE_INSTANCE_ID} --output json | jq -r ' .[].crn' )
70
+ ibmcloud pi service-target ${CRN}
71
+
72
+ # Create the network instance
73
+ ibmcloud pi network-create-public ${IBMPOWERVS_NETWORK_NAME} --dns-servers " 8.8.8.8 9.9.9.9"
74
+
75
+ }
76
+
53
77
init_network_powervs (){
54
78
install_pvsadm
79
+ create_powervs_network_instance
55
80
56
81
# Creating ports using the pvsadm tool
57
82
./pvsadm create port --description " capi-port-e2e" --network ${IBMPOWERVS_NETWORK_NAME} --instance-id ${IBMPOWERVS_SERVICE_INSTANCE_ID}
@@ -68,10 +93,37 @@ prerequisites_powervs(){
68
93
# Assigning PowerVS variables
69
94
export IBMPOWERVS_IMAGE_NAME=${IBMPOWERVS_IMAGE_NAME:- " capibm-powervs-centos-streams8-1-22-4" }
70
95
export IBMPOWERVS_SERVICE_INSTANCE_ID=${IBMPOWERVS_SERVICE_INSTANCE_ID:- " 0f28d13a-6e33-4d86-b6d7-a9b46ff7659e" }
71
- export IBMPOWERVS_NETWORK_NAME=${IBMPOWERVS_NETWORK_NAME :- " capi-e2e-test" }
96
+ export IBMPOWERVS_NETWORK_NAME=${BOSKOS_RESOURCE_NAME :- " capi-e2e-test" }
72
97
}
73
98
74
99
main (){
100
+ # If BOSKOS_HOST is set then acquire an IBM Cloud resource from Boskos.
101
+ if [ -n " ${BOSKOS_HOST:- } " ]; then
102
+ # Check out the resource from Boskos and store the produced environment
103
+ # variables in a temporary file.
104
+ account_env_var_file=" $( mktemp) "
105
+ checkout_account 1> " ${account_env_var_file} "
106
+ checkout_account_status=" ${?} "
107
+
108
+ # If the checkout process was a success then load the
109
+ # environment variables into this process.
110
+ [ " ${checkout_account_status} " = " 0" ] && . " ${account_env_var_file} "
111
+
112
+ # Always remove the account environment variable file which
113
+ # could contain sensitive information.
114
+ rm -f " ${account_env_var_file} "
115
+
116
+ if [ ! " ${checkout_account_status} " = " 0" ]; then
117
+ echo " error getting account from boskos" 1>&2
118
+ exit " ${checkout_account_status} "
119
+ fi
120
+
121
+ # Run the heart beat process to tell Boskos that we are still
122
+ # using the checked out resource periodically.
123
+ heartbeat_account >> " $ARTIFACTS /logs/boskos.log" 2>&1 &
124
+ HEART_BEAT_PID=$( echo $! )
125
+ fi
126
+
75
127
if [[ " ${E2E_FLAVOR} " == " powervs" ]]; then
76
128
prerequisites_powervs
77
129
init_network_powervs
@@ -81,6 +133,9 @@ main(){
81
133
make test-e2e
82
134
test_status=" ${?} "
83
135
echo TESTSTATUS=" ${test_status} "
136
+
137
+ # If Boskos is being used then release the IBM Cloud resource back to Boskos.
138
+ [ -z " ${BOSKOS_HOST:- } " ] || release_account >> " $ARTIFACTS /logs/boskos.log" 2>&1
84
139
}
85
140
86
141
main " $@ "
0 commit comments