Skip to content

Commit 33a2b50

Browse files
committed
adding CNCF runner
Signed-off-by: KMAnju-2021 <[email protected]>
1 parent b5f3713 commit 33a2b50

File tree

4 files changed

+123
-5
lines changed

4 files changed

+123
-5
lines changed

.github/workflows/kind.yml

+33
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,39 @@ jobs:
277277
path: log.tar.gz
278278
retention-days: 30
279279

280+
test-e2e-ipam-feature-enabled:
281+
name: E2e tests on a Kind cluster on Linux with FlexibleIPAM feature enabled
282+
needs: [build-antrea-coverage-image]
283+
runs-on: [ubuntu-latest-4-cores]
284+
steps:
285+
- name: Free disk space
286+
# https://github.com/actions/virtual-environments/issues/709
287+
run: |
288+
sudo apt-get clean
289+
df -h
290+
- uses: actions/checkout@v4
291+
with:
292+
show-progress: false
293+
- uses: actions/setup-go@v5
294+
with:
295+
go-version-file: 'go.mod'
296+
- name: Download Antrea image from previous job
297+
uses: actions/download-artifact@v4
298+
with:
299+
name: antrea-ubuntu-cov
300+
- name: Load Antrea image
301+
run: |
302+
docker load -i antrea-ubuntu.tar
303+
- name: Install Kind
304+
run: |
305+
KIND_VERSION=$(head -n1 ./ci/kind/version)
306+
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
307+
chmod +x ./kind
308+
sudo mv kind /usr/local/bin
309+
- name: Run ipam e2e tests
310+
run: |
311+
./ci/kind/test-e2e-kind.sh --flexible-ipam --encap-mode noEncap
312+
280313
test-e2e-noencap:
281314
name: E2e tests on a Kind cluster on Linux (noEncap)
282315
needs: [build-antrea-coverage-image]

ci/kind/install-ipset.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
if ! command -v ipset >/dev/null 2>&1; then
4+
echo "ipset not found. Installing..."
5+
if command -v apt >/dev/null 2>&1; then
6+
sudo apt update && sudo apt install -y ipset
7+
elif command -v yum >/dev/null 2>&1; then
8+
sudo yum install -y ipset
9+
elif command -v dnf >/dev/null 2>&1; then
10+
sudo dnf install -y ipset
11+
elif command -v pacman >/dev/null 2>&1; then
12+
sudo pacman -S --noconfirm ipset
13+
elif command -v zypper >/dev/null 2>&1; then
14+
sudo zypper install -y ipset
15+
else
16+
echo "Package manager not supported. Please install ipset manually."
17+
exit 1
18+
fi
19+
else
20+
echo "ipset is already installed."
21+
fi
22+

ci/kind/kind-setup.sh

+34-1
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,13 @@ function delete_networks {
327327
docker network rm $networks > /dev/null 2>&1
328328
echo "deleted networks $networks"
329329
fi
330+
331+
if [[ $FLEXIBLE_IPAM == true ]]; then
332+
networks=$(docker network ls -f name=kind --format '{{.Name}}')
333+
networks="$(echo $networks)"
334+
docker network rm $networks > /dev/null 2>&1
335+
echo "deleted networks $networks"
336+
fi
330337
}
331338

