From a339f93a736c9503888d05e47d79b173229042fc Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Tue, 5 Mar 2019 16:56:09 -0500 Subject: improvements to audit inventory feature Adjust test data to add tenant mapping Remove unused unit test already renamed Update logic, to pass hostname not pservername remove unused file that has been refactored Add project to ignore, remove class Address issues in comments on pull request Remove logging that is not needed, used UPdate BPMN to use Boolean Value, change timings Adjust BPMN to not hit deadlock scenario put error message in execution before checking rollback - removed extra code for vnf resource processing found in onap environment. Fix improper use of inclusive gateway causing deadlock Fix flakey unit tests from ONAP Remove qualifier on bean, as it breaks callbacks Adjust pom version of external camunda client Fix polling timers to be more reasonable Updated Junit test for delete vf module in onap. Changed auditInventoryNeeded variable to a boolean to prevent bpmn from erroring out in the event this variable is not found on the execution. Update logic to support writing of self link Change-Id: I2f784a0a58a09f303775282c9be6019031668570 Issue-ID: SO-1597 Signed-off-by: Benjamin, Max (mb388a) --- adapters/mso-openstack-adapters/pom.xml | 142 ++++++++++++------- .../so/adapters/audit/AuditCreateStackService.java | 94 +++++++++++++ .../so/adapters/audit/AuditDeleteStackService.java | 90 +++++++++++++ .../onap/so/adapters/audit/AuditStackService.java | 30 ++++- .../so/adapters/audit/AuditStackServiceData.java | 95 ------------- .../org/onap/so/adapters/audit/AuditVServer.java | 17 ++- .../org/onap/so/adapters/audit/HeatStackAudit.java | 56 +++++--- .../so/adapters/network/NetworkAdapterRest.java | 1 + .../org/onap/so/adapters/vnf/BpelRestClient.java | 2 +- .../src/main/resources/application.yaml | 15 ++- .../audit/AuditCreateStackServiceTest.java | 150 +++++++++++++++++++++ .../adapters/audit/AuditStackServiceDataTest.java | 150 --------------------- .../onap/so/adapters/audit/AuditVServerTest.java | 42 ++++-- .../onap/so/adapters/audit/HeatStackAuditTest.java | 2 +- .../vnf/MsoVnfMulticloudAdapterImplTest.java | 2 +- 15 files changed, 557 insertions(+), 331 deletions(-) create mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java create mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java create mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java delete mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java (limited to 'adapters/mso-openstack-adapters') diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index f2f411d5b6..cb35e90860 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -13,8 +13,8 @@ ${project.artifactId}-${project.version} - - + + org.apache.maven.plugins maven-dependency-plugin @@ -36,25 +36,75 @@ - + org.jacoco jacoco-maven-plugin @@ -76,12 +126,12 @@ - - - + + + - org.eclipse.m2e @@ -118,10 +168,10 @@ - + - org.springframework.boot - spring-boot-starter-actuator + org.springframework.boot + spring-boot-starter-actuator org.springframework.boot @@ -134,7 +184,7 @@ org.apache.cxf cxf-spring-boot-starter-jaxws - ${cxf.version} + ${cxf.version} org.apache.cxf @@ -142,9 +192,9 @@ ${cxf.version} - org.apache.cxf - cxf-rt-rs-service-description-swagger - ${cxf.version} + org.apache.cxf + cxf-rt-rs-service-description-swagger + ${cxf.version} org.webjars @@ -157,16 +207,16 @@ test - janino - janino - 2.5.15 + janino + janino + 2.5.15 - - - - - - + + + + + + org.onap.so.adapters mso-adapter-utils @@ -181,11 +231,11 @@ javax.servlet javax.servlet-api test - + org.mariadb.jdbc mariadb-java-client - + org.onap.so common @@ -214,9 +264,9 @@ ${openstack.version} - org.camunda.bpm - camunda-external-task-client - 1.0.0 - + org.camunda.bpm + camunda-external-task-client + 1.1.1 + diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java new file mode 100644 index 0000000000..24980ae4e0 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.audit; + +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.audit.beans.AuditInventory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +public class AuditCreateStackService { + + private static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI = "Unable to find all VServers and L-Interaces in A&AI"; + + private static final int[] RETRY_SEQUENCE = new int[] { 1, 1, 2, 3, 5, 8, 13, 20}; + + + private static final Logger logger = LoggerFactory.getLogger(AuditCreateStackService.class); + + @Autowired + public HeatStackAudit heatStackAudit; + + @Autowired + public Environment env; + + protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService){ + AuditInventory auditInventory = externalTask.getVariable("auditInventory"); + setupMDC(externalTask); + boolean success = false; + try { + logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,externalTask.getRetries()); + success=heatStackAudit.auditHeatStackCreate(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(), + auditInventory.getTenantId(), auditInventory.getHeatStackName()); + } catch (Exception e) { + logger.error("Error during audit of stack", e); + } + + if (success) { + externalTaskService.complete(externalTask); + logger.debug("The External Task Id: {} Successful", externalTask.getId()); + } else { + if(externalTask.getRetries() == null){ + logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}", externalTask.getId(),RETRY_SEQUENCE.length); + externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, RETRY_SEQUENCE.length, 10000); + }else if(externalTask.getRetries() != null && + externalTask.getRetries()-1 == 0){ + logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId()); + externalTaskService.handleBpmnError(externalTask, "AuditAAIInventoryFailure", "Number of Retries Exceeded auditing inventory"); + }else{ + logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(),externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); + externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); + } + logger.debug("The External Task Id: {} Failed", externalTask.getId()); + } + + + } + private void setupMDC(ExternalTask externalTask) { + String msoRequestId = externalTask.getVariable("mso-request-id"); + if(msoRequestId != null && !msoRequestId.isEmpty()) + MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId); + } + protected long calculateRetryDelay(int currentRetries){ + int retrySequence = RETRY_SEQUENCE.length - currentRetries; + long retryMultiplier = Long.parseLong(env.getProperty("mso.workflow.topics.retryMultiplier","6000")); + return RETRY_SEQUENCE[retrySequence] * retryMultiplier; + } +} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java new file mode 100644 index 0000000000..66d8fbd47c --- /dev/null +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017-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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.audit; + +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.audit.beans.AuditInventory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +public class AuditDeleteStackService { + + private static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI = "All VServers have not been deleted in A&AI"; + + private static final int[] RETRY_SEQUENCE = new int[] { 1, 1, 2, 3, 5, 8, 13, 20}; + + + private static final Logger logger = LoggerFactory.getLogger(AuditDeleteStackService.class); + + @Autowired + public HeatStackAudit heatStackAudit; + + @Autowired + public Environment env; + + protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService){ + AuditInventory auditInventory = externalTask.getVariable("auditInventory"); + setupMDC(externalTask); + boolean success = false; + try { + logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,externalTask.getRetries()); + success=heatStackAudit.auditHeatStackDeleted(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(), + auditInventory.getTenantId(), auditInventory.getHeatStackName()); + } catch (Exception e) { + logger.error("Error during audit of stack", e); + } + + if (success) { + externalTaskService.complete(externalTask); + logger.debug("The External Task Id: {} Successful", externalTask.getId()); + } else { + if(externalTask.getRetries() == null){ + logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}", externalTask.getId(),RETRY_SEQUENCE.length); + externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, RETRY_SEQUENCE.length, 10000); + }else if(externalTask.getRetries() != null && + externalTask.getRetries()-1 == 0){ + logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId()); + externalTaskService.complete(externalTask); + }else{ + logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(),externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); + externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); + } + logger.debug("The External Task Id: {} Failed", externalTask.getId()); + } + } + private void setupMDC(ExternalTask externalTask) { + String msoRequestId = (String)externalTask.getVariable("mso-request-id"); + if(msoRequestId != null && !msoRequestId.isEmpty()) + MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId); + } + protected long calculateRetryDelay(int currentRetries){ + int retrySequence = RETRY_SEQUENCE.length - currentRetries; + long retryMultiplier = Long.parseLong(env.getProperty("mso.workflow.topics.retryMultiplier","6000")); + return RETRY_SEQUENCE[retrySequence] * retryMultiplier; + } +} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java index 499c1137c7..6ea14dcac7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java @@ -46,10 +46,30 @@ public class AuditStackService { public Environment env; @Autowired - private AuditStackServiceData auditStack; + private AuditCreateStackService auditCreateStack; + + @Autowired + private AuditDeleteStackService auditDeleteStack; @PostConstruct - public void auditAAIInventory() { + public void auditAddAAIInventory() { + String auth = ""; + try { + auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey")); + } catch (IllegalStateException | GeneralSecurityException e) { + logger.error("Error Decrypting Password", e); + } + ClientRequestInterceptor interceptor = new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), + auth); + ExternalTaskClient client = ExternalTaskClient.create() + .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor) + .asyncResponseTimeout(120000).build(); + client.subscribe("InventoryAddAudit").lockDuration(60000) + .handler(auditCreateStack::executeExternalTask).open(); + } + + @PostConstruct + public void auditDeleteAAIInventory() { String auth = ""; try { auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey")); @@ -60,9 +80,9 @@ public class AuditStackService { auth); ExternalTaskClient client = ExternalTaskClient.create() .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor) - .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(10000, 2, 120000)).build(); - client.subscribe("InventoryAudit").lockDuration(60000) - .handler(auditStack::executeExternalTask).open(); + .asyncResponseTimeout(120000).build(); + client.subscribe("InventoryDeleteAudit").lockDuration(60000) + .handler(auditDeleteStack::executeExternalTask).open(); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java deleted file mode 100644 index 773705d566..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.audit; - - -import org.camunda.bpm.client.task.ExternalTask; -import org.camunda.bpm.client.task.ExternalTaskService; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.audit.beans.AuditInventory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -@Component -public class AuditStackServiceData { - - private static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI = "Unable to find all VServers and L-Interaces in A&AI"; - - private static final int[] RETRY_SEQUENCE = new int[] { 1, 1, 2, 3, 5, 8, 13, 20}; - - - private static final Logger logger = LoggerFactory.getLogger(AuditStackServiceData.class); - - @Autowired - public HeatStackAudit heatStackAudit; - - @Autowired - public Environment env; - - protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService){ - AuditInventory auditInventory = externalTask.getVariable("auditInventory"); - setupMDC(externalTask); - boolean success = false; - try { - logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,externalTask.getRetries()); - success=heatStackAudit.auditHeatStack(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(), - auditInventory.getTenantId(), auditInventory.getHeatStackName()); - } catch (Exception e) { - logger.error("Error during audit of stack", e); - } - - if (success) { - externalTaskService.complete(externalTask); - logger.debug("The External Task Id: {} Successful", externalTask.getId()); - } else { - if(externalTask.getRetries() == null){ - logger.debug("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}", externalTask.getId(),RETRY_SEQUENCE.length); - externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, RETRY_SEQUENCE.length, 10000); - }else if(externalTask.getRetries() != null && - externalTask.getRetries()-1 == 0){ - logger.debug("The External Task Id: {} Failed, All Retries Exhausted", externalTask.getId()); - externalTaskService.handleBpmnError(externalTask, "AuditAAIInventoryFailure"); - }else{ - logger.debug("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(),externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); - externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries())); - } - logger.debug("The External Task Id: {} Failed", externalTask.getId()); - } - - - } - private void setupMDC(ExternalTask externalTask) { - String msoRequestId = externalTask.getVariable("mso-request-id"); - if(msoRequestId != null && !msoRequestId.isEmpty()) - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId); - } - protected long calculateRetryDelay(int currentRetries){ - int retrySequence = RETRY_SEQUENCE.length - currentRetries; - long retryMultiplier = Long.parseLong(env.getProperty("mso.workflow.topics.retryMultiplier","6000")); - return RETRY_SEQUENCE[retrySequence] * retryMultiplier; - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java index 6e6ecd51d4..c81dac7c6f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java @@ -39,23 +39,32 @@ import org.springframework.stereotype.Component; public class AuditVServer extends AbstractAudit { private static final Logger logger = LoggerFactory.getLogger(AuditVServer.class); - public boolean auditVservers(Set vServersToAudit, String tenantId, String cloudOwner, String cloudRegion) { + public boolean auditAllVserversDoExist(Set vServersToAudit, String tenantId, String cloudOwner, String cloudRegion) { if (vServersToAudit == null || vServersToAudit.isEmpty()){ return false; } return vServersToAudit.stream() - .filter(vServer -> !doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion)).findFirst() + .filter(vServer -> !doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion,true)).findFirst() + .map(v -> false).orElse(true); + } + + public boolean auditAllVserversDoNotExist(Set vServersToAudit, String tenantId, String cloudOwner, String cloudRegion) { + if (vServersToAudit == null || vServersToAudit.isEmpty()){ + return true; + } + return vServersToAudit.stream() + .filter(vServer -> doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion,false)).findFirst() .map(v -> false).orElse(true); } - private boolean doesVServerExistInAAI(Vserver vServer, String tenantId, String cloudOwner, String cloudRegion) { + private boolean doesVServerExistInAAI(Vserver vServer, String tenantId, String cloudOwner, String cloudRegion, boolean checkLinterfaces) { AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, tenantId, vServer.getVserverId()); boolean vServerExists = getAaiClient().exists(vserverURI); boolean doesExist = getAaiClient().exists(vserverURI); logger.info("v-server {} exists: {}", vServer.getVserverId(), doesExist); boolean allNeutronNetworksExist = true; - if (vServerExists && vServer.getLInterfaces() != null) { + if (vServerExists && vServer.getLInterfaces() != null && checkLinterfaces) { allNeutronNetworksExist = vServer.getLInterfaces() .getLInterface().stream().filter(lInterface -> !doesLinterfaceExistinAAI(lInterface, vServer.getVserverId(), tenantId, cloudOwner, cloudRegion)) diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java index da833c7b07..19e3ab71f5 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java @@ -57,26 +57,51 @@ public class HeatStackAudit { @Autowired protected AuditVServer auditVservers; - public boolean auditHeatStack(String cloudRegion, String cloudOwner, String tenantId, String heatStackName) { + public boolean auditHeatStackCreate(String cloudRegion, String cloudOwner, String tenantId, String heatStackName) { try { - logger.debug("Fetching Top Level Stack Information"); - Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName); - List novaResources = resources.getList().stream() - .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList()); - List resourceGroups = resources.getList().stream() - .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces")).collect(Collectors.toList()); - if(novaResources.isEmpty()) - return true; - else{ - Set vserversToAudit = createVserverSet(resources, novaResources); - Set vserversWithSubInterfaces = processSubInterfaces(cloudRegion, tenantId, resourceGroups, - vserversToAudit); - return auditVservers.auditVservers(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion); - } + return auditStack(cloudRegion,cloudOwner,tenantId,heatStackName,true); } catch (Exception e) { logger.error("Error during auditing stack resources", e); return false; } + } + + public boolean auditHeatStackDeleted(String cloudRegion, String cloudOwner, String tenantId, String heatStackName) { + try { + return auditStack(cloudRegion,cloudOwner,tenantId,heatStackName,false); + } catch (Exception e) { + logger.error("Error during auditing stack resources", e); + return false; + } + } + + private boolean auditStack(String cloudRegion, String cloudOwner, String tenantId, String heatStackName,boolean isCreateAudit) throws Exception{ + logger.debug("Fetching Top Level Stack Information"); + Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName); + List novaResources = extractNovaResources(resources); + if(novaResources.isEmpty()) + return true; + else{ + List resourceGroups = extractResourceGroups(resources); + Set vserversToAudit = createVserverSet(resources, novaResources); + Set vserversWithSubInterfaces = processSubInterfaces(cloudRegion, tenantId, resourceGroups, + vserversToAudit); + if(isCreateAudit){ + return auditVservers.auditAllVserversDoExist(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion); + }else{ + return auditVservers.auditAllVserversDoNotExist(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion); + } + } + } + + private List extractResourceGroups(Resources resources) { + return resources.getList().stream() + .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces")).collect(Collectors.toList()); + } + + private List extractNovaResources(Resources resources) { + return resources.getList().stream() + .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList()); } protected Set processSubInterfaces(String cloudRegion, String tenantId, List resourceGroups, @@ -208,5 +233,4 @@ public class HeatStackAudit { return Optional.empty(); } - } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java index 8f9152a86d..253f13d57d 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java @@ -90,6 +90,7 @@ public class NetworkAdapterRest { @Autowired private MsoNetworkAdapterImpl adapter; + @Autowired private Provider bpelRestClientProvider; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java index 7265a59397..8a5a083c63 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java @@ -59,7 +59,7 @@ import org.springframework.stereotype.Component; * org.onap.so.adapters.vnf.retrylist list of response codes that will trigger a retry (the special code * 900 means "connection was not established") */ -@Component() +@Component @Scope("prototype") public class BpelRestClient { public static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER"; diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml index 4e8d389998..cdd04b8c21 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml @@ -30,8 +30,19 @@ spring: ddl-auto: validate naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy enable-lazy-load-no-trans: true - - +org: + onap: + so: + adapters: + default_keystone_url_version: /v2.0 + default_keystone_reg_ex: "/[vV][0-9]" + po: + retryCodes: 504 + retryDelay: 5 + retryCount: 3 + pollTimeout: 7500 + pollInterval: 15 + #Actuator management: endpoints: diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java new file mode 100644 index 0000000000..bcf126d887 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java @@ -0,0 +1,150 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017-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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.audit; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; + +import java.io.IOException; +import java.util.Optional; + +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.aai.domain.yang.LInterface; +import org.onap.so.audit.beans.AuditInventory; +import org.springframework.core.env.Environment; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; + +public class AuditCreateStackServiceTest extends AuditCreateStackService { + + @InjectMocks + AuditCreateStackService auditStackService = new AuditCreateStackService(); + + @Mock + HeatStackAudit heatStackAuditMock; + + @Mock + Environment mockEnv; + + @Mock + ExternalTask mockExternalTask; + + @Mock + ExternalTaskService mockExternalTaskService; + + AuditInventory auditInventory = new AuditInventory(); + + @Before + public void setup() { + auditInventory.setCloudOwner("cloudOwner"); + auditInventory.setCloudRegion("cloudRegion"); + auditInventory.setTenantId("tenantId"); + auditInventory.setHeatStackName("stackName"); + MockitoAnnotations.initMocks(this); + doReturn(auditInventory).when(mockExternalTask).getVariable("auditInventory"); + doReturn("6000").when(mockEnv).getProperty("mso.workflow.topics.retryMultiplier","6000"); + doReturn("aasdfasdf").when(mockExternalTask).getId(); + } + + @Test + public void execute_external_task_audit_success_Test() { + doReturn(true).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); + auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); + Mockito.verify(mockExternalTaskService).complete(mockExternalTask); + } + + @Test + public void execute_external_task_audit_first_failure_Test() { + doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(null).when(mockExternalTask).getRetries(); + auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); + Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask, + "Unable to find all VServers and L-Interaces in A&AI", + "Unable to find all VServers and L-Interaces in A&AI", 8, 10000L); + } + + @Test + public void execute_external_task_audit_intermediate_failure_Test() { + doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(6).when(mockExternalTask).getRetries(); + auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); + Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask, + "Unable to find all VServers and L-Interaces in A&AI", + "Unable to find all VServers and L-Interaces in A&AI", 5, 12000L); + + } + + @Test + public void execute_external_task_audit_final_failure_Test() { + doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName"); + doReturn(1).when(mockExternalTask).getRetries(); + auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); + Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, + "AuditAAIInventoryFailure", "Number of Retries Exceeded auditing inventory"); + } + + @Test + public void retry_sequence_calculation_Test() { + long firstRetry = auditStackService.calculateRetryDelay(8); + assertEquals(6000L, firstRetry); + long secondRetry = auditStackService.calculateRetryDelay(7); + assertEquals(6000L, secondRetry); + long thirdRetry = auditStackService.calculateRetryDelay(6); + assertEquals(12000L, thirdRetry); + long fourthRetry = auditStackService.calculateRetryDelay(5); + assertEquals(18000L, fourthRetry); + long fifthRetry = auditStackService.calculateRetryDelay(4); + assertEquals(30000L, fifthRetry); + long sixRetry = auditStackService.calculateRetryDelay(3); + assertEquals(48000L, sixRetry); + long seventhRetry = auditStackService.calculateRetryDelay(2); + assertEquals(78000L, seventhRetry); + long eigthRetry = auditStackService.calculateRetryDelay(1); + assertEquals(120000L, eigthRetry); + } + + @Test + public void retry_sequence_Test() { + long firstRetry = auditStackService.calculateRetryDelay(8); + assertEquals(6000L, firstRetry); + long secondRetry = auditStackService.calculateRetryDelay(7); + assertEquals(6000L, secondRetry); + long thirdRetry = auditStackService.calculateRetryDelay(6); + assertEquals(12000L, thirdRetry); + long fourthRetry = auditStackService.calculateRetryDelay(5); + assertEquals(18000L, fourthRetry); + long fifthRetry = auditStackService.calculateRetryDelay(4); + assertEquals(30000L, fifthRetry); + long sixRetry = auditStackService.calculateRetryDelay(3); + assertEquals(48000L, sixRetry); + long seventhRetry = auditStackService.calculateRetryDelay(2); + assertEquals(78000L, seventhRetry); + long eigthRetry = auditStackService.calculateRetryDelay(1); + assertEquals(120000L, eigthRetry); + } +} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java deleted file mode 100644 index d7739e56f6..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017-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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.audit; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doReturn; - -import java.io.IOException; -import java.util.Optional; - -import org.camunda.bpm.client.task.ExternalTask; -import org.camunda.bpm.client.task.ExternalTaskService; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.onap.aai.domain.yang.LInterface; -import org.onap.so.audit.beans.AuditInventory; -import org.springframework.core.env.Environment; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -public class AuditStackServiceDataTest extends AuditStackServiceData { - - @InjectMocks - AuditStackServiceData auditStackService = new AuditStackServiceData(); - - @Mock - HeatStackAudit heatStackAuditMock; - - @Mock - Environment mockEnv; - - @Mock - ExternalTask mockExternalTask; - - @Mock - ExternalTaskService mockExternalTaskService; - - AuditInventory auditInventory = new AuditInventory(); - - @Before - public void setup() { - auditInventory.setCloudOwner("cloudOwner"); - auditInventory.setCloudRegion("cloudRegion"); - auditInventory.setTenantId("tenantId"); - auditInventory.setHeatStackName("stackName"); - MockitoAnnotations.initMocks(this); - doReturn(auditInventory).when(mockExternalTask).getVariable("auditInventory"); - doReturn("6000").when(mockEnv).getProperty("mso.workflow.topics.retryMultiplier","6000"); - doReturn("aasdfasdf").when(mockExternalTask).getId(); - } - - @Test - public void execute_external_task_audit_success_Test() { - doReturn(true).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); - auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); - Mockito.verify(mockExternalTaskService).complete(mockExternalTask); - } - - @Test - public void execute_external_task_audit_first_failure_Test() { - doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); - doReturn(null).when(mockExternalTask).getRetries(); - auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); - Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask, - "Unable to find all VServers and L-Interaces in A&AI", - "Unable to find all VServers and L-Interaces in A&AI", 8, 10000L); - } - - @Test - public void execute_external_task_audit_intermediate_failure_Test() { - doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); - doReturn(6).when(mockExternalTask).getRetries(); - auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); - Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask, - "Unable to find all VServers and L-Interaces in A&AI", - "Unable to find all VServers and L-Interaces in A&AI", 5, 12000L); - - } - - @Test - public void execute_external_task_audit_final_failure_Test() { - doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName"); - doReturn(1).when(mockExternalTask).getRetries(); - auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService); - Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, - "AuditAAIInventoryFailure"); - } - - @Test - public void retry_sequence_calculation_Test() { - long firstRetry = auditStackService.calculateRetryDelay(8); - assertEquals(6000L, firstRetry); - long secondRetry = auditStackService.calculateRetryDelay(7); - assertEquals(6000L, secondRetry); - long thirdRetry = auditStackService.calculateRetryDelay(6); - assertEquals(12000L, thirdRetry); - long fourthRetry = auditStackService.calculateRetryDelay(5); - assertEquals(18000L, fourthRetry); - long fifthRetry = auditStackService.calculateRetryDelay(4); - assertEquals(30000L, fifthRetry); - long sixRetry = auditStackService.calculateRetryDelay(3); - assertEquals(48000L, sixRetry); - long seventhRetry = auditStackService.calculateRetryDelay(2); - assertEquals(78000L, seventhRetry); - long eigthRetry = auditStackService.calculateRetryDelay(1); - assertEquals(120000L, eigthRetry); - } - - @Test - public void retry_sequence_Test() { - long firstRetry = auditStackService.calculateRetryDelay(8); - assertEquals(6000L, firstRetry); - long secondRetry = auditStackService.calculateRetryDelay(7); - assertEquals(6000L, secondRetry); - long thirdRetry = auditStackService.calculateRetryDelay(6); - assertEquals(12000L, thirdRetry); - long fourthRetry = auditStackService.calculateRetryDelay(5); - assertEquals(18000L, fourthRetry); - long fifthRetry = auditStackService.calculateRetryDelay(4); - assertEquals(30000L, fifthRetry); - long sixRetry = auditStackService.calculateRetryDelay(3); - assertEquals(48000L, sixRetry); - long seventhRetry = auditStackService.calculateRetryDelay(2); - assertEquals(78000L, seventhRetry); - long eigthRetry = auditStackService.calculateRetryDelay(1); - assertEquals(120000L, eigthRetry); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java index 02557d8c20..9176b58de8 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java @@ -58,8 +58,6 @@ import com.woorea.openstack.heat.model.Resources; @RunWith(MockitoJUnitRunner.Silent.class) public class AuditVServerTest extends AuditVServer { - private ObjectMapper objectMapper = new ObjectMapper(); - @InjectMocks private AuditVServer auditNova = new AuditVServer(); @@ -225,9 +223,13 @@ public class AuditVServerTest extends AuditVServer { @Test public void audit_Vserver_Empty_HashSet() throws JsonParseException, JsonMappingException, IOException { - boolean exists = auditNova.auditVservers(new HashSet(), tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(new HashSet(), tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(new HashSet(), tenantId, cloudOwner, cloudRegion); + assertEquals(true, doNotExist); } + @Test public void audit_Vserver_Found_Test() throws JsonParseException, JsonMappingException, IOException { @@ -246,8 +248,11 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(true, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test @@ -268,8 +273,11 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test @@ -288,16 +296,23 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test - public void audit_Vserver_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException { + public void audit_Vservers_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException { doReturn(false).when(aaiResourcesMock).exists(vserverURI); doReturn(false).when(aaiResourcesMock).exists(vserverURI2); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(true, doNotExist); } @Test @@ -306,8 +321,11 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(vserverURI2); doReturn(Optional.of(test_port_1_plural)).when(aaiResourcesMock).get(LInterface.class,test_port_1_uri); doReturn(Optional.of(test_port_2_plural)).when(aaiResourcesMock).get(LInterface.class,test_port_2_uri); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } @Test @@ -325,8 +343,12 @@ public class AuditVServerTest extends AuditVServer { doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri); doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri); doReturn(false).when(aaiResourcesMock).exists(vserverURI2); - boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion); + + boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); assertEquals(false, exists); + + boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion); + assertEquals(false, doNotExist); } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java index 696784110b..5eea46d09f 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java @@ -203,7 +203,7 @@ public class HeatStackAuditTest extends HeatStackAudit { Resources getResource = objectMapper.readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class); doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion, tenantId, "heatStackName"); - boolean actual = heatStackAudit.auditHeatStack(cloudRegion, "cloudOwner", tenantId, "heatStackName"); + boolean actual = heatStackAudit.auditHeatStackCreate(cloudRegion, "cloudOwner", tenantId, "heatStackName"); assertEquals(true, actual); } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java index 75cea9eafc..376076a0a0 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java @@ -65,7 +65,7 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{ @Test public void createVfModule() throws Exception { - //expectedException.expect(VnfException.class); + Map stackInputs = new HashMap<>(); stackInputs.put("oof_directives", "{}"); stackInputs.put("sdnc_directives", "{}"); -- cgit 1.2.3-korg