Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e0785c1
Use matrix with parametrized ci.yaml for future os upgrades
mpenny-github May 19, 2026
4a524ec
Potential fix for pull request finding
mpenny-github May 19, 2026
aaf989c
Enfore that the docker container should use amd64 version (even when …
mpenny-github May 19, 2026
ab35fa7
Create containerized testing framework
mpenny-github May 19, 2026
3bbf390
Update the Dockerfile with the requirements for running in a container
mpenny-github May 19, 2026
e2fb5d3
Update python tests with python3 syntax
mpenny-github May 19, 2026
0225418
Add tcpdump to Dockerfile. Skip tests that can't be run locally
mpenny-github May 19, 2026
443be59
Resolve: ValueError: must have exactly one of create/read/write/appen…
mpenny-github May 19, 2026
0c1cb03
Add goflags for builds. Skip tests that can't be run outside vagrant
mpenny-github May 19, 2026
eea8fe2
Debug director-xdp failure
mpenny-github May 19, 2026
91a8672
Use the renamed L2ListenSocket object. Ensure that XDP program is det…
mpenny-github May 19, 2026
23a51d6
Use HOSTPATH
mpenny-github May 19, 2026
75e859a
Improve glb-director teardown when run on action
mpenny-github May 19, 2026
1335bc6
Remove the test file that is not needed. Handle scapy teardown better
mpenny-github May 19, 2026
85f5c95
Remove dpdk-rte-kni-dkms
mpenny-github May 19, 2026
711d628
Replace EOL nose with pytest
mpenny-github May 20, 2026
419c02f
Improvements from copilot
mpenny-github May 20, 2026
ccdfa21
Add build artifacts to .gitignore, better handling in glb_test_util.py
mpenny-github May 26, 2026
41ee404
Add pytest.ini for glb-redirect
mpenny-github May 27, 2026
9181172
Remove usused import. Write to devnull to avoid deadlock
mpenny-github May 27, 2026
91802ca
Merge remote-tracking branch 'origin/containerized_test_suite' into u…
mpenny-github May 28, 2026
12187af
Merge remote-tracking branch 'origin/master' into use_pytest
mpenny-github May 28, 2026
5c5e078
Merge remote-tracking branch 'origin/master' into use_pytest
mpenny-github Jun 1, 2026
45ca6cb
Remove conflict markers
mpenny-github Jun 1, 2026
b2a3918
Conflict marker
mpenny-github Jun 1, 2026
1f3a066
Code review feedback
mpenny-github Jun 1, 2026
4bb3646
Close file in cli_tool
mpenny-github Jun 3, 2026
c1b6b73
Open test-config.bin with a with so it always closes
mpenny-github Jun 3, 2026
44c580d
Order of operations
mpenny-github Jun 3, 2026
edd4e15
Merge remote-tracking branch 'origin/master' into use_pytest
mpenny-github Jun 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add goflags for builds. Skip tests that can't be run outside vagrant
  • Loading branch information
mpenny-github committed May 19, 2026
commit 0c1cb03a9c9e90c95ca069fd4b7c1b5f000b14e2
5 changes: 5 additions & 0 deletions script/Dockerfile.focal
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ RUN wget --quiet https://golang.org/dl/go1.24.5.linux-amd64.tar.gz -O- | tar -C
ENV GOROOT /usr/local/go
ENV GOPATH /go
ENV PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"
# Disable VCS stamping in Go 1.24+ builds. The repo is bind-mounted from the
# host so git refuses to operate on it inside the container ("dubious
# ownership"), which causes `go build` to fail with
# "error obtaining VCS status: exit status 128".
ENV GOFLAGS=-buildvcs=false

# fpm for packaging
RUN apt-get update && apt-get install -y ruby ruby-dev rubygems build-essential
Expand Down
16 changes: 16 additions & 0 deletions src/glb-director/tests/glb_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ def wait(self):

class XDPDirectorControl(DirectorControlBase):
def __init__(self):
# XDP requires a Linux kernel with XDP support and the ability to
# attach BPF programs to veth interfaces. Docker Desktop on macOS /
# Windows runs a "linuxkit" kernel that doesn't support this. Detect
# that environment and skip rather than fail so script/test-local
# can still exercise the rest of the suite.
try:
kernel_release = os.uname().release
except Exception:
kernel_release = ''
if 'linuxkit' in kernel_release:
raise SkipTest("Running on linuxkit kernel ({}); XDP/veth attach is "
"not supported. Run on a Linux host to execute these tests.".format(kernel_release))
if not os.path.isdir('/sys/fs/bpf'):
raise SkipTest("/sys/fs/bpf is not available; BPF filesystem not "
"mounted. Run on a Linux host with BPF support to execute these tests.")

self.director = None

# veth pair implementation of XDP_TX silently drops packets unless the other side of the veth
Expand Down
36 changes: 36 additions & 0 deletions src/glb-director/tests/lib/testlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ end_test () {
set +x -e
exec 1>&3 2>&4

if [ -f "$TRASHDIR/.skipped" ]; then
reason=$(cat "$TRASHDIR/.skip_reason" 2>/dev/null)
rm -f "$TRASHDIR/.skipped" "$TRASHDIR/.skip_reason"
printf "test: %-60s SKIPPED (%s)\n" "$test_description ..." "$reason"
unset test_description
return 0
fi

if [ "$test_status" -eq 0 ]; then
printf "test: %-60s OK\n" "$test_description ..."
else
Expand All @@ -90,3 +98,31 @@ end_test () {
end_test_exfail () {
end_test $? 1
}

# Mark the current test as skipped from inside the subshell. The marker file
# is read by end_test to report SKIPPED rather than OK/FAILED. Mirrors the
# SkipTest pattern used by the director Python suite so tests that require
# infrastructure unavailable in the container (e.g. DPDK hugepages on
# Docker Desktop / macOS) don't fail when run via script/test-local.
skip_test () {
reason="${1:-no reason given}"
echo "SKIP: $reason"
: > "$TRASHDIR/.skipped"
echo "$reason" > "$TRASHDIR/.skip_reason"
exit 0
}

# Returns 0 if DPDK can use hugepages on this host. DPDK requires free
# hugepages of one of the supported sizes; without them EAL initialization
# fails with "Cannot get hugepage information." Docker Desktop on macOS
# (linuxkit kernel) does not expose hugepages by default.
hugepages_available () {
for f in /sys/kernel/mm/hugepages/hugepages-*/free_hugepages; do
[ -r "$f" ] || continue
n=$(cat "$f" 2>/dev/null || echo 0)
if [ "${n:-0}" -gt 0 ]; then
return 0
fi
done
return 1
}
6 changes: 6 additions & 0 deletions src/glb-director/tests/pcap_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ set -e

begin_test "run with pcap and example tables"
(
hugepages_available || skip_test "DPDK hugepages not available; skipping pcap director run. Run on a Linux host with hugepages configured."

$BASEDIR/cli/glb-director-cli build-config \
$BASEDIR/tests/data/table.json \
$BASEDIR/tests/data/test-tables.bin
Expand All @@ -50,12 +52,16 @@ end_test

begin_test "tx: should be 1000 packets"
(
hugepages_available || skip_test "DPDK hugepages not available; tx.pcap was not produced."

sudo tcpdump -r $BASEDIR/build/tx.pcap | wc -l | grep 1000
)
end_test

begin_test "tx: verify to/from"
(
hugepages_available || skip_test "DPDK hugepages not available; tx.pcap was not produced."

sudo tcpdump -nr $BASEDIR/build/tx.pcap | grep -q 'IP 65.65.65.65.61139 > 3.4.5.6.19523: UDP, length 52'
)
end_test
42 changes: 42 additions & 0 deletions src/glb-healthcheck/test/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ end_test () {

echo "---- end_test: $test_description ----" >> $HC_LOGFILE

if [ -f "$TRASHDIR/.skipped" ]; then
reason=$(cat "$TRASHDIR/.skip_reason" 2>/dev/null)
rm -f "$TRASHDIR/.skipped" "$TRASHDIR/.skip_reason"
printf "test: %-60s SKIPPED (%s)\n" "$test_description ..." "$reason"
unset test_description
return 0
fi

if [ "$test_status" -eq 0 ]; then
if [ "$ex_fail" -eq 0 ]; then
printf "test: %-60s OK (${elapsed_time}s)\n" "$test_description ..."
Expand All @@ -119,6 +127,33 @@ end_test_exfail () {
end_test $? 1
}

# Mark the current test as skipped from inside the subshell. The marker file
# is read by end_test below to report SKIPPED rather than OK/FAILED. This
# mirrors the SkipTest pattern used by the director Python test suite so that
# tests requiring infrastructure unavailable in the container (e.g. the
# Vagrant proxy1/proxy2 backends) don't fail when run via script/test-local.
skip_test () {
reason="${1:-no reason given}"
echo "SKIP: $reason"
: > "$TRASHDIR/.skipped"
echo "$reason" > "$TRASHDIR/.skip_reason"
exit 0
}

# Returns 0 if the Vagrant proxy backends (proxy1/proxy2) referenced by the
# default forwarding table are reachable on their HTTP healthcheck port.
# Used to decide whether to skip tests that depend on real backends being up.
proxy_backends_available () {
# quick TCP probe with a short timeout; both proxies must answer on :80
for ip in 192.168.50.10 192.168.50.11; do
if ! (exec 3<>/dev/tcp/$ip/80) 2>/dev/null; then
return 1
fi
exec 3<&- 3>&- 2>/dev/null || true
done
return 0
}

atexit () {
[ -z "$KEEPTRASH" ] && rm -rf "$TEMPDIR"
if [ $failures -gt 0 ]; then
Expand Down Expand Up @@ -157,6 +192,13 @@ setup() {

set -e

# When running under Docker (rather than the Vagrant director-test VM),
# the forwarding table references 192.168.50.5 as the local backend for
# the HTTP healthcheck test. Bind it to loopback so that the healthcheck
# daemon can actually reach a local HTTP server. Ignore failures (e.g.
# already added, or not running as root on the host).
ip addr add 192.168.50.5/32 dev lo 2>/dev/null || true

# copy a backup of the initial version to reset later
cp $TEMPDIR/forwarding_table.json $TEMPDIR/forwarding_table.json.bak

Expand Down
6 changes: 5 additions & 1 deletion src/glb-healthcheck/test/test-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ end_test

begin_test "outputs the healthcheck file with valid health"
(
proxy_backends_available || skip_test "Vagrant proxy1/proxy2 backends (192.168.50.10/11) not reachable; requires the Vagrant test network."

setup

sleep 3
Expand All @@ -107,6 +109,8 @@ end_test

begin_test "reload should take effect"
(
proxy_backends_available || skip_test "Vagrant proxy1/proxy2 backends (192.168.50.10/11) not reachable; requires the Vagrant test network."

setup

sleep 3
Expand Down Expand Up @@ -169,7 +173,7 @@ begin_test "responds to health check changes"
[[ "$(jq -r '.tables[1].backends[3].healthy' $TEMPDIR/forwarding_table.hc.json)" == "false" ]]

# start up a HTTP server
python -m SimpleHTTPServer 8765 &
python3 -m http.server 8765 &
http_pid=$!
echo "$http_pid" > "${TEMPDIR}/http.pid"

Expand Down
38 changes: 38 additions & 0 deletions src/glb-redirect/tests/glb_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,46 @@
# along with this project. If not, see <https://www.gnu.org/licenses/>.

from scapy.all import sniff, send, L3RawSocket, L3RawSocket6
import os
import socket
from nose.plugins.skip import SkipTest


def _proxy_backends_available():
"""Return True iff the Vagrant proxy backends (proxy1/proxy2) used by
these tests are reachable. They live in the Vagrant `glb_datacenter_network`
and aren't present when running under script/test-local in Docker."""
for host in ('192.168.50.10', '192.168.50.11'):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(0.2)
# port 22 is used as a liveness probe in the actual tests
rc = s.connect_ex((host, 22))
s.close()
if rc != 0:
return False
except OSError:
return False
return True


def skip_if_no_vagrant_network():
"""Raise SkipTest if the Vagrant proxy network isn't available. The
glb-redirect tests fundamentally require the proxy1/proxy2/director-test
VMs (with the glb-redirect iptables module loaded), so they can't run in
the Docker test image."""
if not _proxy_backends_available():
raise SkipTest(
"Vagrant proxy backends (192.168.50.10/11) not reachable; "
"glb-redirect tests require the Vagrant test network with the "
"glb-redirect iptables module installed on proxy1/proxy2.")


class GLBTestHelpers(object):
@classmethod
def setup_class(cls):
skip_if_no_vagrant_network()

def _sendrecv6(self, pkt, **kwargs):
s = L3RawSocket6()
send(pkt)
Expand Down
Loading