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
--------------------------------------------------------------------------------
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:
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
takes the following arguments:
host: <IP address of host in which DIAL server is running>
app: Name of the application to test against (eg: Netflix, YouTube)
timeToWaitForStateChange: Some of these tests wait for application state
changes before querying for application status. Default is 5000(ms)
server/tests/js_tests/tests$ node tests.js
Usage: node tests.js[options]
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:
server/tests/js_tests/tests> node tests.js host=<ip of DIAL server>
app="Netflix" timeToWaitForStateChange=2000
server/tests/js_tests/tests$ node discoverServerUnderTest.js
To run each test independantly and not through test.js, just call the
appropriate test file name instead of test.js.
Usage: node discoverServerUnderTest.js[options]
Example:
server/tests/js_tests/tests> node discoverServerUnderTest.js
host=<ip of DIAL server> app="Netflix" timeToWaitForStateChange=2000
Any application specific setup/requirements should be taken care of before
running these tests.
Options:
--host IP address of host on which DIAL server under test is
running [string] [required]
--application, --app Application to test [string] [required]
--help, -h Show help [boolean]

View File

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

View File

@@ -3,30 +3,18 @@
const colors = require("colors/safe");
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) {
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"));
}
function printFailure(err) {
function printTestFailure(err) {
return console.log(colors.red(sprintf("%-20s : %-s\n", "TEST FAILED", err)));
}
module.exports.getParam = getParam;
module.exports.printTestInfo = printTestInfo;
module.exports.printSuccess = printSuccess;
module.exports.printFailure = printFailure;
module.exports.printTestSuccess = printTestSuccess;
module.exports.printTestFailure = printTestFailure;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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