Skip to content

Commit

Permalink
Add upgrade tests to integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
ricolin committed Nov 1, 2024
1 parent 1236e40 commit 686066e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
37 changes: 37 additions & 0 deletions hack/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ NETWORK_DRIVER=${NETWORK_DRIVER:-calico}
SONOBUOY_VERSION=${SONOBUOY_VERSION:-0.56.16}
SONOBUOY_ARCH=${SONOBUOY_ARCH:-amd64}
DNS_NAMESERVER=${DNS_NAMESERVER:-1.1.1.1}
UPGRADE_KUBE_TAG=${UPGRADE_KUBE_TAG:-KUBE_TAG}
IMAGE_NAME="${IMAGE_OS}-kube-${KUBE_TAG}"

# If `BUILD_NEW_IMAGE` is true, then we use the provided artifact, otherwise
Expand Down Expand Up @@ -60,6 +61,23 @@ openstack coe cluster template create \
--label fixed_subnet_cidr=192.168.24.0/24 \
k8s-${KUBE_TAG};

if [[ ${UPGRADE_KUBE_TAG} != ${KUBE_TAG} ]]; then
# Create cluster template for upgrade
openstack coe cluster template create \
--image $(openstack image show ${IMAGE_NAME} -c id -f value) \
--external-network public \
--dns-nameserver ${DNS_NAMESERVER} \
--master-lb-enabled \
--master-flavor m1.large \
--flavor m1.large \
--network-driver ${NETWORK_DRIVER} \
--docker-storage-driver overlay2 \
--coe kubernetes \
--label kube_tag=${UPGRADE_KUBE_TAG} \
--label fixed_subnet_cidr=192.168.24.0/24 \
k8s-${UPGRADE_KUBE_TAG};
fi

# Create cluster
openstack coe cluster create \
--cluster-template k8s-${KUBE_TAG} \
Expand Down Expand Up @@ -101,6 +119,25 @@ done
# Get the cluster configuration file
eval $(openstack coe cluster config k8s-cluster)

if [[ ${UPGRADE_KUBE_TAG} != ${KUBE_TAG} ]]; then
# Upgrade cluster
openstack coe cluster upgrade k8s-cluster k8s-${UPGRADE_KUBE_TAG}
# Wait for cluster to be "UPDATE_COMPLETE".
for i in {1..240}; do
CLUSTER_STATUS=$(openstack coe cluster show k8s-cluster -c status -f value)
if [[ ${CLUSTER_STATUS} == *"FAILED"* ]]; then
echo "Cluster failed to upgrade"
exit 1
elif [[ ${CLUSTER_STATUS} == *"UPDATE_COMPLETE"* ]]; then
echo "Cluster upgraded"
break
else
echo "Cluster status: ${CLUSTER_STATUS}"
sleep 5
fi
done
fi

# Download sonobuoy
curl -LO https://github.com/vmware-tanzu/sonobuoy/releases/download/v${SONOBUOY_VERSION}/sonobuoy_${SONOBUOY_VERSION}_linux_${SONOBUOY_ARCH}.tar.gz
tar -xzf sonobuoy_${SONOBUOY_VERSION}_linux_${SONOBUOY_ARCH}.tar.gz
Expand Down
3 changes: 3 additions & 0 deletions zuul.d/jobs-ubuntu-2204.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
parent: magnum-cluster-api-sonobuoy-ubuntu-2204
vars:
kube_tag: v1.28.11
upgrade_kube_tag: v1.29.6
image_url: https://static.atmosphere.dev/artifacts/magnum-cluster-api/ubuntu-jammy-kubernetes-1-28-11-1719601167.qcow2

- job:
Expand All @@ -30,6 +31,7 @@
parent: magnum-cluster-api-sonobuoy-ubuntu-2204
vars:
kube_tag: v1.29.6
upgrade_kube_tag: v1.30.2
image_url: https://static.atmosphere.dev/artifacts/magnum-cluster-api/ubuntu-jammy-kubernetes-1-29-6-1720107687.qcow2

- job:
Expand All @@ -49,6 +51,7 @@
parent: magnum-cluster-api-sonobuoy-ubuntu-2204
vars:
kube_tag: v1.30.2
upgrade_kube_tag: v1.31.1
image_url: https://static.atmosphere.dev/artifacts/magnum-cluster-api/ubuntu-jammy-kubernetes-1-30-2-1720107688.qcow2

- job:
Expand Down
26 changes: 26 additions & 0 deletions zuul.d/playbooks/sonobuoy/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,31 @@
when:
- image_url is defined

- name: Fetch artifact for upgrade
get_url:
url: "{{ item.url }}"
dest: "{{ zuul.project.src_dir }}/{{ image_operating_system }}-kube-{{ upgrade_kube_tag }}.qcow2"
register: fetch_artifact
loop: "{{ zuul.artifacts }}"
when:
- upgrade_kube_tag is defined
- upgrade_kube_tag != kube_tag
- item.name is defined
- item.name == "{{ image_operating_system }}-kube-{{ upgrade_kube_tag }}.qcow2"

- name: Download image for upgrade
get_url:
url: "{{ image_url }}"
dest: "{{ zuul.project.src_dir }}/{{ image_operating_system }}-kube-{{ upgrade_kube_tag }}.qcow2"
register: fetch_artifact
retries: 5
delay: 10
when:
- image_url is defined
- upgrade_kube_tag is defined
- upgrade_kube_tag != kube_tag


- shell: "./hack/stack.sh"
args:
chdir: "{{ zuul.project.src_dir }}"
Expand All @@ -31,6 +56,7 @@
IMAGE_OS: "{{ image_operating_system }}"
OS_DISTRO: "{{ image_os_distro }}"
KUBE_TAG: "{{ kube_tag }}"
UPGRADE_KUBE_TAG: "{{ upgrade_kube_tag | default(kube_tag) }}"
NODE_COUNT: 2
BUILD_NEW_IMAGE: "{{ fetch_artifact.changed }}"
NETWORK_DRIVER: "{{ network_driver }}"
Expand Down

0 comments on commit 686066e

Please sign in to comment.