Martin Sivák has uploaded a new change for review. Change subject: Restructure sources and improve the build system ......................................................................
Restructure sources and improve the build system This change adds VERSION file to the top level of the project that is then providin the version to all places - Makefile, setup.py and spec file It also moves the plugins that are needed for tests to the tests/ subdirectory and consolidates the documentation to doc/ directory. It then adds OSCHEDPROXY_PLUGINS environment variable that can be used to redefine the plugin directory location and uses it in the tests. Change-Id: I372e83f94c944056b2e5212c75139d23f05ae527 Signed-off-by: Martin Sivak <msi...@redhat.com> --- M Makefile A VERSION R doc/PLUGINS.txt R doc/plugin_samples/even_vm_distribution.py R doc/plugin_samples/host_memory_balance.py R doc/plugin_samples/ksm_same_os_score.py R doc/plugin_samples/max_vm_filter.py R doc/plugin_samples/vm_balance.py R doc/rest_api_samples/singlehost.xml R doc/rest_api_samples/singlevm.xml R ovirt-scheduler-proxy.spec.in M setup.py M src/ovirtscheduler/oschedproxyd.py M src/ovirtscheduler/request_handler_test.py M src/ovirtscheduler/runner_test.py R tests/plugins/test_failing_plugin.py R tests/plugins/test_plugin.py 17 files changed, 49 insertions(+), 26 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-scheduler-proxy refs/changes/32/25032/1 diff --git a/Makefile b/Makefile index ce66b85..590417e 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,17 @@ # NAME=ovirt-scheduler-proxy -VERSION=0.1.3 +VERSION=$(shell cat VERSION) TARBALL=$(NAME)-$(VERSION).tar.gz -tarball: - tar --xform='s,^,$(NAME)-$(VERSION)/,' -c -z -f $(TARBALL) `git ls-files` +$(NAME).spec: $(NAME).spec.in + sed -e 's/{VERSION}/$(VERSION)/g' $< >$@ + +tarball: $(NAME).spec + tar --xform='s,^,$(NAME)-$(VERSION)/,' -c -z -f $(TARBALL) `git ls-files` $(NAME).spec + +tag: + git tag $(VERSION) srpm: tarball rpmbuild -ts $(TARBALL) @@ -32,16 +38,16 @@ test: pythontest javatest pythontest: - PYTHONPATH=src:$(PYTHONPATH) nosetests -v + OSCHEDPROXY_PLUGINS=$(PWD)/tests/plugins PYTHONPATH=src:$(PYTHONPATH) nosetests -v javatest: - make start; mvn -f tests/java/pom.xml clean install; make stop + OSCHEDPROXY_PLUGINS=$(PWD)/tests/plugins make start; mvn -f tests/java/pom.xml clean install; make stop pep8: pep8 src start: - python src/ovirtscheduler/oschedproxyd.py & + OSCHEDPROXY_PLUGINS=$(PWD)/tests/plugins python src/ovirtscheduler/oschedproxyd.py & stop: pkill -f "python src/ovirtscheduler/oschedproxyd.py" @@ -52,3 +58,4 @@ restart: $(MAKE) stop $(MAKE) start + diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..b1e80bb --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.3 diff --git a/plugins/README b/doc/PLUGINS.txt similarity index 100% rename from plugins/README rename to doc/PLUGINS.txt diff --git a/plugins/examples/even_vm_distribution.py b/doc/plugin_samples/even_vm_distribution.py similarity index 100% rename from plugins/examples/even_vm_distribution.py rename to doc/plugin_samples/even_vm_distribution.py diff --git a/plugins/examples/host_memory_balance.py b/doc/plugin_samples/host_memory_balance.py similarity index 100% rename from plugins/examples/host_memory_balance.py rename to doc/plugin_samples/host_memory_balance.py diff --git a/plugins/examples/ksm_same_os_score.py b/doc/plugin_samples/ksm_same_os_score.py similarity index 100% rename from plugins/examples/ksm_same_os_score.py rename to doc/plugin_samples/ksm_same_os_score.py diff --git a/plugins/examples/max_vm_filter.py b/doc/plugin_samples/max_vm_filter.py similarity index 100% rename from plugins/examples/max_vm_filter.py rename to doc/plugin_samples/max_vm_filter.py diff --git a/plugins/examples/vm_balance.py b/doc/plugin_samples/vm_balance.py similarity index 100% rename from plugins/examples/vm_balance.py rename to doc/plugin_samples/vm_balance.py diff --git a/samples/singlehost.xml b/doc/rest_api_samples/singlehost.xml similarity index 100% rename from samples/singlehost.xml rename to doc/rest_api_samples/singlehost.xml diff --git a/samples/singlevm.xml b/doc/rest_api_samples/singlevm.xml similarity index 100% rename from samples/singlevm.xml rename to doc/rest_api_samples/singlevm.xml diff --git a/ovirt-scheduler-proxy.spec b/ovirt-scheduler-proxy.spec.in similarity index 98% rename from ovirt-scheduler-proxy.spec rename to ovirt-scheduler-proxy.spec.in index 2cbfaca..7db9c70 100644 --- a/ovirt-scheduler-proxy.spec +++ b/ovirt-scheduler-proxy.spec.in @@ -25,7 +25,7 @@ %endif Name: ovirt-scheduler-proxy -Version: 0.1.3 +Version: {VERSION} Release: 1%{?dist} Summary: Scheduling Proxy for Open Virtualization Group: Virtualization/Management @@ -61,7 +61,7 @@ %setup -q # remove integration (java) tests -rm -rf tests +rm -rf tests/java %build %{__python} setup.py \ @@ -196,7 +196,7 @@ %attr(-, ovirt, ovirt) %{_localstatedir}/log/ovirt-scheduler-proxy # Documentation and example files -%doc LICENSE README plugins samples +%doc LICENSE README doc/* %changelog * Mon Nov 25 2013 Martin Sivak <msi...@redhat.com> - 0.1.3-1 diff --git a/setup.py b/setup.py index 703d65d..6ea5ac3 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,20 @@ -from distutils.core import setup +import os +from setuptools import setup, find_packages + +# Utility function to read the README file. +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() setup( name='ovirt-scheduler-proxy', - version='0.1.3', + version=read('VERSION').strip(), license='ASL2', description='oVirt Scheduler Proxy', author='Doron Fediuck', author_email='dfedi...@redhat.com', url='http://www.ovirt.org/Features/oVirt_External_Scheduling_Proxy', - packages=['ovirtscheduler'], - package_dir={ '': 'src' }, - long_description=open('README').read(), + packages=find_packages("src"), + package_dir={'':'src'}, + long_description=read('README'), ) + diff --git a/src/ovirtscheduler/oschedproxyd.py b/src/ovirtscheduler/oschedproxyd.py index 2517c15..0fc2283 100644 --- a/src/ovirtscheduler/oschedproxyd.py +++ b/src/ovirtscheduler/oschedproxyd.py @@ -45,24 +45,26 @@ class ProxyServer(object): - def __init__(self): + def __init__(self, plugin_path=None): self._server = None self._handler = None + if plugin_path is None: + self._plugin_path = os.path.join(os.getcwd(), "plugins") + else: + self._plugin_path = plugin_path def setup(self): logging.info("Setting up server") self._server = SimpleThreadedXMLRPCServer(("localhost", 18781), allow_none=True) - # TODO make by config - plugins_path = os.path.join(os.getcwd(), "plugins") analyzer_path = os.path.dirname(__file__) - logging.info("Loading modules from %s" % plugins_path) + logging.info("Loading modules from %s" % self._plugin_path) logging.info("Loading analyzer from %s" % analyzer_path) self._handler = RequestHandler( - plugins_path, + self._plugin_path, analyzer_path) def run(self): @@ -74,7 +76,7 @@ #for test runs def main(): - server = ProxyServer() + server = ProxyServer(os.environ.get("OSCHEDPROXY_PLUGINS", None)) server.setup() server.run() @@ -88,3 +90,4 @@ + strftime("%Y%m%d_%H%M%S") + '.log' setup_logging(log_filename) main() + diff --git a/src/ovirtscheduler/request_handler_test.py b/src/ovirtscheduler/request_handler_test.py index 6485d77..bf4a89f 100644 --- a/src/ovirtscheduler/request_handler_test.py +++ b/src/ovirtscheduler/request_handler_test.py @@ -22,8 +22,12 @@ class ExecutorTest(unittest.TestCase): + def setUp(self): + self.plugin_path = os.environ.get("OSCHEDPROXY_PLUGINS", + os.path.join(os.getcwd(), 'plugins')) + def test_discover(self): - executor = RequestHandler(os.path.join(os.getcwd(), 'plugins'), + executor = RequestHandler(self.plugin_path, os.path.join(os.getcwd(), 'src', 'ovirtscheduler')) ret = executor.discover() @@ -54,7 +58,7 @@ """ Tests if the empty filterRunners array results in None. """ - executor = RequestHandler(os.path.join(os.getcwd(), 'plugins'), + executor = RequestHandler(self.plugin_path, os.path.join(os.getcwd(), 'src')) filterRunners = [] assert executor.aggregate_filter_results(filterRunners, '') is None @@ -64,7 +68,7 @@ Checks that the aggregate filter will return None when all runners fail. """ - executor = RequestHandler(os.path.join(os.getcwd(), 'plugins'), + executor = RequestHandler(self.plugin_path, os.path.join(os.getcwd(), 'src')) class NoneResultRunner: @@ -82,3 +86,4 @@ filterRunners = [NoneResultRunner()] assert executor.aggregate_filter_results(filterRunners, '') is None + diff --git a/src/ovirtscheduler/runner_test.py b/src/ovirtscheduler/runner_test.py index d4aebab..4345936 100644 --- a/src/ovirtscheduler/runner_test.py +++ b/src/ovirtscheduler/runner_test.py @@ -21,10 +21,11 @@ class RunnerTest(unittest.TestCase): + def setUp(self): + self.plugin_path = os.environ.get("OSCHEDPROXY_PLUGINS", + os.path.join(os.getcwd(), 'plugins')) def test_with_dummy(self): - scriptpath = os.path.join(os.getcwd(), - 'plugins') - runner = PythonMethodRunner(scriptpath, + runner = PythonMethodRunner(self.plugin_path, 'test_plugin', 'test_plugin', 'do_filter', diff --git a/plugins/test_failing_plugin.py b/tests/plugins/test_failing_plugin.py similarity index 100% rename from plugins/test_failing_plugin.py rename to tests/plugins/test_failing_plugin.py diff --git a/plugins/test_plugin.py b/tests/plugins/test_plugin.py similarity index 100% rename from plugins/test_plugin.py rename to tests/plugins/test_plugin.py -- To view, visit http://gerrit.ovirt.org/25032 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I372e83f94c944056b2e5212c75139d23f05ae527 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-scheduler-proxy Gerrit-Branch: master Gerrit-Owner: Martin Sivák <msi...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches