Skip to content

Commit

Permalink
TEMP: test patch/sch_mirred on github actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
kanaka committed Apr 2, 2024
1 parent bb8fd9e commit 73de6fb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 81 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ jobs:
run: docker-compose -f examples/test1-compose.yaml build

- name: "./run-tests.sh"
timeout-minutes: 5
run: time ./run-tests.sh
timeout-minutes: 1
run: time VERBOSE=1 ./run-tests.sh

- name: show logs
if: always()
run: docker-compose -f examples/test9-compose.yaml logs
5 changes: 1 addition & 4 deletions examples/test9-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker:/var/lib/docker
- ./:/test
command: /app/build/conlink.js --default-bridge-mode linux --compose-file /test/test9-compose.yaml
command: /app/build/conlink.js -v --default-bridge-mode linux --compose-file /test/test9-compose.yaml

Ndefault: &node
image: alpine
Expand All @@ -25,19 +25,16 @@ services:

Nauto: { <<: *node }
Nlinux: { <<: *node }
Novs: { <<: *node }
Npatch: { <<: *node }

x-network:
links:
- {bridge: s1, service: Ndefault, ip: 10.0.1.1/24}
- {bridge: s2, service: Nauto, ip: 10.0.2.1/24}
- {bridge: s3, service: Nlinux, ip: 10.0.3.1/24}
- {bridge: s4, service: Novs, ip: 10.0.4.1/24}
- {bridge: s5, service: Npatch, ip: 10.0.5.1/24}
bridges:
- {bridge: s2, mode: auto}
- {bridge: s3, mode: linux}
- {bridge: s4, mode: ovs}
- {bridge: s5, mode: patch}

87 changes: 16 additions & 71 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@

export VERBOSE=${VERBOSE:-}
export COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-conlink-test}
export DOCKER_COMPOSE=${DOCKER_COMPOSE:-docker-compose}
declare TEST_NUM=0
declare -A RESULTS
declare PASS=0
declare FAIL=0

die() { echo >&2 "${*}"; exit 1; }
vecho() { [ "${VERBOSE}" ] && echo "${*}" || true; }
dc() { docker-compose "${@}"; }
dc() { ${DOCKER_COMPOSE} "${@}"; }
mdc() { ./mdc "${@}" || die "mdc invocation failed"; }

dc_init() {
local cont="${1}" idx="${2}"
dc down --remove-orphans -t1
dc up -d --force-recreate "${@}"
while ! dc logs network | grep "All links connected"; do
vecho "log output:"
[ "${VERBOSE}" ] && sleep 1 && dc logs network
vecho "waiting for conlink startup"
sleep 1
sleep 9
done
}

Expand Down Expand Up @@ -63,76 +66,18 @@ dc_test() {
}


echo -e "\n\n>>> test1: combined config"
GROUP=test1
echo "COMPOSE_FILE=examples/test1-compose.yaml" > .env
dc_init || die "test1 startup failed"

echo " >> Ping nodes from other nodes"
dc_test h1 ping -c1 10.0.0.100
dc_test h2 ping -c1 192.168.1.100
dc_test h3 ping -c1 172.16.0.100

echo -e "\n\n>>> test2: separate config and scaling"
GROUP=test2
echo "COMPOSE_FILE=examples/test2-compose.yaml" > .env
dc_init || die "test2 startup failed"

echo " >> Cross-node ping and ping the 'internet'"
dc_test node_1 ping -c1 10.0.1.2
dc_test node_2 ping -c1 10.0.1.1
dc_test node_1 ping -c1 8.8.8.8
dc_test node_2 ping -c1 8.8.8.8

echo " >> Scale the nodes from 2 to 5"
dc up -d --scale node=5
dc_wait 10 node_5 'ip addr | grep "10\.0\.1\.5"' || die "test2 scale-up failed"
echo " >> Ping the fifth node from the second"
dc_test node_2 ping -c1 10.0.1.5


echo -e "\n\n>>> test4: multiple compose / mdc"
GROUP=test4
export MODES_DIR=./examples/test4-multiple/modes

mdc node1
dc_init; dc_wait 10 r0_1 'ip addr | grep "10\.1\.0\.100"' \
|| die "test4 node1 startup failed"
echo " >> Ping the r0 router host from node1"
dc_test node1_1 ping -c1 10.0.0.100

