Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated testing setup #42

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ rb_ws/bags
.python-requirements.txt.un~
docker-compose.yml~
python-requirements.txt~
*TEMP_DO_NOT_EDIT.txt
rb_ws/src/buggy/bags/2023-02-11-11-38-44.bag
rb_ws/src/buggy/bags/2023-02-11-12-00-49.bag
rb_ws/src/buggy/bags/2023-02-11-12-01-12.bag
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ A complete re-write of the old RoboBuggy.
---
## Open Docker
- Use `cd` to change the working directory to be `RoboBuggy2`
- Then do `./setup_dev.sh` in the main directory (RoboBuggy2) to launch the docker container.
- Then do `./setup_dev.sh` in the main directory (RoboBuggy2) to launch the docker container. Utilize the `--no-gpu`, `--force-gpu`, and `--run-testing` flags as necessary.
- Then you can go in the docker container using the `docker exec -it robobuggy2-main-1 bash`.
- When you are done, type Ctrl+C and use `$exit` to exit.

Expand Down Expand Up @@ -119,7 +119,7 @@ SSH to the computer on ShortCircuit and go to folder
`$ ssh nuc@192.168.1.217`
Then `$ cd RoboBuggy2`
- Setup the docker
`$ ./setup_prod.sh`
`$ ./setup_prod.sh` (Utilize the `--no-gpu`, `--force-gpu`, and `--run-testing` flags as necessary.)
- Go to docker container
`$ docker_exec`
- Open foxglove and do local connection to “ws://192.168.1.217/8765”
Expand Down
52 changes: 52 additions & 0 deletions docker-compose-gpu-automated-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
services:
main:
build: .
volumes:
- ./rb_ws:/rb_ws
- "${RLSENSE_PORT:-/dev/null}:/dev/bus/usb"
- /tmp/.X11-unix:/tmp/.X11-unix
devices:
- "${TEENSY_PORT:-/dev/null}:/dev/ttyUSB0"
- "${WEBCAM_PORT:-/dev/null}:/dev/ttyUSB1"
- "${GPS_PORT:-/dev/null}:/dev/ttyACM0"
- "${FEATHER_PORT:-/dev/null}:/dev/ttyACM1"
stdin_open: true # docker run -i
tty: true # docker run -t
environment:
- DISPLAY=host.docker.internal:0
hostname: main
ports:
- "0.0.0.0:8765:8765" # foxglove bridge
- "0.0.0.0:8760:8760" # Asset server for loading stuff into foxglove
platform: "linux/amd64"
device_cgroup_rules:
- "c *:* rmw"
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 'all'
capabilities: [gpu]
tileserver:
image: maptiler/tileserver-gl
volumes:
- "./maps:/data"
stdin_open: true # docker run -i
tty: true # docker run -t
command: ["-p", "80", "-c", "/data/conf.json"]
ports:
- "8080:80"
tester:
build: .
volumes:
- ./rb_ws:/rb_ws
- /tmp/.X11-unix:/tmp/.X11-unix
stdin_open: true # docker run -i
tty: true # docker run -t
environment:
- DISPLAY=host.docker.internal:0
hostname: tester
platform: "linux/amd64"
device_cgroup_rules:
- "c *:* rmw"
1 change: 1 addition & 0 deletions docker-compose-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
tty: true # docker run -t
environment:
- DISPLAY=host.docker.internal:0
hostname: main
ports:
- "0.0.0.0:8765:8765" # foxglove bridge
- "0.0.0.0:8760:8760" # Asset server for loading stuff into foxglove
Expand Down
45 changes: 45 additions & 0 deletions docker-compose-no-gpu-automated-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
services:
main:
build: ./docker_auton
volumes:
- ./rb_ws:/rb_ws
- "${RLSENSE_PORT:-/dev/null}:/dev/bus/usb"
- /tmp/.X11-unix:/tmp/.X11-unix
devices:
- "${TEENSY_PORT:-/dev/null}:/dev/ttyUSB0"
- "${WEBCAM_PORT:-/dev/null}:/dev/ttyUSB1"
- "${GPS_PORT:-/dev/null}:/dev/ttyACM0"
- "${FEATHER_PORT:-/dev/null}:/dev/ttyACM1"
stdin_open: true # docker run -i
tty: true # docker run -t
environment:
- DISPLAY=host.docker.internal:0
hostname: main
ports:
- "0.0.0.0:8765:8765" # foxglove bridge
- "0.0.0.0:8760:8760" # Asset server for loading stuff into foxglove
platform: "linux/amd64"
device_cgroup_rules:
- "c *:* rmw"
tileserver:
image: maptiler/tileserver-gl
volumes:
- "./maps:/data"
stdin_open: true # docker run -i
tty: true # docker run -t
command: ["-p", "80", "-c", "/data/conf.json"]
ports:
- "8080:80"
tester:
build: ./docker_tester
volumes:
- ./rb_ws:/rb_ws
- /tmp/.X11-unix:/tmp/.X11-unix
stdin_open: true # docker run -i
tty: true # docker run -t
environment:
- DISPLAY=host.docker.internal:0
hostname: tester
platform: "linux/amd64"
device_cgroup_rules:
- "c *:* rmw"
3 changes: 2 additions & 1 deletion docker-compose-no-gpu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
main:
build: .
build: ./docker_auton
volumes:
- ./rb_ws:/rb_ws
- "${RLSENSE_PORT:-/dev/null}:/dev/bus/usb"
Expand All @@ -14,6 +14,7 @@ services:
tty: true # docker run -t
environment:
- DISPLAY=host.docker.internal:0
hostname: main
ports:
- "0.0.0.0:8765:8765" # foxglove bridge
- "0.0.0.0:8760:8760" # Asset server for loading stuff into foxglove
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile → docker_auton/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ RUN apt-get install -y -qq \
ros-noetic-realsense2-description

