aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_dcae-deployments.js
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2019-02-05 13:03:53 -0500
committerAlex Shatov <alexs@att.com>2019-02-05 13:03:53 -0500
commit12c8d505c49b8b999660c52872a66071a9abc4c6 (patch)
tree131ee82476ec1c2d389d4c2db2198754111cc1f8 /tests/test_dcae-deployments.js
parentca00a932eae5e706f01519612fce1015c9ff9d58 (diff)
3.2.0/5.2.0 - fixed zip folder bug by admzip lib
- external version 3.2.0 - internal version 5.2.0 for code change - no API change - fixed the zip folder bug when sending the blueprint to cloudify = this bug was preventing the opening of the blueprint in cloudify UI because the folder record was not properly formatted by admzip lib 0.4.7 - upgraded adm-zip lib to the latest version 0.4.13 - unit tested the zipping of the blueprint file under subfolder without having the subfolder record in zip = manual unzip in linux shows proper subfolder/file structure = automatic unzip is not supported by the old ubuntu = would need upgrading the node.js/ubuntu and installing unzip for proper testing - see code comments in unit-test - zip file created by admzip unzips properly both in linux and in Windows = zip still has some header warnings, but not critical unit test coverage summary Statements : 80.94% ( 943/1165 ) Branches : 58.22% ( 294/505 ) Functions : 81.28% ( 165/203 ) Lines : 81.48% ( 933/1145 ) Change-Id: I48e44f025c21ef51de5a7422c8db9433581c787f Signed-off-by: Alex Shatov <alexs@att.com> Issue-ID: DCAEGEN2-855
Diffstat (limited to 'tests/test_dcae-deployments.js')
-rw-r--r--tests/test_dcae-deployments.js51
1 files changed, 32 insertions, 19 deletions
diff --git a/tests/test_dcae-deployments.js b/tests/test_dcae-deployments.js
index 7bf9831..2f3f7fd 100644
--- a/tests/test_dcae-deployments.js
+++ b/tests/test_dcae-deployments.js
@@ -1,5 +1,5 @@
/*
-Copyright(c) 2018 AT&T Intellectual Property. All rights reserved.
+Copyright(c) 2018-2019 AT&T Intellectual Property. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@ See the License for the specific language governing permissions and limitations
"use strict";
+const fs = require("fs");
+
const nock = require('nock')
, chai = require('chai')
, chaiHttp = require('chai-http')
@@ -354,7 +356,7 @@ function test_put_dcae_deployments_missing_input_error(dh_server) {
return "";
});
- nock(dh.CLOUDIFY_URL).put("/api/v2.1/blueprints/" + DEPLOYMENT_ID_JFL)
+ nock(dh.CLOUDIFY_URL).put(dh.CLOUDIFY_API + "/blueprints/" + DEPLOYMENT_ID_JFL)
.reply(200, function(uri, requestBody) {
console.log(action_timer.step, "put", dh.CLOUDIFY_URL, uri, JSON.stringify(requestBody));
return JSON.stringify(Cloudify.resp_blueprint(DEPLOYMENT_ID_JFL));
@@ -365,7 +367,7 @@ function test_put_dcae_deployments_missing_input_error(dh_server) {
"error_code": "missing_required_deployment_input_error",
"server_traceback": "Traceback blah..."
};
- nock(dh.CLOUDIFY_URL).put("/api/v2.1/deployments/" + DEPLOYMENT_ID_JFL)
+ nock(dh.CLOUDIFY_URL).put(dh.CLOUDIFY_API + "/deployments/" + DEPLOYMENT_ID_JFL)
.reply(400, function(uri) {
console.log(action_timer.step, "put", dh.CLOUDIFY_URL, uri);
return JSON.stringify(depl_rejected);
@@ -411,19 +413,19 @@ function test_put_dcae_deployments_creation_failed(dh_server) {
return JSON.stringify(Inventory.resp_put_service(DEPLOYMENT_ID_JFL_1, INV_EXISTING_SERVICE_TYPE));
});
- nock(dh.CLOUDIFY_URL).put("/api/v2.1/blueprints/" + DEPLOYMENT_ID_JFL_1)
+ nock(dh.CLOUDIFY_URL).put(dh.CLOUDIFY_API + "/blueprints/" + DEPLOYMENT_ID_JFL_1)
.reply(200, function(uri, requestBody) {
console.log(action_timer.step, "put", dh.CLOUDIFY_URL, uri, JSON.stringify(requestBody));
return JSON.stringify(Cloudify.resp_blueprint(DEPLOYMENT_ID_JFL_1));
});
- nock(dh.CLOUDIFY_URL).put("/api/v2.1/deployments/" + DEPLOYMENT_ID_JFL_1)
+ nock(dh.CLOUDIFY_URL).put(dh.CLOUDIFY_API + "/deployments/" + DEPLOYMENT_ID_JFL_1)
.reply(201, function(uri, requestBody) {
console.log(action_timer.step, "put", dh.CLOUDIFY_URL, uri, JSON.stringify(requestBody));
return JSON.stringify(Cloudify.resp_deploy(DEPLOYMENT_ID_JFL_1, DEPLOYMENT_ID_JFL_1, message.inputs));
});
- nock(dh.CLOUDIFY_URL).get("/api/v2.1/executions?deployment_id=" + DEPLOYMENT_ID_JFL_1 + "&workflow_id=create_deployment_environment&_include=id,status")
+ nock(dh.CLOUDIFY_URL).get(dh.CLOUDIFY_API + "/executions?deployment_id=" + DEPLOYMENT_ID_JFL_1 + "&workflow_id=create_deployment_environment&_include=id,status")
.reply(200, function(uri) {
console.log(action_timer.step, "get", dh.CLOUDIFY_URL, uri);
return JSON.stringify(Cloudify.resp_dep_creation(DEPLOYMENT_ID_JFL_1, execution_id, "failed"));
@@ -471,37 +473,37 @@ function test_put_dcae_deployments_success(dh_server) {
return JSON.stringify(Inventory.resp_put_service(DEPLOYMENT_ID_JFL_1, INV_EXISTING_SERVICE_TYPE));
});
- nock(dh.CLOUDIFY_URL).put("/api/v2.1/blueprints/" + DEPLOYMENT_ID_JFL_1)
+ nock(dh.CLOUDIFY_URL).put(dh.CLOUDIFY_API + "/blueprints/" + DEPLOYMENT_ID_JFL_1)
.reply(200, function(uri, requestBody) {
console.log(action_timer.step, "put", dh.CLOUDIFY_URL, uri, JSON.stringify(requestBody));
return JSON.stringify(Cloudify.resp_blueprint(DEPLOYMENT_ID_JFL_1));
});
- nock(dh.CLOUDIFY_URL).put("/api/v2.1/deployments/" + DEPLOYMENT_ID_JFL_1)
+ nock(dh.CLOUDIFY_URL).put(dh.CLOUDIFY_API + "/deployments/" + DEPLOYMENT_ID_JFL_1)
.reply(201, function(uri, requestBody) {
console.log(action_timer.step, "put", dh.CLOUDIFY_URL, uri, JSON.stringify(requestBody));
return JSON.stringify(Cloudify.resp_deploy(DEPLOYMENT_ID_JFL_1, DEPLOYMENT_ID_JFL_1, message.inputs));
});
- nock(dh.CLOUDIFY_URL).get("/api/v2.1/executions?deployment_id=" + DEPLOYMENT_ID_JFL_1 + "&workflow_id=create_deployment_environment&_include=id,status")
+ nock(dh.CLOUDIFY_URL).get(dh.CLOUDIFY_API + "/executions?deployment_id=" + DEPLOYMENT_ID_JFL_1 + "&workflow_id=create_deployment_environment&_include=id,status")
.reply(200, function(uri) {
console.log(action_timer.step, "get", dh.CLOUDIFY_URL, uri);
return JSON.stringify(Cloudify.resp_dep_creation(DEPLOYMENT_ID_JFL_1, execution_id));
});
- nock(dh.CLOUDIFY_URL).post("/api/v2.1/executions")
+ nock(dh.CLOUDIFY_URL).post(dh.CLOUDIFY_API + "/executions")
.reply(201, function(uri, requestBody) {
console.log(action_timer.step, "post", dh.CLOUDIFY_URL, uri, JSON.stringify(requestBody));
return JSON.stringify(Cloudify.resp_execution(DEPLOYMENT_ID_JFL_1, DEPLOYMENT_ID_JFL_1, execution_id));
});
- nock(dh.CLOUDIFY_URL).get("/api/v2.1/executions/" + execution_id)
+ nock(dh.CLOUDIFY_URL).get(dh.CLOUDIFY_API + "/executions/" + execution_id)
.reply(200, function(uri) {
console.log(action_timer.step, "get", dh.CLOUDIFY_URL, uri);
return JSON.stringify(Cloudify.resp_execution(DEPLOYMENT_ID_JFL_1, DEPLOYMENT_ID_JFL_1, execution_id, true));
});
- nock(dh.CLOUDIFY_URL).get("/api/v2.1/deployments/" + DEPLOYMENT_ID_JFL_1 + "/outputs")
+ nock(dh.CLOUDIFY_URL).get(dh.CLOUDIFY_API + "/deployments/" + DEPLOYMENT_ID_JFL_1 + "/outputs")
.reply(200, function(uri) {
console.log(action_timer.step, "get", dh.CLOUDIFY_URL, uri);
return JSON.stringify(Cloudify.resp_outputs(DEPLOYMENT_ID_JFL_1));
@@ -536,7 +538,7 @@ function test_get_dcae_deployments_operation(dh_server) {
it('Get operation execution succeeded', function() {
const action_timer = new utils.ActionTimer();
console.log(action_timer.step, test_txt);
- nock(dh.CLOUDIFY_URL).get("/api/v2.1/executions/" + execution_id)
+ nock(dh.CLOUDIFY_URL).get(dh.CLOUDIFY_API + "/executions/" + execution_id)
.reply(200, function(uri) {
console.log(action_timer.step, "get", dh.CLOUDIFY_URL, uri);
return JSON.stringify(Cloudify.resp_execution(DEPLOYMENT_ID_JFL_1, DEPLOYMENT_ID_JFL_1, execution_id, true));
@@ -600,7 +602,7 @@ function test_delete_dcae_deployments_success(dh_server) {
const action_timer = new utils.ActionTimer();
console.log(action_timer.step, test_txt);
- nock(dh.CLOUDIFY_URL).post("/api/v2.1/executions")
+ nock(dh.CLOUDIFY_URL).post(dh.CLOUDIFY_API + "/executions")
.reply(201, function(uri, requestBody) {
console.log(action_timer.step, "post", dh.CLOUDIFY_URL, uri, JSON.stringify(requestBody));
return JSON.stringify(Cloudify.resp_execution(DEPLOYMENT_ID_JFL_1, DEPLOYMENT_ID_JFL_1,
@@ -613,20 +615,20 @@ function test_delete_dcae_deployments_success(dh_server) {
return "";
});
- nock(dh.CLOUDIFY_URL).get("/api/v2.1/executions/" + execution_id)
+ nock(dh.CLOUDIFY_URL).get(dh.CLOUDIFY_API + "/executions/" + execution_id)
.reply(200, function(uri) {
console.log(action_timer.step, "get", dh.CLOUDIFY_URL, uri);
return JSON.stringify(Cloudify.resp_execution(DEPLOYMENT_ID_JFL_1, DEPLOYMENT_ID_JFL_1,
execution_id, true, workflow_id));
});
- nock(dh.CLOUDIFY_URL).delete("/api/v2.1/deployments/" + DEPLOYMENT_ID_JFL_1)
+ nock(dh.CLOUDIFY_URL).delete(dh.CLOUDIFY_API + "/deployments/" + DEPLOYMENT_ID_JFL_1)
.reply(201, function(uri) {
console.log(action_timer.step, "delete", dh.CLOUDIFY_URL, uri);
return JSON.stringify(Cloudify.resp_deploy(DEPLOYMENT_ID_JFL_1, DEPLOYMENT_ID_JFL_1));
});
- nock(dh.CLOUDIFY_URL).delete("/api/v2.1/blueprints/" + DEPLOYMENT_ID_JFL_1)
+ nock(dh.CLOUDIFY_URL).delete(dh.CLOUDIFY_API + "/blueprints/" + DEPLOYMENT_ID_JFL_1)
.reply(200, function(uri) {
console.log(action_timer.step, "delete", dh.CLOUDIFY_URL, uri);
return JSON.stringify(Cloudify.resp_blueprint(DEPLOYMENT_ID_JFL_1));
@@ -667,10 +669,21 @@ function test_zipper(dh_server) {
for (var i=0; i< 100; i++) {
blueprint = blueprint + (i % 10);
try {
+ const zip_folder = "zip_blueprint_" + ('0' + i).substr(-2);
+ const zip_path = dh.LOG_PATH + zip_folder + ".zip";
+
const zip = new admzip();
- zip.addFile('work/', new Buffer(0));
- zip.addFile('work/blueprint.yaml', new Buffer(blueprint, 'utf8'));
+ // no need for separate folder entry like 'work/' in zip
+ // zip file created by admzip unzips properly in linux, but not in Windows :-(
+ zip.addFile(zip_folder + '/blueprint.yaml', Buffer.from(blueprint, 'utf8'));
const zip_buffer = zip.toBuffer();
+ fs.writeFileSync(zip_path, zip_buffer);
+
+ // gave up on unzipping in old ubuntu that fails to have unzip installed
+ // uncomment the next lines if you have unzip in os to properly test
+ // execSync('unzip ' + zip_folder + ".zip", {"cwd": dh.LOG_PATH});
+ // const bp_from_file = fs.readFileSync(dh.LOG_PATH + zip_folder + '/blueprint.yaml').toString('utf8');
+ // expect(bp_from_file).to.be.equal(blueprint);
success_blueprints.push(blueprint);
} catch (e) {
// TypeError