Skip to content

Commit

Permalink
ci modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Noland committed Jun 5, 2021
1 parent 914dcc2 commit 44a2ab0
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 26 deletions.
25 changes: 15 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
language: rust
dist: trusty
sudo: false
dist: focal
sudo: true
group: edge
script:
- ./scripts/ci.sh
- cargo build --verbose
- cargo test --verbose
addons:
apt:
packages:
- cmake
- cmake-data
- gcc-10
- ibverbs-providers
- iproute2
- jq
- libibverbs1
- ninja-build
- libnl-3-dev
- libnl-genl-3-dev
- libnl-route-3-dev
- libudev-dev
- cmake
- cmake-data
- gcc-5
sources:
- ubuntu-toolchain-r-test
- george-edison55-precise-backports # cmake 3.2.3
- ninja-build
env:
- LLVM_VERSION=3.9.0
- RUST_BACKTRACE=1
rust:
- nightly
- beta
Expand Down
12 changes: 12 additions & 0 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# This is the script run by CI.

set -euxETo pipefail

# Define the name of the SoftRoCE device we would like to create for integration testing.
declare -r RXE_INTERFACE_NAME="rust_ibverbs"

# We need to install linux-modules-extra for our current kernel or else we don't have access to the rdma_rxe module in
# CI.
sudo apt-get install --yes linux-modules-extra-"$(uname --kernel-release)"
sudo ./scripts/make-rdma-loopback.sh "${RXE_INTERFACE_NAME}"
56 changes: 47 additions & 9 deletions scripts/make-rdma-loopback.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env bash
# This script sets up a simple SoftRoCE device to facilitate testing.

set -euxETo pipefail

declare -r RXE_INTERFACE_NAME="rust_ibverbs"
# Configuration
declare -r RXE_INTERFACE_NAME="${1}"

# Print an error message
log_err() {
>&2 echo "${*}"
log() {
>&2 printf "%s\n" "${*}"
}

# Determine if netns state of rdma devices is shared or exclusive
Expand All @@ -22,13 +24,49 @@ confirm_rdma_netns_shared() {
access="$(get_rdma_netns_state)"
declare -r access
if [[ "${access}" != "shared" ]]; then
log_err "rdma netns state is not shared: current state ${access}"
log "rdma netns state is not shared: current state ${access}"
return 1
fi
}

confirm_rdma_netns_shared
ip link add root type dummy
ip link add link root name "${RXE_INTERFACE_NAME}" type macvlan mode bridge
rdma link add "${RXE_INTERFACE_NAME}" type rxe netdev "${RXE_INTERFACE_NAME}"
ip link set group default up
# Set up a SoftRoCE loopback device. To do this we create a dummy device and then hang a macvlan in bridge mode off of
# that dummy device. This strategy allows all ordinary network traffic transmitted to the macvlan to be sent back to
# that macvlan. We then add a rxe device to the macvlan so that RDMA traffic can be exchanged as well.
set_up_soft_roce_loopback_device() {
declare -r DEVICE="${1}"
modprobe rdma_rxe
ip link add root type dummy
ip link add link root name "${DEVICE}" type macvlan mode bridge
rdma link add "${DEVICE}" type rxe netdev "${DEVICE}"
log "Added SoftRoCE link ${DEVICE}"
ip link set dev root up
ip link set dev "${DEVICE}" up
}

# Get state of RDMA device supplied in first argument.
get_rdma_device_state() {
rdma --json link | jq --raw-output --arg device "${1}" '.[] | select(.ifname == $device).state'
}

wait_for_rdma_device_to_be_ready() {
declare -r DEVICE="${1}"
declare -ri MAX_RETRY_COUNT=100
declare -i RETRY_COUNT=0
until [[ "$(get_rdma_device_state "${DEVICE}")" == "ACTIVE" ]]; do
log "waiting for ${DEVICE} RDMA device to be active"
RETRY_COUNT+=1
if [[ "${RETRY_COUNT}" -gt "${MAX_RETRY_COUNT}" ]]; then
log "Timed out waiting for RDMA device ${DEVICE} to be ready"
return 1
fi
sleep 0.1
done
}

main() {
confirm_rdma_netns_shared
set_up_soft_roce_loopback_device "${RXE_INTERFACE_NAME}"
wait_for_rdma_device_to_be_ready "${RXE_INTERFACE_NAME}"
}

main
7 changes: 0 additions & 7 deletions scripts/run.sh

This file was deleted.

0 comments on commit 44a2ab0

Please sign in to comment.