Removed some test workarounds and updated README

This commit is contained in:
Shruti Ranganathan Jothi
2017-03-08 10:56:39 -08:00
parent 8e322de983
commit 6a0edc87dc
19 changed files with 66 additions and 80 deletions

39
README
View File

@@ -80,7 +80,7 @@ client will prompt you to select a server.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
NEW: Node.js tests for DIAL server 2.1 NEW: Node.js tests for DIAL server 2.1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Node.js tests to test DIAL server implementation are now available under Node.js tests to test DIAL server 2.1 implementation are now available under
server/tests/js_tests. To run these tests againsts a DIAL server: server/tests/js_tests. To run these tests againsts a DIAL server:
1. Ensure that the DIAL server is discoverable from the test environment 1. Ensure that the DIAL server is discoverable from the test environment
@@ -92,21 +92,30 @@ The tests themselves are located inside the server/tests/js_tests/tests folder.
The file tests.js is a batch runner and will run all the tests serially. It The file tests.js is a batch runner and will run all the tests serially. It
takes the following arguments: takes the following arguments:
host: <IP address of host in which DIAL server is running> server/tests/js_tests/tests$ node tests.js
app: Name of the application to test against (eg: Netflix, YouTube)
timeToWaitForStateChange: Some of these tests wait for application state Usage: node tests.js[options]
changes before querying for application status. Default is 5000(ms)
Options:
--host IP address of host on which DIAL server
under test is running [string] [required]
--application, --app Application to test [string] [required]
--timeToWaitForStateChange, --ttw Time(ms) to wait between state changes
before querying application status
[string] [default: 5000]
--help, -h Show help [boolean]
To run each test independantly and not through tests.js, just call the
appropriate test file name.
Example: Example:
server/tests/js_tests/tests> node tests.js host=<ip of DIAL server> server/tests/js_tests/tests$ node discoverServerUnderTest.js
app="Netflix" timeToWaitForStateChange=2000
To run each test independantly and not through test.js, just call the Usage: node discoverServerUnderTest.js[options]
appropriate test file name instead of test.js.
Example: Options:
server/tests/js_tests/tests> node discoverServerUnderTest.js --host IP address of host on which DIAL server under test is
host=<ip of DIAL server> app="Netflix" timeToWaitForStateChange=2000 running [string] [required]
--application, --app Application to test [string] [required]
Any application specific setup/requirements should be taken care of before --help, -h Show help [boolean]
running these tests.

View File

