Skip to content
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

TINY-11177: Vastly improve remote testing #145

Merged
merged 64 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
f9e89be
TINY-11177: Add an empty favicon to prevent the browser requesting `f…
TheSpyder Aug 16, 2024
b73ba9a
TINY-11177: Add keep-alive header to stop weird 502 bad gateway errors
TheSpyder Aug 16, 2024
0621111
TINY-11177: Send significantly less reports from the client. Don't wa…
TheSpyder Aug 16, 2024
7c24b29
TINY-11177: Rebase conflicts
jscasca Dec 4, 2024
8e05635
TINY-11177: Re-implemented skip reports, we have enough of them that …
TheSpyder Aug 16, 2024
72d4f7f
TINY-11177: Updated reporter test for logical changes. Fixed a bug wi…
TheSpyder Aug 16, 2024
f277686
TINY-11177: Removed @ephox/wrap-promise-polyfill
TheSpyder Aug 16, 2024
5338432
TINY-11177: Rewriting the entire report system to support batch resul…
TheSpyder Sep 13, 2024
54b707f
TINY-11177: Delete route that accepts a single test result
TheSpyder Sep 15, 2024
2ad5cae
TINY-11177: Changelog
TheSpyder Sep 15, 2024
facf52c
TINY-11177: Fixed test
TheSpyder Sep 16, 2024
7a9892e
TINY-11177: Improved test failure reporting
TheSpyder Sep 16, 2024
ef03603
TINY-11177: The test wasn't broken, my code was. Messages sent close …
TheSpyder Sep 16, 2024
b1c5c5f
TINY-11177: Only update the HUD once for batch results, instead of on…
TheSpyder Sep 16, 2024
f8b7565
TINY-11177: Fixed issue where it was not clear test failures must be …
TheSpyder Sep 16, 2024
ac820f8
TINY-11177: Send start once, not once per page
TheSpyder Sep 16, 2024
fd9bb6a
TINY-11177: Fix HUD test count now that we are sending all results
TheSpyder Sep 16, 2024
872dca2
TINY-11177: Only record results if there are results
TheSpyder Sep 16, 2024
3776218
TINY-11177: Add extra warning for duplicate tests
TheSpyder Sep 16, 2024
0fa6df9
TINY-11177: Post current results before reloading the browser for eit…
TheSpyder Sep 16, 2024
838db0e
TINY-11177: Fixed test waiting for done to decide to post results
TheSpyder Sep 16, 2024
72cffd1
alpha 3
TheSpyder Sep 16, 2024
e54838f
TINY-11177: Warn for skipped tests as well
TheSpyder Sep 16, 2024
fc57378
TINY-11177: Revert failed attempt to fix sending the final result batch
TheSpyder Sep 16, 2024
47ffa61
TINY-11177: Extend HUD limit to the terminal width. Disable the limit…
TheSpyder Sep 17, 2024
df3ee16
TINY-11177: Reduce confusion with test reports and error messaging
TheSpyder Sep 17, 2024
43ef071
TINY-11177: Fail webdriver errors properly, don't generate new errors…
TheSpyder Sep 17, 2024
40151ea
TINY-11177: Alpha 4
TheSpyder Sep 17, 2024
1484158
TINY-11177: Removed usages of IE polyfills
TheSpyder Dec 17, 2024
a245503
TINY-11177: Increased driver connection timeout to 10 minutes
TheSpyder Dec 24, 2024
c3d1e39
TINY-11177: Removed the keep-alive action on page load. It's not nece…
TheSpyder Dec 24, 2024
b0c9c02
TINY-11177: Added an extended timeout for sticky sessions
TheSpyder Jan 14, 2025
6b0857d
TINY-11177: Use immediate shutdown on error
TheSpyder Jan 14, 2025
9e5effe
TINY-11177: Attempt to properly cancel when ctrl+c is pressed
TheSpyder Jan 14, 2025
e16e39e
TINY-11177: Add caching of custom route responses
TheSpyder Jan 15, 2025
72854ae
TINY-11177: Expand console logging of driver capabilities to any dept…
TheSpyder Jan 16, 2025
5306845
TINY-11177: Fix passing wrong object to generateETag
TheSpyder Jan 16, 2025
c525b0b
v15.0.0-alpha.5
TheSpyder Jan 16, 2025
5f4746f
TINY-11177: Increase sticky timeout to 55 seconds, and refactor resul…
TheSpyder Jan 16, 2025
e778bd6
TINY-11177: Output modern JS instead of transpiling for old browsers
TheSpyder Jan 17, 2025
f806c52
TINY-11177: Improve startup logging
TheSpyder Jan 17, 2025
45fb4a3
v15.0.0-alpha.6
TheSpyder Jan 17, 2025
d207f49
TINY-11177: Print how long during the timeout failure, it's failing a…
TheSpyder Jan 17, 2025
01ccdab
TINY-11177: Switch to raw numbers instead of date objects
TheSpyder Jan 17, 2025
12a08d2
TINY-11177: Revert upgrading the source map import to a higher module…
TheSpyder Jan 17, 2025
ceba987
TINY-11177: Can we use node 22?
TheSpyder Jan 17, 2025
fc2c431
TINY-11177: That's a no to Node 22. Downgrade rollup to work on older…
TheSpyder Jan 17, 2025
2914e70
TINY-11177: es2022 is too high for esm, which is a dead project and r…
TheSpyder Jan 17, 2025
5cf4b07
v15.0.0-alpha.7
TheSpyder Jan 17, 2025
7911a13
TINY-11177: Extend idle LambdaTest timeout to 5 minutes
TheSpyder Jan 17, 2025
d018041
v15.0.0-alpha.8
TheSpyder Jan 17, 2025
81e54aa
TINY-11177: Make sure there is at least some interaction with the rem…
TheSpyder Jan 17, 2025
44518a7
v15.0.0-alpha.9
TheSpyder Jan 17, 2025
bcc33ce
TINY-11177: Verbose log bedrock settings. Allow settings to override …
TheSpyder Jan 20, 2025
0629f21
TINY-11177: Enforce that tests are in describe blocks - this will hel…
TheSpyder Jan 21, 2025
b84f05a
TINY-11177: Add describe block wrappers to old style tests to more ea…
TheSpyder Jan 21, 2025
d322a0f
TINY-11177: Add checks to fail a test file if it doesn't clean up DOM…
TheSpyder Jan 21, 2025
b9bd5a0
TINY-11177: Bump default chunk to 2000
TheSpyder Jan 21, 2025
f793b47
v15.0.0-alpha.10
TheSpyder Jan 21, 2025
902eab3
TINY-11177: Fix import spacing
TheSpyder Jan 23, 2025
e4681f3
TINY-11177: Upgrade lambdatest and AWS library dependencies
TheSpyder Jan 24, 2025
d615cab
TINY-11177: Review fixes
TheSpyder Jan 24, 2025
b5c117e
TINY-11177: Why we patch `sourcemapped-stacktrace` to remove the ES6 …
TheSpyder Jan 24, 2025
84ce462
TINY-11177: Move the state checks into the `checkSiblings` function t…
TheSpyder Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## Added
- New server-side APIs to accept a batch of results instead of a single result #TINY-11177

## Changed
- Reverted TINY-10708 which was a server-side fix
- Client no longer waits for log requests to complete between tests, which should speed up remote testing #TINY-11177
- Console HUD no longer updates for individual tests #TINY-11177
- Client now posts test status only in batches every 30 seconds, this is the only time the console HUD will update #TINY-11177

## Removed
- Single result server-side API #TINY-11177
- Server-side monitoring of single test timeouts. This is still monitored client side. #TINY-11177
- The Promise polyfill is no longer allowed on modern NodeJS frameworks so it has been removed. #TINY-11177

## 14.1.5 - 2024-10-18

### Added
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ timestamps {
sh 'yarn build'
},
testDirs: [ 'modules/sample/src/test/ts/**/pass' ],
custom: '--config modules/sample/tsconfig.json --customRoutes modules/sample/routes.json --polyfills Promise Symbol'
custom: '--config modules/sample/tsconfig.json --customRoutes modules/sample/routes.json'
)
}

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"version": "14.1.5",
"version": "15.0.0-alpha.10",
"publish": {
"push": false
}
Expand Down
4 changes: 2 additions & 2 deletions modules/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ephox/bedrock-client",
"version": "14.1.1",
"version": "15.0.0-alpha.10",
"author": "Tiny Technologies Inc",
"license": "Apache-2.0",
"scripts": {
Expand All @@ -10,7 +10,7 @@
"buildAndTest": "yarn prepublishOnly && yarn test"
},
"dependencies": {
"@ephox/bedrock-common": "^14.1.1",
"@ephox/bedrock-common": "^15.0.0-alpha.7",
"@ephox/dispute": "^1.0.3"
},
"main": "./lib/main/ts/api/Main.js",
Expand Down
22 changes: 14 additions & 8 deletions modules/client/src/main/ts/api/UnitTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context, Failure, TestError, TestLabel, TestLogs } from '@ephox/bedrock-common';
import { it } from './Bdd';
import { describe, it } from './Bdd';

type TestLogs = TestLogs.TestLogs;
type TestError = TestError.TestError;
Expand All @@ -10,11 +10,13 @@ export type FailureCallback = (error: TestThrowable, logs?: TestLogs) => void;

/** An asynchronous test with callbacks. */
export const asyncTest = (name: string, test: (this: Context, success: SuccessCallback, failure: FailureCallback) => void): void => {
it(name, function (done) {
test.call(this, () => done(), ((err, logs) => {
const r = Failure.prepFailure(err, logs);
done(r);
}));
describe('old-style test', () => {
it(name, function (done) {
test.call(this, () => done(), ((err, logs) => {
const r = Failure.prepFailure(err, logs);
done(r);
}));
});
});
};

Expand All @@ -23,10 +25,14 @@ export const asynctest = asyncTest;

/** A synchronous test that fails if an exception is thrown */
export const test = (name: string, test: (this: Context) => void): void => {
it(name, test);
describe('old-style test', () => {
it(name, test);
});
};

/** Tests an async function (function that returns a Promise). */
export const promiseTest = (name: string, test: (this: Context) => Promise<void>): void => {
it(name, test);
describe('old-style test', () => {
it(name, test);
});
};
6 changes: 3 additions & 3 deletions modules/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"strict": true,
"noUnusedLocals": true,
"useUnknownInCatchVariables": false,
"target": "es5",
"module": "es2015",
"lib": ["es2015", "dom"],
"target": "es2019",
"module": "es2020",
"lib": ["es2022", "dom"],
"declaration": true,
"sourceMap": true,
"outDir": "lib",
Expand Down
2 changes: 1 addition & 1 deletion modules/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ephox/bedrock-common",
"version": "14.1.1",
"version": "15.0.0-alpha.7",
"author": "Tiny Technologies Inc",
"license": "Apache-2.0",
"scripts": {
Expand Down
7 changes: 4 additions & 3 deletions modules/common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"strict": true,
"noUnusedLocals": true,
"useUnknownInCatchVariables": false,
"target": "es5",
"module": "es2015",
"lib": ["es2015", "dom"],
"target": "es2019",
"module": "es2020",
"lib": ["es2022", "dom"],
"declaration": true,
"sourceMap": true,
"outDir": "lib",

"rootDir": "src",
"types": []
},
Expand Down
9 changes: 4 additions & 5 deletions modules/runner/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ephox/bedrock-runner",
"version": "14.1.1",
"version": "15.0.0-alpha.10",
"author": "Tiny Technologies Inc",
"license": "Apache-2.0",
"scripts": {
Expand All @@ -10,19 +10,18 @@
"buildAndTest": "yarn prepublishOnly && yarn test"
},
"dependencies": {
"@ephox/bedrock-common": "^14.1.1",
"@ephox/wrap-promise-polyfill": "^2.2.0",
"@ephox/bedrock-common": "^15.0.0-alpha.7",
"jquery": "^3.4.1",
"querystringify": "^2.1.1"
},
"devDependencies": {
"@types/diff": "^5.0.0",
"@types/jquery": "^3.5.3",
"@types/querystringify": "^2.0.0",
"rollup": "^1.20.2",
"rollup": "^4.30.1",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-sourcemaps": "^0.6.3",
"sourcemapped-stacktrace": "^1.1.11"
},
"main": "./lib/main/ts/api/Main.js",
Expand Down
File renamed without changes.
15 changes: 7 additions & 8 deletions modules/runner/src/main/ts/api/Main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Failure, Global } from '@ephox/bedrock-common';
import Promise from '@ephox/wrap-promise-polyfill';
import * as Globals from '../core/Globals';
import * as TestLoader from '../core/TestLoader';
import { UrlParams } from '../core/UrlParams';
Expand All @@ -23,16 +22,16 @@ const setupAndRun = (loadError?: Error) => {

const runner = Runner(Globals.rootSuite(), params, callbacks, reporter, ui);
runner.init().then((data) => {
if (data.mode === 'auto') {
// Try to ensure the page has focus
window.focus();
}

// Run the tests if an error didn't occur during loading
if (loadError !== undefined) {
return Promise.reject(loadError);
} else {
return runner.run(data.chunk, data.retries, data.timeout, data.stopOnFailure);
const autoMode = data.mode === 'auto';
if (autoMode) {
// Try to ensure the page has focus
window.focus();
}
return runner.run(data.chunk, data.retries, data.timeout, data.stopOnFailure, autoMode);
}
}).catch((e: Error) => {
console.error('Unexpected error occurred', e);
Expand All @@ -43,7 +42,7 @@ const setupAndRun = (loadError?: Error) => {
};

const run = () => setupAndRun();
const runError = (e: Error) => setupAndRun(e);
const runError = (e: Error) => setupAndRun(Failure.prepFailure(e));

const loadAndRun = (scripts: string[]) => {
// Load the scripts and then run
Expand Down
5 changes: 4 additions & 1 deletion modules/runner/src/main/ts/core/Globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export const afterEach = (title: TitleOrExecuteFn, fn?: ExecuteFn): void => {

export const it = (title: string, fn: ExecuteFn): Test => {
const suite = getCurrentSuiteOrDie();
if (suite === root) {
throw new Error('Tests must be in a `describe` block');
}
const test = createTest(title, fn, suite);

suite.tests.push(test);
Expand Down Expand Up @@ -123,4 +126,4 @@ export const setup = (global: any = Global): void => {
});
};

export const rootSuite = (): Suite => root;
export const rootSuite = (): Suite => root;
3 changes: 1 addition & 2 deletions modules/runner/src/main/ts/core/TestLoader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Promise from '@ephox/wrap-promise-polyfill';
import { ErrorCatcher } from '../errors/ErrorCatcher';

export const load = (scriptUrl: string): Promise<void> =>
Expand Down Expand Up @@ -38,4 +37,4 @@ export const load = (scriptUrl: string): Promise<void> =>

// Add the script to the dom to load it
document.body.appendChild(script);
});
});
7 changes: 3 additions & 4 deletions modules/runner/src/main/ts/core/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Suite, Test } from '@ephox/bedrock-common';
import Promise from '@ephox/wrap-promise-polyfill';
import sourceMappedStackTrace from 'sourcemapped-stacktrace';

// eslint-disable-next-line @typescript-eslint/no-empty-function
Expand All @@ -20,8 +19,8 @@ export const makeUrl = (session: string, offset: number, failed: number, skipped
return baseUrl + makeQueryParams(session, offset, failed, skipped, retry);
};

export const formatElapsedTime = (start: Date, end: Date): string => {
const millis = end.getTime() - start.getTime();
export const formatElapsedTime = (start: number, end: number): string => {
const millis = end - start;
const seconds = Math.floor(millis / 1000);
const point = Math.floor(millis - (seconds * 1000) / 100);
const printable =
Expand Down Expand Up @@ -62,4 +61,4 @@ export const setStack = (error: Error, stack: string | undefined): void => {
} catch (err) {
// Do nothing
}
};
};
50 changes: 32 additions & 18 deletions modules/runner/src/main/ts/reporter/Callbacks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { ErrorData, Global } from '@ephox/bedrock-common';
import Promise from '@ephox/wrap-promise-polyfill';

import { HarnessResponse } from '../core/ServerTypes';

export interface TestReport {
TheSpyder marked this conversation as resolved.
Show resolved Hide resolved
readonly file: string;
readonly name: string;
readonly passed: boolean;
readonly time: string;
readonly skipped: string | null;
readonly error: TestErrorData | null
}

export interface TestErrorData {
readonly data: ErrorData;
readonly text: string;
Expand All @@ -11,25 +20,34 @@ export interface Callbacks {
readonly loadHarness: () => Promise<HarnessResponse>
readonly sendKeepAlive: (session: string) => Promise<void>;
readonly sendInit: (session: string) => Promise<void>;
readonly sendTestStart: (session: string, totalTests: number, file: string, name: string) => Promise<void>;
readonly sendTestResult: (session: string, file: string, name: string, passed: boolean, time: string, error: TestErrorData | null, skipped: string | null) => Promise<void>;
readonly sendTestStart: (session: string, number: number, totalTests: number, file: string, name: string) => Promise<void>;
readonly sendTestResults: (session: string, results: TestReport[]) => Promise<void>;
readonly sendDone: (session: string, error?: string) => Promise<void>;
}

declare const $: JQueryStatic;

const sendJson = <T>(url: string, data: any): Promise<T> => {
function generateErrorMessage(xhr: JQuery.jqXHR<any>, onError: (reason?: any) => void, url: string, requestDetails: string, statusText: 'timeout' | 'error' | 'abort' | 'parsererror', e: string) {
if (xhr.readyState === 0) {
onError(`Unable to open connection to ${url}, ${requestDetails}. Status text "${statusText}", error thrown "${e}"`);
} else {
onError(`Response status ${xhr.status} connecting to ${url}, ${requestDetails}. Status text "${statusText}", error thrown "${e}"`);
}
}

const sendJson = <T>(url: string, jsonData: any): Promise<T> => {
return new Promise((onSuccess, onError) => {
const data = JSON.stringify(jsonData);
$.ajax({
method: 'post',
url,
contentType: 'application/json; charset=UTF-8',
dataType: 'json',
success: onSuccess,
error: (xhr, statusText, e) => {
onError(e);
generateErrorMessage(xhr, onError, url, `sending ${data}`, statusText, e);
},
data: JSON.stringify(data),
data,
});
});
};
Expand All @@ -41,7 +59,7 @@ const getJson = <T>(url: string): Promise<T> => {
dataType: 'json',
success: onSuccess,
error: (xhr, statusText, e) => {
onError(e);
generateErrorMessage(xhr, onError, url, 'as a get request', statusText, e);
}
});
}));
Expand All @@ -64,24 +82,20 @@ export const Callbacks = (): Callbacks => {
});
};

const sendTestStart = (session: string, totalTests: number, file: string, name: string): Promise<void> => {
const sendTestStart = (session: string, number: number, totalTests: number, file: string, name: string): Promise<void> => {
return sendJson('/tests/start', {
number,
totalTests,
session,
file,
name,
});
};

const sendTestResult = (session: string, file: string, name: string, passed: boolean, time: string, error: TestErrorData | null, skipped: string | null): Promise<void> => {
return sendJson('/tests/result', {
const sendTestResults = (session: string, results: TestReport[]): Promise<void> => {
return sendJson('/tests/results', {
session,
file,
name,
passed,
skipped,
time,
error,
results,
});
};

Expand All @@ -101,7 +115,7 @@ export const Callbacks = (): Callbacks => {
sendInit,
sendKeepAlive,
sendTestStart,
sendTestResult,
sendTestResults,
sendDone
};
};
};
Loading
Loading