summaryrefslogtreecommitdiffstats
path: root/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm
diff options
context:
space:
mode:
authorDenes Nemeth <denes.nemeth@nokia.com>2018-04-13 00:46:20 +0200
committerDenes Nemeth <denes.nemeth@nokia.com>2018-04-13 00:49:43 +0200
commitb754227da778e1e835336ae39e304ffc8059a009 (patch)
treeeffc31892c2018b0cef20e41b8481e99707557f9 /nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm
parentb6618c139b786a947efd695b7bc484eac3401642 (diff)
Fix backward compatibility issues
Change-Id: I4f79713050074622e5375096baca64ae52594647 Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com> Issue-ID: VFC-728
Diffstat (limited to 'nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm')
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java7
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java13
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcPackageProvider.java10
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java13
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java1
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java22
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java169
8 files changed, 189 insertions, 48 deletions
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java
index 5f1ecc85..0b49b917 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java
@@ -22,7 +22,6 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import org.onap.vnfmdriver.model.VimInfo;
import org.onap.vnfmdriver.model.VnfmInfo;
import org.springframework.test.util.ReflectionTestUtils;
-import retrofit2.Call;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.fail;
@@ -44,8 +43,7 @@ public class TestVfcExternalSystemInfoProvider extends TestBase {
@Test
public void testVimRetrieval() throws Exception {
VimInfo expectedVimInfo = new VimInfo();
- Call<VimInfo> vimInfoCall = buildCall(expectedVimInfo);
- when(nsLcmApi.queryVIMInfo(VIM_ID)).thenReturn(vimInfoCall);
+ when(nsLcmApi.queryVIMInfo(VIM_ID)).thenReturn(buildObservable(expectedVimInfo));
//when
VimInfo vimInfo = vfcExternalSystemInfoProvider.getVimInfo(VIM_ID);
//verify
@@ -75,8 +73,7 @@ public class TestVfcExternalSystemInfoProvider extends TestBase {
@Test
public void testVnfmRetrieval() throws Exception {
VnfmInfo expectedVimInfo = new VnfmInfo();
- Call<VnfmInfo> vnfmInfoCall = buildCall(expectedVimInfo);
- when(nsLcmApi.queryVnfmInfo(VNFM_ID)).thenReturn(vnfmInfoCall);
+ when(nsLcmApi.queryVnfmInfo(VNFM_ID)).thenReturn(buildObservable(expectedVimInfo));
//when
VnfmInfo vimInfo = vfcExternalSystemInfoProvider.queryVnfmInfoFromSource(VNFM_ID);
//verify
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java
index 6fc61981..b9d44603 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java
@@ -36,7 +36,6 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import org.onap.vnfmdriver.model.*;
import org.onap.vnfmdriver.model.ScaleDirection;
-import retrofit2.Call;
import static java.nio.file.Files.readAllBytes;
@@ -58,8 +57,7 @@ public class TestVfcGrantManager extends TestBase {
@Before
public void initMocks() throws Exception {
setField(VfcGrantManager.class, "logger", logger);
- Call<GrantVNFResponse> grantVNFResponseCall = buildCall(grantResponse);
- when(nsLcmApi.grantvnf(grantRequest.capture())).thenReturn(grantVNFResponseCall);
+ when(nsLcmApi.grantvnf(grantRequest.capture())).thenReturn(buildObservable(grantResponse));
grantResponse.setVim(vim);
}
@@ -105,13 +103,15 @@ public class TestVfcGrantManager extends TestBase {
String cbamVnfdContent = new String(readAllBytes(Paths.get(TestVfcGrantManager.class.getResource("/unittests/vnfd.instantiation.yaml").toURI())));
RuntimeException expectedException = new RuntimeException("a");
when(nsLcmApi.grantvnf(Mockito.any())).thenThrow(expectedException);
+ ArgumentCaptor<String> logCaptor = ArgumentCaptor.forClass(String.class);
+ Mockito.doNothing().when(logger).error(logCaptor.capture(), Mockito.eq(expectedException));
//when
try {
vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, "level1", cbamVnfdContent, JOB_ID);
//verify
fail();
} catch (RuntimeException e) {
- verify(logger).error("Unable to request grant", expectedException);
+ assertTrue(logCaptor.getValue().contains("Unable to request grant with "));
}
}
@@ -228,13 +228,16 @@ public class TestVfcGrantManager extends TestBase {
vnf.getVnfConfigurableProperties().add(prop);
RuntimeException expectedException = new RuntimeException();
when(nsLcmApi.grantvnf(Mockito.any())).thenThrow(expectedException);
+ ArgumentCaptor<String> logCaptor = ArgumentCaptor.forClass(String.class);
+ Mockito.doNothing().when(logger).error(logCaptor.capture(), Mockito.eq(expectedException));
//when
try {
vfcGrantManager.requestGrantForTerminate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, vnf, JOB_ID);
//verify
fail();
} catch (RuntimeException e) {
- verify(logger).error(Mockito.eq("Unable to request grant"), Mockito.eq(expectedException));
+ String value = logCaptor.getValue();
+ assertTrue(value.contains("Unable to request grant with "));
}
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java
index a701a159..ea82882d 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java
@@ -64,7 +64,7 @@ public class TestVfcNotificationSender extends TestBase {
public void init() throws Exception {
vfcNotificationSender = new VfcNotificationSender(driverProperties, vfcRestApiProvider);
setField(VfcNotificationSender.class, "logger", logger);
- when(nsLcmApi.vNFLCMNotification(eq(VNFM_ID), eq(VNF_ID), sentLcnToVfc.capture())).thenReturn(VOID_CALL);
+ when(nsLcmApi.vNFLCMNotification(eq(VNFM_ID), eq(VNF_ID), sentLcnToVfc.capture())).thenReturn(null);
instantiationOperation.setId("instantiationOperationExecutionId");
instantiationOperation.setStartTime(OffsetDateTime.now());
instantiationOperation.setOperationType(OperationType.INSTANTIATE);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcPackageProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcPackageProvider.java
index 8d344c5b..a6bb75ac 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcPackageProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcPackageProvider.java
@@ -29,7 +29,6 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import org.onap.vfccatalog.model.VnfPkgDetailInfo;
import org.onap.vfccatalog.model.VnfPkgInfo;
-import retrofit2.Call;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.fail;
@@ -64,8 +63,7 @@ public class TestVfcPackageProvider extends TestBase {
vnfPackageDetails.setPackageInfo(new VnfPkgInfo());
vnfPackageDetails.getPackageInfo().setVnfdModel("{ \"metadata\" : { \"resourceVendorModelNumber\" : \"" + CBAM_VNFD_ID + "\" }}");
vnfPackageDetails.getPackageInfo().setDownloadUrl("http://127.0.0.1/a.csar");
- Call<VnfPkgDetailInfo> vnfPkgDetailInfoCall = buildCall(vnfPackageDetails);
- when(vfcCatalogApi.queryVnfPackage(CSAR_ID)).thenReturn(vnfPkgDetailInfoCall);
+ when(vfcCatalogApi.queryVnfPackage(CSAR_ID)).thenReturn(buildObservable(vnfPackageDetails));
//when
String cbamVnfdId = vfcPackageProvider.getCbamVnfdId(CSAR_ID);
//verify
@@ -82,8 +80,7 @@ public class TestVfcPackageProvider extends TestBase {
vnfPackageDetails.setPackageInfo(new VnfPkgInfo());
vnfPackageDetails.getPackageInfo().setVnfdModel("{ \"metadata\" : { \"resourceVendorModelNumber\" : \"" + CBAM_VNFD_ID + "\" }}");
vnfPackageDetails.getPackageInfo().setDownloadUrl("http://127.0.0.1/a.csar");
- Call<VnfPkgDetailInfo> vnfPkgDetailInfoCall = buildCall(vnfPackageDetails);
- when(vfcCatalogApi.queryVnfPackage(CSAR_ID)).thenReturn(vnfPkgDetailInfoCall);
+ when(vfcCatalogApi.queryVnfPackage(CSAR_ID)).thenReturn(buildObservable(vnfPackageDetails));
byte[] onapPackageContent = TestUtil.loadFile("unittests/TestCbamCatalogManager.sample.csar");
when(ipMappingProvider.mapPrivateIpToPublicIp("127.0.0.1")).thenReturn("1.2.3.4");
when(entity.getContent()).thenReturn(new ByteArrayInputStream(onapPackageContent));
@@ -123,8 +120,7 @@ public class TestVfcPackageProvider extends TestBase {
vnfPackageDetails.setPackageInfo(new VnfPkgInfo());
vnfPackageDetails.getPackageInfo().setVnfdModel("{ \"metadata\" : { \"resourceVendorModelNumber\" : \"" + CBAM_VNFD_ID + "\" }}");
vnfPackageDetails.getPackageInfo().setDownloadUrl("http://127.0.0.1/a.csar");
- Call<VnfPkgDetailInfo> vnfPkgDetailInfoCall = buildCall(vnfPackageDetails);
- when(vfcCatalogApi.queryVnfPackage(CSAR_ID)).thenReturn(vnfPkgDetailInfoCall);
+ when(vfcCatalogApi.queryVnfPackage(CSAR_ID)).thenReturn(buildObservable(vnfPackageDetails));
byte[] onapPackageContent = TestUtil.loadFile("unittests/TestCbamCatalogManager.sample.csar");
when(ipMappingProvider.mapPrivateIpToPublicIp("127.0.0.1")).thenReturn("1.2.3.4");
IOException expectedException = new IOException();
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
index 8711c3f4..15505ba7 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
@@ -55,12 +55,13 @@ public class TestLcmApi extends TestBase {
@Test
public void testInstantiation() {
VnfInstantiateRequest req = new VnfInstantiateRequest();
+ req.setVnfPackageId("casrId");
//when
lcmApi.instantiateVnf(req, VNFM_ID, httpResponse);
//verify
verify(lifecycleManager).createAndInstantiate(VNFM_ID, req, httpResponse);
verify(httpResponse).setStatus(SC_CREATED);
- verify(logger).info("REST: Instantiate VNF");
+ verify(logger).info("REST: Instantiate VNF with casrId CSAR identifier");
}
/**
@@ -73,7 +74,7 @@ public class TestLcmApi extends TestBase {
lcmApi.healVnf(req, VNFM_ID, VNF_ID, httpResponse);
//verify
verify(lifecycleManager).healVnf(VNFM_ID, VNF_ID, req, empty(), httpResponse);
- verify(logger).info("REST: Heal VNF");
+ verify(logger).info("REST: Heal VNF with " + VNF_ID + " identifier");
}
/**
@@ -85,7 +86,7 @@ public class TestLcmApi extends TestBase {
lcmApi.queryVnf(VNFM_ID, VNF_ID, httpResponse);
//verify
verify(lifecycleManager).queryVnf(VNFM_ID, VNF_ID);
- verify(logger).info("REST: Query VNF");
+ verify(logger).info("REST: Query VNF with " + VNF_ID + " identifier");
}
@@ -99,7 +100,7 @@ public class TestLcmApi extends TestBase {
lcmApi.scaleVnf(req, VNFM_ID, VNF_ID, httpResponse);
//verify
verify(lifecycleManager).scaleVnf(VNFM_ID, VNF_ID, req, httpResponse);
- verify(logger).info("REST: Scale VNF");
+ verify(logger).info("REST: Scale VNF with " + VNF_ID + " identifier");
}
@@ -113,7 +114,7 @@ public class TestLcmApi extends TestBase {
lcmApi.terminateVnf(req, VNFM_ID, VNF_ID, httpResponse);
//verify
verify(lifecycleManager).terminateAndDelete(VNFM_ID, VNF_ID, req, httpResponse);
- verify(logger).info("REST: Terminate VNF");
+ verify(logger).info("REST: Terminate VNF with " + VNF_ID + " identifier");
}
@@ -126,7 +127,7 @@ public class TestLcmApi extends TestBase {
lcmApi.getJob(VNFM_ID, JOB_ID, httpResponse);
//verify
verify(jobManager).getJob(VNFM_ID, JOB_ID);
- verify(logger).debug("REST: Query job");
+ verify(logger).debug("REST: Query job with " + JOB_ID + " identifier");
}
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
index e61edc3c..804f395d 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
@@ -77,7 +77,6 @@ public class TestBase {
public static final String VIM_ID = "myCloudOwnerId_myRegionName";
public static final String JOB_ID = "myJobId";
public static final String CBAM_VNFD_ID = "cbamVnfdId";
- protected static Call<Void> VOID_CALL = buildCall(null);
protected static VoidObservable VOID_OBSERVABLE = new VoidObservable();
@Mock
protected CbamRestApiProvider cbamRestApiProvider;
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java
index 90e064a2..439325ec 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java
@@ -36,7 +36,6 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.IPackageProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
-import retrofit2.Call;
import static junit.framework.TestCase.*;
import static org.junit.Assert.assertArrayEquals;
@@ -58,8 +57,7 @@ public class TestCbamCatalogManager extends TestBase {
@Before
public void initMocks() throws Exception {
setField(CatalogManager.class, "logger", logger);
- Call<List<CatalogAdapterVnfpackage>> value = buildCall(existingVnfPackages);
- when(cbamCatalogApi.list()).thenReturn(value);
+ when(cbamCatalogApi.list()).thenReturn(buildObservable(existingVnfPackages));
cbamCatalogManager = new CatalogManager(cbamRestApiProvider, packageProvider);
}
@@ -73,8 +71,7 @@ public class TestCbamCatalogManager extends TestBase {
existingVnfPackages.add(existingPackage);
CatalogAdapterVnfpackage createdPackage = new CatalogAdapterVnfpackage();
createdPackage.setVnfdId(CBAM_VNFD_ID);
- Call<CatalogAdapterVnfpackage> catalogAdapterVnfpackageCall = buildCall(createdPackage);
- when(cbamCatalogApi.create(uploadedFile.capture())).thenReturn(catalogAdapterVnfpackageCall);
+ when(cbamCatalogApi.create(uploadedFile.capture())).thenReturn(buildObservable(createdPackage));
byte[] onapPackageContent = TestUtil.loadFile("unittests/TestCbamCatalogManager.sample.csar");
when(packageProvider.getPackage(CSAR_ID)).thenReturn(onapPackageContent);
when(packageProvider.getCbamVnfdId(CSAR_ID)).thenReturn(CBAM_VNFD_ID);
@@ -106,8 +103,7 @@ public class TestCbamCatalogManager extends TestBase {
public CatalogAdapterVnfpackage answer(InvocationOnMock invocationOnMock) throws Throwable {
//this is done by an other thread
existingVnfPackages.add(createdPackage);
- Call<CatalogAdapterVnfpackage> catalogAdapterVnfpackageCall = buildCall(createdPackage);
- when(cbamCatalogApi.getById(CBAM_VNFD_ID)).thenReturn(catalogAdapterVnfpackageCall);
+ when(cbamCatalogApi.getById(CBAM_VNFD_ID)).thenReturn(buildObservable(createdPackage));
throw can_not_upload_package;
}
});
@@ -138,8 +134,7 @@ public class TestCbamCatalogManager extends TestBase {
CatalogAdapterVnfpackage existingPackage = new CatalogAdapterVnfpackage();
existingPackage.setVnfdId(CBAM_VNFD_ID);
existingVnfPackages.add(existingPackage);
- Call<CatalogAdapterVnfpackage> catalogAdapterVnfpackageCall = buildCall(existingPackage);
- when(cbamCatalogApi.getById(CBAM_VNFD_ID)).thenReturn(catalogAdapterVnfpackageCall);
+ when(cbamCatalogApi.getById(CBAM_VNFD_ID)).thenReturn(buildObservable(existingPackage));
//when
CatalogAdapterVnfpackage cbamPackage = cbamCatalogManager.preparePackageInCbam(VNFM_ID, CSAR_ID);
//verify
@@ -214,8 +209,7 @@ public class TestCbamCatalogManager extends TestBase {
*/
@Test
public void testExtractVnfdFromPackage() throws Exception {
- Call<ResponseBody> responseBodyCall = buildCall(buildResponse(TestUtil.loadFile("unittests/cbam.package.zip")));
- when(cbamCatalogApi.content(CBAM_VNFD_ID)).thenReturn(responseBodyCall);
+ when(cbamCatalogApi.content(CBAM_VNFD_ID)).thenReturn(buildObservable(buildResponse(TestUtil.loadFile("unittests/cbam.package.zip"))));
//when
String content = cbamCatalogManager.getCbamVnfdContent(VNFM_ID, CBAM_VNFD_ID);
//verify
@@ -227,8 +221,7 @@ public class TestCbamCatalogManager extends TestBase {
*/
@Test
public void testEmptyCbamPackage() throws Exception {
- Call<ResponseBody> responseBodyCall = buildCall(buildResponse(TestUtil.loadFile("unittests/empty.zip")));
- when(cbamCatalogApi.content(CBAM_VNFD_ID)).thenReturn(responseBodyCall);
+ when(cbamCatalogApi.content(CBAM_VNFD_ID)).thenReturn(buildObservable(buildResponse(TestUtil.loadFile("unittests/empty.zip"))));
//when
try {
cbamCatalogManager.getCbamVnfdContent(VNFM_ID, CBAM_VNFD_ID);
@@ -245,8 +238,7 @@ public class TestCbamCatalogManager extends TestBase {
@Test
public void testMissingVnfdCbamPackage() throws Exception {
byte[] bytes = TestUtil.loadFile("unittests/missing.vnfd.zip");
- Call<ResponseBody> response = buildCall(buildResponse(bytes));
- when(cbamCatalogApi.content(CBAM_VNFD_ID)).thenReturn(response);
+ when(cbamCatalogApi.content(CBAM_VNFD_ID)).thenReturn(buildObservable(buildResponse(bytes)));
//when
try {
cbamCatalogManager.getCbamVnfdContent(VNFM_ID, CBAM_VNFD_ID);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
index 7078e02d..0ff2bae1 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
@@ -65,14 +65,11 @@ public class TestLifecycleManager extends TestBase {
public static final String OPERATION_EXECUTION_ID = "operationExecutionId";
private static final String ONAP_CSAR_ID = "myOnapCsarId";
private static final String VIM_ID = "ownerId_regionId";
- private GrantVNFResponseVim vim = new GrantVNFResponseVim();
@Mock
private CatalogManager catalogManager;
@Mock
private VfcGrantManager vfcGrantManager;
@Mock
- private CbamTokenProvider tokenProvider;
- @Mock
private JobManager jobManager;
@Mock
private LifecycleChangeNotificationManager notificationManager;
@@ -362,7 +359,6 @@ public class TestLifecycleManager extends TestBase {
@Test
public void testInstantiationV3() throws Exception {
VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
-
when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -393,12 +389,106 @@ public class TestLifecycleManager extends TestBase {
}
/**
+ * test instantiation with backward compatibility test with Amsterdam release
+ * - the vim identifier is supplied as vimid with not camel case
+ */
+ @Test
+ public void testInstantiationNoVimId() throws Exception {
+ //given
+ VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+ when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
+ additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
+ when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
+ grantResponse.setVimid(VIM_ID);
+ GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo();
+ accessInfo.setTenant(TENANT);
+ grantResponse.setAccessinfo(accessInfo);
+ ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
+ when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(instantiationOperationExecution));
+ //when
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
+ waitForJobToFinishInJobManager(finished);
+ //verify
+ assertEquals(VNF_ID, response.getVnfInstanceId());
+ assertEquals(JOB_ID, response.getJobId());
+ assertEquals(createRequest.getAllValues().size(), 1);
+ assertEquals("myDescription", createRequest.getValue().getDescription());
+ assertEquals("vnfName", createRequest.getValue().getName());
+ assertEquals(CBAM_VNFD_ID, createRequest.getValue().getVnfdId());
+ assertEquals(1, actualInstantiationRequest.getAllValues().size());
+ assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
+ OPENSTACKV2INFO actualVim = (OPENSTACKV2INFO) actualInstantiationRequest.getValue().getVims().get(0);
+ assertEquals(VIM_ID, actualVim.getId());
+ assertEquals(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, actualVim.getVimInfoType());
+ assertEquals(Boolean.valueOf(parseBoolean(vimInfo.getSslInsecure())), actualVim.getInterfaceInfo().isSkipCertificateVerification());
+ assertEquals("cloudUrl", actualVim.getInterfaceInfo().getEndpoint());
+ //FIXME assertEquals();actualVim.getInterfaceInfo().getTrustedCertificates());
+ assertEquals("vimPassword", actualVim.getAccessInfo().getPassword());
+ assertEquals("regionId", actualVim.getAccessInfo().getRegion());
+ assertEquals("myTenant", actualVim.getAccessInfo().getTenant());
+ assertEquals("vimUsername", actualVim.getAccessInfo().getUsername());
+ assertEquals(1, actualInstantiationRequest.getValue().getComputeResourceFlavours().size());
+ assertEquals("flavourProviderId", actualInstantiationRequest.getValue().getComputeResourceFlavours().get(0).getResourceId());
+ assertEquals(VIM_ID, actualInstantiationRequest.getValue().getComputeResourceFlavours().get(0).getVimId());
+ assertEquals("virtualComputeDescId", actualInstantiationRequest.getValue().getComputeResourceFlavours().get(0).getVnfdVirtualComputeDescId());
+ assertEquals(1, actualInstantiationRequest.getValue().getExtManagedVirtualLinks().size());
+ assertEquals(extManVl, actualInstantiationRequest.getValue().getExtManagedVirtualLinks().get(0));
+ assertEquals(2, actualInstantiationRequest.getValue().getExtVirtualLinks().size());
+
+ assertEquals("myNetworkProviderId", actualInstantiationRequest.getValue().getExtVirtualLinks().get(0).getResourceId());
+ assertEquals("myEVlId", actualInstantiationRequest.getValue().getExtVirtualLinks().get(0).getExtVirtualLinkId());
+ assertEquals(1, actualInstantiationRequest.getValue().getExtVirtualLinks().get(0).getExtCps().size());
+ assertEquals("myCpdId", actualInstantiationRequest.getValue().getExtVirtualLinks().get(0).getExtCps().get(0).getCpdId());
+
+ assertEquals(VIM_ID, actualInstantiationRequest.getValue().getExtVirtualLinks().get(1).getVimId());
+ assertEquals("evlId1", actualInstantiationRequest.getValue().getExtVirtualLinks().get(1).getExtVirtualLinkId());
+ assertEquals("networkProviderId1", actualInstantiationRequest.getValue().getExtVirtualLinks().get(1).getResourceId());
+ assertEquals(1, actualInstantiationRequest.getValue().getExtVirtualLinks().get(1).getExtCps().size());
+
+
+ assertEquals(Integer.valueOf(2), actualInstantiationRequest.getValue().getExtVirtualLinks().get(1).getExtCps().get(0).getNumDynamicAddresses());
+ assertEquals("cpdId3", actualInstantiationRequest.getValue().getExtVirtualLinks().get(1).getExtCps().get(0).getCpdId());
+ assertEquals(1, actualInstantiationRequest.getValue().getExtVirtualLinks().get(1).getExtCps().get(0).getAddresses().size());
+ assertEquals("1.2.3.4", actualInstantiationRequest.getValue().getExtVirtualLinks().get(1).getExtCps().get(0).getAddresses().get(0).getIp());
+ assertEquals("mac", actualInstantiationRequest.getValue().getExtVirtualLinks().get(1).getExtCps().get(0).getAddresses().get(0).getMac());
+ assertEquals("subnetId", actualInstantiationRequest.getValue().getExtVirtualLinks().get(1).getExtCps().get(0).getAddresses().get(0).getSubnetId());
+
+ assertEquals("myFlavorId", actualInstantiationRequest.getValue().getFlavourId());
+ assertEquals(Boolean.TRUE, actualInstantiationRequest.getValue().isGrantlessMode());
+ assertEquals("level1", actualInstantiationRequest.getValue().getInstantiationLevelId());
+ assertEquals(1, actualInstantiationRequest.getValue().getZones().size());
+ assertEquals(VIM_ID, actualInstantiationRequest.getValue().getZones().get(0).getVimId());
+ assertEquals("zoneProviderId", actualInstantiationRequest.getValue().getZones().get(0).getResourceId());
+ assertEquals("zoneId", actualInstantiationRequest.getValue().getZones().get(0).getId());
+ assertEquals(1, actualInstantiationRequest.getValue().getSoftwareImages().size());
+ assertEquals(VIM_ID, actualInstantiationRequest.getValue().getSoftwareImages().get(0).getVimId());
+ assertEquals("imageProviderId", actualInstantiationRequest.getValue().getSoftwareImages().get(0).getResourceId());
+ assertEquals("imageId", actualInstantiationRequest.getValue().getSoftwareImages().get(0).getVnfdSoftwareImageId());
+ String actualEmbeddedAdditionParams = new Gson().toJson(actualInstantiationRequest.getValue().getAdditionalParams());
+ assertTrue("{\"jobId\":\"myJobId\",\"a\":\"b\"}".equals(actualEmbeddedAdditionParams) || "{\"a\":\"b\",\"jobId\":\"myJobId\"}".equals(actualEmbeddedAdditionParams));
+ assertTrue(actualVim.getInterfaceInfo().isSkipCertificateVerification());
+ assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck());
+
+ assertEquals(1, actualVnfModifyRequest.getAllValues().size());
+ assertEquals(2, actualVnfModifyRequest.getValue().getExtensions().size());
+ assertEquals(LifecycleManager.ONAP_CSAR_ID, actualVnfModifyRequest.getValue().getExtensions().get(0).getName());
+ assertEquals(ONAP_CSAR_ID, actualVnfModifyRequest.getValue().getExtensions().get(0).getValue());
+ assertEquals(LifecycleManager.EXTERNAL_VNFM_ID, actualVnfModifyRequest.getValue().getExtensions().get(1).getName());
+ assertEquals(VNFM_ID, actualVnfModifyRequest.getValue().getExtensions().get(1).getValue());
+
+ //the 3.2 API does not accept empty array
+ assertNull(actualVnfModifyRequest.getValue().getVnfConfigurableProperties());
+ verify(jobManager).spawnJob(VNF_ID, restResponse);
+ verify(logger).info(eq("Starting {} operation on VNF with {} identifier with {} parameter"), eq("creation"), eq("not yet specified"), anyString());
+ verify(logger).info(eq("Starting {} operation on VNF with {} identifier with {} parameter"), eq("instantiation"), eq(VNF_ID), anyString());
+ }
+
+ /**
* test instantiation with KeyStone V3 based with SSL
*/
@Test
public void testInstantiationV3WithSsl() throws Exception {
VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
-
when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -438,7 +528,6 @@ public class TestLifecycleManager extends TestBase {
@Test
public void testInstantiationV3WithNonSpecifiedSsl() throws Exception {
VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
-
when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -469,6 +558,70 @@ public class TestLifecycleManager extends TestBase {
}
/**
+ * verify backward compatibility with Amsterdam release
+ */
+ @Test
+ public void testInstantiationV3WithNoDomain() throws Exception {
+ additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
+ additionalParam.setDomain("myDomain");
+ VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
+ vimInfo.setDomain(null);
+ when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
+ when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
+ grantResponse.setVimId(VIM_ID);
+ GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo();
+ accessInfo.setTenant(TENANT);
+ vimInfo.setSslInsecure(null);
+ grantResponse.setAccessInfo(accessInfo);
+ ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
+ when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(instantiationOperationExecution));
+ //when
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
+ waitForJobToFinishInJobManager(finished);
+ assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
+ //verify
+ OPENSTACKV3INFO actualVim = (OPENSTACKV3INFO) actualInstantiationRequest.getValue().getVims().get(0);
+ assertEquals(VIM_ID, actualVim.getId());
+ assertEquals(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, actualVim.getVimInfoType());
+ assertEquals("cloudUrl", actualVim.getInterfaceInfo().getEndpoint());
+ //FIXME assertEquals();actualVim.getInterfaceInfo().getTrustedCertificates());
+ assertEquals("vimPassword", actualVim.getAccessInfo().getPassword());
+ assertEquals("regionId", actualVim.getAccessInfo().getRegion());
+ assertEquals("myTenant", actualVim.getAccessInfo().getProject());
+ assertEquals("myDomain", actualVim.getAccessInfo().getDomain());
+ assertEquals("vimUsername", actualVim.getAccessInfo().getUsername());
+ assertTrue(actualVim.getInterfaceInfo().isSkipCertificateVerification());
+ assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck());
+ verify(logger).warn("Setting domain from additional parameters");
+ }
+
+ /**
+ * verify backward compatibility with Amsterdam release
+ * if no domain is specified error is propagated
+ */
+ @Test
+ public void testInstantiationV3WithNoDomainFail() throws Exception {
+ VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
+ vimInfo.setDomain(null);
+ when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
+ additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
+ when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
+ grantResponse.setVimId(VIM_ID);
+ GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo();
+ accessInfo.setTenant(TENANT);
+ vimInfo.setSslInsecure(null);
+ grantResponse.setAccessInfo(accessInfo);
+ ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
+ when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(instantiationOperationExecution));
+ //when
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
+ waitForJobToFinishInJobManager(finished);
+ assertEquals(0, actualInstantiationRequest.getAllValues().size());
+ //verify
+ verify(logger).error("The cloud did not supply the cloud domain (Amsterdam release) and was not supplied as additional data");
+ }
+
+ /**
* test instantiation with vcloud
*/
@Test
@@ -846,7 +999,7 @@ public class TestLifecycleManager extends TestBase {
boolean deleted = false;
while (!deleted) {
try {
- verify(vnfApi).vnfsVnfInstanceIdDelete(VNF_ID, NOKIA_LCM_API_VERSION);
+ verify(logger).info("The VNF with {} identifier has been deleted", VNF_ID);
deleted = true;
} catch (Error e) {
}
@@ -855,7 +1008,7 @@ public class TestLifecycleManager extends TestBase {
verify(notificationManager, never()).waitForTerminationToBeProcessed("terminationId");
verify(logger).warn("The VNF with {} identifier is not instantiated no termination is required", VNF_ID);
verify(logger).info("Deleting VNF with {} identifier", VNF_ID);
- verify(logger).info("The VNF with {} identifier has been deleted", VNF_ID);
+ verify(vnfApi).vnfsVnfInstanceIdDelete(VNF_ID, NOKIA_LCM_API_VERSION);
VOID_OBSERVABLE.assertCalled();
}