# Run this now to cache it separately from other requirements
COPY cuda-requirements.txt cuda-requirements.txt
RUN pip3 install -r cuda-requirements.txt
COPY cuda-requirements_TEMP_DO_NOT_EDIT.txt cuda-requirements.txt
# RUN pip3 install -r cuda-requirements.txt


COPY python-requirements.txt python-requirements.txt
COPY python-requirements_TEMP_DO_NOT_EDIT.txt python-requirements.txt
RUN pip3 install -r python-requirements.txt

RUN echo 'source "/opt/ros/$ROS_DISTRO/setup.bash" --' >> ~/.bashrc
Expand Down
36 changes: 36 additions & 0 deletions docker_tester/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM nvidia/cuda:11.6.2-base-ubuntu20.04 as CUDA

FROM osrf/ros:noetic-desktop-full-focal

COPY --from=CUDA /usr/local/cuda /usr/local/


RUN apt update
RUN apt-get install -y -qq \
python3-pip \
python3-tk \
vim git tmux tree sl htop x11-apps

RUN apt-get install -y -qq \
ros-noetic-rosserial \
ros-noetic-foxglove-bridge \
ros-noetic-microstrain-inertial-driver \
ros-noetic-realsense2-camera \
ros-noetic-realsense2-description \
iputils-ping

COPY python-requirements_TEMP_DO_NOT_EDIT.txt python-requirements.txt
RUN pip3 install -r python-requirements.txt

RUN echo 'source "/opt/ros/$ROS_DISTRO/setup.bash" --' >> ~/.bashrc
RUN echo 'cd rb_ws' >> ~/.bashrc
RUN echo 'catkin_make >/dev/null' >> ~/.bashrc
RUN echo 'source devel/setup.bash' >> ~/.bashrc
RUN echo 'export ROS_MASTER_URI=http://main:11311' >> ~/.bashrc

# shoestring fix since installing numba from pythonrequirements
# smh breaks
RUN pip3 install numba

# add mouse to tmux
RUN echo 'set -g mouse on' >> ~/.tmux.conf
33 changes: 29 additions & 4 deletions setup_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

no_gpu=false
force_gpu=false
run_automated_testing_docker=false

