Skip to content

Commit

Permalink
topotests: Allow runing under both docker and podman
Browse files Browse the repository at this point in the history
Signed-off-by: famfo <[email protected]>
  • Loading branch information
famfo committed Nov 26, 2024
1 parent bcf6e53 commit e8932dd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
13 changes: 11 additions & 2 deletions tests/topotests/docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
#
# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF")

cd "$(dirname "$0")"/..

exec docker build --pull \
which docker > /dev/null
if [[ $? == 0 ]]; then
cmd="docker"
else
which podman > /dev/null
[[ $? != 0 ]] && echo "Could not find docker or podman executable" && exit 1
cmd="podman"
fi

exec "${cmd}" build --pull \
--compress \
-t frrouting/topotests:latest \
.
21 changes: 17 additions & 4 deletions tests/topotests/docker/frr-topotests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
#
# Copyright 2018 Network Device Education Foundation, Inc. ("NetDEF")
Expand Down Expand Up @@ -113,10 +113,23 @@ if [ -z "$TOPOTEST_FRR" ]; then
git -C "$TOPOTEST_FRR" ls-files -z > "${TOPOTEST_LOGS}/git-ls-files"
fi

set +e

which docker > /dev/null
if [[ $? == 0 ]]; then
cmd="docker"
else
which podman > /dev/null
[[ $? != 0 ]] && echo "Could not find docker or podman executable" && exit 1
cmd="podman"
fi

set -e

if [ -z "$TOPOTEST_BUILDCACHE" ]; then
TOPOTEST_BUILDCACHE=topotest-buildcache
docker volume inspect "${TOPOTEST_BUILDCACHE}" &> /dev/null \
|| docker volume create "${TOPOTEST_BUILDCACHE}"
"${cmd}" volume inspect "${TOPOTEST_BUILDCACHE}" &> /dev/null \
|| "${cmd}" volume create "${TOPOTEST_BUILDCACHE}"
fi

if [[ -n "$TMUX" ]]; then
Expand Down Expand Up @@ -145,4 +158,4 @@ if [ -t 0 ]; then
set -- -t "$@"
fi

exec docker run "$@"
exec "${cmd}" run "$@"

0 comments on commit e8932dd

Please sign in to comment.