2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
23 import LoopCache from '../api/LoopCache';
25 const json = require('./LoopCache_mokeLoopJsonCache.json');
27 describe('Verify LoopCache functions', () => {
28 const loopCache = new LoopCache(json);
29 it('getLoopName', () => {
30 expect(loopCache.getLoopName()).toBe("LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca");
33 it('getOperationalPolicyConfigurationJson', () => {
34 const opPolicyConfig = {
36 "operational_policy": {
41 expect(loopCache.getOperationalPolicyConfigurationJson()).toStrictEqual(opPolicyConfig);
44 it('getOperationalPolicies', () => {
46 "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca",
47 "configurationsJson": {
49 "operational_policy": {
56 expect(loopCache.getOperationalPolicies()).toStrictEqual(opPolicy);
59 it('getGlobalProperties', () => {
61 "dcaeDeployParameters": {
64 "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca"
67 expect(loopCache.getGlobalProperties()).toStrictEqual(globelProp);
70 it('getDcaeDeploymentProperties', () => {
71 const deploymentProp = {
74 "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca"
76 expect(loopCache.getDcaeDeploymentProperties()).toStrictEqual(deploymentProp);
79 it('getMicroServiceForName', () => {
81 "name": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca",
82 "modelType": "onap.policies.monitoring.cdap.tca.hi.lo.app",
83 "properties": {"domain": "measurementsForVfScaling"},
85 "jsonRepresentation": {"schema": {}}
87 expect(loopCache.getMicroServiceForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJson);
88 expect(loopCache.getMicroServiceForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull();
91 it('getMicroServicePropertiesForName', () => {
92 const msProp = {"domain": "measurementsForVfScaling"};
93 expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msProp);
94 expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull();
97 it('getMicroServiceJsonRepresentationForName', () => {
98 const msJsonRepresentation = {"schema": {}};
99 expect(loopCache.getMicroServiceJsonRepresentationForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJsonRepresentation);
102 it('getResourceDetailsVfProperty', () => {
104 "vLoadBalancerMS 0": {
105 "resourceVendor": "Test",
106 "resourceVendorModelNumber": "",
107 "name": "vLoadBalancerMS",
108 "description": "vLBMS",
109 "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506",
110 "subcategory": "Load Balancer",
111 "category": "Application L4+",
113 "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6",
115 "resourceVendorRelease": "1.0",
116 "customizationUUID": "465246dc-7748-45f4-a013-308d92922552"
119 expect(loopCache.getResourceDetailsVfProperty()).toStrictEqual(resourceVF);
122 it('getResourceDetailsVfModuleProperty', () => {
124 "Vloadbalancerms..vpkg..module-1": {
125 "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043",
126 "vfModuleModelVersion": "1",
127 "vfModuleModelName": "Vloadbalancerms..vpkg..module-1",
128 "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc",
129 "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52",
130 "min_vf_module_instances": 0,
131 "vf_module_label": "vpkg",
132 "max_vf_module_instances": 1,
133 "vf_module_type": "Expansion",
136 "volume_group": false
139 expect(loopCache.getResourceDetailsVfModuleProperty()).toStrictEqual(vfModule);
142 it('getLoopLogsArray', () => {
147 "logComponent": "CLAMP",
148 "message": "Operational and Guard policies UPDATED",
149 "logInstant": "2019-07-08T09:44:37Z"
152 expect(loopCache.getLoopLogsArray()).toStrictEqual(logs);
155 it('getComponentStates', () => {
159 "stateName": "NOT_SENT",
160 "description": "The policies defined have NOT yet been created on the policy engine"
165 "stateName": "BLUEPRINT_DEPLOYED",
166 "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop"
170 expect(loopCache.getComponentStates()).toStrictEqual(component);
173 it('updateGlobalProperties', () => {
174 const newGlobalProps = {
175 "dcaeDeployParameters": {
176 "location_id": "newLocation",
177 "service_id": "newServiceId",
178 "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2"
181 loopCache.updateGlobalProperties(newGlobalProps);
182 expect(loopCache.getGlobalProperties()).toStrictEqual(newGlobalProps);
185 it('updateOperationalPolicyProperties', () => {
186 const newOpPolicy = [{
187 "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca_new",
188 "configurationsJson": {
189 "guard_policies": {},
190 "operational_policy": {
196 loopCache.updateOperationalPolicyProperties(newOpPolicy);
197 expect(loopCache.getOperationalPolicies()).toStrictEqual(newOpPolicy);
200 it('updateMicroServiceProperties', () => {
201 const newMsPolicyProperties = {"domain": "measurementsForVfScalingNew"};
202 loopCache.updateMicroServiceProperties("TCA_h2NMX_v1_0_ResourceInstanceName1_tca", newMsPolicyProperties);
203 expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(newMsPolicyProperties);