diff options
author | Einat Vinouze <einat.vinouze@intl.att.com> | 2020-05-04 17:22:50 +0300 |
---|---|---|
committer | Eylon Malin <eylon.malin@intl.att.com> | 2020-05-05 20:07:50 +0000 |
commit | 03e4ae0e29eff5bbcc65020f383762af9e3fd5cc (patch) | |
tree | 0067c6585215f883059557f87c545adb5806efcc /vid-app-common/src/test | |
parent | 048bd5e527128ab84a2725cd39761648b8ec9c62 (diff) |
Add pause after completion for vfModule
Issue-ID: VID-821
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Change-Id: Ie3088cd2795c94121c45874d15c319151a10cc95
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Diffstat (limited to 'vid-app-common/src/test')
8 files changed, 234 insertions, 7 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java index b916347d2..8d60b8477 100644 --- a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java @@ -320,7 +320,7 @@ public class ResourceCommandTest { static VfModule createVfModule(Action action) { return new VfModule(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, - false, false, null, null, null, null, null, null, null, null); + false, false, null, null, null, null, null, null, null, null, null); } static Network createNetwork(Action action) { diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/VnfCommandTest.kt b/vid-app-common/src/test/java/org/onap/vid/job/command/VnfCommandTest.kt index 977966271..ab5440658 100644 --- a/vid-app-common/src/test/java/org/onap/vid/job/command/VnfCommandTest.kt +++ b/vid-app-common/src/test/java/org/onap/vid/job/command/VnfCommandTest.kt @@ -26,16 +26,20 @@ import org.hamcrest.core.AllOf.allOf import org.mockito.Answers import org.mockito.InjectMocks import org.mockito.Mock +import org.mockito.Mockito.mock import org.onap.vid.job.JobAdapter import org.onap.vid.job.JobsBrokerService import org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator import org.onap.vid.job.impl.JobSharedData import org.onap.vid.model.Action +import org.onap.vid.model.serviceInstantiation.VfModule +import org.onap.vid.model.serviceInstantiation.VfModule.PauseInstantiation.afterCompletion import org.onap.vid.mso.RestMsoImplementation import org.onap.vid.properties.Features import org.onap.vid.services.AsyncInstantiationBusinessLogic import org.onap.vid.testUtils.TestUtils import org.onap.vid.testUtils.TestUtils.initMockitoMocks +import org.testng.AssertJUnit import org.testng.annotations.BeforeMethod import org.testng.annotations.DataProvider import org.testng.annotations.Test @@ -102,4 +106,28 @@ class VnfCommandTest { ) } + @DataProvider + fun shoudlPause(): Array<Array<out Any?>> { + return arrayOf( + arrayOf("action create, pause in module and flag active", Action.Create, true, true, true), + arrayOf("action create, pause in module and flag not active", Action.Create, true, false, false), + arrayOf("action not create, pause in module and flag active", Action.None, true, true, false), + arrayOf("action create, no pause in module and flag active", Action.Create, false, true, false), + arrayOf("action create, no pause in module and flag not active", Action.Create, false, false, false)) + } + + @Test(dataProvider = "shoudlPause") + fun `shouldPauseAfterInstantiation -- given different flag and pause conditions`(desc: String, vfModuleAction: Action, isPause: Boolean, flag: Boolean, + expectedResult: Boolean) { + val vfModule = mock(VfModule::class.java); + + _when(featureManager.isActive(Features.FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION)).thenReturn(flag) + _when(vfModule.action).thenReturn(vfModuleAction) + + if (isPause) { + _when(vfModule.pauseInstantiation).thenReturn(afterCompletion) + } + + AssertJUnit.assertEquals(desc, expectedResult, vnfCommand.shoudlPauseAfterInstantiation(vfModule)) + } } diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java index dfacf57a3..061b62af2 100644 --- a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java @@ -1030,6 +1030,40 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes getStatusCounter); } + @DataProvider + public static Object[][] pauseInstantiation(Method test) { + return new Object[][]{ + {true, 2}, + {false, 3} + }; + } + + @Test (dataProvider = "pauseInstantiation") + public void viewEdit_existingVnfCreate3VfModulesPauseAfterTheSecond(boolean flag, int expectedNumberOfInvocation) { + RestObject<RequestReferencesContainer> createVfModuleResponse = createResponseRandomIds(202); + RestObject<AsyncRequestStatus> createStatusResponse = asyncRequestStatusResponseAsRestObject(COMPLETE_STR); + JobStatus expectedJobStatus = COMPLETED; + + when(featureManager.isActive(Features.FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION)).thenReturn(flag); + + when(commandUtils.isVfModuleBaseModule(eq("6b528779-44a3-4472-bdff-9cd15ec93450"), + argThat(it -> it.getModelCustomizationName().equals("2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0")))).thenReturn(true); + + UUID jobUUID = asyncInstantiationBL.pushBulkJob( + readJsonResourceFileAsObject("/payload_jsons/vfModuleCreate2AndPauseRequest.json", ServiceInstantiation.class), "userId") + .get(0); + + String createPath= "/serviceInstantiation/v7/serviceInstances/f8791436-8d55-4fde-b4d5-72dd2cf13cfb/vnfs/VNF_INSTANCE_ID/vfModules"; + + when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), eq(createPath), any())).thenReturn(createVfModuleResponse); + when(restMso.GetForObject(endsWith(createVfModuleResponse.get().getRequestReferences().getRequestId()), eq(AsyncRequestStatus.class))).thenReturn(createStatusResponse); + + + processJobsCountTimesAndAssertStatus(jobUUID, 40, expectedJobStatus); + + verify(restMso, times(expectedNumberOfInvocation)).restCall(eq(HttpMethod.POST), any(), any(), eq(createPath), any()); + } + //this test is going along with AsyncInstantiationALaCarteApiTest.delete1Create1NetworkFromService API test //The API test has only the happy flow scenario, while this test also test additional MSO responses (mostly non happy) @Test(dataProvider="createAndDeleteIntegrationTestDataProvider") diff --git a/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java b/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java index 6a5b102a0..26e8f8285 100644 --- a/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java @@ -32,6 +32,7 @@ import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.samePropertyValuesAs; import static org.onap.vid.model.Action.Create; +import static org.onap.vid.model.serviceInstantiation.VfModule.PauseInstantiation.afterCompletion; import static org.onap.vid.testUtils.TestUtils.setStringsInStringFields; import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER; @@ -154,6 +155,7 @@ public class InstantiationModelSerializationTest { true, true, 1, + afterCompletion, "originalName"); verifySerializationAndDeserialization(vfModule); @@ -167,7 +169,7 @@ public class InstantiationModelSerializationTest { VfModule vfModule = new VfModule(newModelInfo(), null, null, null, null, null, null, null, null, false, /* HERE ====> */ USE_PRELOAD, - null, null, null, null, null, null, null, null); + null, null, null, null, null, null, null, null , null); assertThat(vfModule, jsonPartEquals("sdncPreLoad", USE_PRELOAD)); assertThat(vfModule, jsonNodeAbsent("usePreload")); @@ -182,7 +184,7 @@ public class InstantiationModelSerializationTest { /* HERE ====> */ VOLUME_GROUP_INSTANCE_NAME, null, null, null, null, null, null, false, null, null, null, null, null, - null, null, null, null); + null, null, null, null, null); assertThat(vfModule, jsonPartEquals("volumeGroupName", VOLUME_GROUP_INSTANCE_NAME)); assertThat(vfModule, jsonNodeAbsent("volumeGroupInstanceName")); diff --git a/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/VfModuleTest.java b/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/VfModuleTest.java index 89b0acadb..9ed43ff70 100644 --- a/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/VfModuleTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/VfModuleTest.java @@ -55,7 +55,7 @@ public class VfModuleTest { null, null, null, null, null, null, null, null, true, true, null, null, true, null, true, - true, null, null); + true, null, null, null); return setStringsInStringFields(vfModule); } diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java index f61131770..738af18cf 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java @@ -266,12 +266,12 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), "mdt1", null, "88a6ca3ee0394ade9403f075db23167e", instanceParams, supplementaryParams, false, usePreload, null, UUID.randomUUID().toString(), null, null, - null, null, null, "originalName"); + null, null, null, null, "originalName"); } return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), null, null, null, instanceParams, supplementaryParams, false, false, null, UUID.randomUUID().toString(), null, - null, null, null, null, "originalName"); + null, null, null, null, null, "originalName"); } protected ModelInfo createVfModuleModelInfo(String modelName, String modelVersion, String modelVersionId, String modelInvariantId, String modelCustomizationId, String modelCustomizationName) { @@ -281,7 +281,8 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests protected VfModule createVfModuleForReplace(ModelInfo vfModuleModelInfo, String instanceName, String lcpCloudRegionId, String tenantId, Boolean retainAssignments, Boolean retainVolumeGroups, List<UserParamNameAndValue> supplementaryParams) { return new VfModule( vfModuleModelInfo, instanceName, null, Action.Upgrade.name(), lcpCloudRegionId, null, tenantId, - null, supplementaryParams, true, null, null, UUID.randomUUID().toString(), null, null, retainAssignments, retainVolumeGroups, null, "originalName"); + null, supplementaryParams, true, null, null, UUID.randomUUID().toString(), null, + null, retainAssignments, retainVolumeGroups, null, null, "originalName"); } protected ModelInfo createVnfModelInfo(boolean isAlacarte) { diff --git a/vid-app-common/src/test/java/org/onap/vid/utils/KotlinUtilsTest.kt b/vid-app-common/src/test/java/org/onap/vid/utils/KotlinUtilsTest.kt new file mode 100644 index 000000000..ac729e490 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/utils/KotlinUtilsTest.kt @@ -0,0 +1,21 @@ +package org.onap.vid.utils + +import org.testng.AssertJUnit.assertEquals +import org.testng.annotations.DataProvider +import org.testng.annotations.Test + +internal class KotlinUtilsTest { + @DataProvider + fun listsAndPerdicates(): Array<Array<Any>>? { + return arrayOf( + arrayOf("stop on second item", listOf("a", "b", "c", "d"), "b", listOf("a", "b")), + arrayOf("return all of the list", listOf("a", "b", "c", "d"), "z", listOf("a", "b", "c", "d")), + arrayOf("only first item returns", listOf("a", "b", "c", "d"), "a", listOf("a")), + arrayOf("returns an empty list", emptyList<String>(), "z", emptyList<String>())) + } + + @Test(dataProvider = "listsAndPerdicates") + fun testTakeUntilIncludingReturendValue(desc: String, list: List<String>, predicate: String, expectedResultList: List<String>) { + assertEquals(desc, expectedResultList, list.takeUntilIncluding { it == predicate }) + } +} diff --git a/vid-app-common/src/test/resources/payload_jsons/vfModuleCreate2AndPauseRequest.json b/vid-app-common/src/test/resources/payload_jsons/vfModuleCreate2AndPauseRequest.json new file mode 100644 index 000000000..e504195aa --- /dev/null +++ b/vid-app-common/src/test/resources/payload_jsons/vfModuleCreate2AndPauseRequest.json @@ -0,0 +1,141 @@ +{ + "action": "None", + "isDirty": true, + "vnfs": { + "2017-488_PASQUALE-vPE 0": { + "vfModules": { + "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": { + "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0uvfot": { + "instanceName": "VFinstancenameZERO", + "instanceId": "VF_MODULE_INSTANCE_ID", + "action": "Create", + "lcpCloudRegionId": "AAIAIC25", + "legacyRegion": "some legacy region", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "modelInfo": { + "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091", + "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db", + "modelName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0", + "modelVersion": "5", + "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3", + "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0", + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + }, + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db", + "provStatus": "Prov Status", + "orchStatus": "Active", + "inMaint": true + } + }, + "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": { + "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1fshmc": { + "instanceName": "VFinstancename", + "instanceId": "VF_MODULE_INSTANCE_ID", + "action": "Create", + "orchStatus": "Create", + "provStatus": "Prov Status", + "inMaint": false, + "pauseInstantiation": "afterCompletion", + "lcpCloudRegionId": "AAIAIC25", + "legacyRegion": "some legacy region", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "modelInfo": { + "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1", + "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5", + "modelName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1", + "modelVersion": "6", + "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", + "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1", + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + }, + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + } + }, + "2017588_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-2": { + "2017588_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-2frgth": { + "instanceName": "VFinstancename", + "instanceId": "VF_MODULE_INSTANCE_ID1", + "action": "Create", + "orchStatus": "Create", + "provStatus": "Prov Status", + "inMaint": false, + "lcpCloudRegionId": "AAIAIC25", + "legacyRegion": "some legacy region", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "modelInfo": { + "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1", + "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5", + "modelName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1", + "modelVersion": "6", + "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", + "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1", + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + }, + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + } + } + }, + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "AAIAIC25", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "lineOfBusiness": "ONAP", + "platformName": "platform", + "modelInfo": { + "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "modelName": "2017-488_PASQUALE-vPE", + "modelVersion": "5.0", + "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45", + "modelCustomizationName": "2017-488_PASQUALE-vPE 0", + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09" + }, + "orchStatus": "Created", + "inMaint": false, + "instanceId": "VNF_INSTANCE_ID", + "instanceName": "2017488_PASQUALEvPEVNFinstancename", + "action": "None", + "legacyRegion": "some legacy region" + } + }, + "instanceParams": [], + "validationCounter": 0, + "existingNames": { + "mcankinstancename": "" + }, + "existingVNFCounterMap": { + "afacccf6-397d-45d6-b5ae-94c39734b168": 1, + "69e09f68-8b63-4cc9-b9ff-860960b5db09": 3, + "b3c76f73-eeb5-4fb6-9d31-72a889f1811c": 1 + }, + "existingVnfGroupCounterMap": {}, + "existingNetworksCounterMap": {}, + "networks": {}, + "vnfGroups": {}, + "bulkSize": 1, + "instanceId": "f8791436-8d55-4fde-b4d5-72dd2cf13cfb", + "instanceName": "mCaNkinstancename", + "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89", + "subscriptionServiceType": "TYLER SILVIA", + "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "hvf6", + "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054", + "aicZoneId": "NFT1", + "projectName": "WATKINS", + "rollbackOnFailure": true, + "aicZoneName": "NFTJSSSS-NFT1", + "owningEntityName": "WayneHolland", + "tenantName": "AIN Web Tool-15-D-testalexandria", + "modelInfo": { + "modelInvariantId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", + "modelVersionId": "6b528779-44a3-4472-bdff-9cd15ec93450", + "modelName": "action-data", + "modelVersion": "1.0", + "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450" + }, + "isALaCarte": true, + "orchStatus": "Active", + "modelInavariantId": "6b528779-44a3-4472-bdff-9cd15ec93450", + "testApi": "VNF_API" +}
\ No newline at end of file |