Adding more hpa feature support for Polices 51/66651/3
authorliboNet <libo.zhu@intel.com>
Sat, 15 Sep 2018 04:29:04 +0000 (12:29 +0800)
committerliboNet <libo.zhu@intel.com>
Sat, 15 Sep 2018 06:37:27 +0000 (14:37 +0800)
* Add hugePage feature parse
* Add SRIOV feature parse
* Add pciePassthrough feature parse
* Add more test cases and resources

Change-Id: Ib45515a26e3fdac742a631b3a13d739fd1784d2f
Issue-ID: POLICY-927
Signed-off-by: liboNet <libo.zhu@intel.com>
plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java
plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/HpaFeatureAttribute.java
plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java
plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csar [new file with mode: 0644]
plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar [new file with mode: 0644]
plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar [moved from plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar with 94% similarity]

index 4e7f941..1d0f621 100644 (file)
 
 package org.onap.policy.distribution.reception.decoding.pdpx;
 
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
 import java.io.FileWriter;
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
@@ -37,6 +40,8 @@ import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.toscaparser.api.CapabilityAssignment;
 import org.onap.sdc.toscaparser.api.CapabilityAssignments;
 import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.RequirementAssignment;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
 
 /**
  * Extract concerned info from NodeTemplate, currently ONLY HPA Feature.
@@ -51,7 +56,17 @@ public class ExtractFromNode {
     private static final String VIRTUAL_MEM_SIZE_PATH = "virtual_memory#virtual_mem_size";
     private static final String NUM_VIRTUAL_CPU_PATH = "virtual_cpu#num_virtual_cpu";
     private static final String CPU_ARCHITECTURE_PATH = "virtual_cpu#cpu_architecture";
-    private static final String BASIC_CAPABILITIES = "BasicCapabilities";
+    private static final String MEMORY_PAGE_SIZE_PATH = "virtual_memory#vdu_memory_requirements#memoryPageSize";
+    private static final String NETWORK_INTERFACE_TYPE_PATH = 
+        "virtual_network_interface_requirements#network_interface_requirements#interfaceType";
+    private static final String NETWORK_PCI_PATH = 
+        "virtual_network_interface_requirements#nic_io_requirements";
+    private static final String BASIC_CAPABILITIES_HPA_FEATURE = "BasicCapabilities";
+    private static final String HUGE_PAGES_HPA_FEATURE = "hugePages";
+    private static final Map<String, String> NETWORK_HPA_FEATURE_MAP = new HashMap() {{
+        put("SR-IOV", "SriovNICNetwork");
+        put("PCI-Passthrough", "pciePassthrough");
+    }};
 
     ISdcCsarHelper sdcCsarHelper;
     final Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting().disableHtmlEscaping().create();
@@ -136,7 +151,7 @@ public class ExtractFromNode {
                     capabilityAssignments.getCapabilityByName("virtual_compute");
             if (capabilityAssignment != null) {
                 generateBasicCapability(capabilityAssignment, flavorFeature);
-                generateHugePages(capabilityAssignment);
+                generateHugePages(capabilityAssignment,flavorFeature);
             }
             content.getFlavorFeatures().add(flavorFeature);
         }
@@ -148,31 +163,29 @@ public class ExtractFromNode {
      * @param capabilityAssignment represents the capability of node
      * @param flavorFeature represents all the features of specified flavor
      */
-    private void generateBasicCapability(final CapabilityAssignment capabilityAssignment,
-            final FlavorFeature flavorFeature) {
-        // the format is xxx MB/GB like 4096 MB
-        final String virtualMemSize =
-                sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, VIRTUAL_MEM_SIZE_PATH);
+    private void generateBasicCapability(final CapabilityAssignment capabilityAssignment, FlavorFeature flavorFeature){
+        //the format is xxx MB/GB like 4096 MB
+        String virtualMemSize = sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment,
+                VIRTUAL_MEM_SIZE_PATH);
         if (virtualMemSize != null) {
             LOGGER.debug("the virtualMemSize = " + virtualMemSize);
-            final HpaFeatureAttribute hpaFeatureAttribute =
-                    generateHpaFeatureAttribute("virtualMemSize", virtualMemSize);
-            final FlavorProperty flavorProperty = new FlavorProperty();
-            flavorProperty.setHpaFeature(BASIC_CAPABILITIES);
+            HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("virtualMemSize", virtualMemSize);
+            FlavorProperty flavorProperty = new FlavorProperty();
+            flavorProperty.setHpaFeature(BASIC_CAPABILITIES_HPA_FEATURE);
             flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute);
             flavorFeature.getFlavorProperties().add(flavorProperty);
         }
