From 4738720bd026e9d0ecafff8d1ca30e37138a7b2a Mon Sep 17 00:00:00 2001 From: Alan Hinchliff Date: Wed, 6 Dec 2017 14:22:02 -0500 Subject: [PATCH 1/3] initial test for #157 --- .../mock/MockOrcaServiceManager.java | 2 + .../xmlrpc/OrcaRegressionTest.java | 5 +- .../xmlrpc/OrcaXmlrpcAssertions.java | 17 ++++ .../157_mp_diff_resource_type_request.rdf | 98 +++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 embed/src/test/resources/orca/embed/157_mp_diff_resource_type_request.rdf diff --git a/controllers/xmlrpc/src/test/java/orca/controllers/mock/MockOrcaServiceManager.java b/controllers/xmlrpc/src/test/java/orca/controllers/mock/MockOrcaServiceManager.java index 863b0b7bc..094289ecc 100644 --- a/controllers/xmlrpc/src/test/java/orca/controllers/mock/MockOrcaServiceManager.java +++ b/controllers/xmlrpc/src/test/java/orca/controllers/mock/MockOrcaServiceManager.java @@ -113,12 +113,14 @@ private void populateResourceMap() { resource.put("site.vm", 36); resource.put("site.vlan", 9); resource.put("site.lun", 100); + resource.put("site.baremetalce", 2); resourceMap.put(domain, resource); domain = new Domain("orca/ndl/substrate/pscvmsite.rdf"); resource = new HashMap<>(); resource.put("site.vm", 150); resource.put("site.vlan", 8); + resource.put("site.baremetalce", 2); resourceMap.put(domain, resource); domain = new Domain("orca/ndl/substrate/rcivmsite.rdf"); diff --git a/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaRegressionTest.java b/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaRegressionTest.java index 864abf810..2057fa307 100644 --- a/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaRegressionTest.java +++ b/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaRegressionTest.java @@ -66,7 +66,8 @@ public static Collection data() { //{ "../../embed/src/test/resources/orca/embed/TS7/TS7-1.rdf", true, 14-1+11}, // Deprecated. OSG site no longer exists { "../../embed/src/test/resources/orca/embed/request-stitchport-URLcham-TAG3291-3292.rdf", true, 3-2+4}, { "../../embed/src/test/resources/orca/embed/request-stitchport-URLcham-URLncbi.rdf", true, 3-2+4}, - { "src/test/resources/146_create_node_with_two_interfaces_interdomain_request.rdf", true, 5+8} + { "src/test/resources/146_create_node_with_two_interfaces_interdomain_request.rdf", true, 5+8}, + { "../../embed/src/test/resources/orca/embed/157_mp_diff_resource_type_request.rdf", true, 4+6} // TS8 really only tests Post-boot Scripts. Not useful in Unit tests /* { "../../embed/src/test/resources/orca/embed/TS8/TS8-1.rdf", true, 12}, @@ -125,6 +126,8 @@ public void testOrcaRegressionTests() throws Exception { if (requestFilename.contains("106_mp")){ assertEc2InstanceTypePresent(computedReservations); + } else if (requestFilename.contains("157_mp")){ + assertManifestHasNumberOfComputeElements(slice.workflow.getManifestModel(), 6); } assertManifestWillProcess(slice); diff --git a/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaXmlrpcAssertions.java b/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaXmlrpcAssertions.java index b7e3e6b5a..75f47757f 100644 --- a/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaXmlrpcAssertions.java +++ b/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaXmlrpcAssertions.java @@ -1,5 +1,6 @@ package orca.controllers.xmlrpc; +import com.hp.hpl.jena.ontology.Individual; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntResource; import orca.embed.workflow.ManifestParserListener; @@ -9,6 +10,7 @@ import orca.manage.beans.PropertyMng; import orca.manage.beans.ReservationMng; import orca.manage.beans.TicketReservationMng; +import orca.ndl.NdlCommons; import orca.ndl.NdlException; import orca.ndl.NdlManifestParser; import orca.ndl.elements.Interface; @@ -334,4 +336,19 @@ protected static void assertReservationsHaveResourceConstraints(List individuals = manifestModel.listIndividuals(NdlCommons.computeElementClass).toList(); + + assertEquals("List of Compute Elements did not match expected size.", expectedComputeElements, individuals.size()); + } } diff --git a/embed/src/test/resources/orca/embed/157_mp_diff_resource_type_request.rdf b/embed/src/test/resources/orca/embed/157_mp_diff_resource_type_request.rdf new file mode 100644 index 000000000..a0eb6c9c8 --- /dev/null +++ b/embed/src/test/resources/orca/embed/157_mp_diff_resource_type_request.rdf @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + 10000000 + 94492850-cf25-4cad-8b18-7bd5379d3bb3 + + + + Centos 7.3 v1.0.3 + http://geni-images.renci.org/images/standard/centos/centos7.3-v1.0.3/centos7.3-v1.0.3.xml + c3e80c29d021c800dcc122070e5ecbffc417c657 + + + + + + + + + + + + + e57f32cb-7ed8-4c1a-a6a0-1c5ca117740b + + + + + + + + + + + e1aa2304-459c-418c-97c1-9565565e784f + + + + + + + + 1 + + + + + 53ccce9f-32ff-4485-87fd-006a9c348316 + + + + + + + + + From 0cc8dd3a76a48e9b05fb6780adf12f0a5bb0c992 Mon Sep 17 00:00:00 2001 From: Alan Hinchliff Date: Wed, 6 Dec 2017 14:22:44 -0500 Subject: [PATCH 2/3] initial fix for #157 --- .../orca/embed/cloudembed/controller/MultiPointHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/embed/src/main/java/orca/embed/cloudembed/controller/MultiPointHandler.java b/embed/src/main/java/orca/embed/cloudembed/controller/MultiPointHandler.java index 8bc5e9f0e..a4eb9c999 100644 --- a/embed/src/main/java/orca/embed/cloudembed/controller/MultiPointHandler.java +++ b/embed/src/main/java/orca/embed/cloudembed/controller/MultiPointHandler.java @@ -329,7 +329,8 @@ public HashMap > ifMPConnection(NetworkConne HashMap > domainCount = new HashMap >(); if(con_elements.size()>0){ for(NetworkElement e:con_elements){ - e_domain = e.getInDomain(); + // #157 - baremetal and VM in same domain must be treated separately + e_domain = e.getInDomain() + "/" + e.getResourceType().getResourceType(); c_e= (ComputeElement) e; if(e_domain==null){ domainCount = new HashMap >(); From 58e04c8a588e7367a1c1d891fc0e9e305b53d8f3 Mon Sep 17 00:00:00 2001 From: Alan Hinchliff Date: Thu, 7 Dec 2017 09:27:25 -0500 Subject: [PATCH 3/3] cleanup in ifMPConnection --- .../xmlrpc/OrcaRegressionTest.java | 2 +- .../controller/MultiPointHandler.java | 37 ++++++++----------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaRegressionTest.java b/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaRegressionTest.java index 2057fa307..60e29e27a 100644 --- a/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaRegressionTest.java +++ b/controllers/xmlrpc/src/test/java/orca/controllers/xmlrpc/OrcaRegressionTest.java @@ -126,7 +126,7 @@ public void testOrcaRegressionTests() throws Exception { if (requestFilename.contains("106_mp")){ assertEc2InstanceTypePresent(computedReservations); - } else if (requestFilename.contains("157_mp")){ + } else if (requestFilename.contains("157_mp_diff_resource_type_request")){ assertManifestHasNumberOfComputeElements(slice.workflow.getManifestModel(), 6); } diff --git a/embed/src/main/java/orca/embed/cloudembed/controller/MultiPointHandler.java b/embed/src/main/java/orca/embed/cloudembed/controller/MultiPointHandler.java index a4eb9c999..26f7a4ba0 100644 --- a/embed/src/main/java/orca/embed/cloudembed/controller/MultiPointHandler.java +++ b/embed/src/main/java/orca/embed/cloudembed/controller/MultiPointHandler.java @@ -325,30 +325,25 @@ public HashMap > ifMPConnection(NetworkConne LinkedList con_elements = (LinkedList) rc.getConnection(); String e_domain=null; LinkedList elements = null; - ComputeElement c_e = null; HashMap > domainCount = new HashMap >(); - if(con_elements.size()>0){ - for(NetworkElement e:con_elements){ - // #157 - baremetal and VM in same domain must be treated separately - e_domain = e.getInDomain() + "/" + e.getResourceType().getResourceType(); - c_e= (ComputeElement) e; - if(e_domain==null){ - domainCount = new HashMap >(); - break; - } - if(domainCount.containsKey(e_domain)){ - domainCount.get(e_domain).add(e); - //if(c_e.getGroup()==null) - // c_e.setGroup(c_e.getName()); - }else{ - elements = new LinkedList (); - elements.add(e); - //if(c_e.getGroup()==null) - // c_e.setGroup(c_e.getName()); - domainCount.put(e_domain, elements); - } + + for (NetworkElement e : con_elements) { + // #157 - baremetal and VM in same domain must be treated separately + e_domain = e.getInDomain() + "/" + e.getResourceType().getResourceType(); + + if (e.getInDomain() == null) { + domainCount = new HashMap>(); + break; + } + if (domainCount.containsKey(e_domain)) { + domainCount.get(e_domain).add(e); + } else { + elements = new LinkedList(); + elements.add(e); + domainCount.put(e_domain, elements); } } + return domainCount; } }