Skip to content

Commit

Permalink
To support running Antrea Flexible IPAM tests on KIND
Browse files Browse the repository at this point in the history
Signed-off-by: KMAnju-2021 <[email protected]>
  • Loading branch information
KMAnju-2021 committed Feb 8, 2024
1 parent 18bf0d8 commit 7e67f8e
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 2 deletions.
22 changes: 21 additions & 1 deletion ci/jenkins/jobs/macros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,27 @@
return_code=$?
set -ex
./ci/kind/kind-setup.sh destroy "${{FULL_CLUSTER_NAME}}"
exit $return_code
exit $return_code
- builder:
name: builder-kind-flexible-ipam-e2e
builders:
- shell: |-
#!/bin/bash
set -ex
DOCKER_REGISTRY="$(head -n1 ci/docker-registry)"
KIND_TIMEOUT=135
FULL_CLUSTER_NAME='{kind_cluster_name}'-"${{BUILD_NUMBER}}"
./ci/kind/kind-setup.sh destroy --all --until ${{KIND_TIMEOUT}}
./ci/kind/kind-install.sh
./ci/kind/kind-setup.sh --antrea-cni create "${{FULL_CLUSTER_NAME}}"
kind export kubeconfig -n "${{FULL_CLUSTER_NAME}}" --kubeconfig ${{PWD}}/.kube/config
set +e
./ci/jenkins/test.sh --testcase e2e --registry ${{DOCKER_REGISTRY}} --kubeconfig ${{PWD}}/.kube/config --testbed-type "kind-flexible-ipam" --kind-cluster-name "${{FULL_CLUSTER_NAME}}"
return_code=$?
set -ex
./ci/kind/kind-setup.sh destroy "${{FULL_CLUSTER_NAME}}"
exit $return_code
- builder:
name: builder-rancher-e2e
Expand Down
30 changes: 30 additions & 0 deletions ci/jenkins/jobs/projects-lab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1348,3 +1348,33 @@
timeout: 135
type: absolute
publishers: []
- '{name}-{test_name}-for-pull-request':
test_name: kind-flexible-ipam-e2e
node: 'antrea-kind-flexible-ipam-testbed'
description: 'This is the {test_name} test for {name}.'
branches:
- ${{sha1}}
builders:
- builder-kind-flexible-ipam-e2e:
kind_cluster_name: '{test_name}'
trigger_phrase: ^(?!Thanks for your PR).*/test-kind-flexible-ipam-e2e.*
white_list_target_branches: []
allow_whitelist_orgs_as_admins: true
admin_list: '{antrea_admin_list}'
org_list: '{antrea_org_list}'
white_list: '{antrea_white_list}'
only_trigger_phrase: true
trigger_permit_all: true
status_context: jenkins-kind-flexible-ipam-e2e
status_url: --none--
success_status: Build finished.
failure_status: Failed. Add comment /test-kind-flexible-ipam-e2e to re-trigger.
error_status: Failed. Add comment /test-kind-flexible-ipam-e2e to re-trigger.
triggered_status: null
started_status: null
wrappers:
- timeout:
fail: true
timeout: 135
type: absolute
publishers: []
8 changes: 7 additions & 1 deletion ci/jenkins/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ function deliver_antrea {
scp -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i "${WORKDIR}/jenkins_id_rsa" flow-aggregator.tar jenkins@[${IP}]:${DEFAULT_WORKDIR}/flow-aggregator.tar
ssh -o StrictHostKeyChecking=no -i "${WORKDIR}/jenkins_id_rsa" -n jenkins@${IP} "${CLEAN_STALE_IMAGES_CONTAINERD}; ${PRINT_CONTAINERD_STATUS}; ctr -n=k8s.io images import ${DEFAULT_WORKDIR}/antrea-ubuntu.tar; ctr -n=k8s.io images import ${DEFAULT_WORKDIR}/flow-aggregator.tar" || true
done
elif [[ $TESTBED_TYPE == "kind" ]]; then
elif [[ $TESTBED_TYPE == "kind" || $TESTBED_TYPE == "kind-flexible-ipam" ]]; then
kind load docker-image antrea/antrea-agent-ubuntu:latest --name ${KIND_CLUSTER}
kind load docker-image antrea/antrea-controller-ubuntu:latest --name ${KIND_CLUSTER}
kind load docker-image antrea/flow-aggregator:latest --name ${KIND_CLUSTER}
Expand Down Expand Up @@ -821,6 +821,8 @@ function run_e2e {
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider remote -timeout=100m --prometheus --antrea-ipam
elif [[ $TESTBED_TYPE == "kind" ]]; then
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider kind -timeout=100m --prometheus
elif [[ $TESTBED_TYPE == "kind-flexible-ipam" ]]
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider kind -timeout=100m --prometheus --antrea-ipam
else
go test -v antrea.io/antrea/test/e2e --logs-export-dir `pwd`/antrea-test-logs --provider remote -timeout=100m --prometheus
fi
Expand Down Expand Up @@ -1181,6 +1183,10 @@ if [[ $TESTCASE =~ "multicast" ]]; then
./hack/generate-manifest.sh --encap-mode noEncap --multicast --multicast-interfaces "ens224" --verbose-log > build/yamls/antrea.yml
fi

if [[ $TESTBED_TYPE == "kind-flexible-ipam" ]]; then
./hack/generate-manifest.sh --flexible-ipam --multicast --verbose-log > build/yamls/antrea.yml
fi

source $WORKSPACE/ci/jenkins/utils.sh
check_and_upgrade_golang
clean_tmp
Expand Down
39 changes: 39 additions & 0 deletions ci/kind/kind-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ SUBNETS=""
EXTRA_NETWORKS=""
VLAN_SUBNETS=""
VLAN_ID=""
IPAM_VLAN_SUBNETS=""
IPAM_VLAN_IDS=""
ENCAP_MODE=""
PROXY=true
KUBE_PROXY_MODE="iptables"
Expand Down Expand Up @@ -242,6 +244,32 @@ function configure_extra_networks {
done
}

function configure_kind_ipam_vlan_subnets {
if [[ -z $IPAM_VLAN_SUBNETS || -z $IPAM_VLAN_IDS ]]; then
return
fi

IFS=',' read -r -a ipam_vlan_subnets <<< "$IPAM_VLAN_SUBNETS"
IFS=',' read -r -a ipam_vlan_ids <<< "$IPAM_VLAN_IDS"
i=0

for s in "${ipam_vlan_subnets[@]}"; do
vlan_id=${ipam_vlan_ids[$i]}
i=$(($i+1))
echo "Configuring VLAN-$vlan_id subnets"
bridge_id=$(docker network inspect kind -f {{.ID}})
bridge_interface="br-${bridge_id:0:12}"
vlan_interface="br-${bridge_id:0:7}.$vlan_id"

docker_run_with_host_net ip link add link $bridge_interface name $vlan_interface type vlan id $vlan_id
docker_run_with_host_net ip link set $vlan_interface up
echo "Configuring extra IP $s to vlan interface $vlan_interface"
docker_run_with_host_net ip addr add dev $vlan_interface $s
docker_run_with_host_net iptables -t filter -A FORWARD -i $bridge_interface -o $vlan_interface -j ACCEPT
docker_run_with_host_net iptables -t filter -A FORWARD -o $bridge_interface -i $vlan_interface -j ACCEPT
done
}

function configure_vlan_subnets {
if [[ -z $VLAN_SUBNETS || -z $VLAN_ID ]]; then
return
Expand Down Expand Up @@ -410,6 +438,7 @@ EOF

configure_networks
configure_extra_networks
configure_kind_ipam_vlan_subnets
configure_vlan_subnets
setup_external_server
load_images
Expand Down Expand Up @@ -562,6 +591,16 @@ while [[ $# -gt 0 ]]
VLAN_ID="$2"
shift 2
;;
--ipam-vlan-subnets)
add_option "--ipam-vlan-subnets" "create"
IPAM_VLAN_SUBNETS="$2"
shift 2
;;
--ipam-vlan-ids)
add_option "--ipam-vlan-ids" "create"
IPAM_VLAN_IDS="$2"
shift 2
;;
--images)
add_option "--image" "create"
IMAGES="$2"
Expand Down

0 comments on commit 7e67f8e

Please sign in to comment.