summaryrefslogtreecommitdiffstats
path: root/nokiav2
diff options
context:
space:
mode:
authorDenes Nemeth <denes.nemeth@nokia.com>2018-03-10 15:59:42 +0100
committerDenes Nemeth <denes.nemeth@nokia.com>2018-03-10 16:10:01 +0100
commitf5608b8ab40816febb064a61e80b52b572eda768 (patch)
tree2545e8bbb004f12043666f375bb8ef33d5a4e9b5 /nokiav2
parentb48be0c7c0f16b9724d98fcceac898cfe1942f7d (diff)
Add missing tests
Change-Id: I6205fc147d0702c1f4242285f4414645a4e8a3de Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com> Issue-ID: VFC-728
Diffstat (limited to 'nokiav2')
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java4
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java3
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java5
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java27
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java11
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java34
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java5
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java3
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestConditions.java9
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java26
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java7
-rw-r--r--nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml2
14 files changed, 80 insertions, 60 deletions
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java
index ec98e966..64a418de 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java
@@ -60,9 +60,7 @@ public class MsbApiProvider extends IpMappingProvider {
public String getMicroServiceUrl(String name, String version) {
MicroServiceFullInfo microServiceFullInfo = getMicroServiceInfo(name, version);
String ipAnPort = getNodeIpAnPort(microServiceFullInfo);
- //FIXME the enable_ssl field should be used, but it is not available in SDK
- //depends on https://jira.onap.org/browse/MSB-151
- String protocol = (ipAnPort.endsWith(":8443") || ipAnPort.endsWith(":443")) ? "https://" : "http://";
+ String protocol = microServiceFullInfo.isEnable_ssl() ? "https://" : "http://";
//the field name in A&AI is misleading the URL is relative path postfixed to http(s)://ip:port
return protocol + ipAnPort + microServiceFullInfo.getUrl();
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
index 3fda6192..a9e11653 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
@@ -140,8 +140,7 @@ public class SelfRegistrationManager {
microServiceInfo.setVisualRange(INTERNAL_SERVICE);
microServiceInfo.setServiceName(SERVICE_NAME);
microServiceInfo.setVersion(DRIVER_VERSION);
- //FIXME set enable_ssl to false after the field has been added to MSB SDK https://jira.onap.org/browse/MSB-151
- //currently defaults to false, which is good
+ microServiceInfo.setEnable_ssl(true);
Node node = new Node();
microServiceInfo.setNodes(new HashSet<>());
microServiceInfo.getNodes().add(node);
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
index e628458d..8d658310 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
@@ -81,7 +81,7 @@ public class OnapVnfdBuilder {
body.append(buildEcp(node.getKey(), node.getValue(), nodeTemplates));
break;
default:
- //
+ logger.warn("The {} type is not converted", type);
}
}
return buildHeader(topologyTemplate) + body.toString();
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java
index 74ac6ea2..7f63a1a4 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java
@@ -28,6 +28,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
+import java.util.Optional;
+
+import static java.util.Optional.empty;
import static org.apache.http.HttpStatus.SC_CREATED;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.BASE_URL;
import static org.slf4j.LoggerFactory.getLogger;
@@ -146,6 +149,6 @@ public class LcmApi {
@ResponseBody
public JobInfo healVnf(@RequestBody VnfHealRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfInstanceId, HttpServletResponse httpResponse) {
logger.info("REST: Heal VNF");
- return lifecycleManager.healVnf(vnfmId, vnfInstanceId, request, httpResponse);
+ return lifecycleManager.healVnf(vnfmId, vnfInstanceId, request, empty(), httpResponse);
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java
index 70cf11ca..dfb7adaf 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java
@@ -35,7 +35,7 @@ public class AdditionalParameters {
private List<ExtVirtualLinkData> extVirtualLinks = new ArrayList<>();
private Object additionalParams;
- AdditionalParameters() {
+ public AdditionalParameters() {
//only used through reflection (gson)
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
index b78c13a0..79e9487d 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
@@ -131,12 +131,10 @@ public class LifecycleManager {
* @param csarId the identifier of the VNF package
* @param vnfName the name of the VNF
* @param description the description of the VNF
- * @param addtionalParams additional parameters for the VNF instantiation request
* @return the VNF creation result
*/
- public VnfCreationResult create(String vnfmId, String csarId, String vnfName, String description, AdditionalParameters addtionalParams) {
- logOperationInput("not yet specified", "creation", addtionalParams);
- validateVimType(addtionalParams.getVimType());
+ public VnfCreationResult create(String vnfmId, String csarId, String vnfName, String description) {
+ logOperationInput("not yet specified", "creation", csarId);
try {
CatalogAdapterVnfpackage cbamPackage = catalogManager.preparePackageInCbam(vnfmId, csarId);
CreateVnfRequest vnfCreateRequest = new CreateVnfRequest();
@@ -206,7 +204,8 @@ public class LifecycleManager {
*/
public VnfInstantiateResponse createAndInstantiate(String vnfmId, VnfInstantiateRequest request, HttpServletResponse httpResponse) {
AdditionalParameters additionalParameters = convertInstantiationAdditionalParams(request.getVnfPackageId(), request.getAdditionalParam());
- VnfCreationResult creationResult = create(vnfmId, request.getVnfDescriptorId(), request.getVnfInstanceName(), request.getVnfInstanceDescription(), additionalParameters);
+ validateVimType(additionalParameters.getVimType());
+ VnfCreationResult creationResult = create(vnfmId, request.getVnfDescriptorId(), request.getVnfInstanceName(), request.getVnfInstanceDescription());
return instantiate(vnfmId, request, httpResponse, additionalParameters, creationResult.vnfInfo.getId(), creationResult.vnfdId);
}
@@ -557,9 +556,10 @@ public class LifecycleManager {
* @param vnfId the identifier of the VNF
* @param request the heal request
* @param httpResponse the HTTP response
+ * @param vnfcId the identifer of thr VNFC to be healed
* @return the job for tracking the heal
*/
- public JobInfo healVnf(String vnfmId, String vnfId, VnfHealRequest request, HttpServletResponse httpResponse) {
+ public JobInfo healVnf(String vnfmId, String vnfId, VnfHealRequest request, Optional<String> vnfcId, HttpServletResponse httpResponse) {
logOperationInput(vnfId, "heal", request);
return scheduleExecution(vnfId, httpResponse, "heal", job -> {
HealVnfRequest cbamHealRequest = new HealVnfRequest();
@@ -567,6 +567,7 @@ public class LifecycleManager {
additionalParams.put("vmName", request.getAffectedvm().getVmname());
additionalParams.put("action", request.getAction());
additionalParams.put("jobId", job.getJobId());
+ additionalParams.put("vnfcId", vnfcId.orElse("unknown"));
cbamHealRequest.setAdditionalParams(additionalParams);
com.nokia.cbam.lcm.v32.model.VnfInfo vnf = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdGet(vnfId, NOKIA_LCM_API_VERSION);
String vimId = getVimIdFromInstantiationRequest(vnfmId, vnf);
@@ -621,15 +622,19 @@ public class LifecycleManager {
@FunctionalInterface
private interface AsynchronousExecution {
void execute(JobInfo job) throws ApiException;
- }
-
- private static class VnfCreationResult {
- private com.nokia.cbam.lcm.v32.model.VnfInfo vnfInfo;
- private String vnfdId;
+ }
+ public static class VnfCreationResult {
+ private final com.nokia.cbam.lcm.v32.model.VnfInfo vnfInfo;
+ private final String vnfdId;
VnfCreationResult(com.nokia.cbam.lcm.v32.model.VnfInfo vnfInfo, String vnfdId) {
this.vnfInfo = vnfInfo;
this.vnfdId = vnfdId;
}
+
+ public com.nokia.cbam.lcm.v32.model.VnfInfo getVnfInfo() {
+ return vnfInfo;
+ }
+
}
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
index 47e441ff..249e16c9 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
@@ -21,6 +21,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.*;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.ContextClosedEvent;
@@ -138,6 +139,16 @@ public class TestNokiaSvnfmApplication {
}
/**
+ * Spring will instantiate using reflection
+ */
+ @Test
+ public void testUseStaticWay() throws Exception {
+ //verify
+ //the constructor is public even if has no private fields
+ new NokiaSvnfmApplication();
+ }
+
+ /**
* static entry point calling an other static entry point can not be tested
*/
@Test
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java
index aefe63a2..eb3674c3 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java
@@ -121,16 +121,17 @@ public class TestMsbApiProvider extends TestBase {
/**
- * use HTTPS for known ports (443) should be removed if https://jira.onap.org/browse/MSB-151 is solved
+ * use HTTPS for known ports
*/
@Test
- public void testMsb151IssueHack() throws Exception {
+ public void testMsbServiceOverssl() throws Exception {
NodeInfo nonDocker = new NodeInfo();
nonDocker.setIp("173.1.2.3");
- nonDocker.setPort("443");
+ nonDocker.setPort("123");
microServiceInfo.setServiceName("serviceName");
microServiceInfo.setVersion("v1");
microServiceInfo.setUrl("/lead/nslcm/v1");
+ microServiceInfo.setEnable_ssl(true);
when(environment.getProperty(IpMappingProvider.IP_MAP, String.class, "")).thenReturn("173.1.2.3->1.2.3.4");
nodes.add(nonDocker);
msbApiProvider = new MsbApiProvider(environment) {
@@ -142,32 +143,7 @@ public class TestMsbApiProvider extends TestBase {
when(msbClient.queryMicroServiceInfo("serviceName", "v1")).thenReturn(microServiceInfo);
msbApiProvider.afterPropertiesSet();
//when
- assertEquals("https://1.2.3.4:443/lead/nslcm/v1", msbApiProvider.getMicroServiceUrl("serviceName", "v1"));
- }
-
- /**
- * use HTTPS for known ports (443) should be removed if https://jira.onap.org/browse/MSB-151 is solved
- */
- @Test
- public void testMsb151IssueHack2() throws Exception {
- NodeInfo nonDocker = new NodeInfo();
- nonDocker.setIp("173.1.2.3");
- nonDocker.setPort("8443");
- microServiceInfo.setServiceName("serviceName");
- microServiceInfo.setVersion("v1");
- microServiceInfo.setUrl("/lead/nslcm/v1");
- when(environment.getProperty(IpMappingProvider.IP_MAP, String.class, "")).thenReturn("173.1.2.3->1.2.3.4");
- nodes.add(nonDocker);
- msbApiProvider = new MsbApiProvider(environment) {
- @Override
- public MSBServiceClient getMsbClient() {
- return msbClient;
- }
- };
- when(msbClient.queryMicroServiceInfo("serviceName", "v1")).thenReturn(microServiceInfo);
- msbApiProvider.afterPropertiesSet();
- //when
- assertEquals("https://1.2.3.4:8443/lead/nslcm/v1", msbApiProvider.getMicroServiceUrl("serviceName", "v1"));
+ assertEquals("https://1.2.3.4:123/lead/nslcm/v1", msbApiProvider.getMicroServiceUrl("serviceName", "v1"));
}
/**
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java
index 5001eedf..2cd0aa1e 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java
@@ -63,14 +63,11 @@ public class TestOnapVnfdBuilder extends TestBase {
verify(logger).warn("The {} ecp does not have an internal connection point", "myEcpWithoutIcp");
verify(logger).warn("The {} ecp does not have an requirements section", "ecpWithIcpWithOutRequirements");
verify(logger).warn("The {} internal connection point of the {} ecp does not have a VDU", "icpWithoutVdu", "myEcpWithoutIcpWithoutVdu");
-
verify(logger).warn("The {} internal connection point of the {} ecp does not have a requirements section", "icpWithOutRequiements", "myEcpWithoutIcpWithoutIcpReq");
-
-
verify(logger).warn("The {} internal connection point does not have a VDU", "icpWithOutVdu");
verify(logger).warn("The {} internal connection point does not have a requirements section", "icpWithOutRequiements");
verify(logger).warn("The {} internal connection point does not have a VL", "icpWithOutVl");
-
+ verify(logger).warn("The {} type is not converted", "tosca.nodes.nfv.Unknown");
}
/**
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 4d10fd52..6b04d69d 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
@@ -28,6 +28,7 @@ import org.onap.vnfmdriver.model.VnfInstantiateRequest;
import org.onap.vnfmdriver.model.VnfScaleRequest;
import org.onap.vnfmdriver.model.VnfTerminateRequest;
+import static java.util.Optional.empty;
import static org.apache.http.HttpStatus.SC_CREATED;
import static org.mockito.Mockito.verify;
import static org.springframework.test.util.ReflectionTestUtils.setField;
@@ -70,7 +71,7 @@ public class TestLcmApi extends TestBase {
//when
lcmApi.healVnf(req, VNFM_ID, VNF_ID, httpResponse);
//verify
- verify(lifecycleManager).healVnf(VNFM_ID, VNF_ID, req, httpResponse);
+ verify(lifecycleManager).healVnf(VNFM_ID, VNF_ID, req, empty(), httpResponse);
verify(logger).info("REST: Heal VNF");
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestConditions.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestConditions.java
index f716cad6..7a525b37 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestConditions.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestConditions.java
@@ -21,6 +21,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
@@ -63,4 +64,12 @@ public class TestConditions {
TestCase.assertTrue(new Conditions.UseForDirect().matches(conditionContext, null));
}
+ /**
+ * use class in a static way
+ */
+ @Test
+ public void useStaticway(){
+ TestUtil.coveragePrivateConstructorForClassesWithStaticMethodsOnly(Conditions.class);
+ }
+
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java
index 44ba0e52..4b35f2ff 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java
@@ -45,6 +45,10 @@ import java.security.KeyStoreException;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import static junit.framework.TestCase.*;
import static org.mockito.Matchers.eq;
@@ -54,10 +58,10 @@ import static org.springframework.test.util.ReflectionTestUtils.setField;
class HttpTestServer {
Server _server;
- List<String> requests = new ArrayList<>();
- List<Integer> codes = new ArrayList<>();
- List<String> respones = new ArrayList<>();
-
+ volatile List<String> requests = new ArrayList<>();
+ volatile List<Integer> codes = new ArrayList<>();
+ volatile List<String> respones = new ArrayList<>();
+ ExecutorService executorService = Executors.newCachedThreadPool();
public void start() throws Exception {
configureServer();
startServer();
@@ -67,6 +71,18 @@ class HttpTestServer {
requests.clear();
codes.clear();
_server.start();
+ Future<?> serverStarted = executorService.submit(() -> {
+ while(true){
+ try {
+ Thread.sleep(10);
+ if(_server.isStarted()){
+ return;
+ }
+ } catch (InterruptedException e) {
+ }
+ }
+ });
+ serverStarted.get(30, TimeUnit.SECONDS);
}
protected void configureServer() throws Exception {
@@ -119,6 +135,8 @@ public class TestCbamTokenProvider extends TestBase {
testServer.start();
URI uri = testServer._server.getURI();
setField(cbamTokenProvider, "cbamKeyCloakBaseUrl", uri.toString());
+
+
}
private void addGoodTokenResponse() {
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 c601f7ee..c6e76ef6 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
@@ -49,6 +49,7 @@ import java.util.*;
import static java.lang.Boolean.parseBoolean;
import static java.nio.file.Files.readAllBytes;
+import static java.util.Optional.empty;
import static junit.framework.TestCase.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
@@ -1317,7 +1318,7 @@ public class TestLifecycleManager extends TestBase {
String instantiationParams = "{ \"vims\" : [ { \"id\" : \"" + VIM_ID + "\" } ] }";
when(operationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet(instantiationOperationExecution.getId(), NOKIA_LCM_API_VERSION)).thenReturn(new JsonParser().parse(instantiationParams));
//when
- JobInfo job = lifecycleManager.healVnf(VNFM_ID, VNF_ID, healRequest, restResponse);
+ JobInfo job = lifecycleManager.healVnf(VNFM_ID, VNF_ID, healRequest, empty(), restResponse);
//verify
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualHealRequest.getAllValues().size());
@@ -1366,7 +1367,7 @@ public class TestLifecycleManager extends TestBase {
}
});
//when
- JobInfo job = lifecycleManager.healVnf(VNFM_ID, VNF_ID, healRequest, restResponse);
+ JobInfo job = lifecycleManager.healVnf(VNFM_ID, VNF_ID, healRequest, empty(), restResponse);
//verify
waitForJobToFinishInJobManager(finished);
assertEquals(100, expectedExceptions.size());
@@ -1389,7 +1390,7 @@ public class TestLifecycleManager extends TestBase {
healRequest.setAffectedvm(affectedVm);
when(vnfApi.vnfsVnfInstanceIdGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenThrow(expectedException);
//when
- JobInfo job = lifecycleManager.healVnf(VNFM_ID, VNF_ID, healRequest, restResponse);
+ JobInfo job = lifecycleManager.healVnf(VNFM_ID, VNF_ID, healRequest, empty(), restResponse);
//verify
waitForJobToFinishInJobManager(finished);
verify(logger).error("Unable to heal VNF with myVnfId identifier", expectedException);
diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml
index 4f8415e6..985ab276 100644
--- a/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml
+++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml
@@ -20,6 +20,8 @@ topology_template:
- virtual_storage: myStorage2
- unhandled_type: unknown
+ unknownType:
+ type: tosca.nodes.nfv.Unknown
myCompute:
type: tosca.nodes.nfv.VirtualCompute