Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Port rules (#220)
Browse files Browse the repository at this point in the history
* replace logger

* add port rules

* fix logger

* fix logger

* revert logger

* revert logger

* format output

* move warning to worker allocator

* change port rule warning and more unit test

* remove unnecessary changes

* remove unnecessary change

* retrigger test

* retrigger test

* remove coverage
  • Loading branch information
archlichking authored Apr 13, 2017
1 parent 2d6570f commit 0fb03da
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 21 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ node_js:
- v5
- v4
sudo: false
after_success:
- bash <(curl -s https://codecov.io/bash)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testarmada-magellan",
"version": "10.0.4",
"version": "10.0.5",
"description": "Massively parallel automated testing",
"main": "src/main",
"directories": {
Expand Down
31 changes: 24 additions & 7 deletions src/test_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ class TestRunner {
msg.push("-->");
msg.push((this.serial ? "Serial mode" : "Worker " + worker.index) + ",");

msg.push("mock port:" + worker.portOffset + ",");
msg.push("port range: [" + worker.portOffset + ", "
+ (worker.portOffset + settings.BASE_PORT_SPACING - 1) + "],");

if (worker.token) {
msg.push("VM token:" + worker.token + ",");
Expand All @@ -567,7 +568,26 @@ class TestRunner {

this.mkdirSync(tempAssetPath);

testRun = new TestRunClass({
// magellan default port rule
let ports = {
seleniumPort: worker.portOffset,
mockingPort: null
};

if (settings.BASE_PORT_SPACING > 1) {
ports.mockingPort = worker.portOffset + 1;
}

// if executor has its own port rule
if (test.executor.getPorts
&& typeof test.executor.getPorts === "function") {
ports = test.executor.getPorts({
portOffset: worker.portOffset,
portIndent: settings.BASE_PORT_SPACING
});
}

testRun = new TestRunClass(_.assign({
guid: childBuildId,

// The id of this build, used by some reporters to identify the overall suite run. This
Expand All @@ -588,11 +608,8 @@ class TestRunner {
// executor: this.executors[test.profile.executor],

// The locator object originally generated by the plugin itself
locator: test.locator,

seleniumPort: worker.portOffset + 1,
mockingPort: worker.portOffset
});
locator: test.locator
}, ports));
} catch (e) {
deferred.reject(e);
}
Expand Down
26 changes: 16 additions & 10 deletions src/worker_allocator.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ class Allocator {
debug: settings.debug
}, opts);

if (this.debug) {
logger.log("Worker Allocator starting.");
logger.log("Port allocation range from: " + settings.BASE_PORT_START + " to "
+ (settings.BASE_PORT_START + settings.BASE_PORT_RANGE - 1) + " with "
+ settings.BASE_PORT_SPACING + " ports available to each worker.");
logger.debug("Worker Allocator starting.");
logger.debug("Port allocation range from: " + settings.BASE_PORT_START + " to "
+ (settings.BASE_PORT_START + settings.BASE_PORT_RANGE - 1) + " with "
+ settings.BASE_PORT_SPACING + " ports available to each worker.");

/* istanbul ignore if */
if (settings.BASE_PORT_SPACING === 1) {
logger.warn("Only one port is available per worker");
logger.warn("Increase --base_port_spacing to allocate more ports per worker if needed");
}

this.initializeWorkers(MAX_WORKERS);
Expand Down Expand Up @@ -82,11 +86,13 @@ class Allocator {

const portOffset = this.getNextPort();

// Standard Magellan convention: port = mock, port + 1 = selenium
// Other ports after this within the BASE_PORT_SPACING range can
// be used for whatever the user desires, so those are labelled
// as "generic" (if found to be occupied, that is).
const desiredPortLabels = ["mocking port", "selenium port"];
// Standard Magellan port convention:
// let n = settings.BASE_PORT_SPACING - 1;
// portOffset : selenium server
// portOffset + 1 : pre-assigned for mocking (available for application to use)
// ...
// portOffset + n : available for application to use
const desiredPortLabels = ["selenium port"];
const desiredPorts = [];

// if BASE_PORT_SPACING is the default of 3, we'll check 3 ports
Expand Down
2 changes: 1 addition & 1 deletion test/base_listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const expect = chai.expect;
chai.use(chaiAsPromised);

describe("listener", () => {

it("should act like a class", () => {
expect(new BaseListener()).to.be.an.instanceof(BaseListener);
});
Expand Down
18 changes: 18 additions & 0 deletions test/cli_help.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,27 @@ const opts = {
"category": "Usability",
"visible": false,
"description": "FAKE_INVISIBLE_DES"
},
"another-visible-command": {
"category": "Usability",
"description": "FAKE_ANOTHER_VISIBLE_DES"
}
}
}
},
framework: "FAKE_FRAME_NAME",
testFramework: {
help: {
tags: {
example: "tag1,tag2",
visible: true,
description: "Run all tests that match a list of comma-delimited tags (eg: tag1,tag2)"
},
group: {
example: "prefix/path",
description: "Run all tests that match a path prefix like ./tests/smoke"
}
}
}
}
};
Expand Down
6 changes: 6 additions & 0 deletions test/test_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ const executors = {
name: "testarmada-magellan-sauce-executor",
shortName: "sauce",

getPorts(opts) {
return {
seleniumPort: opts.portOffset,
mockingPort: opts.portOffset + 1
}
},
getProfiles(opts) {
return new Promise((resolve) => {
resolve(opts.profiles);
Expand Down

0 comments on commit 0fb03da

Please sign in to comment.