Laszlo Hornyak has uploaded a new change for review.

Change subject: fix tests and pep8 errors
......................................................................

fix tests and pep8 errors

Fixes pep8 violations and test errors

Change-Id: I381b3fd8ab4c5db55cd4a1c5ae00e21511c41269
Signed-off-by: Laszlo Hornyak <lhorn...@redhat.com>
---
M src/ovirtscheduler/loader.py
M src/ovirtscheduler/request_handler.py
M src/ovirtscheduler/request_handler_test.py
M src/ovirtscheduler/runner.py
M tests/java/src/test/java/org/ovirt/schedulerproxy/SchedulerProxyTest.java
5 files changed, 25 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-scheduler-proxy 
refs/changes/47/18147/1

diff --git a/src/ovirtscheduler/loader.py b/src/ovirtscheduler/loader.py
index 00a3e72..87dbd85 100644
--- a/src/ovirtscheduler/loader.py
+++ b/src/ovirtscheduler/loader.py
@@ -1,6 +1,6 @@
 import os
 import utils
-
+import sys
 
 _utils = utils.utils()
 
@@ -19,7 +19,8 @@
             if hasattr(mod, _utils.FILTER_DESCRIPTION):
                 description, custom_properties_map\
                     = getattr(mod, _utils.FILTER_DESCRIPTION)()
-                retValue += ((_utils.FILTER, description, 
custom_properties_map),)
+                retValue +=\
+                    ((_utils.FILTER, description, custom_properties_map),)
             else:
                 retValue += ((_utils.FILTER, "", ""),)
 
@@ -27,7 +28,8 @@
             if hasattr(mod, _utils.SCORE_DESCRIPTION):
                 description, custom_properties_map\
                     = getattr(mod, _utils.SCORE_DESCRIPTION)()
-                retValue += ((_utils.SCORE, description, 
custom_properties_map),)
+                retValue +=\
+                    ((_utils.SCORE, description, custom_properties_map),)
             else:
                 retValue += ((_utils.SCORE, "", ""),)
 
@@ -35,7 +37,8 @@
             if hasattr(mod, _utils.BALANCE_DESCRIPTION):
                 description, custom_properties_map\
                     = getattr(mod, _utils.BALANCE_DESCRIPTION)()
-                retValue += ((_utils.BALANCE, description, 
custom_properties_map),)
+                retValue +=\
+                    ((_utils.BALANCE, description, custom_properties_map),)
             else:
                 retValue += ((_utils.BALANCE, "", ""),)
     except Exception as ex:
diff --git a/src/ovirtscheduler/request_handler.py 
b/src/ovirtscheduler/request_handler.py
index aa5e6fb..3b3355a 100644
--- a/src/ovirtscheduler/request_handler.py
+++ b/src/ovirtscheduler/request_handler.py
@@ -35,6 +35,7 @@
     plugin_dir -- the directory where the plugin scripts are located
     '''
     def __init__(self, pluginDir, analyzerDir):
+        self._logger = logging.getLogger('RequestHandler')
         self._pluginDir = pluginDir
         self._analyzerDir = analyzerDir
         self._filters = dict()
@@ -75,7 +76,8 @@
                          str(runner.getResults()))
 
             if str(runner.getErrors()):
-                logging.error("loadModules::External module failed with error 
- " + str(runner.getErrors()))
+                logging.error("loadModules::External module\
+failed with error - %s ", str(runner.getErrors()))
 
             if runner.getResults() is None:
                 continue
@@ -108,15 +110,20 @@
             "balance": self._balancers}
 
     def aggregate_filter_results(self, filterRunners):
-        resultSet = []
+        resultSet = set()
         for runner in filterRunners:
             if runner.getResults() is None:
+                self._logger.warn('No results from %s', runner._script)
                 continue
-            hosts = runner.getResults()
-            if resultSet is None:
+            hosts = set(runner.getResults())
+            self._logger.debug("results: %s", hosts)
+            if not resultSet:
+                self._logger.debug('hosts: %s', hosts)
                 resultSet = set(hosts)
                 continue
+            self._logger.debug('results - %s', list(resultSet))
             resultSet = resultSet.intersection(hosts)
+        self._logger.debug('end results %s', list(resultSet))
         return list(resultSet)
 
     def run_filters(self, filters, hostIDs, vmID, properties_map):
diff --git a/src/ovirtscheduler/request_handler_test.py 
b/src/ovirtscheduler/request_handler_test.py
index 4e334a8..849eca3 100644
--- a/src/ovirtscheduler/request_handler_test.py
+++ b/src/ovirtscheduler/request_handler_test.py
@@ -31,6 +31,7 @@
                                   os.path.join(os.getcwd(), 'src',
                                                'ovirtscheduler'))
         ret = executor.discover()
+        print ret
         assert ret == {'balance':
                       {'dummy':
                        ('This is a fake balance function that returns '
@@ -65,6 +66,8 @@
                                   os.path.join(os.getcwd(), 'src'))
 
         class NoneResultRunner:
+            def __init__(self):
+                self._script = 'test'
             def getResults(self):
                 return None
 
diff --git a/src/ovirtscheduler/runner.py b/src/ovirtscheduler/runner.py
index 6b173e2..17430bf 100755
--- a/src/ovirtscheduler/runner.py
+++ b/src/ovirtscheduler/runner.py
@@ -21,11 +21,13 @@
 from threading import Thread
 from ast import literal_eval
 from utils import utils
+import logging
 
 
 class PythonMethodRunner(Thread):
     def __init__(self, path, module, method, args):
         super(PythonMethodRunner, self).__init__(group=None)
+        self._logger = logging.getLogger()
         self._path = path
         self._result = None
         self._error = None
@@ -35,6 +37,7 @@
 
     def run(self):
         try:
+            self._logger.debug('running %s in %s', self._script, self._path)
             self._process = self._utils.createProcess(self._script, self._path)
             (result, error) = self._process.communicate()
             self._result = literal_eval(result)
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 9c7a0a2..3c24abc 100644
--- a/tests/java/src/test/java/org/ovirt/schedulerproxy/SchedulerProxyTest.java
+++ b/tests/java/src/test/java/org/ovirt/schedulerproxy/SchedulerProxyTest.java
@@ -46,7 +46,7 @@
        @Test
        public void testFilter() throws XmlRpcException {
                List<String> result = proxy.filter(new String[] { FILE_NAME }, 
HOST_ARRAY, VM_ID, "");
-               assertTrue(result.size() == 2);
+               assertTrue(result.size() == HOST_ARRAY.length);
                assertTrue(result.contains(HOST_ID1));
                assertTrue(result.contains(HOST_ID2));
        }


-- 
To view, visit http://gerrit.ovirt.org/18147
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I381b3fd8ab4c5db55cd4a1c5ae00e21511c41269
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-scheduler-proxy
Gerrit-Branch: master
Gerrit-Owner: Laszlo Hornyak <lhorn...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to