mirror of
https://github.com/librespeed/speedtest.git
synced 2026-08-04 14:48:38 +00:00
Merge pull request #779 from librespeed/chore/playwright-mode-test-plan
Chore/playwright mode test plan
This commit is contained in:
commit
f4acb0d82d
7 changed files with 1369 additions and 8 deletions
4
.github/workflows/docker-publish.yml
vendored
4
.github/workflows/docker-publish.yml
vendored
|
|
@ -13,7 +13,7 @@ on:
|
|||
# Publish semver tags as releases.
|
||||
tags: ["v*.*.*"]
|
||||
pull_request:
|
||||
branches: ["{{is_default_branch}}"]
|
||||
branches: [master]
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ jobs:
|
|||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Install Playwright Chromium
|
||||
run: npx playwright install --with-deps chromium
|
||||
|
|
|
|||
2
.github/workflows/playwright.yml
vendored
2
.github/workflows/playwright.yml
vendored
|
|
@ -21,7 +21,7 @@ jobs:
|
|||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
|
||||
- name: Install Playwright Chromium
|
||||
run: npx playwright install --with-deps chromium
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,7 +3,6 @@ backend/getIP_serverLocation.php
|
|||
db-dir/
|
||||
.vscode/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
playwright-report/
|
||||
test-results/
|
||||
results/speedtest_telemetry.db
|
||||
|
|
|
|||
1327
package-lock.json
generated
Normal file
1327
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
{
|
||||
"name": "External backend testpoint",
|
||||
"server": "http://backend-testpoint/",
|
||||
"server": "http://backend-testpoint:8080/",
|
||||
"dlURL": "garbage.php",
|
||||
"ulURL": "empty.php",
|
||||
"pingURL": "empty.php",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[
|
||||
{
|
||||
"name": "Backend testpoint",
|
||||
"server": "http://backend-testpoint/",
|
||||
"server": "http://backend-testpoint:8080/",
|
||||
"dlURL": "garbage.php",
|
||||
"ulURL": "empty.php",
|
||||
"pingURL": "empty.php",
|
||||
|
|
|
|||
|
|
@ -1,13 +1,48 @@
|
|||
const { execSync } = require('node:child_process');
|
||||
const http = require('node:http');
|
||||
const https = require('node:https');
|
||||
|
||||
const COMPOSE_FILE = 'tests/docker-compose-playwright.yml';
|
||||
|
||||
function isHttpOk(url, requestTimeoutMs = 10_000) {
|
||||
return new Promise((resolve) => {
|
||||
const client = url.startsWith('https://') ? https : http;
|
||||
let settled = false;
|
||||
const settle = (value) => {
|
||||
if (settled) {
|
||||
return;
|
||||
}
|
||||
settled = true;
|
||||
resolve(value);
|
||||
};
|
||||
|
||||
const req = client.get(url, (res) => {
|
||||
const status = res.statusCode || 0;
|
||||
// Drain body so sockets can be reused/closed cleanly.
|
||||
res.resume();
|
||||
settle(status >= 200 && status < 300);
|
||||
});
|
||||
|
||||
req.setTimeout(requestTimeoutMs, () => {
|
||||
req.destroy(new Error(`Request timed out after ${requestTimeoutMs}ms`));
|
||||
});
|
||||
|
||||
req.on('timeout', () => {
|
||||
req.destroy(new Error(`Request timed out after ${requestTimeoutMs}ms`));
|
||||
});
|
||||
|
||||
req.on('error', () => {
|
||||
// Connection issues/timeouts are expected while services are starting.
|
||||
settle(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function waitForReady(name, url, timeoutMs) {
|
||||
const start = Date.now();
|
||||
while (Date.now() - start < timeoutMs) {
|
||||
try {
|
||||
const response = await fetch(url, { redirect: 'manual' });
|
||||
if (response.ok) {
|
||||
if (await isHttpOk(url)) {
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue