Skip to content

Commit

Permalink
Merge branch 'feature/automated-testing-dev' of github.com:ika-rwth-a…
Browse files Browse the repository at this point in the history
…achen/carlos into feature/automated-testing-dev
  • Loading branch information
cgeller committed Feb 5, 2024
2 parents f4ab0d3 + 000f3c2 commit 133bb7e
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/automated-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
scenario-folder-path: ${{ matrix.filedir }}
scenario-file-name: ${{ matrix.filename }}
simulator-image: carla-health # TODO: Change to rwthika/carla:server
simulator-image: carla-health # TODO: Change to rwthika/carla-simulator:server
simulator-offscreen: false

generate-opt-scenario-job-matrix:
Expand Down Expand Up @@ -62,5 +62,5 @@ jobs:
with:
scenario-folder-path: ${{ matrix.filedir }}
scenario-file-name: ${{ matrix.filename }}
simulator-image: carla-health # TODO: Change to rwthika/carla:server
simulator-image: carla-health # TODO: Change to rwthika/carla-simulator:server
simulator-offscreen: false
28 changes: 28 additions & 0 deletions automated-testing/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
services:

carla-simulator:
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
environment:
DISPLAY: $DISPLAY
XAUTHORITY: /.Xauthority
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
- $XAUTHORITY:/.Xauthority:ro
privileged: True
image: carla-health # TODO: Change to rwthika/carla-simulator:server
command: bash -ic './CarlaUE4.sh -nosound $SIMULATOR_FLAGS 2>/dev/null'

carla-scenario-runner:
depends_on:
carla-simulator:
condition: service_healthy
volumes:
- ../utils/scenarios:/scenarios
image: rwthika/carla-scenario-runner:latest
command: bash -ic "python ./scenario_runner.py --host carla-simulator --openscenario /scenarios/town10.xosc.opt --output"
56 changes: 56 additions & 0 deletions automated-testing/evaluate-scenarios.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

set -e

usage() {
echo "Usage: $0 [-d maxdepth] [-e exclude-path] STARTING-POINT QUERY-STRING"
echo "STARTING-POINT : Location from where search should start"
echo "QUERY-STRING : UNIX pattern used for matching and selecting results. Needs to be \"quoted\""
echo "max-depth : Descend at most max-depth levels from STARTING-POINT"
echo "exclude-string : Exclude paths matching this UNIX pattern from final result. Needs to be \"quoted\""
echo "-----"
echo "Example: $0 -d 3 . \"*.xosc\""
}

trap cleanup EXIT
trap cleanup 0

cleanup() {
echo "Cleaning up..."
docker compose -f $COMPOSE_TEMPLATE_PATH kill
docker compose -f $COMPOSE_TEMPLATE_PATH down
xhost -local:
echo "Done cleaning up."
}

restart-simulator() {
echo "Restarting simulator..."
docker compose -f $COMPOSE_TEMPLATE_PATH kill
docker compose -f $COMPOSE_TEMPLATE_PATH down
docker compose -f $COMPOSE_TEMPLATE_PATH up -d carla-simulator
}

export SCENARIO_DIRECTORY="${1:-"../utils/scenarios"}"
export COMPOSE_TEMPLATE_PATH="${2:-"./template.yml"}"
echo $SCENARIO_DIRECTORY

scenarios=($(find $SCENARIO_DIRECTORY -maxdepth 1 -type f -name "*.xosc*" -exec basename {} \;))

if [ ${#scenarios[@]} -eq 0 ]; then
echo "No scenarios found. Exiting..."
exit 1
fi
xhost +local:
echo "Starting simulator..."
docker compose -f $COMPOSE_TEMPLATE_PATH up -d carla-simulator

for scenario in "${scenarios[@]}"; do
echo "Evaluating $scenario ..."

export SCENARIO_NAME=$scenario
docker compose -f $COMPOSE_TEMPLATE_PATH run --rm carla-scenario-runner || true

if [ "$RESTART_SIMULATOR" = true ]; then
restart-simulator
fi
done
28 changes: 28 additions & 0 deletions automated-testing/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
services:

carla-simulator:
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
environment:
DISPLAY: $DISPLAY
XAUTHORITY: /.Xauthority
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
- $XAUTHORITY:/.Xauthority:ro
privileged: True
image: carla-health # TODO: Change to rwthika/carla-simulator:server
command: bash -ic './CarlaUE4.sh -nosound $SIMULATOR_FLAGS 2>/dev/null'

carla-scenario-runner:
depends_on:
carla-simulator:
condition: service_healthy
volumes:
- $SCENARIO_DIRECTORY:/scenarios
image: rwthika/carla-scenario-runner:latest
command: bash -ic "python ./scenario_runner.py --host carla-simulator --openscenario /scenarios/$SCENARIO_NAME --output"

0 comments on commit 133bb7e

Please sign in to comment.