diff options
24 files changed, 156 insertions, 96 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java index 42d200a130..16906957a7 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java @@ -20,10 +20,10 @@ package org.onap.so.cloud.authentication; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import org.onap.so.config.beans.PoConfig; import org.onap.so.db.catalog.beans.CloudIdentity; @@ -89,8 +89,7 @@ public class KeystoneV3Authentication { return result; } - protected RetryPolicy createRetryPolicy() { - RetryPolicy policy = new RetryPolicy(); + protected RetryPolicy<OpenStackResponse> createRetryPolicy() { List<Predicate<Throwable>> result = new ArrayList<>(); result.add(e -> { return e.getCause() instanceof OpenStackResponseException @@ -102,10 +101,8 @@ public class KeystoneV3Authentication { }); Predicate<Throwable> pred = result.stream().reduce(Predicate::or).orElse(x -> false); - - policy.retryOn(error -> pred.test(error)); - - policy.withDelay(poConfig.getRetryDelay(), TimeUnit.SECONDS).withMaxRetries(poConfig.getRetryCount()); + RetryPolicy<OpenStackResponse> policy = new RetryPolicy<OpenStackResponse>().handleIf(error -> pred.test(error)) + .withDelay(Duration.ofSeconds(poConfig.getRetryDelay())).withMaxRetries(poConfig.getRetryCount()); return policy; } diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.1__Add_Column_Rollback_Ext_System_Error_Source.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.1__Add_Column_Rollback_Ext_System_Error_Source.sql new file mode 100644 index 0000000000..a4009be326 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.1__Add_Column_Rollback_Ext_System_Error_Source.sql @@ -0,0 +1,4 @@ +use requestdb; + +ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS ROLLBACK_EXT_SYSTEM_ERROR_SOURCE varchar(80); +ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS ROLLBACK_EXT_SYSTEM_ERROR_SOURCE varchar(80);
\ No newline at end of file diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 30196379a3..94517ccc45 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -107,6 +107,7 @@ import org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRep import org.onap.so.db.catalog.data.repository.CollectionResourceRepository; import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository; +import org.onap.so.db.catalog.data.repository.CvnfcConfigurationCustomizationRepository; import org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository; import org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository; import org.onap.so.db.catalog.data.repository.HeatEnvironmentRepository; @@ -980,6 +981,7 @@ public class ToscaResourceInstaller { Set<CvnfcCustomization> existingCvnfcSet = new HashSet<>(); Set<VnfcCustomization> existingVnfcSet = new HashSet<>(); + List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom = new ArrayList<>(); for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { @@ -1000,7 +1002,7 @@ public class ToscaResourceInstaller { if (matchingObject.isPresent()) { VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource, - service, existingCvnfcSet, existingVnfcSet); + existingCvnfcSet, existingVnfcSet, existingCvnfcConfigurationCustom); vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources()); } else throw new Exception( @@ -1928,8 +1930,9 @@ public class ToscaResourceInstaller { protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, - IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, - Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) { + IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Set<CvnfcCustomization> existingCvnfcSet, + Set<VnfcCustomization> existingVnfcSet, + List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom) { VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource, vfModuleData.getVfModuleModelCustomizationUUID()); @@ -1955,7 +1958,7 @@ public class ToscaResourceInstaller { // * Extract VFC's and CVFC's then add them to VFModule // ****************************************************************************************************************** - Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = new HashSet<>(); + List<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = new ArrayList<>(); Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<>(); Set<VnfcCustomization> vnfcCustomizations = new HashSet<>(); @@ -2060,8 +2063,6 @@ public class ToscaResourceInstaller { .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code")); cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); - cvnfcCustomizations.add(cvnfcCustomization); - existingCvnfcSet.add(cvnfcCustomization); // ***************************************************************************************************************************************** // * Extract Fabric Configuration @@ -2074,8 +2075,9 @@ public class ToscaResourceInstaller { ConfigurationResource fabricConfig = null; - ConfigurationResource existingConfig = findExistingConfiguration(service, - fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + ConfigurationResource existingConfig = + findExistingConfiguration(existingCvnfcConfigurationCustom, + fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); if (existingConfig == null) { @@ -2089,11 +2091,16 @@ public class ToscaResourceInstaller { createCvnfcConfigurationCustomization(fabricTemplate, toscaResourceStructure, vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate, vfModuleMemberName); + cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization); - fabricConfig.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations); + existingCvnfcConfigurationCustom.add(cvnfcConfigurationCustomization); + } cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations); + cvnfcCustomizations.add(cvnfcCustomization); + existingCvnfcSet.add(cvnfcCustomization); + } } @@ -2152,13 +2159,14 @@ public class ToscaResourceInstaller { return cvnfcConfigurationCustomization; } - protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) { + protected ConfigurationResource findExistingConfiguration( + List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom, String modelUUID) { ConfigurationResource configResource = null; - for (ConfigurationResourceCustomization configurationResourceCustom : service - .getConfigurationCustomizations()) { - if (configurationResourceCustom.getConfigurationResource() != null - && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) { - configResource = configurationResourceCustom.getConfigurationResource(); + for (CvnfcConfigurationCustomization cvnfcConfigCustom : existingCvnfcConfigurationCustom) { + if (cvnfcConfigCustom != null) { + if (cvnfcConfigCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) { + configResource = cvnfcConfigCustom.getConfigurationResource(); + } } } diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql index 5e4af83e0e..652fc8f0de 100644 --- a/asdc-controller/src/test/resources/schema.sql +++ b/asdc-controller/src/test/resources/schema.sql @@ -1461,7 +1461,10 @@ CREATE TABLE `infra_active_requests` ( `CONFIGURATION_NAME` varchar(200) DEFAULT NULL, `OPERATIONAL_ENV_ID` varchar(45) DEFAULT NULL, `OPERATIONAL_ENV_NAME` varchar(200) DEFAULT NULL, - `REQUEST_URL` varchar(500) DEFAULT NULL, + `REQUEST_URL` varchar(500) DEFAULT NULL, + `ORIGINAL_REQUEST_ID` varchar(45) DEFAULT NULL, + `EXT_SYSTEM_ERROR_SOURCE` varchar(80) DEFAULT NULL, + `ROLLBACK_EXT_SYSTEM_ERROR_SOURCE` varchar(80) DEFAULT NULL, PRIMARY KEY (`REQUEST_ID`), UNIQUE KEY `UK_bhu6w8p7wvur4pin0gjw2d5ak` (`CLIENT_REQUEST_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java index 9e10058ec8..e9d8a5dee9 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java @@ -516,6 +516,11 @@ public class BuildingBlockTestDataSetup { modelInfoVfModule.setModelUUID("testModelUUID" + vfModuleCounter); modelInfoVfModule.setModelName("testModelName" + vfModuleCounter); modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter); + if (vfModuleCounter == 1) { + modelInfoVfModule.setIsBaseBoolean(Boolean.TRUE); + } else { + modelInfoVfModule.setIsBaseBoolean(Boolean.FALSE); + } vfModule.setModelInfoVfModule(modelInfoVfModule); return vfModule; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index fffaee0f7c..0553afb318 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -811,7 +811,9 @@ public class WorkflowAction { for (VfModule vfModule : vnf.getVfModules()) { aaiResourceIds.add( new Pair<WorkflowType, String>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); - resourceCounter.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false)); + Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false); + resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean()); + resourceCounter.add(resource); } } if (vnf.getVolumeGroups() != null) { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java index ff6426d351..825c703b74 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java @@ -542,6 +542,11 @@ public class TestDataSetup { modelInfoVfModule.setModelUUID("testModelUUID" + vfModuleCounter); modelInfoVfModule.setModelName("testModelName" + vfModuleCounter); modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter); + if (vfModuleCounter == 1) { + modelInfoVfModule.setIsBaseBoolean(Boolean.TRUE); + } else { + modelInfoVfModule.setIsBaseBoolean(Boolean.FALSE); + } vfModule.setModelInfoVfModule(modelInfoVfModule); return vfModule; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 09ba55aac0..176a09a04b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -29,6 +29,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; @@ -73,6 +74,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.Relationships; @@ -347,13 +349,10 @@ public class WorkflowActionTest extends BaseTaskTest { new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); vnf.setVnfId("vnf0"); - org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = - new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); - vfModule.setVfModuleId("vfModule0"); + + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule(); vnf.getVfModules().add(vfModule); - org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = - new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); - vfModule2.setVfModuleId("vfModule1"); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = buildVfModule(); vnf.getVfModules().add(vfModule2); org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = @@ -374,10 +373,10 @@ public class WorkflowActionTest extends BaseTaskTest { "ActivateServiceInstanceBB"); assertEquals("volumeGroup0", ebbs.get(0).getWorkflowResourceIds().getVolumeGroupId()); assertEquals("volumeGroup0", ebbs.get(1).getWorkflowResourceIds().getVolumeGroupId()); - assertEquals("vfModule0", ebbs.get(2).getWorkflowResourceIds().getVfModuleId()); - assertEquals("vfModule1", ebbs.get(3).getWorkflowResourceIds().getVfModuleId()); - assertEquals("vfModule0", ebbs.get(4).getWorkflowResourceIds().getVfModuleId()); - assertEquals("vfModule1", ebbs.get(5).getWorkflowResourceIds().getVfModuleId()); + assertEquals("testVfModuleId1", ebbs.get(2).getWorkflowResourceIds().getVfModuleId()); + assertEquals("testVfModuleId2", ebbs.get(3).getWorkflowResourceIds().getVfModuleId()); + assertEquals("testVfModuleId1", ebbs.get(4).getWorkflowResourceIds().getVfModuleId()); + assertEquals("testVfModuleId2", ebbs.get(5).getWorkflowResourceIds().getVfModuleId()); assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId()); assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId()); @@ -682,13 +681,9 @@ public class WorkflowActionTest extends BaseTaskTest { new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); vnf.setVnfId("vnfId123"); - org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = - new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); - vfModule.setVfModuleId("vfModule1"); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule(); vnf.getVfModules().add(vfModule); - org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = - new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); - vfModule2.setVfModuleId("vfModule2"); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = buildVfModule(); vnf.getVfModules().add(vfModule2); org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = @@ -737,13 +732,9 @@ public class WorkflowActionTest extends BaseTaskTest { new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); vnf.setVnfId("vnfId123"); - org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = - new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); - vfModule.setVfModuleId("vfModule1"); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule(); vnf.getVfModules().add(vfModule); - org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = - new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule(); - vfModule2.setVfModuleId("vfModule2"); + org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = buildVfModule(); vnf.getVfModules().add(vfModule2); org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = @@ -1063,7 +1054,7 @@ public class WorkflowActionTest extends BaseTaskTest { vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource); vnfVfmoduleCvnfcConfigurationCustomization.setModelInstanceName("modelInstanceName1"); vnfVfmoduleCvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization); - Set<CvnfcConfigurationCustomization> custSet = new HashSet<CvnfcConfigurationCustomization>(); + List<CvnfcConfigurationCustomization> custSet = new ArrayList<CvnfcConfigurationCustomization>(); custSet.add(vnfVfmoduleCvnfcConfigurationCustomization); cvnfcCustomization.setCvnfcConfigurationCustomization(custSet); cvnfcCustomization.setDescription("description"); @@ -1077,7 +1068,7 @@ public class WorkflowActionTest extends BaseTaskTest { vnfVfmoduleCvnfcConfigurationCustomization2.setConfigurationResource(configurationResource2); vnfVfmoduleCvnfcConfigurationCustomization2.setModelInstanceName("modelInstanceName2"); vnfVfmoduleCvnfcConfigurationCustomization2.setCvnfcCustomization(cvnfcCustomization2); - Set<CvnfcConfigurationCustomization> custSet2 = new HashSet<CvnfcConfigurationCustomization>(); + List<CvnfcConfigurationCustomization> custSet2 = new ArrayList<CvnfcConfigurationCustomization>(); custSet2.add(vnfVfmoduleCvnfcConfigurationCustomization2); cvnfcCustomization2.setCvnfcConfigurationCustomization(custSet2); cvnfcCustomization2.setDescription("description2"); @@ -1726,6 +1717,7 @@ public class WorkflowActionTest extends BaseTaskTest { .getConfiguration("testConfigurationId2"); workflowAction.traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds); assertEquals(8, resourceCounter.size()); + assertTrue(resourceCounter.get(2).isBaseVfModule()); assertThat(aaiResourceIds, sameBeanAs(getExpectedResourceIds())); } catch (Exception e) { fail("Unexpected exception was thrown."); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java index 34ad1b0fd4..6b5395ae07 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java @@ -89,7 +89,7 @@ public class WorkflowActionUnitTest { configuration.setToscaNodeType("FabricConfiguration"); configuration.setModelUUID("my-uuid"); vfModuleCustomization.setConfigurationResource(configuration); - cvnfcCustomization.setCvnfcConfigurationCustomization(Collections.singleton(vfModuleCustomization)); + cvnfcCustomization.setCvnfcConfigurationCustomization(Collections.singletonList(vfModuleCustomization)); List<CvnfcCustomization> cvnfcCustomizations = Arrays.asList(cvnfcCustomization); // when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(any(String.class), // any(String.class))) diff --git a/common/pom.xml b/common/pom.xml index 4490b63c3b..a52897170a 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -111,7 +111,7 @@ <dependency> <groupId>net.jodah</groupId> <artifactId>failsafe</artifactId> - <version>1.1.0</version> + <version>2.0.1</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java index 0b3aa651a0..d3a4d444f7 100644 --- a/common/src/main/java/org/onap/so/client/RestClient.java +++ b/common/src/main/java/org/onap/so/client/RestClient.java @@ -26,6 +26,7 @@ import java.net.SocketTimeoutException; import java.net.URI; import java.net.URL; import java.security.GeneralSecurityException; +import java.time.Duration; import java.util.ArrayList; import java.util.Base64; import java.util.HashMap; @@ -33,7 +34,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; -import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -275,22 +275,20 @@ public abstract class RestClient { } public Response method(String method, Object entity) { - RetryPolicy policy = new RetryPolicy(); List<Predicate<Throwable>> items = retryOn(); Predicate<Throwable> pred = items.stream().reduce(Predicate::or).orElse(x -> false); - policy.retryOn(error -> pred.test(error)); + RetryPolicy<Object> policy = + new RetryPolicy<>().handleIf(pred).withDelay(Duration.ofMillis(this.props.getDelayBetweenRetries())) + .withMaxRetries(this.props.getRetries()); - policy.withDelay(this.props.getDelayBetweenRetries(), TimeUnit.MILLISECONDS) - .withMaxRetries(this.props.getRetries()); - - return Failsafe.with(policy).get(buildRequest(method, entity)); + return Failsafe.with(policy).get(() -> buildRequest(method, entity)); } - protected RestRequest buildRequest(String method, Object entity) { - return new RestRequest(this, method, entity); + protected Response buildRequest(String method, Object entity) throws Exception { + return new RestRequest(this, method, entity).get(); } private <T> Optional<T> format(Response response, Class<T> resultClass) { diff --git a/common/src/main/java/org/onap/so/client/RestRequest.java b/common/src/main/java/org/onap/so/client/RestRequest.java index 9d2fa42d00..9e6e818171 100644 --- a/common/src/main/java/org/onap/so/client/RestRequest.java +++ b/common/src/main/java/org/onap/so/client/RestRequest.java @@ -23,15 +23,15 @@ package org.onap.so.client; import java.util.Optional; -import java.util.concurrent.Callable; import javax.ws.rs.HttpMethod; import javax.ws.rs.NotFoundException; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import net.jodah.failsafe.function.CheckedSupplier; -public class RestRequest implements Callable<Response> { +public class RestRequest implements CheckedSupplier<Response> { private static final Logger logger = LoggerFactory.getLogger(RestRequest.class); @@ -46,7 +46,7 @@ public class RestRequest implements Callable<Response> { } @Override - public Response call() throws Exception { + public Response get() throws Exception { final Response response; if ("GET".equals(method)) { response = this.client.getBuilder().accept(this.client.getAccept()).get(); diff --git a/common/src/main/java/org/onap/so/rest/exceptions/ExhaustedRetriesException.java b/common/src/main/java/org/onap/so/rest/exceptions/ExhaustedRetriesException.java new file mode 100644 index 0000000000..6c91516b84 --- /dev/null +++ b/common/src/main/java/org/onap/so/rest/exceptions/ExhaustedRetriesException.java @@ -0,0 +1,19 @@ +package org.onap.so.rest.exceptions; + +public class ExhaustedRetriesException extends RuntimeException { + + private static final long serialVersionUID = -8303091412739222943L; + + public ExhaustedRetriesException(String s) { + super(s); + } + + public ExhaustedRetriesException(Throwable t) { + super(t); + } + + public ExhaustedRetriesException(String s, Throwable t) { + super(s, t); + } + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java index e9d9d87b10..e236003631 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java @@ -38,6 +38,8 @@ public class RequestStatus { protected String timeStamp; @JsonProperty("extSystemErrorSource") protected String extSystemErrorSource; + @JsonProperty("rollbackExtSystemErrorSource") + protected String rollbackExtSystemErrorSource; public String getExtSystemErrorSource() { return extSystemErrorSource; @@ -79,10 +81,19 @@ public class RequestStatus { this.timeStamp = timeStamp; } + public String getRollbackExtSystemErrorSource() { + return rollbackExtSystemErrorSource; + } + + public void setRollbackExtSystemErrorSource(String rollbackExtSystemErrorSource) { + this.rollbackExtSystemErrorSource = rollbackExtSystemErrorSource; + } + @Override public String toString() { return new ToStringBuilder(this).append("requestState", requestState).append("statusMessage", statusMessage) .append("percentProgress", percentProgress).append("timestamp", timeStamp) - .append("extSystemErrorSource", extSystemErrorSource).toString(); + .append("extSystemErrorSource", extSystemErrorSource) + .append("rollbackExtSystemErrorSource", rollbackExtSystemErrorSource).toString(); } } diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java index b550079607..745dee23e8 100644 --- a/common/src/test/java/org/onap/so/client/RestClientTest.java +++ b/common/src/test/java/org/onap/so/client/RestClientTest.java @@ -22,24 +22,24 @@ package org.onap.so.client; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; import java.net.MalformedURLException; import java.net.SocketTimeoutException; import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilderException; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.Mock; import org.mockito.ArgumentMatchers; -import org.onap.so.utils.TargetEntity; +import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.utils.TargetEntity; @RunWith(MockitoJUnitRunner.class) public class RestClientTest { @@ -49,34 +49,34 @@ public class RestClientTest { @Mock private RestProperties props; + @Rule + public ExpectedException thrown = ExpectedException.none(); @Test public void retries() throws Exception { RestClient spy = buildSpy(); - RestRequest mockCallable = mock(RestRequest.class); - when(mockCallable.call()).thenThrow(new WebApplicationException(new SocketTimeoutException())); - doReturn(mockCallable).when(spy).buildRequest(any(String.class), ArgumentMatchers.isNull()); + doThrow(new WebApplicationException(new SocketTimeoutException())).when(spy).buildRequest(any(String.class), + ArgumentMatchers.isNull()); try { spy.get(); } catch (Exception e) { - // we expect an exception, ignore it + // ignore this exception for this test } - verify(mockCallable, times(3)).call(); + verify(spy, times(3)).buildRequest(any(String.class), ArgumentMatchers.isNull()); } @Test public void exceptionDoNotRetry() throws Exception { RestClient spy = buildSpy(); - RestRequest mockCallable = mock(RestRequest.class); - when(mockCallable.call()).thenThrow(new WebApplicationException(new NotFoundException())); - doReturn(mockCallable).when(spy).buildRequest(any(String.class), ArgumentMatchers.isNull()); + doThrow(new WebApplicationException(new NotFoundException())).when(spy).buildRequest(any(String.class), + ArgumentMatchers.isNull()); try { spy.get(); } catch (Exception e) { // we expect an exception, ignore it } - verify(mockCallable, times(1)).call(); + verify(spy, times(1)).buildRequest(any(String.class), ArgumentMatchers.isNull()); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index b4a3128de8..b63e3916f3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -440,6 +440,7 @@ public class OrchestrationRequests { boolean extSystemErrorSource) { if (extSystemErrorSource) { status.setExtSystemErrorSource(iar.getExtSystemErrorSource()); + status.setRollbackExtSystemErrorSource(iar.getRollbackExtSystemErrorSource()); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java index a400caeae2..99ff4ffe9e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java @@ -29,8 +29,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import javax.ws.rs.core.Response; @@ -74,19 +72,13 @@ public class OrchestrationRequestsUnitTest { private static final String ORIGINAL_REQUEST_ID = "8f2d38a6-7c20-465a-bd7e-075645f1394b"; private static final String SERVICE = "service"; private static final String EXT_SYSTEM_ERROR_SOURCE = "external system error source"; + private static final String ROLLBACK_EXT_SYSTEM_ERROR_SOURCE = "SDNC"; private InfraActiveRequests iar; boolean includeCloudRequest = false; boolean extSystemErrorSource = false; - private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName"; - private static final String VNF_ID = "00032ab7-na18-42e5-965d-8ea592502017"; - private static final String VFMODULE_ID = "00032ab7-na18-42e5-965d-8ea592502016"; - private static final String NETWORK_ID = "00032ab7-na18-42e5-965d-8ea592502015"; - private static final String VOLUME_GROUP_ID = "00032ab7-na18-42e5-965d-8ea592502014"; - private static final String VNF_NAME = "vnfName"; - private static final String VFMODULE_NAME = "vfModuleName"; - private static final String NETWORK_NAME = "networkName"; - private static final String VOLUME_GROUP_NAME = "volumeGroupName"; + private static final String VERSION = "v7"; + List<org.onap.so.db.request.beans.RequestProcessingData> requestProcessingData = new ArrayList<>(); @Before @@ -164,6 +156,7 @@ public class OrchestrationRequestsUnitTest { instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); requestStatus.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE); + requestStatus.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE); Request expected = new Request(); expected.setRequestId(REQUEST_ID); @@ -174,6 +167,7 @@ public class OrchestrationRequestsUnitTest { extSystemErrorSource = true; includeCloudRequest = false; iar.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE); + iar.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE); Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, extSystemErrorSource); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index 948283453b..731d2bec4d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -1290,7 +1290,10 @@ CREATE TABLE `infra_active_requests` ( `CONFIGURATION_NAME` varchar(200) DEFAULT NULL, `OPERATIONAL_ENV_ID` varchar(45) DEFAULT NULL, `OPERATIONAL_ENV_NAME` varchar(200) DEFAULT NULL, - `REQUEST_URL` varchar(500) DEFAULT NULL, + `REQUEST_URL` varchar(500) DEFAULT NULL, + `ORIGINAL_REQUEST_ID` varchar(45) DEFAULT NULL, + `EXT_SYSTEM_ERROR_SOURCE` varchar(80) DEFAULT NULL, + `ROLLBACK_EXT_SYSTEM_ERROR_SOURCE` varchar(80) DEFAULT NULL, PRIMARY KEY (`REQUEST_ID`), UNIQUE KEY `UK_bhu6w8p7wvur4pin0gjw2d5ak` (`CLIENT_REQUEST_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql index a47e1c44af..192e6d55b6 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql @@ -98,7 +98,8 @@ CREATE TABLE IF NOT EXISTS PUBLIC.INFRA_ACTIVE_REQUESTS( INSTANCE_GROUP_NAME VARCHAR SELECTIVITY 1, REQUEST_URL VARCHAR SELECTIVITY 1, ORIGINAL_REQUEST_ID VARCHAR SELECTIVITY 1, - EXT_SYSTEM_ERROR_SOURCE VARCHAR SELECTIVITY 1 + EXT_SYSTEM_ERROR_SOURCE VARCHAR SELECTIVITY 1, + ROLLBACK_EXT_SYSTEM_ERROR_SOURCE VARCHAR SELECTIVITY 1 ); INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, CLIENT_REQUEST_ID, ACTION, REQUEST_STATUS, STATUS_MESSAGE, PROGRESS, START_TIME, END_TIME, SOURCE, VNF_ID, VNF_NAME, VNF_TYPE, SERVICE_TYPE, AIC_NODE_CLLI, TENANT_ID, PROV_STATUS, VNF_PARAMS, VNF_OUTPUTS, REQUEST_BODY, RESPONSE_BODY, LAST_MODIFIED_BY, MODIFY_TIME, REQUEST_TYPE, VOLUME_GROUP_ID, VOLUME_GROUP_NAME, VF_MODULE_ID, VF_MODULE_NAME, VF_MODULE_MODEL_NAME, AAI_SERVICE_ID, AIC_CLOUD_REGION, CALLBACK_URL, CORRELATOR, NETWORK_ID, NETWORK_NAME, NETWORK_TYPE, REQUEST_SCOPE, REQUEST_ACTION, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, REQUESTOR_ID, CONFIGURATION_ID, CONFIGURATION_NAME, OPERATIONAL_ENV_ID, OPERATIONAL_ENV_NAME, REQUEST_URL) VALUES diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java index 9da6ff21ac..d0a4aa2c5f 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java @@ -89,6 +89,7 @@ public class InfraActiveRequests extends InfraRequests { .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId()) .append("operationalEnvName", getOperationalEnvName()).append("requestUrl", getRequestUrl()) .append("originalRequestId", getOriginalRequestId()) - .append("extSystemErrorSource", getExtSystemErrorSource()).toString(); + .append("extSystemErrorSource", getExtSystemErrorSource()) + .append("rollbackExtSystemErrorSource", getRollbackExtSystemErrorSource()).toString(); } } diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java index ecc4f46149..464cacb6b0 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java @@ -157,6 +157,8 @@ public abstract class InfraRequests implements java.io.Serializable { private String originalRequestId; @Column(name = "EXT_SYSTEM_ERROR_SOURCE", length = 80) private String extSystemErrorSource; + @Column(name = "ROLLBACK_EXT_SYSTEM_ERROR_SOURCE", length = 80) + private String rollbackExtSystemErrorSource; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "SO_REQUEST_ID", referencedColumnName = "REQUEST_ID") @@ -590,6 +592,14 @@ public abstract class InfraRequests implements java.io.Serializable { this.extSystemErrorSource = extSystemErrorSource; } + public String getRollbackExtSystemErrorSource() { + return this.rollbackExtSystemErrorSource; + } + + public void setRollbackExtSystemErrorSource(String rollbackExtSystemErrorSource) { + this.rollbackExtSystemErrorSource = rollbackExtSystemErrorSource; + } + @PrePersist protected void onCreate() { if (requestScope == null) @@ -653,6 +663,6 @@ public abstract class InfraRequests implements java.io.Serializable { .append("operationalEnvName", getOperationalEnvName()).append("instanceGroupId", getInstanceGroupId()) .append("instanceGroupName", getInstanceGroupName()).append("requestUrl", getRequestUrl()) .append("originalRequestId", originalRequestId).append("extSystemErrorSource", extSystemErrorSource) - .toString(); + .append("rollbackExtSystemErrorSource", rollbackExtSystemErrorSource).toString(); } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java index da3e391e11..7fb328fdb5 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CvnfcCustomization.java @@ -22,6 +22,7 @@ package org.onap.so.db.catalog.beans; import java.io.Serializable; import java.util.Date; +import java.util.List; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -100,7 +101,7 @@ public class CvnfcCustomization implements Serializable { private VnfcCustomization vnfcCustomization; @OneToMany(cascade = CascadeType.ALL, mappedBy = "cvnfcCustomization") - private Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomization; + private List<CvnfcConfigurationCustomization> cvnfcConfigurationCustomization; @Override public boolean equals(final Object other) { @@ -142,12 +143,12 @@ public class CvnfcCustomization implements Serializable { } @LinkedResource - public Set<CvnfcConfigurationCustomization> getCvnfcConfigurationCustomization() { + public List<CvnfcConfigurationCustomization> getCvnfcConfigurationCustomization() { return cvnfcConfigurationCustomization; } public void setCvnfcConfigurationCustomization( - Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomization) { + List<CvnfcConfigurationCustomization> cvnfcConfigurationCustomization) { this.cvnfcConfigurationCustomization = cvnfcConfigurationCustomization; } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcConfigurationCustomizationRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcConfigurationCustomizationRepository.java index 1e5a07350d..d974e88890 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcConfigurationCustomizationRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CvnfcConfigurationCustomizationRepository.java @@ -20,6 +20,7 @@ package org.onap.so.db.catalog.data.repository; +import java.util.List; import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @@ -29,4 +30,6 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; public interface CvnfcConfigurationCustomizationRepository extends JpaRepository<CvnfcConfigurationCustomization, Integer> { + List<CvnfcConfigurationCustomization> findByModelCustomizationUUID(String modelCustomizationUUID); + } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java index 80e3d53c57..4010328ad9 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java @@ -21,7 +21,9 @@ package org.onap.so.db.catalog.beans; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; import org.junit.Test; @@ -54,7 +56,7 @@ public class CvnfcCustomizationTest { cvnfcCustomization.setNfcNamingCode(NFC_NAMING_CODE); cvnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE); cvnfcCustomization.setVfModuleCustomization(setupVfModuleCustomization()); - Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizationSet = new HashSet(); + List<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizationSet = new ArrayList(); cvnfcConfigurationCustomizationSet.add(setupCvnfcConfigurationCustomization()); cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizationSet); |