aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins/src/test
diff options
context:
space:
mode:
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.java153
-rw-r--r--plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csarbin0 -> 131275 bytes
-rw-r--r--plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csarbin0 -> 131411 bytes
-rw-r--r--plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar (renamed from plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar)bin131336 -> 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
new file mode 100644
index 00000000..e1fdc70c
--- /dev/null
+++ b/plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csar
Binary files 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
index 00000000..652bc877
--- /dev/null
+++ b/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar
Binary files differ
diff --git a/plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar b/plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar
index f79d2866..ffe996a9 100644
--- a/plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar
+++ b/plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar
Binary files differ