usage() {
echo "Usage: $0 [options]"
echo "Options:"
echo " --no-gpu Disable CUDA support. Required to run on systems without Nvidia Container Toolkit."
echo " --force-gpu Force a GPU build even if Nvidia Container Toolkit is not detected"
echo " --run-testing Run the testing docker container"
}

while [ $# -gt 0 ]; do
Expand All @@ -22,6 +24,9 @@ while [ $# -gt 0 ]; do
--force-gpu)
force_gpu=true
;;
--run-testing)
run_automated_testing_docker=true
;;
*)
echo "Invalid option: $1" >&2
usage
Expand Down Expand Up @@ -50,16 +55,36 @@ fi
# Actual logic here #
#####################

if $no_gpu
if $no_gpu && ! $run_automated_testing_docker
then
dockerfile="docker-compose-no-gpu.yml"
else
fi

if ! $no_gpu && ! $run_automated_testing_docker
then
dockerfile="docker-compose-gpu.yml"
fi

if $no_gpu && $run_automated_testing_docker
then
dockerfile="docker-compose-no-gpu-automated-testing.yml"
fi

if ! $no_gpu && $run_automated_testing_docker
then
dockerfile="docker-compose-gpu-automated-testing.yml"
fi

echo "Killing old development containers..."
docker compose -f docker-compose-no-gpu.yml down # kill old containers
docker compose -f docker-compose-gpu.yml down # kill old containers
docker compose -f docker-compose-gpu-automated-testing.yml down # kill old containers, this is most complete

# copy python-requirements + cuda-requirements into appropriate folders for docker compose
cp python-requirements.txt docker_auton
mv docker_auton/python-requirements.txt docker_auton/python-requirements_TEMP_DO_NOT_EDIT.txt
cp python-requirements.txt docker_tester
mv docker_tester/python-requirements.txt docker_tester/python-requirements_TEMP_DO_NOT_EDIT.txt
cp cuda-requirements.txt docker_auton
mv docker_auton/cuda-requirements.txt docker_auton/cuda-requirements_TEMP_DO_NOT_EDIT.txt

echo "Building containers..."
docker compose -f $dockerfile build
Expand Down
31 changes: 29 additions & 2 deletions setup_prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

no_gpu=false
force_gpu=false
run_automated_testing_docker=false

usage() {
echo "Usage: $0 [options]"
echo "Options:"
echo " --no-gpu Disable CUDA support. Required to run on systems without Nvidia Container Toolkit."
echo " --force-gpu Force a GPU build even if Nvidia Container Toolkit is not detected"
echo " --run-testing Run the testing docker container"
}

while [ $# -gt 0 ]; do
Expand All @@ -22,6 +24,9 @@ while [ $# -gt 0 ]; do
--force-gpu)
force_gpu=true
;;
--run-testing)
run_automated_testing_docker=true
;;
*)
echo "Invalid option: $1" >&2
usage
Expand Down Expand Up @@ -49,16 +54,38 @@ fi
# Actual logic here #
#####################

if $no_gpu
if $no_gpu && ! $run_automated_testing_docker
then
dockerfile="docker-compose-no-gpu.yml"
else
fi

if ! $no_gpu && ! $run_automated_testing_docker
then
dockerfile="docker-compose-gpu.yml"
fi

if $no_gpu && $run_automated_testing_docker
then
dockerfile="docker-compose-no-gpu-automated-testing.yml"
fi

if ! $no_gpu && $run_automated_testing_docker
then
dockerfile="docker-compose-gpu-automated-testing.yml"
fi

echo "Killing all containers..."
docker kill $(docker ps -q)


# copy python-requirements + cuda-requirements into appropriate folders for docker compose
cp python-requirements.txt docker_auton
mv docker_auton/python-requirements.txt docker_auton/python-requirements_TEMP_DO_NOT_EDIT.txt
cp python-requirements.txt docker_tester
mv docker_tester/python-requirements.txt docker_tester/python-requirements_TEMP_DO_NOT_EDIT.txt
cp cuda-requirements.txt docker_auton
mv docker_auton/cuda-requirements.txt docker_auton/cuda-requirements_TEMP_DO_NOT_EDIT.txt

echo "Building containers..."
docker compose -f $dockerfile build

Expand Down
Loading