Consolidate mosquitto startup into test scripts (#1003)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
This commit is contained in:
41
.github/workflows/tests.yml
vendored
41
.github/workflows/tests.yml
vendored
@@ -31,8 +31,6 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
- name: Start mosquitto
|
|
||||||
run: mosquitto -c /etc/mosquitto/conf.d/default.conf -d
|
|
||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
run: yarn install --frozen-lockfile
|
run: yarn install --frozen-lockfile
|
||||||
- name: Build Browser Mode
|
- name: Build Browser Mode
|
||||||
@@ -59,8 +57,6 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
- name: Start mosquitto
|
|
||||||
run: mosquitto -c /etc/mosquitto/conf.d/default.conf -d
|
|
||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
run: yarn install --frozen-lockfile
|
run: yarn install --frozen-lockfile
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -170,20 +166,10 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
- name: Install and Start Mosquitto
|
- name: Install System Dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y mosquitto mosquitto-clients
|
sudo apt-get install -y mosquitto mosquitto-clients
|
||||||
|
|
||||||
# Create a minimal configuration file for testing
|
|
||||||
sudo tee /etc/mosquitto/conf.d/test.conf > /dev/null <<EOF
|
|
||||||
listener 1883
|
|
||||||
allow_anonymous true
|
|
||||||
persistence false
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Start mosquitto in detached mode
|
|
||||||
sudo mosquitto -c /etc/mosquitto/mosquitto.conf -d
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
@@ -198,26 +184,5 @@ jobs:
|
|||||||
run: yarn test:app
|
run: yarn test:app
|
||||||
- name: Test Backend
|
- name: Test Backend
|
||||||
run: yarn test:backend
|
run: yarn test:backend
|
||||||
- name: Start Server in Background
|
- name: Run Browser UI Tests
|
||||||
run: |
|
run: ./scripts/runBrowserTests.sh
|
||||||
yarn start:server &
|
|
||||||
echo $! > server.pid
|
|
||||||
env:
|
|
||||||
MQTT_EXPLORER_USERNAME: test
|
|
||||||
MQTT_EXPLORER_PASSWORD: test123
|
|
||||||
PORT: 3000
|
|
||||||
- name: Wait for Server
|
|
||||||
run: |
|
|
||||||
timeout 30 bash -c 'until curl -f http://localhost:3000; do sleep 1; done'
|
|
||||||
- name: Browser Smoke Test
|
|
||||||
run: |
|
|
||||||
# Test server is running
|
|
||||||
curl -f http://localhost:3000 || exit 1
|
|
||||||
echo "Browser mode server is running successfully"
|
|
||||||
- name: Stop Server
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
if [ -f server.pid ]; then
|
|
||||||
kill $(cat server.pid) || true
|
|
||||||
rm server.pid
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Browser Mode Test Runner
|
# Browser Mode Test Runner
|
||||||
#
|
#
|
||||||
# This script runs UI tests against the browser mode server (instead of Electron).
|
# This script runs UI tests against the browser mode server (instead of Electron).
|
||||||
# It expects a mosquitto MQTT broker to be running (via service or manually started).
|
# It starts a mosquitto MQTT broker automatically and cleans it up on exit.
|
||||||
# The broker address is configured via environment variables.
|
# The broker address is configured via environment variables.
|
||||||
#
|
#
|
||||||
# Environment Variables:
|
# Environment Variables:
|
||||||
@@ -23,10 +23,20 @@ function finish {
|
|||||||
echo "Stopping server ($PID_SERVER).."
|
echo "Stopping server ($PID_SERVER).."
|
||||||
kill "$PID_SERVER" || echo "Already stopped"
|
kill "$PID_SERVER" || echo "Already stopped"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ! -z "$PID_MOSQUITTO" ]]; then
|
||||||
|
echo "Stopping mosquitto ($PID_MOSQUITTO).."
|
||||||
|
kill "$PID_MOSQUITTO" || echo "Already stopped"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
trap finish EXIT
|
trap finish EXIT
|
||||||
|
|
||||||
|
# Start mqtt broker
|
||||||
|
mosquitto &
|
||||||
|
export PID_MOSQUITTO=$!
|
||||||
|
sleep 1
|
||||||
|
|
||||||
# Set credentials for browser authentication (tests will use these to login)
|
# Set credentials for browser authentication (tests will use these to login)
|
||||||
export MQTT_EXPLORER_USERNAME=${MQTT_EXPLORER_USERNAME:-test}
|
export MQTT_EXPLORER_USERNAME=${MQTT_EXPLORER_USERNAME:-test}
|
||||||
export MQTT_EXPLORER_PASSWORD=${MQTT_EXPLORER_PASSWORD:-test123}
|
export MQTT_EXPLORER_PASSWORD=${MQTT_EXPLORER_PASSWORD:-test123}
|
||||||
|
|||||||
Reference in New Issue
Block a user