-
-        // the format is int like 2
-        final String numVirtualCpu =
-                sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, NUM_VIRTUAL_CPU_PATH);
+            
+        //the format is int like 2 
+        String numVirtualCpu = sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment,
+            NUM_VIRTUAL_CPU_PATH);
         if (numVirtualCpu != null) {
             LOGGER.debug("the numVirtualCpu = " + numVirtualCpu);
-            final HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("numVirtualCpu", numVirtualCpu);
-            final String cpuArchitecture =
-                    sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, CPU_ARCHITECTURE_PATH);
-            final FlavorProperty flavorProperty = new FlavorProperty();
-            flavorProperty.setHpaFeature(BASIC_CAPABILITIES);
+            HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("numVirtualCpu", numVirtualCpu);
+            String cpuArchitecture = sdcCsarHelper.getCapabilityPropertyLeafValue
+                    (capabilityAssignment,CPU_ARCHITECTURE_PATH);
+            FlavorProperty flavorProperty = new FlavorProperty();
+            flavorProperty.setHpaFeature(BASIC_CAPABILITIES_HPA_FEATURE);
             if (cpuArchitecture != null) {
                 flavorProperty.setArchitecture(cpuArchitecture);
             }
@@ -189,7 +202,7 @@ public class ExtractFromNode {
      * @param featureValue get from the high layer tosca DM
      */
     private HpaFeatureAttribute generateHpaFeatureAttribute(final String hpaAttributeKey, final String featureValue) {
-
+        //based on input featureValue, return back a suitable hpaFeatureAttribute
         final HpaFeatureAttribute hpaFeatureAttribute = new HpaFeatureAttribute();
         hpaFeatureAttribute.setHpaAttributeKey(hpaAttributeKey);
         final String tmp = featureValue.replace(" ", "");
@@ -215,8 +228,26 @@ public class ExtractFromNode {
      * @param capabilityAssignment represents the capability of node
      * @param flavorFeature represents all the features of specified flavor
      */
-    private void generateHugePages(final CapabilityAssignment capabilityAssignment) {
-        // add HugePages support
+    private void generateHugePages(final CapabilityAssignment capabilityAssignment, FlavorFeature flavorFeature){
+        String memoryPageSize = sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment,
+            MEMORY_PAGE_SIZE_PATH);
+        LOGGER.debug("the memoryPageSize = " + memoryPageSize);
+        if (memoryPageSize != null) {
+            Map<String, Object> retMap = gson.fromJson(memoryPageSize, 
+                new TypeToken<HashMap<String, Object>>() {}.getType());
+            LOGGER.debug("the retMap = " + retMap);
+            String memoryPageSizeValue = retMap.get("configuration-value").toString();
+            String mandatory = retMap.get("mandatory").toString();
+            HpaFeatureAttribute hpaFeatureAttribute = 
+                generateHpaFeatureAttribute("memoryPageSize",memoryPageSizeValue);
+            FlavorProperty flavorProperty = new FlavorProperty();
+            flavorProperty.setHpaFeature(HUGE_PAGES_HPA_FEATURE);
+            if (mandatory != null) {
+                flavorProperty.setMandatory(mandatory);
+            }
+            flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute);
+            flavorFeature.getFlavorProperties().add(flavorProperty);
+        }
     }
 
     /**
@@ -225,9 +256,79 @@ public class ExtractFromNode {
      *
      * @param lnodeVduCp the list of VduCp node
      * @param content to be change based on lnodeVduCp
+     * @throws PolicyDecodingException if extract CP fails
      */
-    public void extractInfoVduCp(final List<NodeTemplate> lnodeVduCp, final Content content) {
-        // to add VDU cp Hpa feature extract
-    }
+    public void extractInfoVduCp(final List<NodeTemplate> lnodeVduCp, Content content) throws PolicyDecodingException {
+        // each CP will binds to a VDU so need the vdu flavor map info.
+        Map<String, FlavorFeature> vduFlavorMap = new HashMap<>();
+        for ( FlavorFeature flavorFeature: content.getFlavorFeatures()) {
+            LOGGER.debug("the id = " + flavorFeature.getId());
+            vduFlavorMap.put(flavorFeature.getId(),flavorFeature);
+        }
+        for ( NodeTemplate node : lnodeVduCp) {
+            String interfaceType = sdcCsarHelper.getNodeTemplatePropertyLeafValue(node,NETWORK_INTERFACE_TYPE_PATH);
+            LOGGER.debug("the interfaceType = " + interfaceType);     
+            Map<String, Object> retMap = new HashMap<>();
+            if (interfaceType != null) {
+                retMap = gson.fromJson(interfaceType, new TypeToken<HashMap<String, Object>>() {}.getType());
+                LOGGER.debug("the retMap = " + retMap);
+            }
+
+            String networkHpaFeature; 
+            if ( retMap.containsKey("configuration-value")) {
+                String interfaceTypeValue = retMap.get("configuration-value").toString();
+                LOGGER.debug(" the interfacetype value is =" + interfaceTypeValue);
+                if ( NETWORK_HPA_FEATURE_MAP.containsKey(interfaceTypeValue)) {
+                    networkHpaFeature = NETWORK_HPA_FEATURE_MAP.get(interfaceTypeValue);
+                    LOGGER.debug(" the networkHpaFeature is =" + networkHpaFeature);
+                } else {
+                    LOGGER.debug(" unspported network interface ");
+                    return;
+                }
+            }else{
+                LOGGER.debug(" no configuration-value defined in interfaceType");
+                return;
+            }
+            
+            for (RequirementAssignment requriement: sdcCsarHelper.getRequirementsOf(node).getAll()) {
+                String nodeTemplateName = requriement.getNodeTemplateName().toLowerCase();
+                LOGGER.debug("getNodeTemplateName =" + nodeTemplateName);
+                if ( nodeTemplateName == null) {
+                        continue; 
+                } 
+                if (!vduFlavorMap.containsKey(nodeTemplateName)) {
+                    throw new PolicyDecodingException("vdu Flavor Map should contains the key " + nodeTemplateName);
+                }
+                generateNetworkFeature(networkHpaFeature, node, vduFlavorMap.get(nodeTemplateName));
+            }
+        }
+    }   
 
+    /*
+     * GenerateNetworkFeature, all pci feature are grouped into FlavorFeature together.
+     *
+     * @param networkHpaFeature represents the specified Hpa feature
+     * @param node represents the CP Node
+     * @param flavorFeature represents all the features of specified flavor
+     */
+    private void generateNetworkFeature(final String networkHpaFeature, final NodeTemplate node, FlavorFeature flavorFeature) {
+        //the format is a map like: {"schema-version": "0", "schema-location": "", "platform-id": "generic", 
+        // "mandatory": true, "configuration-value": "2 MB"}
+        FlavorProperty flavorProperty = new FlavorProperty();
+        flavorProperty.setHpaFeature(networkHpaFeature);
+        String[] pciKeys = { "pciVendorId", "pciDeviceId", "pciNumDevices", "physicalNetwork"};
+        for (String pciKey: pciKeys) {
+            LOGGER.debug("the pciKey = " + pciKey);
+            String pciKeyPath = NETWORK_PCI_PATH + "#" + pciKey;
+            String pciValue = sdcCsarHelper.getNodeTemplatePropertyLeafValue(node,pciKeyPath);
+            if (pciValue != null) {
+                LOGGER.debug("the pciValue = " + pciValue);
+                Map<String, Object> retMap = gson.fromJson(pciValue, new TypeToken<HashMap<String, Object>>() {}.getType());
+                String pciConfigValue = retMap.get("configuration-value").toString();
+                HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute(pciKey,pciConfigValue);
+                flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute);
+            }
+        }
+        flavorFeature.getFlavorProperties().add(flavorProperty);
+    }
 }
