Skip to content

Commit 0e4d7eb

Browse files
authored
Add e2e-test script (#536)
1 parent 0a725fc commit 0e4d7eb

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
bin/
66
cmd/clusterctl/clusterctl
77
cmd/manager/manager
8+
pvsadm
89

910
# command generated files
1011
kubeconfig
@@ -27,6 +28,7 @@ junit*.xml
2728

2829
#e2e test files
2930
test/e2e/config/ibmcloud-e2e-envsubst.yaml
31+
pvsadm.log
3032

3133
# dep ensured 3rd code
3234
vendor/sigs.k8s.io/cluster-api/docs/book/*.json

scripts/ci-e2e.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
# Copyright 2022 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
22+
cd "${REPO_ROOT}" || exit 1
23+
24+
# shellcheck source=../hack/ensure-go.sh
25+
source "${REPO_ROOT}/hack/ensure-go.sh"
26+
27+
ARTIFACTS="${ARTIFACTS:-${PWD}/_artifacts}"
28+
mkdir -p "${ARTIFACTS}/logs/"
29+
30+
ARCH=$(uname -m)
31+
PVSADM_VERSION=${PVSADM_VERSION:-"v0.1.3"}
32+
E2E_FLAVOR=${E2E_FLAVOR:-}
33+
34+
trap cleanup EXIT
35+
36+
cleanup(){
37+
# Delete the created ports for the network instance
38+
[ -n "${NEW_PORT}" ] && ./pvsadm delete port --network ${IBMPOWERVS_NETWORK_NAME} --port-id ${PORT_ID} --instance-id ${IBMPOWERVS_SERVICE_INSTANCE_ID}
39+
}
40+
41+
install_pvsadm(){
42+
[ "${ARCH}" == "x86_64" ] && ARCH="amd64"
43+
44+
# Installing binaries from github releases
45+
curl -fsL https://github.com/ppc64le-cloud/pvsadm/releases/download/${PVSADM_VERSION}/pvsadm-linux-${ARCH} -o pvsadm
46+
chmod +x ./pvsadm
47+
}
48+
49+
init_network_powervs(){
50+
install_pvsadm
51+
52+
# Creating ports using the pvsadm tool
53+
./pvsadm create port --description "capi-port-e2e" --network ${IBMPOWERVS_NETWORK_NAME} --instance-id ${IBMPOWERVS_SERVICE_INSTANCE_ID}
54+
55+
# Get and assign the IPs to the required variables
56+
NEW_PORT=$(./pvsadm get ports --network ${IBMPOWERVS_NETWORK_NAME} --instance-id ${IBMPOWERVS_SERVICE_INSTANCE_ID} | sed -n '4 p')
57+
PORT_ID="$(echo ${NEW_PORT} | cut -d'|' -f6 | xargs )"
58+
export IBMPOWERVS_VIP="$(echo ${NEW_PORT} | cut -d'|' -f4 | xargs )"
59+
export IBMPOWERVS_VIP_EXTERNAL="$(echo ${NEW_PORT} | cut -d'|' -f3 | xargs )"
60+
export IBMPOWERVS_VIP_CIDR=${IBMPOWERVS_VIP_CIDR:="29"}
61+
}
62+
63+
prerequisites_powervs(){
64+
# Assigning PowerVS variables
65+
export IBMPOWERVS_IMAGE_NAME=${IBMPOWERVS_IMAGE_NAME:-"capibm-powervs-centos-streams8-1-22-4"}
66+
export IBMPOWERVS_SERVICE_INSTANCE_ID=${IBMPOWERVS_SERVICE_INSTANCE_ID:-"0f28d13a-6e33-4d86-b6d7-a9b46ff7659e"}
67+
export IBMPOWERVS_NETWORK_NAME=${IBMPOWERVS_NETWORK_NAME:-"capi-e2e-test"}
68+
}
69+
70+
main(){
71+
if [[ "${E2E_FLAVOR}" == "powervs" ]]; then
72+
prerequisites_powervs
73+
init_network_powervs
74+
fi
75+
76+
# Run the e2e tests
77+
make test-e2e
78+
test_status="${?}"
79+
echo TESTSTATUS="${test_status}"
80+
}
81+
82+
main "$@"
83+
exit "${test_status}"

0 commit comments

Comments
 (0)