-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDFAB-582][SDFAB-584] Porting PTF run scripts from fabric-p4tests to…
… fabric-tna (#384) * Make ptf/run/bmv2/ scripts consistent with ptf/run/tna/ * Add port map for BmV2 * Remove Tofino-model scripts * Rename --tofino-pipeline-config parameter in --pipeline-config * Fix license header for ptf/run/bmv2/port_map.veth.json * Fix tofino-pipeline-config parameter to pipeline-config * Fix Linter * Add mn-stratum container's digest * Remove comments on old docker tester image * Remove Todo * Edit help message in --pipeline-config parser argument * Refactor update_config() making it more generic. * Refactor build pipeline method * Refactor and address changes * Fix license header * Refactor container name * Rename Bmv2 docker image * Address review changes * Fix license header * Fix license header
- Loading branch information
1 parent
9915737
commit a6ebb69
Showing
15 changed files
with
365 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright 2021-present Open Networking Foundation | ||
# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 | ||
log/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2021-present Open Networking Foundation | ||
# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 | ||
|
||
define run_tests | ||
python3 -u ptf_runner.py \ | ||
--platform bmv2 \ | ||
--port-map /fabric-tna/ptf/run/bmv2/port_map.veth.json \ | ||
--ptf-dir ../../tests/unary --cpu-port 255 --device-id 1 \ | ||
--grpc-addr 127.0.0.1:28000 \ | ||
--p4info /fabric-tna/"${P4C_OUT}"/p4info.txt \ | ||
--pipeline-config /fabric-tna/"${P4C_OUT}"/bmv2.json \ | ||
--profile $(1) \ | ||
$(2) | ||
endef | ||
|
||
.DEFAULT_GOAL := all | ||
|
||
#Nothing to check | ||
_checkenv: | ||
|
||
include ../../tests/common/Makefile.profiles | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
# Copyright 2021-present Open Networking Foundation | ||
# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 | ||
|
||
set -eu -o pipefail | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" | ||
FABRIC_TNA_ROOT="${DIR}"/../../.. | ||
|
||
randomNum=${RANDOM} | ||
|
||
# shellcheck source=.env | ||
source "${FABRIC_TNA_ROOT}"/.env | ||
|
||
PTF_FILTER=${PTF_FILTER:-} | ||
STRATUM_DOCKER_FLAG=${STRATUM_DOCKER_FLAG:-} | ||
|
||
fabricProfile=$1 | ||
if [ -z "${fabricProfile}" ]; then | ||
echo "fabric profile is not set" | ||
exit 1 | ||
fi | ||
|
||
echo "*** Testing profile '${fabricProfile}'..." | ||
|
||
echo "Running for BMV2" | ||
P4C_OUT=p4src/v1model/build/${fabricProfile}/bmv2 | ||
echo "*** Using P4 compiler output in ${P4C_OUT}..." | ||
|
||
# Clean up old logs (if any) | ||
rm -rf "${DIR}"/log | ||
mkdir "${DIR}"/log | ||
|
||
# stratum_bmv2 | ||
stratumBmv2ImageName=${STRATUM_BMV2_IMG} | ||
stratumBmv2RunName=stratum-bmv2-${randomNum} | ||
|
||
function stop_stratum_bmv2() { | ||
set +e | ||
echo "*** Stopping ${stratumBmv2ImageName}..." | ||
docker stop -t0 "${stratumBmv2RunName}" > /dev/null | ||
} | ||
trap stop_stratum_bmv2 EXIT | ||
|
||
|
||
echo "*** Starting ${stratumBmv2RunName}..." | ||
docker run --name ${stratumBmv2RunName} -d -it --rm --privileged \ | ||
-v "${FABRIC_TNA_ROOT}":/fabric-tna \ | ||
--entrypoint "/fabric-tna/ptf/run/bmv2/stratum_entrypoint.sh" \ | ||
"${stratumBmv2ImageName}" | ||
sleep 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
description: "stratum_bmv2 dut" | ||
chassis { | ||
platform: PLT_P4_SOFT_SWITCH | ||
name: "bmv2_dut" | ||
} | ||
nodes { | ||
id: 1 | ||
name: "bmv2_dut" | ||
slot: 1 | ||
index: 1 | ||
} | ||
singleton_ports { | ||
id: 0 | ||
name: "veth1" | ||
slot: 1 | ||
port: 0 | ||
channel: 1 | ||
speed_bps: 10000000000 | ||
config_params { | ||
admin_state: ADMIN_STATE_ENABLED | ||
} | ||
node: 1 | ||
} | ||
singleton_ports { | ||
id: 1 | ||
name: "veth3" | ||
slot: 1 | ||
port: 1 | ||
channel: 1 | ||
speed_bps: 10000000000 | ||
config_params { | ||
admin_state: ADMIN_STATE_ENABLED | ||
} | ||
node: 1 | ||
} | ||
singleton_ports { | ||
id: 2 | ||
name: "veth5" | ||
slot: 1 | ||
port: 2 | ||
channel: 1 | ||
speed_bps: 10000000000 | ||
config_params { | ||
admin_state: ADMIN_STATE_ENABLED | ||
} | ||
node: 1 | ||
} | ||
singleton_ports { | ||
id: 3 | ||
name: "veth7" | ||
slot: 1 | ||
port: 3 | ||
channel: 1 | ||
speed_bps: 10000000000 | ||
config_params { | ||
admin_state: ADMIN_STATE_ENABLED | ||
} | ||
node: 1 | ||
} | ||
singleton_ports { | ||
id: 4 | ||
name: "veth9" | ||
slot: 1 | ||
port: 4 | ||
channel: 1 | ||
speed_bps: 10000000000 | ||
config_params { | ||
admin_state: ADMIN_STATE_ENABLED | ||
} | ||
node: 1 | ||
} | ||
singleton_ports { | ||
id: 5 | ||
name: "veth11" | ||
slot: 1 | ||
port: 5 | ||
channel: 1 | ||
speed_bps: 10000000000 | ||
config_params { | ||
admin_state: ADMIN_STATE_ENABLED | ||
} | ||
node: 1 | ||
} | ||
singleton_ports { | ||
id: 6 | ||
name: "veth13" | ||
slot: 1 | ||
port: 6 | ||
channel: 1 | ||
speed_bps: 10000000000 | ||
config_params { | ||
admin_state: ADMIN_STATE_ENABLED | ||
} | ||
node: 1 | ||
} | ||
singleton_ports { | ||
id: 7 | ||
name: "veth15" | ||
slot: 1 | ||
port: 7 | ||
channel: 1 | ||
speed_bps: 10000000000 | ||
config_params { | ||
admin_state: ADMIN_STATE_ENABLED | ||
} | ||
node: 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[ | ||
{ | ||
"ptf_port": 0, | ||
"p4_port": 0, | ||
"iface_name": "veth1" | ||
}, | ||
{ | ||
"ptf_port": 1, | ||
"p4_port": 1, | ||
"iface_name": "veth3" | ||
}, | ||
{ | ||
"ptf_port": 2, | ||
"p4_port": 2, | ||
"iface_name": "veth5" | ||
}, | ||
{ | ||
"ptf_port": 3, | ||
"p4_port": 3, | ||
"iface_name": "veth7" | ||
}, | ||
{ | ||
"ptf_port": 4, | ||
"p4_port": 4, | ||
"iface_name": "veth9" | ||
}, | ||
{ | ||
"ptf_port": 5, | ||
"p4_port": 5, | ||
"iface_name": "veth11" | ||
}, | ||
{ | ||
"ptf_port": 6, | ||
"p4_port": 6, | ||
"iface_name": "veth13" | ||
}, | ||
{ | ||
"ptf_port": 7, | ||
"p4_port": 7, | ||
"iface_name": "veth15" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2021-present Open Networking Foundation | ||
# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 | ||
|
||
set -e | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" | ||
|
||
# shellcheck source=ptf/run/bmv2/base.sh | ||
source "${DIR}/base.sh" | ||
testerRunName=tester-${randomNum} | ||
echo "*** Starting ${testerRunName}..." | ||
|
||
# Do not attach stdin if running in an environment without it (e.g., Jenkins) | ||
it=$(test -t 0 && echo "-it" || echo "-t") | ||
# shellcheck disable=SC2068 disable=2086 | ||
docker run --name "${testerRunName}" "${it}" --rm --privileged \ | ||
--network "container:${stratumBmv2RunName}" \ | ||
-e P4C_OUT="${P4C_OUT}" \ | ||
-e PTF_FILTER="${PTF_FILTER}" \ | ||
-v "${FABRIC_TNA_ROOT}":/fabric-tna \ | ||
--entrypoint /fabric-tna/ptf/run/bmv2/start_test.sh \ | ||
${TESTER_DOCKER_IMG} \ | ||
${@} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2021-present Open Networking Foundation | ||
# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 | ||
|
||
set -e | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" | ||
PTF_ROOT=${DIR}/../.. | ||
TEST_DIR=${PTF_ROOT}/tests/common | ||
|
||
err_report() { | ||
|
||
echo "************************************************" | ||
echo "SOME PTF TESTS FAILED :(" | ||
echo "************************************************" | ||
exit 1 | ||
} | ||
|
||
trap 'err_report' ERR | ||
cd "${TEST_DIR}" | ||
|
||
echo "************************************************" | ||
echo "STARTING PTF TESTS..." | ||
echo "************************************************" | ||
|
||
# shellcheck disable=SC2068 | ||
make -f "${DIR}"/Makefile ${@} | ||
|
||
echo "************************************************" | ||
echo "ALL PTF TESTS PASSED :)" | ||
echo "************************************************" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2021-present Open Networking Foundation | ||
# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 | ||
|
||
set -ex | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" | ||
|
||
# From: | ||
# https://github.com/p4lang/behavioral-model/blob/master/tools/veth_setup.sh | ||
|
||
for idx in 0 1 2 3 4 5 6 7 8; do | ||
intf0="veth$((idx * 2))" | ||
intf1="veth$((idx * 2 + 1))" | ||
if ! ip link show $intf0 &> /dev/null; then | ||
ip link add name $intf0 type veth peer name $intf1 | ||
ip link set dev $intf0 up | ||
ip link set dev $intf1 up | ||
|
||
# Set the MTU of these interfaces to be larger than default of | ||
# 1500 bytes, so that P4 behavioral-model testing can be done | ||
# on jumbo frames. | ||
# Note: ifconfig is deprecated, and no longer installed by | ||
# default in Ubuntu Linux minimal installs starting with | ||
# Ubuntu 18.04. The ip command is installed in Ubuntu | ||
# versions since at least 16.04, and probably older versions, | ||
# too. | ||
ip link set $intf0 mtu 9500 | ||
ip link set $intf1 mtu 9500 | ||
|
||
# Disable IPv6 on the interfaces, so that the Linux kernel | ||
# will not automatically send IPv6 MDNS, Router Solicitation, | ||
# and Multicast Listener Report packets on the interface, | ||
# which can make P4 program debugging more confusing. | ||
# | ||
# Testing indicates that we can still send IPv6 packets across | ||
# such interfaces, both from scapy to simple_switch, and from | ||
# simple_switch out to scapy sniffing. | ||
# | ||
# https://superuser.com/questions/356286/how-can-i-switch-off-ipv6-nd-ra-transmissions-in-linux | ||
sysctl net.ipv6.conf.${intf0}.disable_ipv6=1 | ||
sysctl net.ipv6.conf.${intf1}.disable_ipv6=1 | ||
fi | ||
done | ||
|
||
stratum_bmv2 \ | ||
-bmv2_log_level=trace \ | ||
-chassis_config_file="${DIR}"/chassis_config.txt \ | ||
-cpu_port=255 \ | ||
-device_id=1 \ | ||
-external-stratum-urls=0.0.0.0:28000 \ | ||
-forwarding_pipeline_configs_file=/dev/null \ | ||
-initial_pipeline=/root/dummy.json \ | ||
-local_stratum_url=localhost:28000 \ | ||
-log_dir="${DIR}"/log/ \ | ||
-logtostderr=true \ | ||
-persistent_config_dir=/tmp/ \ | ||
-write_req_log_file="${DIR}"/log/p4rt-write-reqs.log \ | ||
&> "${DIR}"/log/stratum_bmv2.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.