diff options
author | Alex Shatov <alexs@att.com> | 2017-09-27 18:51:43 -0400 |
---|---|---|
committer | Alex Shatov <alexs@att.com> | 2017-09-27 18:51:43 -0400 |
commit | a2ffa33f55ae178e91df119aa19d2bede35d083f (patch) | |
tree | 67fd5579f3a8a599093f8b6cf12648766ce7b826 /deployment-handler.js | |
parent | f7f1ab925d8e9e81cb28f4bc3f5ae2be8bdf5f98 (diff) |
51% unit test of the deployment-handler
* only unit testing the /policy/components at the moment
* use -f Dockerfile_UT when building the image
* unit test runs inside docker container
* after docker run finishes copy the logs and coverage folder
from docker container. Sample commands:
docker cp test_deployment_handler:/opt/app/dh test_logs/
docker logs test_deployment_handler > \
test_logs/$(date +%Y_%m%d-%H%M%S)_test_deployment_handler.log 2>&1
Change-Id: I77276550e2ffb7094e02ffa20741afac6bfea96f
Issue-Id: DCAEGEN2-62
Signed-off-by: Alex Shatov <alexs@att.com>
Diffstat (limited to 'deployment-handler.js')
-rw-r--r-- | deployment-handler.js | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/deployment-handler.js b/deployment-handler.js index 01455d4..171f73c 100644 --- a/deployment-handler.js +++ b/deployment-handler.js @@ -34,6 +34,27 @@ const DEPLOYMENTS_PATH = "/dcae-deployments"; const POLICY_PATH = "/policy"; const SWAGGER_UI_PATH = "/swagger-ui"; +const app = express(); + +/* Set up the application */ +app.set('x-powered-by', false); +app.set('etag', false); + +/* Give each request a unique request ID */ +app.use(require('./lib/middleware').assignId); + +/* If authentication is set up, check it */ +app.use(require('./lib/auth').checkAuth); + +/* Set up API routes */ +app.use(INFO_PATH, require('./lib/info')); +app.use(DEPLOYMENTS_PATH, require('./lib/dcae-deployments')); +app.use(POLICY_PATH, require('./lib/policy')); +app.use(SWAGGER_UI_PATH, require('./lib/swagger-ui')); + +/* Set up error handling */ +app.use(require('./lib/middleware').handleErrors); + const start = function(config) { const startTime = new Date(); @@ -56,26 +77,6 @@ const start = function(config) { log.debug(null, "Configuration: " + JSON.stringify(config)); - /* Set up the application */ - const app = express(); - app.set('x-powered-by', false); - app.set('etag', false); - - /* Give each request a unique request ID */ - app.use(require('./lib/middleware').assignId); - - /* If authentication is set up, check it */ - app.use(require('./lib/auth').checkAuth); - - /* Set up API routes */ - app.use(INFO_PATH, require('./lib/info')); - app.use(DEPLOYMENTS_PATH, require('./lib/dcae-deployments')); - app.use(POLICY_PATH, require('./lib/policy')); - app.use(SWAGGER_UI_PATH, require('./lib/swagger-ui')); - - /* Set up error handling */ - app.use(require('./lib/middleware').handleErrors); - /* Start the server */ var server = null; var usingTLS = false; @@ -105,7 +106,7 @@ const start = function(config) { server.listen(config.listenPort, config.listenHost, function(err) { var addr = server.address(); - var msg = ("Dispatcher version " + config.version + " listening on " + var msg = ("Deployment-handler version " + config.version + " listening on " + addr.address + ":" + addr.port + " pid: " + process.pid + (usingTLS ? " " : " not ") + "using TLS (HTTPS)"); log.metrics(null, {startTime: startTime, complete: true}, msg); @@ -143,7 +144,9 @@ conf.configure() .then(start) .catch(function(e) { log.error(e.logCode ? e : createError( - 'Dispatcher exiting due to start-up problem: ' + e.message, 500, + 'Deployment-handler exiting due to start-up problem: ' + e.message, 500, 'system', 552)); - console.error("Dispatcher exiting due to startup problem: " + e.message); -});
\ No newline at end of file + console.error("Deployment-handler exiting due to startup problem: " + e.message); +}); + +module.exports = app;
\ No newline at end of file |