Skip to content

Commit

Permalink
test/e2e: switch to using pkgs.k8s.io repos.
Browse files Browse the repository at this point in the history
Switch provisioning of both fedora and ubuntu-based e2e test VMs
to the pkgs.k8s.io repositories. Also try autodetecting and using
the latest available K8s, containerd and CRI-O releases/versions,
unless this is overridden by the user.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
  • Loading branch information
klihub committed Mar 12, 2024
1 parent ad41e5e commit b27c140
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
4 changes: 4 additions & 0 deletions test/e2e/files/Vagrantfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ HOSTNAME = "SERVER_NAME"
# How many nodes to create
N = 1

K8S_RELEASE = "#{ENV['k8s_release']}"
K8S_VERSION = "#{ENV['k8s_version']}"
CRI_RUNTIME = "#{ENV['k8scri']}"
CRIO_RELEASE = "1.28.1"
CRIO_SRC = ""
Expand Down Expand Up @@ -88,6 +90,8 @@ Vagrant.configure("2") do |config|
https_proxy: "#{ENV['HTTPS_PROXY']}",
http_proxy: "#{ENV['HTTP_PROXY']}",
no_proxy: "#{ENV['NO_PROXY']}",
k8s_release: K8S_RELEASE,
k8s_version: K8S_VERSION,
cri_runtime: CRI_RUNTIME,
containerd_release: CONTAINERD_RELEASE,
containerd_src: CONTAINERD_SRC,
Expand Down
12 changes: 7 additions & 5 deletions test/e2e/playbook/provision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
become_user: root
vars:
cri_runtime: "{{ cri_runtime }}"
k8s_release: "{{ k8s_release }}"
k8s_version: "{{ k8s_version }}"
is_containerd: false
is_crio: false
containerd_release: "{{ containerd_release }}"
Expand Down Expand Up @@ -50,24 +52,24 @@
- swapoff --all
when: ansible_swaptotal_mb > 0

- name: Download public signing key Kubernetes
- name: Download public signing key for Kubernetes
ansible.builtin.apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
url: https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/deb/Release.key
state: present
when: ansible_facts['distribution'] == "Ubuntu"

- name: Add apt repository for Kubernetes
ansible.builtin.apt_repository:
repo: "deb https://apt.kubernetes.io/ kubernetes-xenial main"
repo: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/deb/ /"
state: present
filename: /etc/apt/sources.list.d/kubernetes.list
when: ansible_facts['distribution'] == "Ubuntu"

- name: Add yum repository for Kubernetes
ansible.builtin.yum_repository:
description: Kubernetes repository
baseurl: "https://packages.cloud.google.com/yum/repos/kubernetes-el7-$basearch"
gpgkey: "https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg"
baseurl: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/rpm/"
gpgkey: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version }}/rpm/repodata/repomd.xml.key"
state: present
name: kubernetes
when: ansible_facts['distribution'] == "Fedora"
Expand Down
51 changes: 49 additions & 2 deletions test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,35 @@ export cni_plugin=${cni_plugin:-cilium}
export cni_release=${cni_release:-latest}
TOPOLOGY_DIR=${TOPOLOGY_DIR:=e2e}

K8S_REPO="https://github.com/kubernetes/kubernetes"
export k8s_release=${k8s_release:-"latest"}
export k8s_version=""

source "$LIB_DIR"/vm.bash

latest-github-release () {
local repo="$1"
local latest=$(wget -q -O- $repo/releases/latest | grep '/tree/v[0-9.]*' |
sed -E 's:.*/tree/v([0-9]*\.[0-9]*)(\.[0-9]*).*:\1\2:g' | head -1)
if [ -z "$latest" ]; then
echo "failed to determine latest release of $repo"
exit 1
fi
echo "$latest"
}

if [ "$k8s_release" = "latest" ]; then
if ! k8s_release=$(latest-github-release $K8S_REPO); then
error "$k8s_release"
fi
echo "Latest Kubernetes release: $k8s_release"
fi

export k8s_version=$(echo $k8s_release | sed -E 's/([0-9]*\.[0-9]*)(\.[0-9]*)/\1/g')
if [ -z "$k8s_version" ]; then
error "failed to determine latest Kubernetes version from \"$k8s_release"\"
fi

export vm_name=${vm_name:=$(vm-create-name "$k8scri" "$(basename "$TOPOLOGY_DIR")" ${distro})}
ESCAPED_VM=$(printf '%s\n' "$vm_name" | sed -e 's/[\/]/-/g')
export VM_HOSTNAME="$ESCAPED_VM"
Expand Down Expand Up @@ -53,17 +80,34 @@ fi
# from a release tarball with the version given below... unless
# a source directory is given, which is then expected to contain
# a compiled version of containerd which we should install.
export containerd_release=${containerd_release:-1.7.6}
CONTAINERD_REPO="https://github.com/containerd/containerd"
export containerd_release=${containerd_release:-latest}

if [ "$k8scri" = "containerd" -a "$containerd_release" = "latest" ]; then
if ! containerd_release=$(latest-github-release $CONTAINERD_REPO); then
error "$containerd_release"
fi
echo "Latest containerd release: $containerd_release"
fi

export containerd_src=${containerd_src:-}


# If we run tests with CRI-O as the runtime, we install it from
# a release tarball with the version given below... unless a
# source directory is given, which is then expected to contain
# a compiled version of CRI-O which we should install.
export crio_release=${crio_release:-1.28.1}
CRIO_REPO="https://github.com/cri-o/cri-o"
export crio_release=${crio_release:-latest}
export crio_src=${crio_src:-}

if [ "$k8scri" = "crio" -a "$crio_release" = "latest" ]; then
if ! crio_release=$(latest-github-release $CRIO_REPO); then
error "$crio_release"
fi
echo "Latest CRI-O release: $crio_release"
fi

# Default topology if not given. The run_tests.sh script will figure out
# the topology from the test directory structure and contents.
if [ -z "$topology" ]; then
Expand Down Expand Up @@ -108,6 +152,9 @@ fi
echo
echo " VM = $vm_name"
echo " Distro = $distro"
echo " Kubernetes"
echo " - release = $k8s_release"
echo " - version = $k8s_version"
echo " Runtime = $k8scri"
echo " Output dir = $OUTPUT_DIR"
echo " Test output dir = $TEST_OUTPUT_DIR"
Expand Down

0 comments on commit b27c140

Please sign in to comment.