Noam Slomianko has uploaded a new change for review. Change subject: Change balance return value ......................................................................
Change balance return value Added a list of underutilised hosts to the balance return value Changed the tests to reflect that Signed-off-by: Noam Slomianko <[email protected]> Change-Id: I74a1040cb02565297c3828610eddf26063f9c627 --- M plugins/dummy.py M tests/java/src/main/java/org/ovirt/schedulerproxy/SchedulerProxy.java M tests/java/src/test/java/org/ovirt/schedulerproxy/SchedulerProxyTest.java 3 files changed, 13 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-scheduler-proxy refs/changes/79/17579/1 diff --git a/plugins/dummy.py b/plugins/dummy.py index e2e16d0..30e21e7 100755 --- a/plugins/dummy.py +++ b/plugins/dummy.py @@ -105,7 +105,8 @@ def balance(self, hosts, args): #use hosts IDs to call the Rest API and make a decision - return ['33333333-3333-3333-3333-333333333333'] + #return the wanted vm and a list of underutilised hosts + return '33333333-3333-3333-3333-333333333333', ['11111111-1111-1111-1111-111111111111'] def balanceFunction(hosts, args): diff --git a/tests/java/src/main/java/org/ovirt/schedulerproxy/SchedulerProxy.java b/tests/java/src/main/java/org/ovirt/schedulerproxy/SchedulerProxy.java index 482307c..1ac9aa3 100644 --- a/tests/java/src/main/java/org/ovirt/schedulerproxy/SchedulerProxy.java +++ b/tests/java/src/main/java/org/ovirt/schedulerproxy/SchedulerProxy.java @@ -119,7 +119,7 @@ return retValue; } - public String balance(String balanceName, String[] HostID, String args) throws XmlRpcException { + public HashMap<String, List<String>> balance(String balanceName, String[] HostID, String args) throws XmlRpcException { Object[] sentObject = new Object[3]; //balance name sentObject[0] = balanceName; @@ -132,15 +132,17 @@ return parseBalanceResults(execute); } - private String parseBalanceResults(Object result){ + private HashMap<String, List<String>> parseBalanceResults(Object result){ if (result == null || ! (result instanceof Object[])){ System.out.println("balance error"); } Object[] castedResult = (Object[]) result; - if (castedResult.length != 1){ - //is it an error to get more then one vm to balance? - System.out.println("got more then one vm to balance"); + HashMap<String, List<String>> retValue = new HashMap<String, List<String>>(); + List<String> hostIDs = new LinkedList<String>(); + for (Object hostID : (Object[])castedResult[1]) { + hostIDs.add(hostID.toString()); } - return castedResult[0].toString(); + retValue.put(castedResult[0].toString(), hostIDs); + return retValue; } } \ No newline at end of file diff --git a/tests/java/src/test/java/org/ovirt/schedulerproxy/SchedulerProxyTest.java b/tests/java/src/test/java/org/ovirt/schedulerproxy/SchedulerProxyTest.java index 22f094b..9c7a0a2 100644 --- a/tests/java/src/test/java/org/ovirt/schedulerproxy/SchedulerProxyTest.java +++ b/tests/java/src/test/java/org/ovirt/schedulerproxy/SchedulerProxyTest.java @@ -17,7 +17,6 @@ static String HOST_ID2 = "22222222-2222-2222-2222-222222222222"; static String[] HOST_ARRAY = new String[] { HOST_ID1, HOST_ID2 }; static String VM_ID = "33333333-3333-3333-3333-333333333333"; - static String BALANCE_RESULT = "33333333-3333-3333-3333-333333333333"; static String FILTER_DESCRIPTION = "This is a simple filter that returns all given host ID"; static String SCORE_DESCRIPTION = "This is a simple score function that returns all given host ID with score 50"; static String BALANCE_DESCRIPTION = "This is a fake balance function that returns always return the guid 33333333-3333-3333-3333-333333333333"; @@ -62,7 +61,8 @@ @Test public void testBalance() throws XmlRpcException { - String result = proxy.balance(FILE_NAME, HOST_ARRAY, ""); - assertTrue(result.equals(BALANCE_RESULT)); + HashMap<String, List<String>> result = proxy.balance(FILE_NAME, HOST_ARRAY, ""); + assertTrue(result.containsKey(VM_ID)); + assertTrue(result.get(VM_ID).contains(HOST_ID1)); } } \ No newline at end of file -- To view, visit http://gerrit.ovirt.org/17579 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I74a1040cb02565297c3828610eddf26063f9c627 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-scheduler-proxy Gerrit-Branch: master Gerrit-Owner: Noam Slomianko <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
