diff options
author | liboNet <libo.zhu@intel.com> | 2018-09-15 12:29:04 +0800 |
---|---|---|
committer | liboNet <libo.zhu@intel.com> | 2018-09-15 14:37:27 +0800 |
commit | 41fc409d63322291ed3d5de95cc948ca024c6f6d (patch) | |
tree | 9073c3a0136ac50a1076ac4b065fc50f6660c221 /plugins/reception-plugins/src/test | |
parent | dbffbe7e96ae04ca75f0bb143c483c284cd88cb8 (diff) |
Adding more hpa feature support for Polices
* 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>
Diffstat (limited to 'plugins/reception-plugins/src/test')
-rw-r--r-- | plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java | 153 | ||||
-rw-r--r-- | plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csar | bin | 0 -> 131275 bytes | |||
-rw-r--r-- | plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar | bin | 0 -> 131411 bytes | |||
-rw-r--r-- | plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar (renamed from plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar) | bin | 131336 -> 131404 bytes |
4 files changed, 151 insertions, 2 deletions
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java index 1ce5786c..11bce326 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java @@ -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 Binary files differnew file mode 100644 index 00000000..e1fdc70c --- /dev/null +++ b/plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csar diff --git a/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar b/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar Binary files differnew file mode 100644 index 00000000..652bc877 --- /dev/null +++ b/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar diff --git a/plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar b/plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar Binary files differindex f79d2866..ffe996a9 100644 --- a/plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar +++ b/plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar |