Skip to content

Commit 576905d

Browse files
committed
Add loadtest-controller part of emulated browsers feature
1 parent 022ccf8 commit 576905d

15 files changed

Lines changed: 556 additions & 328 deletions

File tree

.github/workflows/openvidu-loadtest-e2e-dockerized-test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828
exit 1
2929
fi
3030
31-
echo "ovurl=https://$LAN_PRIVATE_IP.openvidu-local.dev:7443" >> "$GITHUB_OUTPUT"
31+
LAN_PRIVATE_IP_DASHED="${LAN_PRIVATE_IP//./-}"
32+
echo "ovurl=https://$LAN_PRIVATE_IP_DASHED.openvidu-local.dev:7443" >> "$GITHUB_OUTPUT"
3233
3334
- name: Run Browser Emulator E2E Tests in Docker
3435
env:
@@ -37,10 +38,10 @@ jobs:
3738
cd browser-emulator
3839
docker compose -f docker-compose.test.yml up --build --abort-on-container-exit --exit-code-from browser-emulator-tests
3940
40-
- name: Run OpenVidu LoadTest E2E Tests
41+
- name: Run All OpenVidu LoadTest E2E Tests
4142
run: |
4243
cd e2e-tests/scripts
43-
./run-smoke-test.sh ${{ steps.openvidu_env.outputs.ovurl }}
44+
./run-all-e2e-tests.sh ${{ steps.openvidu_env.outputs.ovurl }} devkey secret
4445
4546
- name: Clean up
4647
if: always()

AGENTS.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,20 @@ mvn spring-boot:run # Start the controller
9494
```bash
9595
cd e2e-tests
9696

97-
# Run smoke test (requires OpenVidu instance)
98-
./scripts/run-smoke-test.sh <PLATFORM_URL> [APIKEY] [APISECRET]
97+
# Run all e2e tests (requires OpenVidu instance)
98+
./scripts/run-all-e2e-tests.sh <PLATFORM_URL> [APIKEY] [APISECRET]
99+
100+
# Run central test runner with custom config
101+
./scripts/run-e2e-test.sh <CONFIG_FILE> <VALIDATION_SCRIPT> <PLATFORM_URL> [APIKEY] [APISECRET]
99102

100103
# Direct Docker Compose
101-
docker-compose up --build
104+
docker compose up --build
102105
```
103106

107+
**Default credentials**: API key defaults to `devkey`, API secret defaults to `secret` if not provided.
108+
109+
**Test discovery**: The unified runner (`run-all-e2e-tests.sh`) automatically discovers all `*-config.yaml` files in `config/` and maps them to validation scripts using convention: `foo-config.yaml``validate-foo.sh` (fallback: `validate-default.sh`).
110+
104111
## Code Style Guidelines
105112

106113
### TypeScript/JavaScript (Browser Emulator)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Define multiple test scenarios that run sequentially. Each test case can have th
160160
| `topology` | **Yes** | - | `N:N`, `N:M`, `TEACHING`, or `ONE_SESSION` |
161161
| `participants` | **Yes** | - | List of participant counts (e.g., `["2", "10"]`). Each element of the list will create a new test scenario |
162162
| `sessions` | **Yes** | - | Number of sessions or `infinite` |
163-
| `browser` | No | `chrome` | Browser to use: `chrome` or `firefox` |
163+
| `browser` | No | `chrome` | Browser to use: `chrome`, `firefox`, or `emulated` |
164164
| `resolution` | No | `640x480` | Try to force video to resolution: `640x480`, `1280x720`, `1920x1080` |
165165
| `frameRate` | No | `30` | Try to force video frame rate |
166166
| `startingParticipants` | No | `0` | Adds a configurable initial batch of participants |

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ services:
3333
MEDIAFILES_HOST_DIR: ${MEDIAFILES_HOST_DIR:-${PWD}/browser-emulator/mediafiles}
3434
SCRIPTS_LOGS_HOST_DIR: ${SCRIPTS_LOGS_HOST_DIR:-${PWD}/browser-emulator/logs}
3535
METRICBEAT_CONFIG: ${METRICBEAT_CONFIG:-${PWD}/browser-emulator/src/assets/metricbeat-config/metricbeat.yml}
36-
ports:
37-
- '5000:5000'
36+
stop_grace_period: 60s
3837
networks:
3938
- browseremulator
4039
volumes:

e2e-tests/README.md

Lines changed: 63 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,93 @@ This directory contains end-to-end tests that validate the complete OpenVidu Loa
1414
2. An OpenVidu instance available for testing (you can use a local development installation)
1515
3. The OpenVidu instance URL, API key, and API secret
1616