@@ -65,8 +65,7 @@ function getApplicationStatus(host, app, clientDialVer) {
if(statusCode !== 200) { if(statusCode !== 200) {
return reject(new Error("Expected statusCode 200 while querying application status but got " + statusCode)); return reject(new Error("Expected statusCode 200 while querying application status but got " + statusCode));
} }
// TODO: Remove application/xml from accepted types if(contentType.indexOf("text/xml") === -1) {
if(contentType.indexOf("text/xml") === -1 && contentType.indexOf("application/xml") === -1) {
return reject(new Error("Expected MIME type 'text/xml' while querying application status but got " + contentType)); return reject(new Error("Expected MIME type 'text/xml' while querying application status but got " + contentType));
} }
// Extract fields from body // Extract fields from body
@@ -121,8 +120,6 @@ function launchApplication(host, app, payload) {
method: "POST", method: "POST",
timeout: 6000, timeout: 6000,
headers: { headers: {
// TODO: Remove host header
"Host" : appResourceUrl.split("http://")[1].split("/")[0],
"Content-Type" : "text/plain;charset=\"utf-8\"" "Content-Type" : "text/plain;charset=\"utf-8\""
} }
}; };
@@ -162,9 +159,7 @@ function stopApplication(host, app) {
var request = { var request = {
url: appResourceUrl, url: appResourceUrl,
method: "DELETE", method: "DELETE",
timeout: 6000, timeout: 6000
// TODO: Remove host header
headers: {"Host" : appResourceUrl.split("http://")[1].split("/")[0]}
}; };
return new Q.Promise(function (resolve, reject) { return new Q.Promise(function (resolve, reject) {
return httpRequest(request, function handleResponse(error, response) { return httpRequest(request, function handleResponse(error, response) {
@@ -193,9 +188,7 @@ function hideApplication(host, app) {
var request = { var request = {
url: appResourceUrl, url: appResourceUrl,
method: "POST", method: "POST",
timeout: 6000, timeout: 6000
// TODO: Remove host header
headers: {"Host" : appResourceUrl.split("http://")[1].split("/")[0]}
}; };
return new Q.Promise(function (resolve, reject) { return new Q.Promise(function (resolve, reject) {
return httpRequest(request, function handleResponse(error, response) { return httpRequest(request, function handleResponse(error, response) {
@@ -218,9 +211,7 @@ function stopApplicationInstance(instanceUrl) {
var request = { var request = {
url: instanceUrl, url: instanceUrl,
method: "DELETE", method: "DELETE",
timeout: 6000, timeout: 6000
// TODO: Remove host header
headers: {"Host" : instanceUrl.split("http://")[1].split("/")[0]}
}; };
return new Q.Promise(function (resolve, reject) { return new Q.Promise(function (resolve, reject) {
return httpRequest(request, function handleResponse(error, response) { return httpRequest(request, function handleResponse(error, response) {
@@ -239,9 +230,7 @@ function hideApplicationInstance(instanceUrl) {
var request = { var request = {
url: instanceUrl, url: instanceUrl,
method: "POST", method: "POST",
timeout: 6000, timeout: 6000
// TODO: Remove host header
headers: {"Host" : instanceUrl.split("http://")[1].split("/")[0]}
}; };
return new Q.Promise(function (resolve, reject) { return new Q.Promise(function (resolve, reject) {
return httpRequest(request, function handleResponse(error, response) { return httpRequest(request, function handleResponse(error, response) {

View File

@@ -3,30 +3,18 @@
const colors = require("colors/safe"); const colors = require("colors/safe");
const sprintf = require("sprintf-js").sprintf; const sprintf = require("sprintf-js").sprintf;
function getParam(key) {
var value;
var args = process.argv.slice(2);
args.forEach(function (param) {
if(param.indexOf(key + "=") === 0) {
value = param.split("=")[1];
}
});
return value;
}
function printTestInfo(test, msg) { function printTestInfo(test, msg) {
return console.log(sprintf("%-20s : %-s\n%-20s : %-s", "Test", test, "Description", msg)); return console.log(sprintf("%-20s : %-s\n%-20s : %-s", "Test", test, "Description", msg));
} }
function printSuccess() { function printTestSuccess() {
return console.log(colors.green("TEST PASSED\n")); return console.log(colors.green("TEST PASSED\n"));
} }
function printFailure(err) { function printTestFailure(err) {
return console.log(colors.red(sprintf("%-20s : %-s\n", "TEST FAILED", err))); return console.log(colors.red(sprintf("%-20s : %-s\n", "TEST FAILED", err)));
} }
module.exports.getParam = getParam; module.exports.printTestInfo = printTestInfo;
module.exports.printTestInfo = printTestInfo; module.exports.printTestSuccess = printTestSuccess;
module.exports.printSuccess = printSuccess; module.exports.printTestFailure = printTestFailure;
module.exports.printFailure = printFailure;

View File

@@ -39,10 +39,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -88,10 +88,10 @@ function test() {
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -81,10 +81,10 @@ function test() {
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -71,10 +71,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -81,10 +81,10 @@ function test() {
}) })
.delay(timeToWaitForStateChange) .delay(timeToWaitForStateChange)
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -81,10 +81,10 @@ function test() {
}) })
.delay(timeToWaitForStateChange) .delay(timeToWaitForStateChange)
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -79,10 +79,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -80,10 +80,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -81,10 +81,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -81,10 +81,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -40,10 +40,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -68,10 +68,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -88,10 +88,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -80,10 +80,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -107,10 +107,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }

View File

@@ -67,10 +67,10 @@ function test() {
} }
}) })
.then(function () { .then(function () {
utils.printSuccess() utils.printTestSuccess()
}) })
.fail(function handleError(err) { .fail(function handleError(err) {
utils.printFailure(err); utils.printTestFailure(err);
}); });
} }