-
Notifications
You must be signed in to change notification settings - Fork 178
feat(examples): websocket autobahn test suit integration (IDF-14864) #960
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| name: "websocket-autobahn: build/linux-tests" | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, labeled] | ||
|
|
||
| jobs: | ||
| linux_websocket_autobahn: | ||
| runs-on: ubuntu-22.04 | ||
| if: github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'websocket-autobahn')) | ||
|
|
||
| env: | ||
| TEST_DIR: components/esp_websocket_client/tests/autobahn-testsuite | ||
| TESTEE_DIR: components/esp_websocket_client/tests/autobahn-testsuite/testee | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Start Autobahn Fuzzing Server | ||
| run: | | ||
| mkdir -p ${{ env.TEST_DIR }}/reports/clients | ||
|
|
||
| HOST_IP=$(ip route get 8.8.8.8 | grep -oP 'src \K\S+' || hostname -I | awk '{print $1}' || echo "172.17.0.1") | ||
| echo "Host IP address: $HOST_IP" | ||
| echo "HOST_IP=$HOST_IP" >> $GITHUB_ENV | ||
|
|
||
| docker run -d \ | ||
| --name fuzzing-server \ | ||
| --network host \ | ||
| -v ${{ github.workspace }}/${{ env.TEST_DIR }}/config:/config:ro \ | ||
| -v ${{ github.workspace }}/${{ env.TEST_DIR }}/reports:/reports \ | ||
| crossbario/autobahn-testsuite:latest \ | ||
| wstest -m fuzzingserver -s /config/fuzzingserver.json | ||
|
|
||
| echo "Waiting for fuzzing server..." | ||
| for i in {1..5}; do | ||
| if curl -f http://localhost:9001/info >/dev/null 2>&1; then | ||
| echo "Fuzzing server ready!" | ||
| exit 0 | ||
| fi | ||
| echo "Attempt $i/5 – waiting 2s..." | ||
| sleep 2 | ||
| done | ||
|
|
||
| echo "Server start failed. Container logs:" | ||
| docker logs fuzzing-server | ||
| exit 1 | ||
|
|
||
| - name: Build test (Linux target) | ||
| working-directory: ${{ env.TESTEE_DIR }} | ||
| run: | | ||
| docker run --rm \ | ||
| -v ${{ github.workspace }}:/work \ | ||
| -w /work/${{ env.TESTEE_DIR }} \ | ||
| espressif/idf:latest \ | ||
| bash -c " | ||
| . \$IDF_PATH/export.sh | ||
| cp sdkconfig.ci.linux sdkconfig.defaults | ||
| echo 'Building...' | ||
| idf.py build | ||
| " | ||
|
|
||
| - name: Verify fuzzing server connectivity | ||
| run: | | ||
| HOST_IP=${HOST_IP:-$(ip route get 8.8.8.8 | grep -oP 'src \K\S+' || hostname -I | awk '{print $1}' || echo "172.17.0.1")} | ||
| echo "Testing connectivity to $HOST_IP:9001" | ||
|
|
||
| docker run --rm \ | ||
| --network host \ | ||
| espressif/idf:latest \ | ||
| bash -c " | ||
| curl -f http://$HOST_IP:9001/info || { | ||
| echo 'ERROR: Cannot connect to fuzzing server at $HOST_IP:9001' | ||
| exit 1 | ||
| } | ||
| echo 'Fuzzing server is accessible' | ||
| " | ||
|
|
||
| - name: Run Autobahn tests | ||
| run: | | ||
| docker run --rm \ | ||
| --network host \ | ||
| -v ${{ github.workspace }}:/work \ | ||
| -w /work/${{ env.TESTEE_DIR }}/build \ | ||
| espressif/idf:latest \ | ||
| bash -c " | ||
| apt-get update && apt-get install -y file curl net-tools || true | ||
|
|
||
| HOST_IP=\$(ip route get 8.8.8.8 2>/dev/null | grep -oP 'src \\K\\S+' || hostname -I | awk '{print \$1}' || echo '172.17.0.1') | ||
| curl -f http://\${HOST_IP}:9001/info || { | ||
| echo \"ERROR: Server not reachable at \${HOST_IP}:9001\" | ||
| exit 1 | ||
| } | ||
|
|
||
| echo 'Running autobahn_testee.elf' | ||
| WS_URI=\"ws://\${HOST_IP}:9001\" | ||
| echo \"WebSocket URI: \${WS_URI}\" | ||
| (sleep 0.5; printf \"\${WS_URI}\\n\") | timeout 30m ./autobahn_testee.elf || { | ||
| EXIT_CODE=\$? | ||
| echo 'Test failed' | ||
| exit \$EXIT_CODE | ||
| } | ||
| echo 'All Autobahn tests passed!' | ||
| " | ||
|
|
||
| - name: Show reports | ||
| if: always() | ||
| working-directory: ${{ env.TEST_DIR }} | ||
| run: | | ||
| if [ -d reports/clients ]; then | ||
| ls -la reports/clients/ | ||
| else | ||
| echo "No reports" | ||
| fi | ||
|
|
||
| - name: Generate summary | ||
| if: always() | ||
| working-directory: ${{ env.TEST_DIR }} | ||
| run: python3 scripts/generate_summary.py || true | ||
|
|
||
| - name: Upload reports | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: autobahn-reports-linux-${{ github.run_id }} | ||
| path: ${{ env.TEST_DIR }}/reports/** | ||
| if-no-files-found: warn | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,225 @@ | ||
| name: "websocket-autobahn: build/target-tests" | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, labeled] | ||
|
|
||
| jobs: | ||
| build_websocket_autobahn: | ||
| if: contains(github.event.pull_request.labels.*.name, 'websocket-autobahn') || github.event_name == 'push' | ||
| name: Build | ||
| strategy: | ||
| matrix: | ||
| idf_ver: ["release-v5.5", "latest"] | ||
| idf_target: ["esp32"] | ||
| runs-on: ubuntu-22.04 | ||
| container: espressif/idf:${{ matrix.idf_ver }} | ||
| env: | ||
| TEST_DIR: components/esp_websocket_client/examples/autobahn-testsuite/testee | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Workflow uses wrong path for testee directoryThe target-test workflow defines |
||
| steps: | ||
| - name: Checkout esp-protocols | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| - name: Build autobahn testee with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }} | ||
| working-directory: ${{ env.TEST_DIR }} | ||
| env: | ||
| IDF_TARGET: ${{ matrix.idf_target }} | ||
| shell: bash | ||
| run: | | ||
| . ${IDF_PATH}/export.sh | ||
| test -f sdkconfig.ci.target.plain_tcp && cat sdkconfig.ci.target.plain_tcp >> sdkconfig.defaults || echo "No sdkconfig.ci.plain_tcp" | ||
| idf.py set-target ${{ matrix.idf_target }} | ||
| idf.py build | ||
| - name: Merge binaries with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }} | ||
| working-directory: ${{ env.TEST_DIR }}/build | ||
| env: | ||
| IDF_TARGET: ${{ matrix.idf_target }} | ||
| shell: bash | ||
| run: | | ||
| . ${IDF_PATH}/export.sh | ||
| esptool.py --chip ${{ matrix.idf_target }} merge_bin --fill-flash-size 4MB -o flash_image.bin @flash_args | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: autobahn_testee_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }} | ||
| path: | | ||
| ${{ env.TEST_DIR }}/build/bootloader/bootloader.bin | ||
| ${{ env.TEST_DIR }}/build/partition_table/partition-table.bin | ||
| ${{ env.TEST_DIR }}/build/*.bin | ||
| ${{ env.TEST_DIR }}/build/*.elf | ||
| ${{ env.TEST_DIR }}/build/flasher_args.json | ||
| ${{ env.TEST_DIR }}/build/config/sdkconfig.h | ||
| ${{ env.TEST_DIR }}/build/config/sdkconfig.json | ||
| if-no-files-found: error | ||
|
|
||
| # run-target-autobahn: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please be sure that an issue was created to track(I think we already have one) |
||
| # # Skip running on forks since it won't have access to secrets | ||
| # if: | | ||
| # github.repository == 'espressif/esp-protocols' && | ||
| # ( contains(github.event.pull_request.labels.*.name, 'autobahn') || github.event_name == 'push' ) | ||
| # name: Target test | ||
| # needs: build_autobahn | ||
| # strategy: | ||
| # fail-fast: false | ||
| # matrix: | ||
| # idf_ver: ["latest"] | ||
| # idf_target: ["esp32"] | ||
| # runs-on: | ||
| # - self-hosted | ||
| # - ESP32-ETHERNET-KIT | ||
| # env: | ||
| # TEST_DIR: components/esp_websocket_client/examples/autobahn-testsuite | ||
| # TESTEE_DIR: components/esp_websocket_client/examples/autobahn-testsuite/testee | ||
| # steps: | ||
| # - uses: actions/checkout@v4 | ||
| # with: | ||
| # submodules: recursive | ||
| # - uses: actions/download-artifact@v4 | ||
| # with: | ||
| # name: autobahn_testee_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }} | ||
| # path: ${{ env.TESTEE_DIR }}/build | ||
| # - name: Install Docker Compose | ||
| # run: | | ||
| # sudo apt-get update | ||
| # sudo apt-get install -y docker-compose-plugin || sudo apt-get install -y docker-compose | ||
| # # Ensure user has permission to use Docker (if not already in docker group) | ||
| # sudo usermod -aG docker $USER || true | ||
| # # Start Docker service if not running | ||
| # sudo systemctl start docker || true | ||
| # - name: Start Autobahn Fuzzing Server | ||
| # working-directory: ${{ env.TEST_DIR }} | ||
| # run: | | ||
| # # Get host IP address for ESP32 to connect to | ||
| # HOST_IP=$(hostname -I | awk '{print $1}') | ||
| # echo "HOST_IP=$HOST_IP" >> $GITHUB_ENV | ||
| # echo "Autobahn server will be accessible at ws://$HOST_IP:9001" | ||
| # | ||
| # # Start the fuzzing server using pre-built image | ||
| # # For CI, we may need to specify platform if architecture differs | ||
| # echo "Starting Autobahn fuzzing server..." | ||
| # # Set platform for CI if needed (uncomment if you get exec format error) | ||
| # # export DOCKER_DEFAULT_PLATFORM=linux/amd64 | ||
| # docker compose up -d || docker-compose up -d | ||
| # | ||
| # # Wait for server to be ready | ||
| # echo "Waiting for fuzzing server to start..." | ||
| # sleep 10 | ||
| # | ||
| # # Check if container is running and healthy | ||
| # if ! docker ps | grep -q ws-fuzzing-server; then | ||
| # echo "Error: Fuzzing server failed to start" | ||
| # echo "Container logs:" | ||
| # docker compose logs || docker-compose logs | ||
| # echo "Checking available Python executables in container:" | ||
| # docker compose run --rm fuzzing-server which python python3 || true | ||
| # exit 1 | ||
| # fi | ||
| # | ||
| # # Verify the server is actually responding | ||
| # echo "Checking if server is responding..." | ||
| # sleep 5 | ||
| # if ! curl -s http://localhost:8080 > /dev/null 2>&1; then | ||
| # echo "Warning: Server may not be fully ready, but container is running" | ||
| # docker compose logs --tail=20 || docker-compose logs --tail=20 | ||
| # fi | ||
| # | ||
| # echo "✓ Fuzzing server started successfully" | ||
| # - name: Flash ESP32 Testee | ||
| # working-directory: ${{ env.TESTEE_DIR }}/build | ||
| # env: | ||
| # IDF_TARGET: ${{ matrix.idf_target }} | ||
| # run: | | ||
| # python -m esptool --chip ${{ matrix.idf_target }} write_flash 0x0 flash_image.bin | ||
| # - name: Run Autobahn Tests | ||
| # working-directory: ${{ env.TESTEE_DIR }} | ||
| # env: | ||
| # PIP_EXTRA_INDEX_URL: "https://www.piwheels.org/simple" | ||
| # run: | | ||
| # # Detect ESP32 port if not set in environment | ||
| # if [ -z "${ESP_PORT:-}" ]; then | ||
| # for port in /dev/ttyUSB* /dev/ttyACM*; do | ||
| # if [ -e "$port" ]; then | ||
| # export ESP_PORT="$port" | ||
| # echo "Detected ESP32 port: $ESP_PORT" | ||
| # break | ||
| # fi | ||
| # done | ||
| # fi | ||
| # | ||
| # # Default to /dev/ttyUSB0 if still not found | ||
| # export ESP_PORT="${ESP_PORT:-/dev/ttyUSB0}" | ||
| # | ||
| # if [ ! -e "$ESP_PORT" ]; then | ||
| # echo "Error: ESP32 port not found. Please set ESP_PORT environment variable." | ||
| # echo "Available ports:" | ||
| # ls -la /dev/tty* || true | ||
| # exit 1 | ||
| # fi | ||
| # | ||
| # echo "Using ESP32 port: $ESP_PORT" | ||
| # export PYENV_ROOT="$HOME/.pyenv" | ||
| # export PATH="$PYENV_ROOT/bin:$PATH" | ||
| # eval "$(pyenv init --path)" | ||
| # eval "$(pyenv init -)" | ||
| # if ! pyenv versions --bare | grep -q '^3\.12\.6$'; then | ||
| # echo "Installing Python 3.12.6..." | ||
| # pyenv install -s 3.12.6 | ||
| # fi | ||
| # if ! pyenv virtualenvs --bare | grep -q '^myenv$'; then | ||
| # echo "Creating pyenv virtualenv 'myenv'..." | ||
| # pyenv virtualenv 3.12.6 myenv | ||
| # fi | ||
| # pyenv activate myenv | ||
| # python --version | ||
| # pip install --prefer-binary pytest-embedded pytest-embedded-serial-esp pytest-embedded-idf pytest-custom_exit_code esptool pyserial | ||
| # pip install --extra-index-url https://dl.espressif.com/pypi/ -r $GITHUB_WORKSPACE/ci/requirements.txt | ||
| # | ||
| # echo "Starting Autobahn test suite on ESP32..." | ||
| # echo "Tests may take 15-30 minutes to complete..." | ||
| # | ||
| # # Send server URI via serial (stdin) and monitor for completion | ||
| # # Script is in the parent directory (TEST_DIR) from TESTEE_DIR | ||
| # SERVER_URI="ws://$HOST_IP:9001" | ||
| # echo "Sending server URI to ESP32: $SERVER_URI" | ||
| # python3 ../scripts/monitor_serial.py --port "$ESP_PORT" --uri "$SERVER_URI" --timeout 2400 | ||
| # - name: Collect Test Reports | ||
| # working-directory: ${{ env.TEST_DIR }} | ||
| # if: always() | ||
| # run: | | ||
| # # Stop the fuzzing server | ||
| # docker compose down || docker-compose down | ||
| # | ||
| # # Check if reports were generated | ||
| # if [ -d "reports/clients" ]; then | ||
| # echo "✓ Test reports found" | ||
| # ls -la reports/clients/ | ||
| # else | ||
| # echo "⚠ No test reports found in reports/clients/" | ||
| # fi | ||
| # - name: Generate Test Summary | ||
| # working-directory: ${{ env.TEST_DIR }} | ||
| # if: always() | ||
| # run: | | ||
| # # Generate summary from test results | ||
| # # Check for JSON files in both reports/ and reports/clients/ | ||
| # if [ -d "reports" ] && ( [ -n "$(ls -A reports/*.json 2>/dev/null)" ] || [ -n "$(ls -A reports/clients/*.json 2>/dev/null)" ] ); then | ||
| # echo "Generating test summary..." | ||
| # python3 scripts/generate_summary.py | ||
| # echo "" | ||
| # echo "Summary generated successfully!" | ||
| # if [ -f "reports/summary.html" ]; then | ||
| # echo "HTML summary available at: reports/summary.html" | ||
| # fi | ||
| # else | ||
| # echo "⚠ No JSON test results found, skipping summary generation" | ||
| # fi | ||
| # - uses: actions/upload-artifact@v4 | ||
| # if: always() | ||
| # with: | ||
| # name: autobahn_reports_${{ matrix.idf_target }}_${{ matrix.idf_ver }} | ||
| # path: | | ||
| # ${{ env.TEST_DIR }}/reports/** | ||
| # if-no-files-found: warn | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| idf_component_register(SRCS esp_timer_linux.c timer_task.cpp | ||
| INCLUDE_DIRS include) | ||
| INCLUDE_DIRS include | ||
| REQUIRES esp_common) | ||
|
|
||
| set_target_properties(${COMPONENT_LIB} PROPERTIES | ||
| CXX_STANDARD 17 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can remove this. |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.