Skip to content

Commit

Permalink
Merge pull request #404 from Bolodya1997/fix-vfio-tests
Browse files Browse the repository at this point in the history
Fix VFIO test
  • Loading branch information
haiodo authored Mar 1, 2021
2 parents c4fe7cc + 26b43ec commit 0422de5
Showing 1 changed file with 38 additions and 23 deletions.
61 changes: 38 additions & 23 deletions examples/use-cases/Vfio2Noop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,46 @@ Get NSC pod:
NSC=$(kubectl -n ${NAMESPACE} get pods -l app=nsc --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
```

Check connection result:
Check connectivity:
```bash
kubectl -n ${NAMESPACE} logs ${NSC} sidecar |
grep "All client init operations are done."
```
function dpdk_ping() {
err_file="$(mktemp)"
trap 'rm -f "${err_file}"' RETURN

Test connection:
```bash
PING_RESULTS=$(kubectl -n ${NAMESPACE} exec ${NSC} --container pinger -- /bin/bash -c ' \
/root/dpdk-pingpong/build/app/pingpong \
--no-huge \
-- \
-n 500 \
-c \
-C 0a:11:22:33:44:55 \
-S 0a:55:44:33:22:11 \
' 2>&1) || (echo "${PING_RESULTS}" 1>&2 && false)
```
```bash
PONG_PACKETS="$(echo "${PING_RESULTS}" | grep "rx .* pong packets" | sed -E 's/rx ([0-9]*) pong packets/\1/g')" \
|| (echo "${PING_RESULTS}" 1>&2 && false)
out="$(kubectl -n ${NAMESPACE} exec ${NSC} --container pinger -- /bin/bash -c '\
/root/dpdk-pingpong/build/app/pingpong \
--no-huge \
-- \
-n 500 \
-c \
-C 0a:11:22:33:44:55 \
-S 0a:55:44:33:22:11 \
' 2>"${err_file}")"

if [[ "$?" != 0 ]]; then
cat "${err_file}" 1>&2
echo "${out}" 1>&2
return 1
fi

if ! pong_packets="$(echo "${out}" | grep "rx .* pong packets" | sed -E 's/rx ([0-9]*) pong packets/\1/g')"; then
cat "${err_file}" 1>&2
echo "${out}" 1>&2
return 1
fi

if [[ "${pong_packets}" == 0 ]]; then
cat "${err_file}" 1>&2
echo "${out}" 1>&2
return 1
fi

echo "${out}"
return 0
}
```
```bash
test "${PONG_PACKETS}" -ne 0 \
|| (echo "${PING_RESULTS}" 1>&2 && false)
dpdk_ping
```

## Cleanup
Expand All @@ -87,8 +102,8 @@ Stop ponger:
NSE=$(kubectl -n ${NAMESPACE} get pods -l app=nse --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
```
```bash
kubectl -n ${NAMESPACE} exec ${NSE} --container ponger -- /bin/bash -c ' \
sleep 10 && kill $(ps -A | grep "pingpong" | sed -E "s/ *([0-9]*).*/\1/g") 1>/dev/null 2>&1 & \
kubectl -n ${NAMESPACE} exec ${NSE} --container ponger -- /bin/bash -c '\
sleep 10 && kill $(pgrep "pingpong") 1>/dev/null 2>&1 & \
'
```

Expand Down

0 comments on commit 0422de5

Please sign in to comment.