summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-03-05 16:56:09 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-03-06 10:29:49 -0500
commita339f93a736c9503888d05e47d79b173229042fc (patch)
tree4b8f1f89e2d20e4f251422f8538bbe5fdb920bbd /adapters/mso-openstack-adapters/src
parent91426ec9f221e288ea3f54fa62030e6f17420b90 (diff)
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) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-openstack-adapters/src')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java (renamed from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java)9
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java90
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java30
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java17
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java56
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java1
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/resources/application.yaml15
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java (renamed from adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java)14
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java42
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java2
12 files changed, 228 insertions, 52 deletions
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/AuditCreateStackService.java
index 773705d566..24980ae4e0 100644
--- 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/AuditCreateStackService.java
@@ -22,7 +22,6 @@
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;
@@ -35,14 +34,14 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Component
-public class AuditStackServiceData {
+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(AuditStackServiceData.class);
+ private static final Logger logger = LoggerFactory.getLogger(AuditCreateStackService.class);
@Autowired
public HeatStackAudit heatStackAudit;
@@ -56,7 +55,7 @@ public class AuditStackServiceData {
boolean success = false;
try {
logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,externalTask.getRetries());
- success=heatStackAudit.auditHeatStack(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(),
+ success=heatStackAudit.auditHeatStackCreate(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(),
auditInventory.getTenantId(), auditInventory.getHeatStackName());
} catch (Exception e) {
logger.error("Error during audit of stack", e);
@@ -72,7 +71,7 @@ public class AuditStackServiceData {
}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");
+ 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()));
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/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<Vserver> vServersToAudit, String tenantId, String cloudOwner, String cloudRegion) {
+ public boolean auditAllVserversDoExist(Set<Vserver> 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<Vserver> 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<Resource> novaResources = resources.getList().stream()
- .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());
- List<Resource> 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<Vserver> vserversToAudit = createVserverSet(resources, novaResources);
- Set<Vserver> 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<Resource> novaResources = extractNovaResources(resources);
+ if(novaResources.isEmpty())
+ return true;
+ else{
+ List<Resource> resourceGroups = extractResourceGroups(resources);
+ Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources);
+ Set<Vserver> 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<Resource> extractResourceGroups(Resources resources) {
+ return resources.getList().stream()
+ .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces")).collect(Collectors.toList());
+ }
+
+ private List<Resource> extractNovaResources(Resources resources) {
+ return resources.getList().stream()
+ .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());
}
protected Set<Vserver> processSubInterfaces(String cloudRegion, String tenantId, List<Resource> 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<BpelRestClient> 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/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java
index d7739e56f6..bcf126d887 100644
--- 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/AuditCreateStackServiceTest.java
@@ -40,10 +40,10 @@ import org.springframework.core.env.Environment;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
-public class AuditStackServiceDataTest extends AuditStackServiceData {
+public class AuditCreateStackServiceTest extends AuditCreateStackService {
@InjectMocks
- AuditStackServiceData auditStackService = new AuditStackServiceData();
+ AuditCreateStackService auditStackService = new AuditCreateStackService();
@Mock
HeatStackAudit heatStackAuditMock;
@@ -73,14 +73,14 @@ public class AuditStackServiceDataTest extends AuditStackServiceData {
@Test
public void execute_external_task_audit_success_Test() {
- doReturn(true).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName");
+ 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).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName");
+ doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName");
doReturn(null).when(mockExternalTask).getRetries();
auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask,
@@ -90,7 +90,7 @@ public class AuditStackServiceDataTest extends AuditStackServiceData {
@Test
public void execute_external_task_audit_intermediate_failure_Test() {
- doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName");
+ doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName");
doReturn(6).when(mockExternalTask).getRetries();
auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask,
@@ -101,11 +101,11 @@ public class AuditStackServiceDataTest extends AuditStackServiceData {
@Test
public void execute_external_task_audit_final_failure_Test() {
- doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName");
+ doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName");
doReturn(1).when(mockExternalTask).getRetries();
auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask,
- "AuditAAIInventoryFailure");
+ "AuditAAIInventoryFailure", "Number of Retries Exceeded auditing inventory");
}
@Test
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<Vserver>(), tenantId, cloudOwner, cloudRegion);
+ boolean exists = auditNova.auditAllVserversDoExist(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion);
assertEquals(false, exists);
+
+ boolean doNotExist = auditNova.auditAllVserversDoNotExist(new HashSet<Vserver>(), 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<String, Object> stackInputs = new HashMap<>();
stackInputs.put("oof_directives", "{}");
stackInputs.put("sdnc_directives", "{}");