From bfdffbbb60b0ee6cff12022bbb17bd075c1ffd51 Mon Sep 17 00:00:00 2001 From: Alex Shatov Date: Wed, 9 May 2018 12:31:48 -0400 Subject: 2.1.4 - fixed "value" argument is out of bounds - using the original "adm-zip": "0.4.7" because the latest "adm-zip": "0.4.9" is broken - external version 2.1.4, internal version 4.4.4 - unit test code coverage Statements : 83.99% ( 939/1118 ) Branches : 62.75% ( 320/510 ) Functions : 81.15% ( 155/191 ) Lines : 84.13% ( 928/1103 ) Change-Id: I7e82b1d7a51c562eb88cffbc12a0bfa0d92eebee Signed-off-by: Alex Shatov Issue-ID: DCAEGEN2-487 --- tests/test_dcae-deployments.js | 58 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_dcae-deployments.js b/tests/test_dcae-deployments.js index ea81278..a010017 100644 --- a/tests/test_dcae-deployments.js +++ b/tests/test_dcae-deployments.js @@ -24,7 +24,8 @@ const nock = require('nock') , chai = require('chai') , chaiHttp = require('chai-http') , expect = chai.expect - , assert = chai.assert; + , assert = chai.assert + , admzip = require('adm-zip'); chai.use(chaiHttp); @@ -103,7 +104,7 @@ const Inventory = { "owner": "dcaeorch", "typeName": "svc-type-000", "typeVersion": 1, - "blueprintTemplate": "--- \r\ntosca_definitions_version: cloudify_dsl_1_3\r\nimports: \r\n - \"http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\"\r\n - \"https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/dockerplugin/3.2.0/dockerplugin_types.yaml\"\r\n - \"https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/relationshipplugin/1.0.0/relationshipplugin_types.yaml\"\r\n - \"https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml\"\r\ninputs: \r\n aaiEnrichmentHost: \r\n default: none\r\n type: string\r\n aaiEnrichmentPort: \r\n default: 8443\r\n type: string\r\n cbs_host: \r\n default: config-binding-service.dcae\r\n type: string\r\n cbs_port: \r\n default: \"10000\"\r\n type: string\r\n consul_host: \r\n default: consul-server.onap-consul\r\n type: string\r\n consul_port: \r\n default: \"8500\"\r\n type: string\r\n dh_location_id: \r\n default: zone1\r\n type: string\r\n dh_override: \r\n default: component_dockerhost\r\n type: string\r\n dmaap_host: \r\n default: dmaap.onap-message-router\r\n type: string\r\n dmaap_port: \r\n default: 3904\r\n type: string\r\n enableAAIEnrichment: \r\n default: false\r\n type: string\r\n enableRedisCaching: \r\n default: false\r\n type: string\r\n external_port: \r\n default: \"32014\"\r\n description: \"Port for CDAPgui to be exposed\"\r\n type: string\r\n policy_id: \r\n default: none\r\n type: string\r\n redisHosts: \r\n type: string\r\n tag_version: \r\n default: \"nexus3.onap.org:10001/onap//onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.0.0\"\r\n type: string\r\nnode_templates: \r\n docker_service_host: \r\n properties: \r\n docker_host_override: \r\n get_input: dh_override\r\n location_id: \r\n get_input: dh_location_id\r\n type: dcae.nodes.SelectedDockerHost\r\n tca_docker: \r\n interfaces: \r\n cloudify.interfaces.lifecycle: \r\n start: \r\n inputs: \r\n envs: \r\n AAIHOST: \r\n get_input: aaiEnrichmentHost\r\n AAIPORT: \r\n get_input: aaiEnrichmentPort\r\n CBS_HOST: \r\n get_input: cbs_host\r\n CBS_PORT: \r\n get_input: cbs_port\r\n CONFIG_BINDING_SERVICE: config_binding_service\r\n CONSUL_HOST: \r\n get_input: consul_host\r\n CONSUL_PORT: \r\n get_input: consul_port\r\n DMAAPHOST: \r\n get_input: dmaap_host\r\n DMAAPPORT: \r\n get_input: dmaap_port\r\n DMAAPPUBTOPIC: unauthenticated.DCAE_CL_OUTPUT\r\n DMAAPSUBTOPIC: unauthenticated.SEC_MEASUREMENT_OUTPUT\r\n# SERVICE_11011_IGNORE: \"true\"\r\n SERVICE_11015_IGNORE: \"true\"\r\n ports:\r\n - concat: [\"11011:\", { get_input: external_port }] \r\n stop: \r\n inputs: \r\n cleanup_image: true\r\n properties: \r\n application_config: \r\n app_config: \r\n appDescription: \"DCAE Analytics Threshold Crossing Alert Application\"\r\n appName: dcae-tca\r\n tcaAlertsAbatementTableName: TCAAlertsAbatementTable\r\n tcaAlertsAbatementTableTTLSeconds: \"1728000\"\r\n tcaSubscriberOutputStreamName: TCASubscriberOutputStream\r\n tcaVESAlertsTableName: TCAVESAlertsTable\r\n tcaVESAlertsTableTTLSeconds: \"1728000\"\r\n tcaVESMessageStatusTableName: TCAVESMessageStatusTable\r\n tcaVESMessageStatusTableTTLSeconds: \"86400\"\r\n thresholdCalculatorFlowletInstances: \"2\"\r\n app_preferences: \r\n aaiEnrichmentHost: \r\n get_input: aaiEnrichmentHost\r\n aaiEnrichmentIgnoreSSLCertificateErrors: \"true\"\r\n aaiEnrichmentPortNumber: \"8443\"\r\n aaiEnrichmentProtocol: https\r\n aaiEnrichmentUserName: DCAE\r\n aaiEnrichmentUserPassword: DCAE\r\n aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query\r\n aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf\r\n enableAAIEnrichment: \r\n get_input: enableAAIEnrichment\r\n enableAlertCEFFormat: \"false\"\r\n enableRedisCaching: \r\n get_input: enableRedisCaching\r\n publisherContentType: application/json\r\n publisherHostName: \r\n get_input: dmaap_host\r\n publisherHostPort: \r\n get_input: dmaap_port\r\n publisherMaxBatchSize: \"1\"\r\n publisherMaxRecoveryQueueSize: \"100000\"\r\n publisherPollingInterval: \"20000\"\r\n publisherProtocol: http\r\n publisherTopicName: unauthenticated.DCAE_CL_OUTPUT\r\n redisHosts: \r\n get_input: redisHosts\r\n subscriberConsumerGroup: OpenDCAE-c12\r\n subscriberConsumerId: c12\r\n subscriberContentType: application/json\r\n subscriberHostName: \r\n get_input: dmaap_host\r\n subscriberHostPort: \r\n get_input: dmaap_port\r\n subscriberMessageLimit: \"-1\"\r\n subscriberPollingInterval: \"30000\"\r\n subscriberProtocol: http\r\n subscriberTimeoutMS: \"-1\"\r\n subscriberTopicName: unauthenticated.SEC_MEASUREMENT_OUTPUT\r\n tca_policy: \"{\\\"domain\\\":\\\"measurementsForVfScaling\\\",\\\"metricsPerEventName\\\":[{\\\"eventName\\\":\\\"vFirewallBroadcastPackets\\\",\\\"controlLoopSchemaType\\\":\\\"VNF\\\",\\\"policyScope\\\":\\\"DCAE\\\",\\\"policyName\\\":\\\"DCAE.Config_tca-hi-lo\\\",\\\"policyVersion\\\":\\\"v0.0.1\\\",\\\"thresholds\\\":[{\\\"closedLoopControlName\\\":\\\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\\\",\\\"version\\\":\\\"1.0.2\\\",\\\"fieldPath\\\":\\\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta\\\",\\\"thresholdValue\\\":300,\\\"direction\\\":\\\"LESS_OR_EQUAL\\\",\\\"severity\\\":\\\"MAJOR\\\",\\\"closedLoopEventStatus\\\":\\\"ONSET\\\"},{\\\"closedLoopControlName\\\":\\\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\\\",\\\"version\\\":\\\"1.0.2\\\",\\\"fieldPath\\\":\\\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta\\\",\\\"thresholdValue\\\":700,\\\"direction\\\":\\\"GREATER_OR_EQUAL\\\",\\\"severity\\\":\\\"CRITICAL\\\",\\\"closedLoopEventStatus\\\":\\\"ONSET\\\"}]},{\\\"eventName\\\":\\\"vLoadBalancer\\\",\\\"controlLoopSchemaType\\\":\\\"VM\\\",\\\"policyScope\\\":\\\"DCAE\\\",\\\"policyName\\\":\\\"DCAE.Config_tca-hi-lo\\\",\\\"policyVersion\\\":\\\"v0.0.1\\\",\\\"thresholds\\\":[{\\\"closedLoopControlName\\\":\\\"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3\\\",\\\"version\\\":\\\"1.0.2\\\",\\\"fieldPath\\\":\\\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta\\\",\\\"thresholdValue\\\":300,\\\"direction\\\":\\\"GREATER_OR_EQUAL\\\",\\\"severity\\\":\\\"CRITICAL\\\",\\\"closedLoopEventStatus\\\":\\\"ONSET\\\"}]},{\\\"eventName\\\":\\\"Measurement_vGMUX\\\",\\\"controlLoopSchemaType\\\":\\\"VNF\\\",\\\"policyScope\\\":\\\"DCAE\\\",\\\"policyName\\\":\\\"DCAE.Config_tca-hi-lo\\\",\\\"policyVersion\\\":\\\"v0.0.1\\\",\\\"thresholds\\\":[{\\\"closedLoopControlName\\\":\\\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\\\",\\\"version\\\":\\\"1.0.2\\\",\\\"fieldPath\\\":\\\"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\\\",\\\"thresholdValue\\\":0,\\\"direction\\\":\\\"EQUAL\\\",\\\"severity\\\":\\\"MAJOR\\\",\\\"closedLoopEventStatus\\\":\\\"ABATED\\\"},{\\\"closedLoopControlName\\\":\\\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\\\",\\\"version\\\":\\\"1.0.2\\\",\\\"fieldPath\\\":\\\"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\\\",\\\"thresholdValue\\\":0,\\\"direction\\\":\\\"GREATER\\\",\\\"severity\\\":\\\"CRITICAL\\\",\\\"closedLoopEventStatus\\\":\\\"ONSET\\\"}]}]}\"\r\n docker_config: \r\n healthcheck: \r\n endpoint: /\r\n interval: 15s\r\n timeout: 1s\r\n type: http\r\n image: \r\n get_input: tag_version\r\n service_component_type: dcaegen2-analytics_tca\r\n relationships: \r\n - \r\n target: docker_service_host\r\n type: dcae.relationships.component_contained_in\r\n - \r\n target: tca_policy\r\n type: cloudify.relationships.depends_on\r\n type: dcae.nodes.DockerContainerForComponentsUsingDmaap\r\n tca_policy: \r\n properties: \r\n policy_id: \r\n get_input: policy_id\r\n type: dcae.nodes.policy\r\n", + "blueprintTemplate": "tosca_definitions_version: cloudify_dsl_1_3\nimports:\n - \"http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\"\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/dockerplugin/3.2.0/dockerplugin_types.yaml\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/relationshipplugin/1.0.0/relationshipplugin_types.yaml\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml\n\ninputs:\n dh_override:\n type: string\n default: \"dockerhost\"\n dh_location_id:\n type: string\n default: \"zone1\"\n aaiEnrichmentHost:\n type: string\n default: \"none\"\n aaiEnrichmentPort:\n type: string \n default: 8443\n enableAAIEnrichment:\n type: string\n default: false\n dmaap_host:\n type: string\n default: dmaap.onap-message-router \n dmaap_port:\n type: string\n default: 3904 \n enableRedisCaching:\n type: string\n default: false \n redisHosts:\n type: string \n tag_version:\n type: string\n default: \"nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.0.0\"\n consul_host:\n type: string\n default: consul-server.onap-consul\n consul_port:\n type: string\n default: \"8500\"\n cbs_host:\n type: string\n default: \"config-binding-service.dcae\"\n cbs_port:\n type: string\n default: \"10000\"\n policy_id:\n type: string\n default: \"none\"\n external_port:\n type: string\n description: \"Port for CDAPgui to be exposed\"\n default: \"32010\"\n scn_name: \n default: dcaegen2-analytics_tca_clampinstance_1\n type: string\nnode_templates:\n docker_service_host:\n properties:\n docker_host_override:\n get_input: dh_override\n location_id:\n get_input: dh_location_id\n type: dcae.nodes.SelectedDockerHost\n tca_docker:\n relationships:\n - type: dcae.relationships.component_contained_in\n target: docker_service_host\n - target: tca_policy\n type: cloudify.relationships.depends_on \n type: dcae.nodes.DockerContainerForComponentsUsingDmaap\n properties:\n application_config:\n app_config:\n appDescription: DCAE Analytics Threshold Crossing Alert Application\n appName: dcae-tca\n tcaAlertsAbatementTableName: TCAAlertsAbatementTable\n tcaAlertsAbatementTableTTLSeconds: '1728000'\n tcaSubscriberOutputStreamName: TCASubscriberOutputStream\n tcaVESAlertsTableName: TCAVESAlertsTable\n tcaVESAlertsTableTTLSeconds: '1728000'\n tcaVESMessageStatusTableName: TCAVESMessageStatusTable\n tcaVESMessageStatusTableTTLSeconds: '86400'\n thresholdCalculatorFlowletInstances: '2'\n app_preferences:\n aaiEnrichmentHost: \n get_input: aaiEnrichmentHost\n aaiEnrichmentIgnoreSSLCertificateErrors: 'true'\n aaiEnrichmentPortNumber: '8443'\n aaiEnrichmentProtocol: https\n aaiEnrichmentUserName: DCAE\n aaiEnrichmentUserPassword: DCAE\n aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query\n aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf\n enableAAIEnrichment: \n get_input: enableAAIEnrichment\n enableRedisCaching: \n get_input: enableRedisCaching\n redisHosts: \n get_input: redisHosts\n enableAlertCEFFormat: 'false'\n publisherContentType: application/json\n publisherHostName: \n get_input: dmaap_host\n publisherHostPort: \n get_input: dmaap_port \n publisherMaxBatchSize: '1'\n publisherMaxRecoveryQueueSize: '100000'\n publisherPollingInterval: '20000'\n publisherProtocol: http\n publisherTopicName: unauthenticated.DCAE_CL_OUTPUT\n subscriberConsumerGroup: OpenDCAE-c12\n subscriberConsumerId: c12\n subscriberContentType: application/json\n subscriberHostName: \n get_input: dmaap_host\n subscriberHostPort:\n get_input: dmaap_port \n subscriberMessageLimit: '-1'\n subscriberPollingInterval: '30000'\n subscriberProtocol: http\n subscriberTimeoutMS: '-1'\n subscriberTopicName: unauthenticated.SEC_MEASUREMENT_OUTPUT\n tca_policy_default: '{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"vFirewallBroadcastPackets\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ONSET\"},{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":700,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"Measurement_vGMUX\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"GREATER\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]}]}'\n service_component_type: dcaegen2-analytics_tca \n docker_config:\n healthcheck:\n endpoint: /\n interval: 15s\n timeout: 1s\n type: http\n image:\n get_input: tag_version \n service_component_name_override: \n get_input: scn_name \n interfaces:\n cloudify.interfaces.lifecycle:\n start:\n inputs:\n envs:\n DMAAPHOST: \n { get_input: dmaap_host }\n DMAAPPORT:\n { get_input: dmaap_port }\n DMAAPPUBTOPIC: \"unauthenticated.DCAE_CL_OUTPUT\"\n DMAAPSUBTOPIC: \"unauthenticated.SEC_MEASUREMENT_OUTPUT\"\n AAIHOST: \n { get_input: aaiEnrichmentHost }\n AAIPORT: \n { get_input: aaiEnrichmentPort }\n CONSUL_HOST: \n { get_input: consul_host }\n CONSUL_PORT: \n { get_input: consul_port }\n CBS_HOST: \n { get_input: cbs_host }\n CBS_PORT: \n { get_input: cbs_port }\n CONFIG_BINDING_SERVICE: \"config_binding_service\" \n SERVICE_11011_NAME: \n { get_input: scn_name }\n SERVICE_11015_IGNORE: \"true\" \n ports:\n - concat: [\"11011:\", { get_input: external_port }] \n stop:\n inputs:\n cleanup_image: true \n tca_policy:\n type: dcae.nodes.policy\n properties:\n policy_id:\n get_input: policy_id\n", "serviceIds": null, "vnfTypes": ["TESTVNF000"], "serviceLocations": null, @@ -567,7 +568,60 @@ function test_delete_dcae_deployments_success(dh_server) { }); } +function test_zipper(dh_server) { + const test_txt = 'zip the blueprint'; + describe(test_txt, () => { + it(test_txt, function() { + var blueprint = ""; + const failed_blueprints = []; + const success_blueprints = []; + const action_timer = new utils.ActionTimer(); + console.log(action_timer.step, test_txt); + + return utils.sleep(100).then(function() { + console.log("starting test_zipper"); + var first_exc; + for (var i=0; i< 100; i++) { + blueprint = blueprint + (i % 10); + try { + const zip = new admzip(); + zip.addFile('work/', new Buffer(0)); + zip.addFile('work/blueprint.yaml', new Buffer(blueprint, 'utf8')); + const zip_buffer = zip.toBuffer(); + success_blueprints.push(blueprint); + } catch (e) { + // TypeError + const error = "failed to zip: " + e.message + + " " + (e.stack || "").replace(/\n/g, " ") + + "blueprint(" + blueprint + ")"; + console.error(error); + failed_blueprints.push(blueprint); + if (!first_exc) { + first_exc = e; + first_exc.blueprint = blueprint; + } + } + } + console.log("success", success_blueprints.length / (failed_blueprints.length + success_blueprints.length)); + console.log("failed_blueprints", failed_blueprints); + console.log("success_blueprints", success_blueprints); + if (first_exc) { + throw first_exc; + } + }) + .catch(function(e) { + const error = "test of zipper exiting due to test problem: " + e.message + + " " + (e.stack || "").replace(/\n/g, " ") + "blueprint(" + e.blueprint + ")"; + console.error(error); + throw e; + }); + }); + }); +} + + dh.add_tests([ + test_zipper, test_get_dcae_deployments, test_get_dcae_deployments_service_type_unknown, test_put_dcae_deployments_i_dont_know, -- cgit 1.2.3-korg