summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Aharoni <pa0916@att.com>2017-05-25 20:29:43 +0300
committerPavel Aharoni <pa0916@att.com>2017-05-25 20:29:43 +0300
commit2aed5c9968c48f665b85569333aa61011e611321 (patch)
tree89d369125093e7d621d795808679234f954f5c0f
parent9e430cd9d4722c3e614c8a2fd822cff1604be1f2 (diff)
[SDC-24] sdnc problems
Change-Id: I5bb5fd91ae1daf73fdf63cf8108531295bb8e96d Signed-off-by: Pavel Aharoni <pa0916@att.com>
-rw-r--r--.gitignore1
-rw-r--r--sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java42
-rw-r--r--sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java2
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java12
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java5
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java7
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java53
-rw-r--r--sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java6
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-Renanatst2-csar.csarbin0 -> 321286 bytes
-rw-r--r--sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-get-input.csarbin0 -> 45214 bytes
10 files changed, 105 insertions, 23 deletions
diff --git a/.gitignore b/.gitignore
index 233ca40..70a26f7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,4 @@ target/
.idea/*
/bin/
sdc-tosca-parser/test-output/**/*
+*.iml
diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java
index 1166109..c5cce09 100644
--- a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java
+++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java
@@ -26,8 +26,11 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.stream.Collectors;
+import org.json.JSONArray;
+import org.json.JSONObject;
import org.openecomp.sdc.api.IDistributionClient;
import org.openecomp.sdc.api.consumer.IDistributionStatusMessage;
import org.openecomp.sdc.api.consumer.INotificationCallback;
@@ -157,7 +160,7 @@ public class SimpleCallback implements INotificationCallback {
if (downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) {
- handleSuccessfullDownload(data, relevantArtifact);
+ handleSuccessfullDownload(data, relevantArtifact, downloadResult.getArtifactPayload());
} else {
handleFailedDownload(data, relevantArtifact);
}
@@ -207,7 +210,7 @@ public class SimpleCallback implements INotificationCallback {
postDownloadStatusSendLogic(sendDownloadStatus);
}
- private void handleSuccessfullDownload(INotificationData data, IArtifactInfo relevantArtifact) {
+ private void handleSuccessfullDownload(INotificationData data, IArtifactInfo relevantArtifact, byte[] payload) {
// Send Download Status
IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_OK));
@@ -216,7 +219,7 @@ public class SimpleCallback implements INotificationCallback {
// Doing deployment ...
postDownloadStatusSendLogic(sendDownloadStatus);
- boolean isDeployedSuccessfully = handleDeployment();
+ boolean isDeployedSuccessfully = handleDeployment(data, relevantArtifact, payload);
IDistributionClientResult deploymentStatus;
try {
Thread.sleep(1000);
@@ -269,8 +272,37 @@ public class SimpleCallback implements INotificationCallback {
return false;
}
- private boolean handleDeployment() {
- return true;
+ private boolean handleDeployment(INotificationData data, IArtifactInfo relevantArtifact, byte[] payload) {
+ if (relevantArtifact.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.name())) {
+
+ try {
+ List<IArtifactInfo> serviceArtifacts = data.getServiceArtifacts();
+ JSONArray jsonData = new JSONArray(new String(payload));
+ boolean artifactIsFound = true;
+ for (int index = 0 ; index < jsonData.length(); index++) {
+
+ JSONObject jsonObject = (JSONObject) jsonData.get(index);
+ JSONArray artifacts = (JSONArray) jsonObject.get("artifacts");
+ for (int i = 0 ; i < artifacts.length(); i++) {
+ String artifact = artifacts.getString(i).toString();
+ Optional<IArtifactInfo> serviceArtifactFound = serviceArtifacts.stream().filter(x -> x.getArtifactUUID().equals(artifact)).findFirst();
+ if (!serviceArtifactFound.isPresent()) {
+ artifactIsFound = false;
+ System.out.println("################ Artifact: " + artifact + " NOT FOUND in Notification Data ################");
+ }
+ }
+ }
+ return artifactIsFound;
+
+ } catch (Exception e) {
+ System.out.println("################ Couldn't convert vf_modules_metadata.json to json : " + e.getMessage());
+ return false;
+ }
+ }
+ else {
+ return true;
+ }
+
// to return deploy_error use return false
// return false;
}
diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java
index 9c07c12..115bfab 100644
--- a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java
+++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java
@@ -150,7 +150,7 @@ public class SimpleConfiguration implements IConfiguration{
}
public static Boolean toDownload() {
- return false;
+ return true;
}
public static String downloadPath() {
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
index c53dcec..cf4806d 100644
--- a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -41,6 +41,7 @@ import org.openecomp.sdc.toscaparser.api.TopologyTemplate;
import org.openecomp.sdc.toscaparser.api.ToscaTemplate;
import org.openecomp.sdc.toscaparser.api.elements.Metadata;
import org.openecomp.sdc.toscaparser.api.elements.NodeType;
+import org.openecomp.sdc.toscaparser.api.functions.Function;
import org.openecomp.sdc.toscaparser.api.parameters.Input;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -74,7 +75,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
String[] split = getSplittedPath(leafValuePath);
LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
Object property = processProperties(split, properties);
- return property == null ? null : String.valueOf(property);
+ return property == null || property instanceof Function ? null : String.valueOf(property);
}
@Override
@@ -124,11 +125,12 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
String fullPathToSearch = PREFIX + cpName + "_" + item;
Object value = getNodeTemplatePropertyAsObject(vfc, fullPathToSearch);
if (value != null) {
- if (!cps.containsKey(cpName))
+ if (!cps.containsKey(cpName)){
cps.put(cpName, new HashMap<>());
+ }
+ cps.get(cpName).put(item, value);
}
- cps.get(cpName).put(item, value);
}
}
}
@@ -250,7 +252,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
Input input = findFirst.get();
Object current = input.getDefault();
Object property = iterateProcessPath(2, current, split);
- return property == null ? null : String.valueOf(property);
+ return property == null || property instanceof Function? null : String.valueOf(property);
}
}
log.error("getServiceInputLeafValue - value not found");
@@ -360,7 +362,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
String[] split = getSplittedPath(leafValuePath);
LinkedHashMap<String, Property> properties = group.getProperties();
Object property = processProperties(split, properties);
- return property == null ? null : String.valueOf(property);
+ return property == null || property instanceof Function? null : String.valueOf(property);
}
@Override
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
index 6746df7..7ea231c 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/SdcToscaParserBasicTest.java
@@ -25,6 +25,7 @@ public abstract class SdcToscaParserBasicTest {
static ISdcCsarHelper rainyCsarHelperMultiVfs;
static ISdcCsarHelper fdntCsarHelper;
static ISdcCsarHelper complexCps;
+ static ISdcCsarHelper fdntCsarHelperWithInputs;
static Map<String, HashMap<String, List<String>>> fdntCsarHelper_Data;
@BeforeClass
@@ -34,7 +35,9 @@ public abstract class SdcToscaParserBasicTest {
fdntCsarHelper = getCsarHelper("csars/service-ServiceFdnt-with-allotted.csar");
rainyCsarHelperMultiVfs = getCsarHelper("csars/service-ServiceFdnt-csar-rainy.csar");
rainyCsarHelperSingleVf = getCsarHelper("csars/service-ServiceFdnt-csar.csar");
- complexCps = getCsarHelper("csars/1service-ServiceWithPorts.csar");
+ complexCps = getCsarHelper("csars/service-Renanatst2-csar.csar");
+ fdntCsarHelperWithInputs = getCsarHelper("csars/service-ServiceFdnt-with-get-input.csar");
+
fdntCsarHelper_Data = new HashMap<String, HashMap<String, List<String>>>(){
{
HashMap<String, List<String>> FDNT ;
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
index 01c888f..d7321d1 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserGroupTest.java
@@ -76,6 +76,13 @@ public class ToscaParserGroupTest extends SdcToscaParserBasicTest{
assertEquals("false", volumeGroup);
}
+// @Test
+// public void testGroupFlatGetInputProperty() throws SdcToscaParserException {
+// List<Group> vfModulesByVf = fdntCsarHelperWithInputs.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
+// String volumeGroup = fdntCsarHelperWithInputs.getGroupPropertyLeafValue(vfModulesByVf.get(1), "volume_group");
+// assertEquals("false", volumeGroup);
+// }
+
@Test
public void testGroupPropertyLeafValueByNullProperty() {
List<Group> vfModulesByVf = fdntCsarHelper.getVfModulesByVf(VF_CUSTOMIZATION_UUID);
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
index dd895c3..61d8781 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java
@@ -3,16 +3,18 @@ package org.openecomp.sdc.impl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
-import org.testng.annotations.Test;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.openecomp.sdc.toscaparser.api.Group;
import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.testng.annotations.Test;
public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
@@ -43,6 +45,12 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
}
@Test
+ public void testNodeTemplateFlatFunctionProperty() throws SdcToscaParserException {
+ List<NodeTemplate> serviceVfList = fdntCsarHelperWithInputs.getServiceVfList();
+ assertEquals(null, fdntCsarHelperWithInputs.getNodeTemplatePropertyLeafValue(serviceVfList.get(1), "target_network_role"));
+ }
+
+ @Test
public void testNodeTemplateNestedProperty() throws SdcToscaParserException {
List<NodeTemplate> serviceVlList = fdntCsarHelper.getServiceVlList();
NodeTemplate nodeTemplate = serviceVlList.get(0);
@@ -50,7 +58,7 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
assertEquals("24", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#cidr_mask"));
assertEquals("7a6520b-9982354-ee82992c-105720", fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_flows#vpn_binding"));
}
-
+
@Test
public void testNodeTemplateNestedPropertyFromInput() throws SdcToscaParserException {
List<NodeTemplate> serviceVfList = fdntCsarHelper.getServiceVfList();
@@ -308,20 +316,43 @@ public class ToscaParserNodeTemplateTest extends SdcToscaParserBasicTest {
//region getCpPropertiesFromVfc
@Test
public void testGetCpPropertiesFromVfc() {
- List<NodeTemplate> vfcs = complexCps.getVfcListByVf(VF_CUSTOMIZATION_UUID);
- Map<String, Map<String, Object>> cps = complexCps.getCpPropertiesFromVfc(vfcs.get(0));
+ List<NodeTemplate> vfcs = complexCps.getVfcListByVf("f999e2ca-72c0-42d3-9b11-13f2122fb8ef");
+ boolean isChecked = false;
+ boolean isChecked1 = false;
+ for (int i = 0; i < vfcs.size(); i++) {
+
+ if(vfcs.get(i).getName().equalsIgnoreCase("abstract_ddc"))
+ {
+ isChecked = true;
+ Map<String, Map<String, Object>> cps = complexCps.getCpPropertiesFromVfc(vfcs.get(i));
- assertEquals(5, cps.size());
+ assertEquals(3,cps.size());
- assertEquals(1, cps.get("port_fe1_sigtran").get("ip_requirements#ip_count_required#count"));
- assertEquals(true, cps.get("port_fe1_sigtran").get("ip_requirements#dhcp_enabled"));
- assertEquals(4, cps.get("port_fe1_sigtran").get("ip_requirements#ip_version"));
+ assertEquals(new Integer(1), cps.get("ddc_int_imbl__port").get("ip_requirements#ip_count_required#count"));
+ assertEquals(new Boolean(true), cps.get("ddc_int_imbl__port").get("ip_requirements#dhcp_enabled"));
+ assertEquals(new Integer(6), cps.get("ddc_int_imbl__port").get("ip_requirements#ip_version"));
+ assertEquals(null, cps.get("ddc_int_imbl__port").get("subnetpoolid"));
- assertEquals(2, cps.get("port_fe_cluster").get("ip_requirements#ip_count_required#count"));
- assertEquals(true, cps.get("port_fe_cluster").get("ip_requirements#dhcp_enabled"));
- assertEquals(4, cps.get("port_fe_cluster").get("ip_requirements#ip_version"));
+ //assertEquals("\"int_imsp\"", cps.get("mon_ist_imsp__port").get("network_role_tag"));
+
+ }
+
+ if(vfcs.get(i).getName().equalsIgnoreCase("abstract_mda"))
+ {
+ isChecked1 = true;
+ Map<String, Map<String, Object>> cps1 = complexCps.getCpPropertiesFromVfc(vfcs.get(i));
+
+ assertEquals(new Integer(4), cps1.get("mda_int_imsp__port").get("ip_requirements#ip_version"));
+ assertEquals(null, cps1.get("mda_int_imsp__port").get("ip_requirements#ip_count_required#count"));
+
+ }
+
+ }
+ assertTrue(isChecked);
+ assertTrue(isChecked1);
}
+
@Test
public void testGetCpPropertiesFromVfcForNullVFC() {
Map<String, Map<String, Object>> cps = complexCps.getCpPropertiesFromVfc(null);
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java
index 0b172f5..ea5c2ef 100644
--- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java
+++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserServiceInputTest.java
@@ -34,6 +34,12 @@ public class ToscaParserServiceInputTest extends SdcToscaParserBasicTest {
assertEquals("test service naming", serviceInputLeafValue);
}
+// @Test
+// public void testGetServiceInputLeafValueWithGetInput(){
+// String serviceInputLeafValue = fdntCsarHelperWithInputs.getServiceInputLeafValueOfDefault("my_input#default");
+// assertEquals(null, serviceInputLeafValue);
+// }
+
@Test
public void testGetServiceInputLeafValueNotExists(){
String serviceInputLeafValue = fdntCsarHelper.getServiceInputLeafValueOfDefault("service_naming#default#kuku");
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-Renanatst2-csar.csar b/sdc-tosca-parser/src/test/resources/csars/service-Renanatst2-csar.csar
new file mode 100644
index 0000000..37baffb
--- /dev/null
+++ b/sdc-tosca-parser/src/test/resources/csars/service-Renanatst2-csar.csar
Binary files differ
diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar
new file mode 100644
index 0000000..53aea49
--- /dev/null
+++ b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-get-input.csar
Binary files differ