332339
function load_images {
@@ -711,7 +718,6 @@ if [[ $ACTION == "destroy" ]]; then
711718
exit
712719
fi
713720

714-
715721
kind_version=$(kind version | awk '{print $2}')
716722
kind_version=${kind_version:1} # strip leading 'v'
717723
function version_lt() { test "$(printf '%s\n' "$@" | sort -rV | head -n 1)" != "$1"; }
@@ -728,5 +734,32 @@ if [[ $ACTION == "create" ]]; then
728734
echoerr "Only one of '--subnets' and '--extra-networks' can be specified"
729735
exit 1
730736
fi
737+
if [[ $FLEXIBLE_IPAM == true ]]; then
738+
docker network create -d bridge --subnet 192.168.240.0/24 kind
739+
# chmod +x ./ci/kind/install-ipset.sh
740+
# ./ci/kind/install-ipset.sh
741+
uname -a
742+
sudo apt update
743+
sudo apt install -y ipset
744+
ipset --version
745+
sudo dmesg | grep ip_set
746+
sudo modprobe ip_set
747+
sudo modprobe xt_set
748+
sudo ipset create excluded_subnets hash:net
749+
sudo ipset add excluded_subnets 192.168.241.0/24
750+
sudo ipset add excluded_subnets 192.168.242.0/24
751+
sudo ipset list excluded_subnets
752+
753+
bridge_id=$(docker network inspect kind -f {{.ID}})
754+
bridge_interface="br-${bridge_id:0:12}"
755+
sudo iptables -t nat -A POSTROUTING ! -o $bridge_interface -s 192.168.240.0/24 -m set ! --match-set excluded_subnets dst -j MASQUERADE
756+
757+
sudo ipset create excluded_ipam_subnets hash:net
758+
sudo ipset add excluded_ipam_subnets 192.168.241.0/24
759+
sudo ipset add excluded_ipam_subnets 192.168.242.0/24
760+
sudo ipset add excluded_ipam_subnets 192.168.240.0/24
761+
sudo ipset list excluded_ipam_subnets
762+
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
763+
fi
731764
create
732765
fi

ci/kind/test-e2e-kind.sh

+34-4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ setup_only=false
8989
cleanup_only=false
9090
test_only=false
9191
run=""
92+
flexible_ipam=false
9293
antrea_controller_image="antrea/antrea-controller-ubuntu"
9394
antrea_agent_image="antrea/antrea-agent-ubuntu"
9495
use_non_default_images=false
@@ -110,6 +111,10 @@ case $key in
110111
proxy_all=true
111112
shift
112113
;;
114+
--flexible-ipam)
115+
flexible_ipam=true
116+
shift
117+
;;
113118
--no-kube-proxy)
114119
no_kube_proxy=true
115120
shift
@@ -249,6 +254,10 @@ if $flow_visibility; then
249254
manifest_args="$manifest_args --feature-gates FlowExporter=true,L7FlowExporter=true --extra-helm-values-file $FLOW_VISIBILITY_HELM_VALUES"
250255
fi
251256

257+
if $flexible_ipam; then
258+
manifest_args="$manifest_args --flexible-ipam --multicast"
259+
fi
260+
252261
COMMON_IMAGES_LIST=("registry.k8s.io/e2e-test-images/agnhost:2.40" \
253262
"antrea/nginx:1.21.6-alpine" \
254263
"antrea/toolbox:1.3-0")
@@ -302,6 +311,10 @@ if $extra_vlan; then
302311
fi
303312
fi
304313

314+
if $flexible_ipam; then
315+
vlan_args="$vlan_args --vlan-subnets 11=192.168.241.1/24 --vlan-subnets 12=192.168.242.1/24"
316+
fi
317+
305318
function setup_cluster {
306319
args=$1
307320

@@ -330,7 +343,11 @@ function setup_cluster {
330343
fi
331344

332345
echo "creating test bed with args $args"
333-
eval "timeout 600 $TESTBED_CMD create kind $args"
346+
if $flexible_ipam; then
347+
eval "timeout 600 $TESTBED_CMD --flexible-ipam create kind $args"
348+
else
349+
eval "timeout 600 $TESTBED_CMD create kind $args"
350+
fi
334351
}
335352

336353
function run_test {
@@ -348,8 +365,13 @@ function run_test {
348365
timeout="80m"
349366
coverage_args="--coverage --coverage-dir $ANTREA_COV_DIR"
350367
else
351-
$YML_CMD --encap-mode $current_mode $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea.yml
352-
$YML_CMD --ipsec $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea-ipsec.yml
368+
if $flexible_ipam; then
369+
$YML_CMD --flexible-ipam --multicast --encap-mode $current_mode $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea.yml
370+
echo "debug-1"
371+
else
372+
$YML_CMD --encap-mode $current_mode $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea.yml
373+
$YML_CMD --ipsec $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea-ipsec.yml
374+
fi
353375
timeout="75m"
354376
fi
355377

@@ -401,7 +423,15 @@ function run_test {
401423
EXTRA_ARGS="$EXTRA_ARGS --external-frr-cid $external_frr_cid --external-frr-ips $external_frr_ips"
402424
fi
403425

404-
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
426+
if $flexible_ipam; then
427+
sudo iptables -t nat -vnL
428+
kubectl get pods -o wide -A
429+
ip route
430+
export GO111MODULE=on
431+
go test -v antrea.io/antrea/test/e2e --provider kind -timeout=100m --prometheus --antrea-ipam
432+
else
433+
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
434+
fi
405435

406436
if $coverage; then
407437
pushd $ANTREA_COV_DIR

0 commit comments

Comments
 (0)