Skip to content

Commit

Permalink
Add upgrade e2e test with helm
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Jain <[email protected]>
  • Loading branch information
reachjainrahul committed Jun 5, 2023
1 parent dcf5425 commit 7591a21
Show file tree
Hide file tree
Showing 9 changed files with 655 additions and 12 deletions.
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,17 @@ $(CONTROLLER_GEN):
# Run integration-tests
integration-test-aws:
ginkgo -v --timeout=90m --fail-fast --focus=".*test-aws.*" test/integration/ -- \
-manifest-path=../../config/nephe.yml -preserve-setup-on-fail=true -cloud-provider=AWS
-manifest-path=../../config/nephe.yml -preserve-setup-on-fail=true -cloud-provider=AWS

integration-test-azure:
ginkgo -v --timeout=90m --fail-fast --focus=".*test-azure.*" test/integration/ -- \
-manifest-path=../../config/nephe.yml -preserve-setup-on-fail=true -cloud-provider=Azure
-manifest-path=../../config/nephe.yml -preserve-setup-on-fail=true -cloud-provider=Azure

# Upgrade tests
upgrade-test-aws:
ginkgo -v --timeout=90m --fail-fast --focus=".*test-aws.*" test/upgrade/ -- \
-from-version=0.5.0 -to-version="latest" -chart-dir="../../build/charts/nephe" -preserve-setup-on-fail=false -cloud-provider=AWS

upgrade-test-azure:
ginkgo -v --timeout=90m --fail-fast --focus=".*test-azure.*" test/upgrade/ -- \
-from-version=0.5.0 -to-version="latest" -chart-dir="../../build/charts/nephe" -preserve-setup-on-fail=true -cloud-provider=Azure
11 changes: 11 additions & 0 deletions ci/jenkins/nephe-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,15 @@ case $testType in
--azure-tenant-id ${AZURE_TENANT_ID} --azure-secret ${AZURE_PASSWORD} --owner ${owner} --with-agent \
--with-agent-windows"
;;
aws-upgrade)
echo "Run upgrade tests on Kind cluster with AWS VMs"
ssh -i id_rsa ubuntu@${ip_addr} "cd ~/nephe; ./ci/jenkins/scripts/test-aws.sh --aws-access-key-id ${AWS_ACCESS_KEY_ID} --aws-secret-key ${AWS_ACCESS_KEY_SECRET} \
--aws-service-user-role-arn ${AWS_SERVICE_USER_ROLE_ARN} --aws-service-user ${AWS_SERVICE_USER_NAME} --owner ${owner} \
--upgrade"
;;
azure-upgrade)
echo "Run upgrade tests on Kind cluster with Azure VMs"
ssh -i id_rsa ubuntu@${ip_addr} "cd ~/nephe; ./ci/jenkins/scripts/test-azure.sh --azure-subscription-id ${AZURE_SUBSCRIPTION_ID} --azure-app-id ${AZURE_APP_ID} \
--azure-tenant-id ${AZURE_TENANT_ID} --azure-secret ${AZURE_PASSWORD} --owner ${owner} --upgrade"
;;
esac
7 changes: 7 additions & 0 deletions ci/jenkins/scripts/install-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ function install_common_packages() {
sudo rm -rf /usr/local/go && sudo tar -zxf go${GO_VERSION}.linux-amd64.tar.gz -C /usr/local/
rm go${GO_VERSION}.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

echo "Installing Helm"
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
sudo apt-get install apt-transport-https --yes
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm
}

