-
-
Notifications
You must be signed in to change notification settings - Fork 62
[Test Load Balancing] Validate load-balance option and enable to load test balanced
#136
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
Merged
stefanpenner
merged 28 commits into
ember-cli:master
from
choheekim:enable_test_load_balance
Mar 15, 2019
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1c62727
[Feature] Test Load Balancing
6143f27
1. Create EmberExamTestLoader that extends TestLoader.
a2be9ea
1. Resolve mixing usage of this and testLoader
45fad80
Adding testem-event.js and execution-state-manager.js, handle string …
step2yeung e6dd86a
EmberExamTestLoader extends either ember-qunit or ember-mocha
step2yeung 03379b9
1. Adding acceptance tests to test load-balance & replay-execution op…
step2yeung 358d4ae
Modify --parallel to accept a number & --load-balance accept a boolean
step2yeung 576f82b
Write test-execution json when browser crashes
step2yeung ebf87f1
Splitting ember-exam-test-loader for qunit and mocha & moving setupQu…
step2yeung 813fa16
1. Prefix ember-exam error message with `EmberExam:`
35d3048
Minor fixes
step2yeung a5dea38
1. Add async-iterator class to simplify async promises and add tests …
dfa55e8
- Add an inline comment for qunit callbacks
941a999
- create a dummy testem instance for async-iterator-test in order not…
aca8646
use window.Testem and check _testem is undefined
step2yeung 6314ca2
Fix exam-test and testem-events-test & Run Prettier on tests & remove…
step2yeung db0ce01
Removing async await usages
step2yeung a37566d
Add `--execution-only` option to allow not writing test-execution jso…
0c1b3a1
1. with `--no-launch` a key, test_page, isn't set in launcher setting…
df56609
Rename `execution-only` to `no-execution-file` and change conditional…
560bdf0
1. Fix usage of Map
5d8364a
Fixes to make --server reruns with replay-execution mode work
step2yeung b3ba43e
update testem.js timeout to 15s
step2yeung a9a8581
Adding fixturify to devDependencies
step2yeung 80d343a
Fixes for refreshing browser using `replay-execution` and `no-launch`…
8141a5d
Remove ember-cli-version-checker and use this.project.pkg to get the …
step2yeung c691151
1. Throw an error when no-launch is used with load-balance
fbbe3a5
Prettier, renaming, changes of usage im map
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| 'use strict'; | ||
|
|
||
| import getUrlParams from './get-url-params'; | ||
|
|
||
| /** | ||
| * A class to iterate a sequencial set of asynchronous events. | ||
| * | ||
| * @class AsyncIterator | ||
| */ | ||
| export default class AsyncIterator { | ||
| constructor(testem, options) { | ||
| this._testem = testem; | ||
| this._request = options.request; | ||
| this._response = options.response; | ||
| this._done = false; | ||
| this._current = null; | ||
| this._boundHandleResponse = this.handleResponse.bind(this); | ||
| this._waiting = false; | ||
| // Set a timeout value from either url parameter or default timeout value, 2 s. | ||
| this._timeout = getUrlParams().get('asyncTimeout') || 2; | ||
| this._browserId = getUrlParams().get('browser'); | ||
|
|
||
| testem.on(this._response, this._boundHandleResponse); | ||
| } | ||
|
|
||
| /** | ||
| * Return whether the response queue is done. | ||
| */ | ||
| get done() { | ||
| return this._done; | ||
| } | ||
|
|
||
| toString() { | ||
| return `<AsyncIterator (request: ${this._request} response: ${ | ||
| this._response | ||
| })>`; | ||
| } | ||
|
|
||
| /** | ||
| * Handle a response when it's waiting for a response | ||
| * | ||
| * @param {*} response | ||
| */ | ||
| handleResponse(response) { | ||
| if (this._waiting === false) { | ||
| throw new Error( | ||
| `${this.toString()} Was not expecting a response, but got a response` | ||
| ); | ||
| } else { | ||
| this._waiting = false; | ||
| } | ||
|
|
||
| try { | ||
| if (response.done) { | ||
| this.dispose(); | ||
| } | ||
| this._current.resolve(response); | ||
| } catch (e) { | ||
| this._current.reject(e); | ||
| } finally { | ||
| this._current = null; | ||
|
|
||
| if (this.timer) { | ||
| clearTimeout(this.timer); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Dispose when an iteration is finished. | ||
| * | ||
| */ | ||
| dispose() { | ||
| this._done = true; | ||
| this._testem.removeEventCallbacks( | ||
| this._response, | ||
| this._boundHandleResponse | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Emit the current request. | ||
| * | ||
| */ | ||
| _makeNextRequest() { | ||
| this._waiting = true; | ||
| this._testem.emit(this._request, this._browserId); | ||
| } | ||
|
|
||
| /** | ||
| * Set a timeout to reject a promise if it doesn't get response within the timeout threshold. | ||
| * | ||
| * @param {*} reject | ||
| */ | ||
| _setTimeout(reject) { | ||
| clearTimeout(this.timeout); | ||
| this.timer = setTimeout(() => { | ||
| if (!this._waiting) { | ||
| return; | ||
| } | ||
| let err = new Error( | ||
| `EmberExam: Promise timed out after ${ | ||
| this._timeout | ||
| } s while waiting for response for ${this._request}` | ||
| ); | ||
| reject(err); | ||
| }, this._timeout * 1000); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the next response from the request and resolve the promise. | ||
| * if it's end of the iteration resolve the promise with done being true. | ||
| * | ||
| * @return {Promise} | ||
| */ | ||
| next() { | ||
| if (this._done) { | ||
| return Promise.resolve({ done: true, value: null }); | ||
| } | ||
| if (this._current) { | ||
| return this._current.promise; | ||
| } | ||
|
|
||
| let resolve, reject; | ||
| let promise = new Promise((_resolve, _reject) => { | ||
| resolve = _resolve; | ||
| reject = _reject; | ||
| this._setTimeout(reject); | ||
| }); | ||
|
|
||
| this._current = { | ||
| resolve, | ||
| reject, | ||
| promise | ||
|
choheekim marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| this._makeNextRequest(); | ||
|
|
||
| return promise; | ||
| } | ||
| } | ||
69 changes: 69 additions & 0 deletions
69
addon-test-support/-private/ember-exam-mocha-test-loader.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import getUrlParams from './get-url-params'; | ||
| import splitTestModules from './split-test-modules'; | ||
| import { TestLoader } from 'ember-mocha/test-loader'; | ||
|
|
||
| /** | ||
| * EmberExamMochaTestLoader extends ember-mocha/test-loader used by `ember test`, since it | ||
| * overrides moduleLoadFailure() to log a test failure when a module fails to load | ||
| * @class EmberExamMochaTestLoader | ||
| * @extends {TestLoader} | ||
| */ | ||
| export default class EmberExamMochaTestLoader extends TestLoader { | ||
| constructor(testem, urlParams) { | ||
| super(); | ||
| this._testModules = []; | ||
| this._testem = testem; | ||
| this._urlParams = urlParams || getUrlParams(); | ||
| } | ||
|
|
||
| get urlParams() { | ||
| return this._urlParams; | ||
| } | ||
|
|
||
| /** | ||
| * Ember-cli-test-loader instantiates a new TestLoader instance and calls loadModules. | ||
| * EmberExamMochaTestLoader does not support load() in favor of loadModules(). | ||
| */ | ||
| static load() { | ||
| throw new Error('`EmberExamMochaTestLoader` doesn\'t support `load()`.'); | ||
| } | ||
|
|
||
| /** | ||
| * require() collects the full list of modules before requiring each module with | ||
| * super.require, instead of requiring and unseeing a module when each gets loaded. | ||
| * | ||
| * @param {string} moduleName | ||
| */ | ||
| require(moduleName) { | ||
| this._testModules.push(moduleName); | ||
| } | ||
|
|
||
| /** | ||
| * Make unsee a no-op to avoid any unwanted resets | ||
| */ | ||
| unsee() {} | ||
|
stefanpenner marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Loads the test modules depending on the urlParam | ||
| */ | ||
| loadModules() { | ||
|
stefanpenner marked this conversation as resolved.
|
||
| let partitions = this._urlParams.get('partition'); | ||
| let split = parseInt(this._urlParams.get('split'), 10); | ||
|
|
||
| split = isNaN(split) ? 1 : split; | ||
|
|
||
| if (partitions === undefined) { | ||
| partitions = [1]; | ||
| } else if (!Array.isArray(partitions)) { | ||
| partitions = [partitions]; | ||
| } | ||
|
|
||
| super.loadModules(); | ||
|
|
||
| this._testModules = splitTestModules(this._testModules, split, partitions); | ||
| this._testModules.forEach((moduleName) => { | ||
| super.require(moduleName); | ||
| super.unsee(moduleName); | ||
| }); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.