From db98566084278cd60f3a00588d52809b6ab3b265 Mon Sep 17 00:00:00 2001 From: Maxime Desroches Date: Tue, 29 Oct 2024 16:59:48 -0700 Subject: [PATCH] ci: faster sim test (#33888) * sim * no more --- .github/workflows/selfdrive_tests.yaml | 20 +++++++++++++++++++ .github/workflows/tools_tests.yaml | 18 ----------------- tools/sim/bridge/metadrive/metadrive_world.py | 2 +- tools/sim/tests/test_metadrive_bridge.py | 5 +---- tools/sim/tests/test_sim_bridge.py | 5 +---- 5 files changed, 23 insertions(+), 27 deletions(-) diff --git a/.github/workflows/selfdrive_tests.yaml b/.github/workflows/selfdrive_tests.yaml index 9456914371..9d37714c17 100644 --- a/.github/workflows/selfdrive_tests.yaml +++ b/.github/workflows/selfdrive_tests.yaml @@ -327,6 +327,26 @@ jobs: comment_id: ${{ steps.fc.outputs.comment-id }} }) + simulator_driving: + name: simulator driving + runs-on: ${{ ((github.repository == 'commaai/openpilot') && + ((github.event_name != 'pull_request') || + (github.event.pull_request.head.repo.full_name == 'commaai/openpilot'))) && 'namespace-profile-amd64-8x16' || 'ubuntu-24.04' }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: ./.github/workflows/setup-with-retry + - name: Build openpilot + run: | + ${{ env.RUN }} "scons -j$(nproc)" + - name: Driving test + timeout-minutes: 1 + run: | + ${{ env.RUN }} "source selfdrive/test/setup_xvfb.sh && \ + source selfdrive/test/setup_vsound.sh && \ + CI=1 pytest tools/sim/tests/test_metadrive_bridge.py" + create_ui_report: # This job name needs to be the same as UI_JOB_NAME in ui_preview.yaml name: Create UI Report diff --git a/.github/workflows/tools_tests.yaml b/.github/workflows/tools_tests.yaml index c1c3552472..493671051f 100644 --- a/.github/workflows/tools_tests.yaml +++ b/.github/workflows/tools_tests.yaml @@ -25,24 +25,6 @@ env: jobs: - simulator_driving: - name: simulator driving - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: ./.github/workflows/setup-with-retry - - name: Build openpilot - run: | - ${{ env.RUN }} "scons -j$(nproc)" - - name: Run bridge test - run: | - ${{ env.RUN }} "source selfdrive/test/setup_xvfb.sh && \ - source selfdrive/test/setup_vsound.sh && \ - CI=1 pytest tools/sim/tests/test_metadrive_bridge.py" - devcontainer: name: devcontainer runs-on: ubuntu-latest diff --git a/tools/sim/bridge/metadrive/metadrive_world.py b/tools/sim/bridge/metadrive/metadrive_world.py index 5bb4555dc1..a34d270994 100644 --- a/tools/sim/bridge/metadrive/metadrive_world.py +++ b/tools/sim/bridge/metadrive/metadrive_world.py @@ -105,7 +105,7 @@ class MetaDriveWorld(World): if x_dist >= dist_threshold or y_dist >= dist_threshold: # position not the same during staying still, > threshold is considered moving self.distance_moved += x_dist + y_dist - time_check_threshold = 30 + time_check_threshold = 15 current_time = time.monotonic() since_last_check = current_time - self.last_check_timestamp if since_last_check >= time_check_threshold: diff --git a/tools/sim/tests/test_metadrive_bridge.py b/tools/sim/tests/test_metadrive_bridge.py index 8849e901cb..04ce5d584f 100644 --- a/tools/sim/tests/test_metadrive_bridge.py +++ b/tools/sim/tests/test_metadrive_bridge.py @@ -12,10 +12,7 @@ from openpilot.tools.sim.tests.test_sim_bridge import TestSimBridgeBase class TestMetaDriveBridge(TestSimBridgeBase): @pytest.fixture(autouse=True) def setup_create_bridge(self, test_duration): - # run bridge test for at least 60s, since not-moving check runs every 30s - if test_duration < 60: - test_duration = 60 - self.test_duration = test_duration + self.test_duration = 30 def create_bridge(self): return MetaDriveBridge(False, False, self.test_duration, True) diff --git a/tools/sim/tests/test_sim_bridge.py b/tools/sim/tests/test_sim_bridge.py index 12f38b86c3..d58cddff7f 100644 --- a/tools/sim/tests/test_sim_bridge.py +++ b/tools/sim/tests/test_sim_bridge.py @@ -89,7 +89,4 @@ class TestSimBridgeBase: p.terminate() for p in reversed(self.processes): - if isinstance(p, subprocess.Popen): - p.wait(15) - else: - p.join(15) + p.kill()