Skip to content

Commit

Permalink
E2E Tests: CNI parametrized
Browse files Browse the repository at this point in the history
  • Loading branch information
cheina97 authored and adamjensenbot committed Apr 27, 2023
1 parent f590cef commit 0a911ed
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ jobs:
repository: ${{github.event.pull_request.head.repo.full_name}}
persist-credentials: false
- name: Run Shellcheck
uses: azohra/shell-linter@v0.6.0
uses: ludeeus/action-shellcheck@2.0.0
env:
# Allow 'source' outside of FILES
SHELLCHECK_OPTS: -x

markdownlint:
name: Lint markdown files
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/pipeline/infra/cluster-api/cni.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

function install_calico () {
local kubeconfig=$1
curl https://raw.githubusercontent.com/projectcalico/calico/v3.24.4/manifests/calico.yaml \
| sed -E 's|^( +)# (- name: CALICO_IPV4POOL_CIDR)$|\1\2|g;'\
"s|^( +)# ( value: )\"192.168.0.0/16\"|\1\2\"$POD_CIDR\"|g;"\
'/- name: CLUSTER_TYPE/{ n; s/( +value: ").+/\1k8s"/g };'\
'/- name: CALICO_IPV4POOL_IPIP/{ n; s/value: "Always"/value: "Never"/ };'\
'/- name: CALICO_IPV4POOL_VXLAN/{ n; s/value: "Never"/value: "Always"/};'\
'/# Set Felix endpoint to host default action to ACCEPT./a\ - name: FELIX_VXLANPORT\n value: "6789"' \
| "${KUBECTL}" apply -f - --kubeconfig "$kubeconfig"
}
19 changes: 10 additions & 9 deletions test/e2e/pipeline/infra/cluster-api/setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#shellcheck disable=SC1091

# This scripts expects the following variables to be set:
# CLUSTER_NUMBER -> the number of liqo clusters
Expand All @@ -15,6 +16,7 @@
# KUBECTL -> the path where kubectl is stored
# POD_CIDR_OVERLAPPING -> the pod CIDR of the clusters is overlapping
# CLUSTER_TEMPLATE_FILE -> the file where the cluster template is stored
# CNI -> the CNI plugin used

set -e # Fail in case of error
set -o nounset # Fail if undefined variables are used
Expand All @@ -27,6 +29,12 @@ error() {
}
trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR

FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck source=./cni.sh
source "$WORKDIR/cni.sh"

CLUSTER_NAME=cluster

export K8S_VERSION=${K8S_VERSION:-"1.25.5"}
Expand Down Expand Up @@ -76,15 +84,8 @@ do
mkdir -p "${TMPDIR}/kubeconfigs"
clusterctl get kubeconfig -n "$TARGET_NAMESPACE" "${CAPI_CLUSTER_NAME}${i}" > "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"

# install calico
curl https://raw.githubusercontent.com/projectcalico/calico/v3.24.4/manifests/calico.yaml \
| sed -E 's|^( +)# (- name: CALICO_IPV4POOL_CIDR)$|\1\2|g;'\
"s|^( +)# ( value: )\"192.168.0.0/16\"|\1\2\"$POD_CIDR\"|g;"\
'/- name: CLUSTER_TYPE/{ n; s/( +value: ").+/\1k8s"/g };'\
'/- name: CALICO_IPV4POOL_IPIP/{ n; s/value: "Always"/value: "Never"/ };'\
'/- name: CALICO_IPV4POOL_VXLAN/{ n; s/value: "Never"/value: "Always"/};'\
'/# Set Felix endpoint to host default action to ACCEPT./a\ - name: FELIX_VXLANPORT\n value: "6789"' \
| "${KUBECTL}" apply -f - --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"
echo "Installing ${CNI} for cluster ${CLUSTER_NAME}${i}"
"install_${CNI}" "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"

# install local-path storage class
"${KUBECTL}" apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.24/deploy/local-path-storage.yaml --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pipeline/infra/k3s/pre-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ fi

if [[ ! -f "${BINDIR}/k3d" ]]; then
echo "k3d could not be found. Downloading https://k3d.sigs.k8s.io/dl/${K3D_VERSION}/k3d-${OS}-${ARCH} ..."
curl -Lo "${BINDIR}"/k3d https://github.com/k3d-io/k3d/releases/download/${K3D_VERSION}/k3d-${OS}-${ARCH}
curl -Lo "${BINDIR}"/k3d "https://github.com/k3d-io/k3d/releases/download/${K3D_VERSION}/k3d-${OS}-${ARCH}"
chmod +x "${BINDIR}"/k3d
fi
2 changes: 1 addition & 1 deletion test/e2e/pipeline/infra/kind/pre-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ chmod +x "${KUBECTL}"

if [[ ! -f "${BINDIR}/kind" ]]; then
echo "kind could not be found. Downloading https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-${OS}-${ARCH} ..."
curl -Lo "${BINDIR}"/kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-${OS}-${ARCH}
curl -Lo "${BINDIR}"/kind "https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-${OS}-${ARCH}"
chmod +x "${BINDIR}"/kind
fi

0 comments on commit 0a911ed

Please sign in to comment.