Skip to content

Commit

Permalink
Fix ci/test-e2e-kind.sh script on macOS (antrea-io#6117)
Browse files Browse the repository at this point in the history
The script was failing with:
```
Deleting VLAN subnets
Option "-br" is unknown, try "ip help".
```
when cleaning-up a test cluster.

This is because the ip command on macOS only supports a subset of the
command-line options supported on Linux. In any case, on macOS, the
command needs be wrapped with docker_run_with_host_net, since we are
looking for VLAN interfaces running in the Docker Linux VM.

As a minor improvement, we also add the "antrea" prefix to the external
server container we create, along with a short random suffix ($RANDOM is
sufficient for this) to avoid possible conflicts.

Fixes antrea-io#6022

Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
  • Loading branch information
antoninbas authored Mar 20, 2024
1 parent 01694ee commit bf06790
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions ci/kind/kind-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function delete_vlan_subnets {
bridge_interface="br-${bridge_id:0:12}"
vlan_interface_prefix="br-${bridge_id:0:7}."

found_vlan_interfaces=$(ip -br link show type vlan | cut -d " " -f 1)
found_vlan_interfaces=$(docker_run_with_host_net ip -br link show type vlan | cut -d " " -f 1)
for interface in $found_vlan_interfaces ; do
if [[ $interface =~ ${vlan_interface_prefix}[0-9]+@${bridge_interface} ]]; then
interface_name=${interface%@*}
Expand Down Expand Up @@ -441,9 +441,9 @@ function destroy {
else
kind delete cluster --name $CLUSTER_NAME
fi
destroy_external_server
delete_networks
delete_vlan_subnets
destroy_external_server
}

function printUnixTimestamp {
Expand All @@ -457,13 +457,14 @@ function printUnixTimestamp {

function setup_external_server {
if [[ $DEPLOY_EXTERNAL_SERVER == true ]]; then
docker run -d --name external-server --network kind -it --rm registry.k8s.io/e2e-test-images/agnhost:2.29 netexec &> /dev/null
docker run -d --name antrea-external-server-$RANDOM --network kind -it --rm registry.k8s.io/e2e-test-images/agnhost:2.29 netexec &> /dev/null
fi
}

function destroy_external_server {
echo "Deleting external server"
docker rm -f external-server &> /dev/null || true
cid=$(docker ps -f name="^antrea-external-server" --format '{{.ID}}')
docker rm -f $cid &> /dev/null || true
}

function clean_kind {
Expand Down Expand Up @@ -643,7 +644,7 @@ fi

if [[ $ACTION == "destroy" ]]; then
destroy
exit 0
exit
fi

if [[ -n "$VLAN_SUBNETS" || -n "$VLAN_ID" ]]; then
Expand Down
4 changes: 3 additions & 1 deletion ci/kind/test-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ function run_test {
RUN_OPT="-run $run"
fi

EXTRA_ARGS="$vlan_args --external-server-ips $(docker inspect external-server -f '{{.NetworkSettings.Networks.kind.IPAddress}},{{.NetworkSettings.Networks.kind.GlobalIPv6Address}}')"
external_server_cid=$(docker ps -f name="^antrea-external-server" --format '{{.ID}}')
external_server_ips=$(docker inspect $external_server_cid -f '{{.NetworkSettings.Networks.kind.IPAddress}},{{.NetworkSettings.Networks.kind.GlobalIPv6Address}}')
EXTRA_ARGS="$vlan_args --external-server-ips $external_server_ips"

go test -v -timeout=$timeout $RUN_OPT antrea.io/antrea/test/e2e $flow_visibility_args -provider=kind --logs-export-dir=$ANTREA_LOG_DIR --skip-cases=$skiplist $coverage_args $EXTRA_ARGS
}
Expand Down

0 comments on commit bf06790

Please sign in to comment.