You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by kl...@apache.org on 2017/07/23 23:35:50 UTC

[1/2] mesos git commit: Added package and test infrastructure for 'src/python/lib/mesos'.

Repository: mesos
Updated Branches:
  refs/heads/master d687808e4 -> 2d19111e4


Added package and test infrastructure for 'src/python/lib/mesos'.

Part of MESOS-7310, this patch adds the test infrastructure necessary
for reliably running unit tests for the mesos package located under
'src/python/lib/mesos'.

'setup.py' is added under src/python/lib to define the Python package.
'tox.ini' is added under the same dir to enable automated unit tests via
the command tox, which runs tests via pytest.

Review: https://reviews.apache.org/r/60719/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/456a0ac3
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/456a0ac3
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/456a0ac3

Branch: refs/heads/master
Commit: 456a0ac34deb9321c20f57b7ed74fb61253999c3
Parents: d687808
Author: Kevin Klues <kl...@gmail.com>
Authored: Sun Jul 23 16:21:36 2017 -0700
Committer: Kevin Klues <kl...@gmail.com>
Committed: Sun Jul 23 16:32:59 2017 -0700

----------------------------------------------------------------------
 src/cli_new/pip-requirements.txt    |  1 +
 src/python/lib/mesos/__init__.py    | 21 ++++++++++++++
 src/python/lib/requirements-test.in |  4 +++
 src/python/lib/requirements.in      |  0
 src/python/lib/setup.py             | 49 ++++++++++++++++++++++++++++++++
 src/python/lib/tests/__init__.py    | 19 +++++++++++++
 src/python/lib/tests/test_mesos.py  | 30 +++++++++++++++++++
 src/python/lib/tox.ini              | 16 +++++++++++
 support/mesos-style.py              |  3 +-
 9 files changed, 142 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/456a0ac3/src/cli_new/pip-requirements.txt
----------------------------------------------------------------------
diff --git a/src/cli_new/pip-requirements.txt b/src/cli_new/pip-requirements.txt
index cb657e1..7aeac34 100644
--- a/src/cli_new/pip-requirements.txt
+++ b/src/cli_new/pip-requirements.txt
@@ -12,4 +12,5 @@ pylint==1.6.4
 six==1.10.0
 termcolor==1.1.0
 toml==0.9.2
+tox==2.7.0
 wrapt==1.10.8

http://git-wip-us.apache.org/repos/asf/mesos/blob/456a0ac3/src/python/lib/mesos/__init__.py
----------------------------------------------------------------------
diff --git a/src/python/lib/mesos/__init__.py b/src/python/lib/mesos/__init__.py
index e69de29..40219c5 100644
--- a/src/python/lib/mesos/__init__.py
+++ b/src/python/lib/mesos/__init__.py
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Client library for the Mesos HTTP ReST API
+"""
+
+__version__ = '0.0.0.dev'

http://git-wip-us.apache.org/repos/asf/mesos/blob/456a0ac3/src/python/lib/requirements-test.in
----------------------------------------------------------------------
diff --git a/src/python/lib/requirements-test.in b/src/python/lib/requirements-test.in
new file mode 100644
index 0000000..b2b73aa
--- /dev/null
+++ b/src/python/lib/requirements-test.in
@@ -0,0 +1,4 @@
+coverage
+mock
+pytest
+pytest-cov

http://git-wip-us.apache.org/repos/asf/mesos/blob/456a0ac3/src/python/lib/requirements.in
----------------------------------------------------------------------
diff --git a/src/python/lib/requirements.in b/src/python/lib/requirements.in
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/mesos/blob/456a0ac3/src/python/lib/setup.py
----------------------------------------------------------------------
diff --git a/src/python/lib/setup.py b/src/python/lib/setup.py
new file mode 100644
index 0000000..08f854f
--- /dev/null
+++ b/src/python/lib/setup.py
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Setup script for the mesos package
+"""
+
+from setuptools import find_packages, setup
+
+from mesos import __version__
+
+
+def read_requirements(filename="requirements.in"):
+    """
+    Load list of dependent packages for the mesos package.
+
+    :param filename: filename to load requirements from
+    :type filename: str
+    :rtype: list[str]
+    """
+    with open(filename) as f:
+        return f.readlines()
+
+
+setup(
+    author='Apache Mesos',
+    author_email='dev@mesos.apache.org',
+    description='Client library for Mesos http rest api',
+    include_package_data=True,
+    install_requires=read_requirements(),
+    license='apache',
+    name='mesos',
+    packages=find_packages(),
+    version=__version__,
+    zip_safe=False,
+)