mdc node1,nodes2
dc_init; dc_wait 10 node2_2 'ip addr | grep "10\.2\.0\.2"' \
|| die "test4 node1,nodes2 startup failed"
echo " >> From both node2 replicas, ping node1 across the r0 router"
dc_test node2_1 ping -c1 10.1.0.1
dc_test node2_2 ping -c1 10.1.0.1
echo " >> From node1, ping both node2 replicas across the r0 router"
dc_test node1 ping -c1 10.2.0.1
dc_test node1 ping -c1 10.2.0.2

mdc all
dc_init; dc exec -T r0 /scripts/wait.sh -t 10.0.0.100:80 \
|| die "test4 all startup failed"
echo " >> From node2, download from the web server in r0"
dc_test node2_1 wget -O- 10.0.0.100
dc_test node2_2 wget -O- 10.0.0.100


echo -e "\n\n>>> test7: MAC, MTU, and NetEm settings"
echo -e "\n\n>>> test9: patch test"
GROUP=test7
echo "COMPOSE_FILE=examples/test7-compose.yaml" > .env

dc_init; dc_wait 10 node_1 'ip addr | grep "10\.0\.1\.1"' \
|| die "test7 startup failed"
echo " >> Ensure MAC and MTU are set correctly"
dc_test node_1 'ip link show eth0 | grep "ether 00:0a:0b:0c:0d:01"'
dc_test node_2 'ip link show eth0 | grep "ether 00:0a:0b:0c:0d:02"'
dc_test node_1 'ip link show eth0 | grep "mtu 4111"'
dc_test node_2 'ip link show eth0 | grep "mtu 4111"'
echo " >> Check for round-trip ping delay of 80ms"
dc_test node_1 'ping -c2 10.0.1.2 | tail -n1 | grep "max = 80\."'

echo "COMPOSE_FILE=examples/test9-compose.yaml" > .env

dc_init; dc_wait 10 Npatch_1 'ip addr | grep "10\.0\.5\.1"' \
|| die "test9 startup failed"
echo " >> Ensure ingest filter rules exist"
dc_test network 'tc filter show dev Npatch_1-eth0 parent ffff: | grep "action order 1: mirred"'
dc_test network 'tc filter show dev Npatch_2-eth0 parent ffff: | grep "action order 1: mirred"'
echo " >> Check for round-trip connectivity"
dc_test Npatch_1 'ping -c2 10.0.5.2'
dc_test Npatch_2 'ping -c2 10.0.5.1'

echo -e "\n\n>>> Cleaning up"
dc down -t1 --remove-orphans
Expand Down
9 changes: 5 additions & 4 deletions src/conlink/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[clojure.pprint :refer [pprint]]
[promesa.core :as P]
[cljs-bean.core :refer [->clj ->js]]
[conlink.util :refer [parse-opts Eprintln fatal
[conlink.util :refer [parse-opts Eprn Eprintln fatal
trim indent interpolate-walk deep-merge
spawn read-file load-config resolve-path]]
[conlink.addrs :as addrs]
Expand Down Expand Up @@ -127,9 +127,9 @@ General Options:
[{:as bridge-opts :keys [bridge mode]}]
(let [{:keys [warn default-bridge-mode kmod-ovs? kmod-mirred?]} @ctx
mode (keyword (or mode default-bridge-mode))
_ (when (and (= :patch mode) (not kmod-mirred?))
(fatal 1 (str "bridge " bridge " mode is 'patch', "
"but no 'act_mirred' kernel module loaded")))
;;_ (when (and (= :patch mode) (not kmod-mirred?))
;; (fatal 1 (str "bridge " bridge " mode is 'patch', "
;; "but no 'act_mirred' kernel module loaded")))
_ (when (and (= :ovs mode) (not kmod-ovs?))
(fatal 1 (str "bridge " bridge " mode is 'ovs', "
"but no 'openvswitch' kernel module loaded")))
Expand All @@ -140,6 +140,7 @@ General Options:
mode (if (= :auto mode)
(if kmod-ovs? :ovs :linux)
mode)]
(Eprn :bridge bridge :orig-mode (:mode bridge-opts) :mode mode :kmod-ovs? kmod-ovs?)
(assoc bridge-opts :mode mode)))

(defn enrich-network-config
Expand Down

0 comments on commit 73de6fb

Please sign in to comment.