Skip to content

Commit

Permalink
adding CNCF runner
Browse files Browse the repository at this point in the history
Signed-off-by: KMAnju-2021 <[email protected]>
  • Loading branch information
KMAnju-2021 committed Jan 2, 2025
1 parent b5f3713 commit 33a2b50
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 5 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,39 @@ jobs:
path: log.tar.gz
retention-days: 30

test-e2e-ipam-feature-enabled:
name: E2e tests on a Kind cluster on Linux with FlexibleIPAM feature enabled
needs: [build-antrea-coverage-image]
runs-on: [ubuntu-latest-4-cores]
steps:
- name: Free disk space
# https://github.com/actions/virtual-environments/issues/709
run: |
sudo apt-get clean
df -h
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v4
with:
name: antrea-ubuntu-cov
- name: Load Antrea image
run: |
docker load -i antrea-ubuntu.tar
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
- name: Run ipam e2e tests
run: |
./ci/kind/test-e2e-kind.sh --flexible-ipam --encap-mode noEncap
test-e2e-noencap:
name: E2e tests on a Kind cluster on Linux (noEncap)
needs: [build-antrea-coverage-image]
Expand Down
22 changes: 22 additions & 0 deletions ci/kind/install-ipset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

if ! command -v ipset >/dev/null 2>&1; then
echo "ipset not found. Installing..."
if command -v apt >/dev/null 2>&1; then
sudo apt update && sudo apt install -y ipset
elif command -v yum >/dev/null 2>&1; then
sudo yum install -y ipset
elif command -v dnf >/dev/null 2>&1; then
sudo dnf install -y ipset
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm ipset
elif command -v zypper >/dev/null 2>&1; then
sudo zypper install -y ipset
else
echo "Package manager not supported. Please install ipset manually."
exit 1
fi
else
echo "ipset is already installed."
fi

35 changes: 34 additions & 1 deletion ci/kind/kind-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ function delete_networks {
docker network rm $networks > /dev/null 2>&1
echo "deleted networks $networks"
fi

if [[ $FLEXIBLE_IPAM == true ]]; then
networks=$(docker network ls -f name=kind --format '{{.Name}}')
networks="$(echo $networks)"
docker network rm $networks > /dev/null 2>&1
echo "deleted networks $networks"
fi
}

function load_images {
Expand Down Expand Up @@ -711,7 +718,6 @@ if [[ $ACTION == "destroy" ]]; then
exit
fi


kind_version=$(kind version | awk '{print $2}')
kind_version=${kind_version:1} # strip leading 'v'
function version_lt() { test "$(printf '%s\n' "$@" | sort -rV | head -n 1)" != "$1"; }
Expand All @@ -728,5 +734,32 @@ if [[ $ACTION == "create" ]]; then
echoerr "Only one of '--subnets' and '--extra-networks' can be specified"
exit 1
fi
if [[ $FLEXIBLE_IPAM == true ]]; then
docker network create -d bridge --subnet 192.168.240.0/24 kind
# chmod +x ./ci/kind/install-ipset.sh
# ./ci/kind/install-ipset.sh
uname -a
sudo apt update
sudo apt install -y ipset
ipset --version
sudo dmesg | grep ip_set
sudo modprobe ip_set
sudo modprobe xt_set
sudo ipset create excluded_subnets hash:net
sudo ipset add excluded_subnets 192.168.241.0/24
sudo ipset add excluded_subnets 192.168.242.0/24
sudo ipset list excluded_subnets

bridge_id=$(docker network inspect kind -f {{.ID}})
bridge_interface="br-${bridge_id:0:12}"
sudo iptables -t nat -A POSTROUTING ! -o $bridge_interface -s 192.168.240.0/24 -m set ! --match-set excluded_subnets dst -j MASQUERADE

sudo ipset create excluded_ipam_subnets hash:net
sudo ipset add excluded_ipam_subnets 192.168.241.0/24
sudo ipset add excluded_ipam_subnets 192.168.242.0/24
sudo ipset add excluded_ipam_subnets 192.168.240.0/24
sudo ipset list excluded_ipam_subnets
sudo iptables -t nat -A POSTROUTING ! -o $bridge_interface -s 10.244.0.0/16 -m set ! --match-set excluded_ipam_subnets dst -j MASQUERADE
fi
create
fi
38 changes: 34 additions & 4 deletions ci/kind/test-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ setup_only=false
cleanup_only=false
test_only=false
run=""
flexible_ipam=false
antrea_controller_image="antrea/antrea-controller-ubuntu"
antrea_agent_image="antrea/antrea-agent-ubuntu"
use_non_default_images=false
Expand All @@ -110,6 +111,10 @@ case $key in
proxy_all=true
shift
;;
--flexible-ipam)
flexible_ipam=true
shift
;;
--no-kube-proxy)
no_kube_proxy=true
shift
Expand Down Expand Up @@ -249,6 +254,10 @@ if $flow_visibility; then
manifest_args="$manifest_args --feature-gates FlowExporter=true,L7FlowExporter=true --extra-helm-values-file $FLOW_VISIBILITY_HELM_VALUES"
fi

