Set TESTS_MQTT_BROKER_HOST globally for all jobs with mosquitto services (#989)
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:
6
.github/workflows/docker-browser.yml
vendored
6
.github/workflows/docker-browser.yml
vendored
@@ -30,6 +30,10 @@ jobs:
|
|||||||
packages: write
|
packages: write
|
||||||
id-token: write
|
id-token: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
TESTS_MQTT_BROKER_HOST: localhost
|
||||||
|
TESTS_MQTT_BROKER_PORT: 1883
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# MQTT broker for testing
|
# MQTT broker for testing
|
||||||
mosquitto:
|
mosquitto:
|
||||||
@@ -191,8 +195,6 @@ jobs:
|
|||||||
MQTT_EXPLORER_USERNAME: test
|
MQTT_EXPLORER_USERNAME: test
|
||||||
MQTT_EXPLORER_PASSWORD: test123
|
MQTT_EXPLORER_PASSWORD: test123
|
||||||
BROWSER_MODE_URL: http://localhost:3000
|
BROWSER_MODE_URL: http://localhost:3000
|
||||||
MQTT_BROKER_HOST: localhost
|
|
||||||
MQTT_BROKER_PORT: 1883
|
|
||||||
|
|
||||||
- name: Clean up browser test container
|
- name: Clean up browser test container
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
9
.github/workflows/tests.yml
vendored
9
.github/workflows/tests.yml
vendored
@@ -28,6 +28,9 @@ jobs:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./:/app
|
- ./:/app
|
||||||
options: --user root
|
options: --user root
|
||||||
|
env:
|
||||||
|
TESTS_MQTT_BROKER_HOST: mosquitto
|
||||||
|
TESTS_MQTT_BROKER_PORT: 1883
|
||||||
services:
|
services:
|
||||||
mosquitto:
|
mosquitto:
|
||||||
image: eclipse-mosquitto:2
|
image: eclipse-mosquitto:2
|
||||||
@@ -49,9 +52,6 @@ jobs:
|
|||||||
- name: Run Browser UI Tests
|
- name: Run Browser UI Tests
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
run: ./scripts/runBrowserTests.sh
|
run: ./scripts/runBrowserTests.sh
|
||||||
env:
|
|
||||||
MQTT_BROKER_HOST: mosquitto
|
|
||||||
MQTT_BROKER_PORT: 1883
|
|
||||||
- name: Upload Test Screenshots
|
- name: Upload Test Screenshots
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@@ -141,6 +141,9 @@ jobs:
|
|||||||
|
|
||||||
test-browser:
|
test-browser:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
TESTS_MQTT_BROKER_HOST: localhost
|
||||||
|
TESTS_MQTT_BROKER_PORT: 1883
|
||||||
services:
|
services:
|
||||||
mosquitto:
|
mosquitto:
|
||||||
image: eclipse-mosquitto:2
|
image: eclipse-mosquitto:2
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
# MQTT_EXPLORER_PASSWORD - Password for browser authentication (default: test123)
|
# MQTT_EXPLORER_PASSWORD - Password for browser authentication (default: test123)
|
||||||
# PORT - Server port (default: 3000)
|
# PORT - Server port (default: 3000)
|
||||||
# BROWSER_MODE_URL - URL for browser tests (set automatically)
|
# BROWSER_MODE_URL - URL for browser tests (set automatically)
|
||||||
# MQTT_BROKER_HOST - MQTT broker host for tests (required, default: 127.0.0.1)
|
# TESTS_MQTT_BROKER_HOST - MQTT broker host for tests (required, default: 127.0.0.1)
|
||||||
# MQTT_BROKER_PORT - MQTT broker port for tests (default: 1883)
|
# TESTS_MQTT_BROKER_PORT - MQTT broker port for tests (default: 1883)
|
||||||
#
|
#
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -52,10 +52,10 @@ done
|
|||||||
|
|
||||||
# Run browser tests
|
# Run browser tests
|
||||||
export BROWSER_MODE_URL="http://localhost:${PORT}"
|
export BROWSER_MODE_URL="http://localhost:${PORT}"
|
||||||
export MQTT_BROKER_HOST="${MQTT_BROKER_HOST:-127.0.0.1}"
|
export TESTS_MQTT_BROKER_HOST="${TESTS_MQTT_BROKER_HOST:-127.0.0.1}"
|
||||||
export MQTT_BROKER_PORT="${MQTT_BROKER_PORT:-1883}"
|
export TESTS_MQTT_BROKER_PORT="${TESTS_MQTT_BROKER_PORT:-1883}"
|
||||||
|
|
||||||
echo "Using MQTT broker at $MQTT_BROKER_HOST:$MQTT_BROKER_PORT"
|
echo "Using MQTT broker at $TESTS_MQTT_BROKER_HOST:$TESTS_MQTT_BROKER_PORT"
|
||||||
|
|
||||||
yarn test:browser
|
yarn test:browser
|
||||||
TEST_EXIT_CODE=$?
|
TEST_EXIT_CODE=$?
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ export async function createTestMock(): Promise<mqtt.MqttClient> {
|
|||||||
return mqttClient
|
return mqttClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use MQTT_BROKER_HOST from environment, default to localhost
|
// Use TESTS_MQTT_BROKER_HOST from environment, default to localhost
|
||||||
const brokerHost = process.env.MQTT_BROKER_HOST || '127.0.0.1'
|
const brokerHost = process.env.TESTS_MQTT_BROKER_HOST || '127.0.0.1'
|
||||||
const brokerPort = process.env.MQTT_BROKER_PORT || '1883'
|
const brokerPort = process.env.TESTS_MQTT_BROKER_PORT || '1883'
|
||||||
const brokerUrl = `mqtt://${brokerHost}:${brokerPort}`
|
const brokerUrl = `mqtt://${brokerHost}:${brokerPort}`
|
||||||
|
|
||||||
console.log(`Connecting to MQTT broker at ${brokerUrl}`)
|
console.log(`Connecting to MQTT broker at ${brokerUrl}`)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import type { MqttClient } from 'mqtt'
|
|||||||
* - Handle MQTT asynchronous operations properly
|
* - Handle MQTT asynchronous operations properly
|
||||||
*
|
*
|
||||||
* Prerequisites:
|
* Prerequisites:
|
||||||
* - MQTT broker running (default: localhost:1883, configurable via MQTT_BROKER_HOST and MQTT_BROKER_PORT)
|
* - MQTT broker running (default: localhost:1883, configurable via TESTS_MQTT_BROKER_HOST and TESTS_MQTT_BROKER_PORT)
|
||||||
* - Application built with `yarn build`
|
* - Application built with `yarn build`
|
||||||
*/
|
*/
|
||||||
// tslint:disable:only-arrow-functions ter-prefer-arrow-callback no-unused-expression
|
// tslint:disable:only-arrow-functions ter-prefer-arrow-callback no-unused-expression
|
||||||
@@ -125,8 +125,8 @@ describe('MQTT Explorer Comprehensive UI Tests', function () {
|
|||||||
page = await electronApp.firstWindow({ timeout: 30000 })
|
page = await electronApp.firstWindow({ timeout: 30000 })
|
||||||
await page.locator('//label[contains(text(), "Host")]/..//input').waitFor({ timeout: 10000 })
|
await page.locator('//label[contains(text(), "Host")]/..//input').waitFor({ timeout: 10000 })
|
||||||
|
|
||||||
// Use MQTT_BROKER_HOST from environment, default to localhost
|
// Use TESTS_MQTT_BROKER_HOST from environment, default to localhost
|
||||||
const brokerHost = process.env.MQTT_BROKER_HOST || '127.0.0.1'
|
const brokerHost = process.env.TESTS_MQTT_BROKER_HOST || '127.0.0.1'
|
||||||
console.log(`Connecting to MQTT broker at ${brokerHost}...`)
|
console.log(`Connecting to MQTT broker at ${brokerHost}...`)
|
||||||
await connectTo(brokerHost, page)
|
await connectTo(brokerHost, page)
|
||||||
await sleep(3000) // Give time for all topics to load
|
await sleep(3000) // Give time for all topics to load
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ describe('MQTT Explorer UI Tests', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('Connecting to MQTT broker...')
|
console.log('Connecting to MQTT broker...')
|
||||||
const brokerHost = process.env.MQTT_BROKER_HOST || '127.0.0.1'
|
const brokerHost = process.env.TESTS_MQTT_BROKER_HOST || '127.0.0.1'
|
||||||
await connectTo(brokerHost, page)
|
await connectTo(brokerHost, page)
|
||||||
await sleep(3000) // Give time for topics to load
|
await sleep(3000) // Give time for topics to load
|
||||||
console.log('Setup complete')
|
console.log('Setup complete')
|
||||||
|
|||||||
Reference in New Issue
Block a user