17-
## Smoke Test
17+
## Script Architecture
1818

19-
The smoke test performs a basic end-to-end test with 2 participants in a single session using the N:N topology.
19+
The e2e test scripts follow a modular architecture:
2020

21-
### Configuration
21+
- **`run-all-e2e-tests.sh`** - Unified test runner that discovers and runs all tests sequentially
22+
- **`run-e2e-test.sh`** - Central test runner for a single test (called by unified runner)
23+
- **`validate-default.sh`** - Default validation script for smoke test expectations
2224

23-
The smoke test script accepts command-line arguments for OpenVidu connection details:
25+
## Running All Tests
26+
27+
To run all e2e tests in one command:
2428

2529
```bash
2630
cd e2e-tests/scripts
27-
./run-smoke-test.sh <PLATFORM_URL> [PLATFORM_APIKEY] [PLATFORM_APISECRET]
28-
```
31+
./run-all-e2e-tests.sh <PLATFORM_URL> [API_KEY] [API_SECRET]
2932

30-
Where:
33+
# Example
34+
./run-all-e2e-tests.sh https://172-31-224-178.openvidu-local.dev:7443 devkey secret
35+
```
3136

32-
- `PLATFORM_URL`: Required. The URL of your OpenVidu deployment (e.g., https://your-openvidu-url.io:7443)
33-
- `PLATFORM_APIKEY`: Optional. API key for authentication (defaults to "devkey")
34-
- `PLATFORM_APISECRET`: Optional. API secret for authentication (defaults to "secret")
37+
The unified runner will:
3538

36-
### Configuration File
39+
1. Discover all `*-config.yaml` files in the `config/` directory
40+
2. Map each config to its validation script using convention (see below)
41+
3. Run each test sequentially
42+
4. Print a summary of all test results
3743

38-
The smoke test uses the configuration file `config/smoke-test-config.yaml` which specifies `advanced.reportOutput: html,txt` to generate both text and HTML reports.
44+
## Running Individual Tests
3945

40-
### Running the Smoke Test
46+
### Smoke Test (Chrome)
4147

4248
```bash
43-
# Example with all parameters
4449
cd e2e-tests/scripts
45-
./run-smoke-test.sh https://your-openvidu-url.io:7443 myapikey myapisecret
50+
./run-e2e-test.sh emulated-smoke-test-config.yaml validate-default.sh <PLATFORM_URL> [API_KEY] [API_SECRET]
51+
```
52+
53+
### Emulated Browser Test
4654

47-
# Example with defaults for API key and secret
55+
```bash
4856
cd e2e-tests/scripts
49-
./run-smoke-test.sh https://your-openvidu-url.io:7443
57+
./run-e2e-test.sh smoke-test-config.yaml validate-default.sh <PLATFORM_URL> [API_KEY] [API_SECRET]
5058
```
5159

52-
This script will:
60+
## Test Discovery and Validation Mapping
61+
62+
The unified runner uses convention-based mapping to determine which validation script to use for each config file:
63+
64+
1. For a config file named `foo-config.yaml`, the runner looks for `validate-foo.sh`
65+
2. If a specific validation script is not found, it falls back to `validate-default.sh`
66+
67+
**Example:**
68+
69+
- `smoke-test-config.yaml` → looks for `validate-smoke-test.sh` → falls back to `validate-default.sh`
70+
- `emulated-smoke-test-config.yaml` → looks for `validate-emulated-smoke-test.sh` → falls back to `validate-default.sh`
71+
72+
## Adding New Test Types
5373

54-
1. Start both services using Docker Compose
55-
2. Wait for the test to complete
56-
3. Stop the services
57-
4. Display and validate the test results
74+
To add a new test type:
5875

59-
### Expected Results
76+
1. **Create a configuration file** in `config/` (e.g., `my-test-config.yaml`)
6077

61-
The test should:
78+
2. **Optionally create a validation script** in `scripts/` if the expected results differ from the default:
79+
- Name it `validate-my-test.sh` (matching the config name without `-config.yaml`)
80+
- If not created, `validate-default.sh` will be used automatically
81+
82+
3. **No workflow changes needed** - the unified runner automatically discovers and runs all config files
83+
84+
## Configuration-Validation Mapping Examples
85+
86+
| Config file | Validation script (if exists) | Fallback |
87+
| --------------------------------- | --------------------------------- | --------------------- |
88+
| `smoke-test-config.yaml` | `validate-smoke-test.sh` | `validate-default.sh` |
89+
| `emulated-smoke-test-config.yaml` | `validate-emulated-smoke-test.sh` | `validate-default.sh` |
90+
| `load-test-config.yaml` | `validate-load-test.sh` | `validate-default.sh` |
91+
92+
## Expected Results
93+
94+
All smoke tests should:
6295

6396
- Start both loadtest-controller and browser-emulator services
64-
- Launch 2 Chrome browsers that connect to the OpenVidu instance
6597
- Create a single session with 2 participants in N:N topology
6698
- Generate results in the `results/` directory:
6799
- `results.txt` (text summary)
68-
- `report.html` (HTML report, with user retry details if retries occurred)
100+
- `report.html` (HTML report)
69101
- Complete successfully and shut down cleanly
70102

71-
### Validation Checks
72-
73-
The smoke test validates that both `results.txt` and `report.html` files are generated and contain expected content.
103+
### Validation Checks (Default)
74104

75105
**results.txt validation:**
76106

@@ -87,26 +117,13 @@ The smoke test validates that both `results.txt` and `report.html` files are gen
87117
- "Sessions Created"
88118
- "Total Participants"
89119
- "User Connections" (mandatory)
90-
- Table columns: User, Session, Join date (from successful connection), Disconnect Date (captured from ParticipantDisconnected websocket event), Retry Number (count of retries per user)
120+
- Table columns: User, Session, Join date, Disconnect Date, Retry Number
91121
- Two user rows (User1 and User2) present
92122

93-
The smoke test configuration uses `advanced.reportOutput: html,txt` to generate both output formats. If validation fails, the result files are kept in the `results/` directory for debugging.
94-
95-
## Extending the Test Suite
96-
97-
Additional test scenarios can be added by:
98-
99-
1. Creating new configuration files in `configs/` directory
100-
2. Adding new scripts in `scripts/` directory or modifying the existing one
101-
3. Following the same pattern as the smoke test
102-
103-
Examples of additional test scenarios:
104-
105-
- Scaling tests with different participant counts
106-
- Different topologies (N:M, TEACHING, etc.)
107-
- Different browsers (Chrome vs Firefox)
123+
If validation fails, the result files are kept in the `results/` directory for debugging.
108124

109125
## Notes
110126

111127
- Make sure your OpenVidu instance is accessible from the Docker containers
112-
- For troubleshooting, check the Docker Compose logs with `docker-compose logs`
128+
- For troubleshooting, check the Docker Compose logs with `docker compose logs`
129+
- Tests run sequentially to avoid resource conflicts
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# yaml-language-server: $schema=../../schema/openvidu-loadtest-schema.json
2+
platform:
3+
url: https://to-be-replaced:7443
4+
apiKey: devkey
5+
apiSecret: secret
6+
7+
testcases:
8+
- topology: N:N
9+
participants:
10+
- "2"
11+
sessions: 1
12+
browser: emulated
13+
description: "Basic N:N topology test with emulated browsers"
14+
15+
workers:
16+
urls:
17+
- browser-emulator
18+
19+
distribution:
20+
usersPerWorker: 2
21+
22+
advanced:
23+
reportOutput:
24+
- html
25+
- txt

e2e-tests/docker-compose.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ services:
3030
container_name: browser-emulator-e2e
3131
restart: no
3232
environment:
33-
RUNNING_IN_DOCKER: true
34-
DOCKER_NETWORK_NAME: browseremulator-e2e
35-
DOCKER_BROWSER_EMULATOR_HOST: browser-emulator
36-
MEDIAFILES_HOST_DIR: ${MEDIAFILES_HOST_DIR:-${PWD}/../../browser-emulator/mediafiles}
37-
SCRIPTS_LOGS_HOST_DIR: ${SCRIPTS_LOGS_HOST_DIR:-${PWD}/../../browser-emulator/logs}
33+
SERVER_PORT: ${SERVER_PORT:-5000}
34+
WEBSOCKET_PORT: ${WEBSOCKET_PORT:-5001}
35+
RUNNING_IN_DOCKER: true
36+
DOCKER_NETWORK_NAME: browseremulator-e2e
37+
DOCKER_BROWSER_EMULATOR_HOST: browser-emulator
38+
MEDIAFILES_HOST_DIR: ${MEDIAFILES_HOST_DIR}
39+
SCRIPTS_LOGS_HOST_DIR: ${SCRIPTS_LOGS_HOST_DIR}
40+
METRICBEAT_CONFIG: ${METRICBEAT_CONFIG}
41+
stop_grace_period: 60s
3842
networks:
3943
- browseremulator
4044
volumes:
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/bin/bash
2+
3+
# Unified e2e test runner for OpenVidu Load Test
4+
# This script discovers and runs all e2e tests sequentially
5+
# Usage: ./run-all-e2e-tests.sh <PLATFORM_URL> [API_KEY] [API_SECRET]
6+
# Example: ./run-all-e2e-tests.sh https://172-31-224-178.openvidu-local.dev:7443 devkey secret
7+
8+
set -e
9+
10+
echo "Starting OpenVidu Load Test E2E Test Suite..."
11+
12+
# Check if docker compose is available
13+
if ! command -v docker compose &> /dev/null; then
14+
echo "docker compose not found. Please install docker compose."
15+
exit 1
16+
fi
17+
18+
# Check arguments
19+
if [ $# -lt 1 ]; then
20+
echo "Usage: $0 <PLATFORM_URL> [API_KEY] [API_SECRET]"
21+
echo "Example: $0 https://openvidu.example.com:7443 devkey secret"
22+
exit 1
23+
fi
24+
25+
PLATFORM_URL="$1"
26+
PLATFORM_APIKEY="${2:-devkey}"
27+
PLATFORM_APISECRET="${3:-secret}"
28+
29+
# Configuration
30+
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
31+
E2E_TEST_DIR="$(realpath "$SCRIPT_DIR/..")"
32+
CONFIG_DIR="$E2E_TEST_DIR/config"
33+
DEFAULT_VALIDATION="validate-default.sh"
34+
35+
# Discover all config files
36+
CONFIG_FILES=()
37+
for config in "$CONFIG_DIR"/*.yaml; do
38+
if [ -f "$config" ]; then
39+
CONFIG_FILES+=("$config")
40+
fi
41+
done
42+
43+
if [ ${#CONFIG_FILES[@]} -eq 0 ]; then
44+
echo "ERROR: No configuration files found in $CONFIG_DIR"
45+
exit 1
46+
fi
47+
48+
echo "Found ${#CONFIG_FILES[@]} test configuration(s)"
49+
50+
# Track test results
51+
TOTAL_TESTS=0
52+
PASSED_TESTS=0
53+
FAILED_TESTS=0
54+
FAILED_TEST_NAMES=()
55+
56+
# Run each test
57+
for config_path in "${CONFIG_FILES[@]}"; do
58+
config_file="$(basename "$config_path")"
59+
60+
# Extract test name: e.g., "smoke-test" from "smoke-test-config.yaml"
61+
test_name="$(echo "$config_file" | sed 's/-config\.yaml$//')"
62+
63+
# Determine validation script using convention:
64+
# Look for validate-<test-name>.sh, fallback to validate-default.sh
65+
specific_validation="validate-${test_name}.sh"
66+
if [ -f "$SCRIPT_DIR/$specific_validation" ]; then
67+
validation_script="$specific_validation"
68+
else
69+
validation_script="$DEFAULT_VALIDATION"
70+
fi
71+
72+
if [ ! -f "$SCRIPT_DIR/$validation_script" ]; then
73+
echo "ERROR: Validation script not found: $validation_script"
74+
exit 1
75+
fi
76+
77+
TOTAL_TESTS=$((TOTAL_TESTS + 1))
78+
79+
echo ""
80+
echo "========================================"
81+
echo "Running test $TOTAL_TESTS: $test_name"
82+
echo " Config: $config_file"
83+
echo " Validation: $validation_script"
84+
echo "========================================"
85+
echo ""
86+
87+
# Run the test
88+
if bash "$SCRIPT_DIR/run-e2e-test.sh" "$config_file" "$validation_script" "$PLATFORM_URL" "$PLATFORM_APIKEY" "$PLATFORM_APISECRET"; then
89+
echo "✓ Test '$test_name' PASSED"
90+
PASSED_TESTS=$((PASSED_TESTS + 1))
91+
else
92+
echo "✗ Test '$test_name' FAILED"
93+
FAILED_TESTS=$((FAILED_TESTS + 1))
94+
FAILED_TEST_NAMES+=("$test_name")
95+
fi
96+
done
97+
98+
# Print summary
99+
echo ""
100+
echo "========================================"
101+
echo "E2E Test Suite Summary"
102+
echo "========================================"
103+
echo "Total tests: $TOTAL_TESTS"
104+
echo "Passed: $PASSED_TESTS"
105+
echo "Failed: $FAILED_TESTS"
106+
107+
if [ $FAILED_TESTS -gt 0 ]; then
108+
echo ""
109+
echo "Failed tests:"
110+
for name in "${FAILED_TEST_NAMES[@]}"; do
111+
echo " - $name"
112+
done
113+
echo ""
114+
echo "E2E Test Suite FAILED"
115+
exit 1
116+
fi
117+
118+
echo ""
119+
echo "E2E Test Suite PASSED"
120+
exit 0

0 commit comments

Comments
 (0)