function install_kind() {
Expand Down
23 changes: 18 additions & 5 deletions ci/jenkins/scripts/test-aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Setup and run integration tests on Kind cluster with AWS VMs.
[--aws-service-user <ServiceUserName>] AWS Service User Name.
[--aws-service-user-role-arn <ServiceUserRoleARN>] AWS Service User Role ARN.
[--aws-region <Region>] AWS region where the setup will be deployed. Defaults to us-east-2.
[--owner <OwnerName>] Setup will be prefixed with owner name."
[--owner <OwnerName>] Setup will be prefixed with owner name.
[--upgrade] Run upgrade test."

function print_usage {
echoerr "$_usage"
Expand All @@ -41,6 +42,7 @@ function print_help {
# Defaults
export TF_VAR_owner="ci"
export AWS_DEFAULT_REGION="us-east-2"
export UPGRADE=true # Reset to false

while [[ $# -gt 0 ]]
do
Expand Down Expand Up @@ -71,6 +73,10 @@ case $key in
export TF_VAR_owner="$2"
shift 2
;;
--upgrade)
export UPGRADE=true
shift 1
;;
-h|--help)
print_usage
exit 0
Expand Down Expand Up @@ -140,15 +146,22 @@ ci/kind/kind-setup.sh create kind

# Create a key pair
KEY_PAIR="nephe-$$"
aws ec2 import-key-pair --key-name ${KEY_PAIR} --public-key-material fileb://~/.ssh/id_rsa.pub --region ${AWS_DEFAULT_REGION}
aws ec2 import-key-pair --key-name ${KEY_PAIR} --public-key-material fileb://~/.ssh/id_rsa.pub --region "${AWS_DEFAULT_REGION}"

export TF_VAR_aws_key_pair_name=${KEY_PAIR}

function cleanup() {
# Delete key pair
aws ec2 delete-key-pair --key-name ${KEY_PAIR} --region ${AWS_DEFAULT_REGION}
aws ec2 delete-key-pair --key-name ${KEY_PAIR} --region "${AWS_DEFAULT_REGION}"
}
trap cleanup EXIT

mkdir -p $HOME/logs
ci/bin/integration.test -ginkgo.v -ginkgo.timeout 90m -ginkgo.focus=".*test-aws.*" -kubeconfig=$HOME/.kube/config -cloud-provider=AWS -support-bundle-dir=$HOME/logs
mkdir -p "$HOME"/logs

if [ "$UPGRADE" = true ] ; then
ci/bin/upgrade.test -ginkgo.v -ginkgo.timeout 90m -ginkgo.focus=".*test-aws.*" -kubeconfig="$HOME"/.kube/config \
-from-version=0.5.0 -to-version="latest" -chart-dir="build/charts/nephe" -cloud-provider=AWS -support-bundle-dir="$HOME"/logs
else
ci/bin/integration.test -ginkgo.v -ginkgo.timeout 90m -ginkgo.focus=".*test-aws.*" -kubeconfig="$HOME"/.kube/config \
-cloud-provider=AWS -support-bundle-dir="$HOME"/logs
fi
20 changes: 15 additions & 5 deletions ci/jenkins/scripts/test-azure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Setup and Run integration tests on Kind cluster with Azure VMs.
[--azure-tenant-id <TenantID>] Azure Service Principal Tenant ID.
[--azure-secret <Secret>] Azure Service Principal Secret.
[--azure-location <Location>] The Azure location where the setup will be deployed. Defaults to West US 2.
[--owner <OwnerName>] Setup will be prefixed with owner name."
[--owner <OwnerName>] Setup will be prefixed with owner name.
[--upgrade] Run upgrade test."

function print_usage {
echoerr "$_usage"
Expand All @@ -43,6 +44,7 @@ function print_help {
# Defaults
export TF_VAR_owner="ci"
export TF_VAR_location="West US 2"
export UPGRADE=true # Reset to false

while [[ $# -gt 0 ]]
do
Expand Down Expand Up @@ -73,6 +75,10 @@ case $key in
export TF_VAR_owner="$2"
shift 2
;;
--upgrade)
export UPGRADE=true
shift 1
;;
-h|--help)
print_usage
exit 0
Expand Down Expand Up @@ -107,7 +113,11 @@ echo "Creating Kind cluster"
hack/install-cloud-tools.sh
ci/kind/kind-setup.sh create kind

echo $TF_VAR_azure_client_subscription_id $TF_VAR_azure_client_id $TF_VAR_azure_client_tenant_id $TF_VAR_azure_client_secret

mkdir -p $HOME/logs
ci/bin/integration.test -ginkgo.v -ginkgo.timeout 90m -ginkgo.focus=".*test-azure.*" -kubeconfig=$HOME/.kube/config -cloud-provider=Azure -support-bundle-dir=$HOME/logs
mkdir -p "$HOME"/logs
if [ "$UPGRADE" = true ] ; then
ci/bin/upgrade.test -ginkgo.v -ginkgo.timeout 90m -ginkgo.focus=".*test-azure.*" -kubeconfig="$HOME"/.kube/config \
-from-version=0.5.0 -to-version="latest" -chart-dir="build/charts/nephe" -cloud-provider=Azure -support-bundle-dir="$HOME"/logs
else
ci/bin/integration.test -ginkgo.v -ginkgo.timeout 90m -ginkgo.focus=".*test-azure.*" -kubeconfig="$HOME"/.kube/config \
-cloud-provider=Azure -support-bundle-dir="$HOME"/logs
fi
2 changes: 2 additions & 0 deletions hack/build-bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ echo "GOBIN=$(pwd)/bin CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go i
GOBIN=$(pwd)/bin CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go install -ldflags="-s -w" antrea.io/nephe/cmd/...
echo "CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go test -c antrea.io/nephe/test/integration/ -ldflags="-s -w" -o ./ci/bin/integration.test"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go test -c antrea.io/nephe/test/integration/ -ldflags="-s -w" -o ./ci/bin/integration.test
echo "CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go test -c antrea.io/nephe/test/upgrade/ -ldflags="-s -w" -o ./ci/bin/upgrade.test"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go test -c antrea.io/nephe/test/upgrade/ -ldflags="-s -w" -o ./ci/bin/upgrade.test
Loading

0 comments on commit 7591a21

Please sign in to comment.