http://git-wip-us.apache.org/repos/asf/mesos/blob/456a0ac3/src/python/lib/tests/__init__.py
----------------------------------------------------------------------
diff --git a/src/python/lib/tests/__init__.py b/src/python/lib/tests/__init__.py
new file mode 100644
index 0000000..c5d2d89
--- /dev/null
+++ b/src/python/lib/tests/__init__.py
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Tests for everything under src/python/lib
+"""

http://git-wip-us.apache.org/repos/asf/mesos/blob/456a0ac3/src/python/lib/tests/test_mesos.py
----------------------------------------------------------------------
diff --git a/src/python/lib/tests/test_mesos.py b/src/python/lib/tests/test_mesos.py
new file mode 100644
index 0000000..285a071
--- /dev/null
+++ b/src/python/lib/tests/test_mesos.py
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Tests for the mesos package
+"""
+
+from __future__ import absolute_import
+
+import mesos
+
+
+def test_version():
+    """
+    Test to ensure the __version__ attr exists
+    """
+    assert hasattr(mesos, '__version__')

http://git-wip-us.apache.org/repos/asf/mesos/blob/456a0ac3/src/python/lib/tox.ini
----------------------------------------------------------------------
diff --git a/src/python/lib/tox.ini b/src/python/lib/tox.ini
new file mode 100644
index 0000000..8ad030d
--- /dev/null
+++ b/src/python/lib/tox.ini
@@ -0,0 +1,16 @@
+# Tox (http://tox.testrun.org/) is a tool for running tests
+# in multiple virtualenvs. This configuration file will run the
+# test suite on all supported python versions. To use it, "pip install tox"
+# and then run "tox" from this directory.
+
+[tox]
+envlist = py27
+skipsdist = true
+
+[testenv]
+commands = py.test tests -vv --cov=mesos --cov-report=term-missing
+deps =
+    coverage
+    mock
+    pytest
+    pytest-cov

http://git-wip-us.apache.org/repos/asf/mesos/blob/456a0ac3/support/mesos-style.py
----------------------------------------------------------------------
diff --git a/support/mesos-style.py b/support/mesos-style.py
index 48d816f..ff3e405 100755
--- a/support/mesos-style.py
+++ b/support/mesos-style.py
@@ -279,7 +279,8 @@ class PyLinter(LinterBase):
     """The linter for Python files, uses pylint."""
     linter_type = 'Python'
 
-    source_dirs = [os.path.join('src', 'cli_new')]
+    source_dirs = [os.path.join('src', 'cli_new'),
+                   os.path.join('src', 'python', 'lib')]
 
     exclude_files = '(' \
                     r'protobuf\-2\.4\.1|' \


[2/2] mesos git commit: Added extra directives to 'src/python/.gitignore'.

Posted by kl...@apache.org.
Added extra directives to 'src/python/.gitignore'.

The new ignored files are in support of adding a new 'lib/mesos'
directory that contains shared mesos library code. The '.virtualenv'
folder is the standard python virtual environment we use to build,
run, and test the python code under 'lib/mesos'. The '.tox' and
'.coverage' files are files generated as part of a unit test runner
called 'tox'. The 'build' and 'mesos.egg-info' folders are standard
folders created when running 'python setup.py build' on the new
'lib/mesos' python package.

Review: https://reviews.apache.org/r/60719/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2d19111e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2d19111e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2d19111e

Branch: refs/heads/master
Commit: 2d19111e4852aed25161e4549ff704f9d4c2f37b
Parents: 456a0ac
Author: Kevin Klues <kl...@gmail.com>
Authored: Sun Jul 23 16:27:58 2017 -0700
Committer: Kevin Klues <kl...@gmail.com>
Committed: Sun Jul 23 16:33:07 2017 -0700

----------------------------------------------------------------------
 src/python/.gitignore | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2d19111e/src/python/.gitignore
----------------------------------------------------------------------
diff --git a/src/python/.gitignore b/src/python/.gitignore
index 0d20b64..fee529d 100644
--- a/src/python/.gitignore
+++ b/src/python/.gitignore
@@ -1 +1,6 @@
 *.pyc
+.virtualenv
+.coverage
+.tox
+build/
+mesos.egg-info