if $flexible_ipam; then
manifest_args="$manifest_args --flexible-ipam --multicast"
fi

COMMON_IMAGES_LIST=("registry.k8s.io/e2e-test-images/agnhost:2.40" \
"antrea/nginx:1.21.6-alpine" \
"antrea/toolbox:1.3-0")
Expand Down Expand Up @@ -302,6 +311,10 @@ if $extra_vlan; then
fi
fi

if $flexible_ipam; then
vlan_args="$vlan_args --vlan-subnets 11=192.168.241.1/24 --vlan-subnets 12=192.168.242.1/24"
fi

function setup_cluster {
args=$1

Expand Down Expand Up @@ -330,7 +343,11 @@ function setup_cluster {
fi

echo "creating test bed with args $args"
eval "timeout 600 $TESTBED_CMD create kind $args"
if $flexible_ipam; then
eval "timeout 600 $TESTBED_CMD --flexible-ipam create kind $args"
else
eval "timeout 600 $TESTBED_CMD create kind $args"
fi
}

function run_test {
Expand All @@ -348,8 +365,13 @@ function run_test {
timeout="80m"
coverage_args="--coverage --coverage-dir $ANTREA_COV_DIR"
else
$YML_CMD --encap-mode $current_mode $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea.yml
$YML_CMD --ipsec $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea-ipsec.yml
if $flexible_ipam; then
$YML_CMD --flexible-ipam --multicast --encap-mode $current_mode $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea.yml
echo "debug-1"
else
$YML_CMD --encap-mode $current_mode $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea.yml
$YML_CMD --ipsec $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea-ipsec.yml
fi
timeout="75m"
fi

Expand Down Expand Up @@ -401,7 +423,15 @@ function run_test {
EXTRA_ARGS="$EXTRA_ARGS --external-frr-cid $external_frr_cid --external-frr-ips $external_frr_ips"
fi

go test -v -timeout=$timeout $RUN_OPT antrea.io/antrea/test/e2e $flow_visibility_args -provider=kind --logs-export-dir=$ANTREA_LOG_DIR $np_evaluation_flag --skip-cases=$skiplist $coverage_args $EXTRA_ARGS
if $flexible_ipam; then
sudo iptables -t nat -vnL
kubectl get pods -o wide -A
ip route
export GO111MODULE=on
go test -v antrea.io/antrea/test/e2e --provider kind -timeout=100m --prometheus --antrea-ipam
else
go test -v -timeout=$timeout $RUN_OPT antrea.io/antrea/test/e2e $flow_visibility_args -provider=kind --logs-export-dir=$ANTREA_LOG_DIR $np_evaluation_flag --skip-cases=$skiplist $coverage_args $EXTRA_ARGS
fi

if $coverage; then
pushd $ANTREA_COV_DIR
Expand Down

0 comments on commit 33a2b50

Please sign in to comment.