index 1617956..91008aa 100644 (file)
@@ -30,7 +30,7 @@ import com.google.gson.annotations.SerializedName;
 class HpaFeatureAttribute {
     @SerializedName(value = "hpa-attribute-key")
     private String hpaAttributeKey;
-    @SerializedName(value = "hap-attribute-value")
+    @SerializedName(value = "hpa-attribute-value")
     private String hpaAttributeValue;
     private String operator;
     private String unit;
index 1ce5786..11bce32 100644 (file)
@@ -41,24 +41,173 @@ public class TestPolicyDecoderCsarPdpx {
     @Test
     public void testHpaPolicy2Vnf() throws IOException {
         Csar csar = new Csar("src/test/resources/service-TestNs8-csar.csar");
+        PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
+        try {
+            Collection<PdpxPolicy> ret = policyDecoderCsarPdpx.decode(csar);
+            assertEquals(2, ret.size());
+            PdpxPolicy pdpxPolicy = (PdpxPolicy) ret.toArray()[0];
+            assertEquals("Optimization", pdpxPolicy.getContent().getPolicyType());
+            assertEquals(1, pdpxPolicy.getContent().getFlavorFeatures().size());
+
+            FlavorFeature flavorFeature = pdpxPolicy.getContent().getFlavorFeatures().get(0);
+            assertEquals("vdu_vnf_1", flavorFeature.getId());
+            assertEquals("tosca.node.nfv.Vdu.Compute", flavorFeature.getType());
+            assertEquals(1, flavorFeature.getDirectives().size());
+            Directive directive = flavorFeature.getDirectives().get(0);
+            assertEquals("flavor_directive", directive.getType());            
+            assertEquals(1, directive.getAttributes().size());
+            assertEquals("flavorName", directive.getAttributes().get(0).getAttributeName());
+            assertEquals("", directive.getAttributes().get(0).getAttributeValue());
+            assertEquals(2, flavorFeature.getFlavorProperties().size());
+            FlavorProperty flavorProperty = flavorFeature.getFlavorProperties().get(0);
+            assertEquals("BasicCapabilities", flavorProperty.getHpaFeature());
+            assertEquals("true", flavorProperty.getMandatory());
+            assertEquals("generic", flavorProperty.getArchitecture());
+            assertEquals("v1", flavorProperty.getHpaVersion());
+            assertEquals(0, flavorProperty.getDirectives().size());
+            assertEquals(1, flavorProperty.getHpaFeatureAttributes().size());
+            HpaFeatureAttribute hpaFeatreAttribute = flavorProperty.getHpaFeatureAttributes().get(0);
+            assertEquals("virtualMemSize",hpaFeatreAttribute.getHpaAttributeKey());
+            assertEquals("4096",hpaFeatreAttribute.getHpaAttributeValue());
+            assertEquals("",hpaFeatreAttribute.getOperator());
+            assertEquals("MB",hpaFeatreAttribute.getUnit());
+            
+        } catch (Exception e) {
+            fail("test should not thrown an exception here: " + e.getMessage());
+        }
+    }
 
+    @Test
+    public void testHpaPolicySriov() throws IOException {
+        Csar csar = new Csar("src/test/resources/hpaPolicySriov.csar");
         PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
         try {
             Collection<PdpxPolicy> ret = policyDecoderCsarPdpx.decode(csar);
             assertEquals(2, ret.size());
+            PdpxPolicy pdpxPolicy = (PdpxPolicy) ret.toArray()[0];
+            assertEquals("Optimization", pdpxPolicy.getContent().getPolicyType());
+            assertEquals(1, pdpxPolicy.getContent().getFlavorFeatures().size());
+
+            FlavorFeature flavorFeature = pdpxPolicy.getContent().getFlavorFeatures().get(0);
+            assertEquals("vdu_vnf_1", flavorFeature.getId());
+            assertEquals("tosca.node.nfv.Vdu.Compute", flavorFeature.getType());
+            assertEquals(1, flavorFeature.getDirectives().size());
+            Directive directive = flavorFeature.getDirectives().get(0);
+            assertEquals("flavor_directive", directive.getType());            
+            assertEquals(1, directive.getAttributes().size());
+            assertEquals("flavorName", directive.getAttributes().get(0).getAttributeName());
+            assertEquals("", directive.getAttributes().get(0).getAttributeValue());
+            assertEquals(4, flavorFeature.getFlavorProperties().size());
+            FlavorProperty flavorProperty = flavorFeature.getFlavorProperties().get(3);
+            assertEquals("SriovNICNetwork", flavorProperty.getHpaFeature());
+            assertEquals("true", flavorProperty.getMandatory());
+            assertEquals("generic", flavorProperty.getArchitecture());
+            assertEquals("v1", flavorProperty.getHpaVersion());
+            assertEquals(0, flavorProperty.getDirectives().size());
+            assertEquals(3, flavorProperty.getHpaFeatureAttributes().size());
+
+            HpaFeatureAttribute pciVendorId = flavorProperty.getHpaFeatureAttributes().get(0);
+            assertEquals("pciVendorId",pciVendorId.getHpaAttributeKey());
+            assertEquals("1234",pciVendorId.getHpaAttributeValue());
+            assertEquals("",pciVendorId.getOperator());
+            assertEquals("",pciVendorId.getUnit());
+            HpaFeatureAttribute pciDeviceId = flavorProperty.getHpaFeatureAttributes().get(1);
+            assertEquals("pciDeviceId",pciDeviceId.getHpaAttributeKey());
+            assertEquals("5678",pciDeviceId.getHpaAttributeValue());
+            assertEquals("",pciDeviceId.getOperator());
+            assertEquals("",pciDeviceId.getUnit());
+            HpaFeatureAttribute pciNumDevices = flavorProperty.getHpaFeatureAttributes().get(2);
+            assertEquals("pciNumDevices",pciNumDevices.getHpaAttributeKey());
+            assertEquals("1",pciNumDevices.getHpaAttributeValue());
+            assertEquals("",pciNumDevices.getOperator());
+            assertEquals("",pciNumDevices.getUnit());
         } catch (Exception e) {
             fail("test should not thrown an exception here: " + e.getMessage());
         }
     }
 
     @Test
-    public void testHpaPolicyFeature() throws IOException {
-        Csar csar = new Csar("src/test/resources/hpaPolicySRIOV.csar");
+    public void testHpaPolicyPciePassthrough() throws IOException {
+        Csar csar = new Csar("src/test/resources/hpaPolicyPciePassthrough.csar");
+        PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
+        try {
+            Collection<PdpxPolicy> ret = policyDecoderCsarPdpx.decode(csar);
+            assertEquals(2, ret.size());
+            PdpxPolicy pdpxPolicy = (PdpxPolicy) ret.toArray()[0];
+            assertEquals("Optimization", pdpxPolicy.getContent().getPolicyType());
+            assertEquals(1, pdpxPolicy.getContent().getFlavorFeatures().size());
+
+            FlavorFeature flavorFeature = pdpxPolicy.getContent().getFlavorFeatures().get(0);
+            assertEquals("vdu_vnf_1", flavorFeature.getId());
+            assertEquals("tosca.node.nfv.Vdu.Compute", flavorFeature.getType());
+            assertEquals(1, flavorFeature.getDirectives().size());
+            Directive directive = flavorFeature.getDirectives().get(0);
+            assertEquals("flavor_directive", directive.getType());            
+            assertEquals(1, directive.getAttributes().size());
+            assertEquals("flavorName", directive.getAttributes().get(0).getAttributeName());
+            assertEquals("", directive.getAttributes().get(0).getAttributeValue());
+            assertEquals(4, flavorFeature.getFlavorProperties().size());
+            FlavorProperty flavorProperty = flavorFeature.getFlavorProperties().get(3);
+            assertEquals("pciePassthrough", flavorProperty.getHpaFeature());
+            assertEquals("true", flavorProperty.getMandatory());
+            assertEquals("generic", flavorProperty.getArchitecture());
+            assertEquals("v1", flavorProperty.getHpaVersion());
+            assertEquals(0, flavorProperty.getDirectives().size());
+            assertEquals(3, flavorProperty.getHpaFeatureAttributes().size());
+
+            HpaFeatureAttribute pciVendorId = flavorProperty.getHpaFeatureAttributes().get(0);
+            assertEquals("pciVendorId",pciVendorId.getHpaAttributeKey());
+            assertEquals("1234",pciVendorId.getHpaAttributeValue());
+            assertEquals("",pciVendorId.getOperator());
+            assertEquals("",pciVendorId.getUnit());
+            HpaFeatureAttribute pciDeviceId = flavorProperty.getHpaFeatureAttributes().get(1);
+            assertEquals("pciDeviceId",pciDeviceId.getHpaAttributeKey());
+            assertEquals("5678",pciDeviceId.getHpaAttributeValue());
+            assertEquals("",pciDeviceId.getOperator());
+            assertEquals("",pciDeviceId.getUnit());
+            HpaFeatureAttribute pciNumDevices = flavorProperty.getHpaFeatureAttributes().get(2);
+            assertEquals("pciNumDevices",pciNumDevices.getHpaAttributeKey());
+            assertEquals("1",pciNumDevices.getHpaAttributeValue());
+            assertEquals("",pciNumDevices.getOperator());
+            assertEquals("",pciNumDevices.getUnit());
+        } catch (Exception e) {
+            fail("test should not thrown an exception here: " + e.getMessage());
+        }
+    }
 
+    @Test
+    public void testHpaPolicyHugePage() throws IOException {
+        Csar csar = new Csar("src/test/resources/hpaPolicyHugePage.csar");
         PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
         try {
             Collection<PdpxPolicy> ret = policyDecoderCsarPdpx.decode(csar);
             assertEquals(2, ret.size());
+            PdpxPolicy pdpxPolicy = (PdpxPolicy) ret.toArray()[0];
+            assertEquals("Optimization", pdpxPolicy.getContent().getPolicyType());
+            assertEquals(1, pdpxPolicy.getContent().getFlavorFeatures().size());
+
+            FlavorFeature flavorFeature = pdpxPolicy.getContent().getFlavorFeatures().get(0);
+            assertEquals("vdu_vnf_1", flavorFeature.getId());
+            assertEquals("tosca.node.nfv.Vdu.Compute", flavorFeature.getType());
+            assertEquals(1, flavorFeature.getDirectives().size());
+            Directive directive = flavorFeature.getDirectives().get(0);
+            assertEquals("flavor_directive", directive.getType());            
+            assertEquals(1, directive.getAttributes().size());
+            assertEquals("flavorName", directive.getAttributes().get(0).getAttributeName());
+            assertEquals("", directive.getAttributes().get(0).getAttributeValue());
+            assertEquals(3, flavorFeature.getFlavorProperties().size());
+            FlavorProperty flavorProperty = flavorFeature.getFlavorProperties().get(2);
+            assertEquals("hugePages", flavorProperty.getHpaFeature());
+            assertEquals("false", flavorProperty.getMandatory());
+            assertEquals("generic", flavorProperty.getArchitecture());
+            assertEquals("v1", flavorProperty.getHpaVersion());
+            assertEquals(0, flavorProperty.getDirectives().size());
+            assertEquals(1, flavorProperty.getHpaFeatureAttributes().size());
+            HpaFeatureAttribute hpaFeatreAttribute = flavorProperty.getHpaFeatureAttributes().get(0);
+            assertEquals("memoryPageSize",hpaFeatreAttribute.getHpaAttributeKey());
+            assertEquals("2",hpaFeatreAttribute.getHpaAttributeValue());
+            assertEquals("",hpaFeatreAttribute.getOperator());
+            assertEquals("MB",hpaFeatreAttribute.getUnit());
         } catch (Exception e) {
             fail("test should not thrown an exception here: " + e.getMessage());
         }
diff --git a/plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csar b/plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csar
new file mode 100644 (file)
index 0000000..e1fdc70
Binary files /dev/null and b/plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csar differ
diff --git a/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar b/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar
new file mode 100644 (file)
index 0000000..652bc87
Binary files /dev/null and b/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar differ
similarity index 94%
rename from plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar
rename to plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar
index f79d286..ffe996a 100644 (file)
Binary files a/plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar and b/plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar differ