[Pkg-freeipa-devel] pytest-multihost: Changes to 'master'
Timo Aaltonen
tjaalton at moszumanska.debian.org
Tue Sep 20 05:40:44 UTC 2016
debian/changelog | 7 +++
debian/control | 2 -
pytest_multihost/config.py | 15 +++++++-
pytest_multihost/host.py | 57 +++++++++++++++++++-------------
python-pytest-multihost.spec | 5 ++
setup.py | 3 +
test_pytestmultihost/test_testconfig.py | 12 ++++++
7 files changed, 72 insertions(+), 29 deletions(-)
New commits:
commit a87e0920ea761b9b0877439be9127f6f00f9cc02
Author: Timo Aaltonen <tjaalton at debian.org>
Date: Tue Sep 20 08:40:01 2016 +0300
releasing package pytest-multihost version 1.1-1
diff --git a/debian/changelog b/debian/changelog
index 4eb6230..633f61f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,9 @@
-pytest-multihost (1.1-1) UNRELEASED; urgency=medium
+pytest-multihost (1.1-1) unstable; urgency=medium
* New upstream release.
* control: Bump policy to 3.9.8, no changes.
- -- Timo Aaltonen <tjaalton at debian.org> Tue, 20 Sep 2016 08:35:52 +0300
+ -- Timo Aaltonen <tjaalton at debian.org> Tue, 20 Sep 2016 08:39:28 +0300
pytest-multihost (1.0-1) unstable; urgency=low
commit 81504aeda2ef8b7e459f42bb54a60e77aa73e035
Author: Timo Aaltonen <tjaalton at debian.org>
Date: Tue Sep 20 08:39:24 2016 +0300
control: Bump policy to 3.9.8, no changes.
diff --git a/debian/changelog b/debian/changelog
index 025613d..4eb6230 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
pytest-multihost (1.1-1) UNRELEASED; urgency=medium
* New upstream release.
+ * control: Bump policy to 3.9.8, no changes.
-- Timo Aaltonen <tjaalton at debian.org> Tue, 20 Sep 2016 08:35:52 +0300
diff --git a/debian/control b/debian/control
index 90b0e1c..7c0d29c 100644
--- a/debian/control
+++ b/debian/control
@@ -10,7 +10,7 @@ Build-Depends:
python-setuptools (>= 0.6b3),
python3-all,
python3-setuptools,
-Standards-Version: 3.9.7
+Standards-Version: 3.9.8
Homepage: https://fedorahosted.org/python-pytest-multihost/
Vcs-Git: https://anonscm.debian.org/git/pkg-freeipa/pytest-multihost.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-freeipa/pytest-multihost.git
commit 6ec2e2c38696adf50aa24aaa084d855ddb7a8f25
Author: Timo Aaltonen <tjaalton at debian.org>
Date: Tue Sep 20 08:39:01 2016 +0300
update changelog
diff --git a/debian/changelog b/debian/changelog
index 8f13cef..025613d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+pytest-multihost (1.1-1) UNRELEASED; urgency=medium
+
+ * New upstream release.
+
+ -- Timo Aaltonen <tjaalton at debian.org> Tue, 20 Sep 2016 08:35:52 +0300
+
pytest-multihost (1.0-1) unstable; urgency=low
* Initial release. (Closes: #819407)
commit 4cac817ed1b6b54fc787c1a8b73ee24c4534f4fc
Author: Petr Viktorin <pviktori at redhat.com>
Date: Fri Apr 22 13:25:03 2016 +0200
Bump version to 1.1
diff --git a/python-pytest-multihost.spec b/python-pytest-multihost.spec
index 462c769..8602a1a 100644
--- a/python-pytest-multihost.spec
+++ b/python-pytest-multihost.spec
@@ -12,7 +12,7 @@
%global srcname pytest-multihost
%global modulename pytest_multihost
-%global srcversion 1.0
+%global srcversion 1.1
%global versionedname %{srcname}-%{srcversion}
Name: python-%{srcname}
@@ -133,6 +133,9 @@ popd
%changelog
+* Thu Apr 22 2016 Petr Viktorin <encukou at gmail.com> - 1.1-1
+- Much improved support for Windows hosts (thanks to Niranjan MR)
+
* Thu Feb 03 2016 Petr Viktorin <encukou at gmail.com> - 1.0-1
- Add error handling in config file handling (thanks to Abhijeet Kasurde)
- Add support to specify username/password per host (thanks to Niranjan MR)
diff --git a/setup.py b/setup.py
index a3d66ca..5c0b79f 100644
--- a/setup.py
+++ b/setup.py
@@ -11,7 +11,7 @@ with io.open('README.rst', 'rt', encoding='utf-8') as f:
setup_args = dict(
name = "pytest-multihost",
- version = "1.0",
+ version = "1.1",
description = "Utility for writing multi-host tests for pytest",
long_description = readme_contents,
url = "https://fedorahosted.org/python-pytest-multihost/",
commit 7eb346c0bf29b1fddfd962675258a3895fbc8300
Author: Niranjan MR <mrniranjan at fedoraproject.org>
Date: Tue Apr 12 17:18:10 2016 +0530
Add 'host_type', make it possible to use Windows hosts
Add global parameter windows_test_dir to specify test directory
for Windows
Windows hosts (WinHost) use this directory by default.
test_dir can now be set individually for each host.
Move run_command from Host class to BaseHost class
Add a "host_type" configuration option and Host attribute. This
is used to select the Host subclass. By default it can
be 'default' or 'windows' (but Config subclasses can define more).
Signed-off-by: Petr Viktorin <pviktroi at redhat.com>
diff --git a/pytest_multihost/config.py b/pytest_multihost/config.py
index 31045c2..197d7ad 100644
--- a/pytest_multihost/config.py
+++ b/pytest_multihost/config.py
@@ -45,6 +45,7 @@ class Config(object):
self.ssh_password = kwargs.get('ssh_password')
self.ssh_username = kwargs.get('ssh_username', 'root')
self.ipv6 = bool(kwargs.get('ipv6', False))
+ self.windows_test_dir = kwargs.get('windows_test_dir', '/home/Administrator')
if not self.ssh_password and not self.ssh_key_filename:
self.ssh_key_filename = '~/.ssh/id_rsa'
@@ -80,6 +81,8 @@ class Config(object):
dct['ssh_key_filename'] = dct.pop('root_ssh_key_filename')
if 'root_password' in dct:
dct['ssh_password'] = dct.pop('root_password')
+ if 'windows_test_dir' in dct:
+ dct['windows_test_dir'] = dct.pop('windows_test_dir')
all_init_args = set(init_args) | set(cls.extra_init_args)
extra_args = set(dct) - all_init_args
@@ -179,8 +182,16 @@ class Domain(object):
self.hosts = []
def get_host_class(self, host_dict):
- from pytest_multihost.host import Host
- return Host
+ host_type = host_dict.get('host_type', 'default')
+ return self.host_classes[host_type]
+
+ @property
+ def host_classes(self):
+ from pytest_multihost.host import Host, WinHost
+ return {
+ 'default': Host,
+ 'windows': WinHost,
+ }
@property
def roles(self):
diff --git a/pytest_multihost/host.py b/pytest_multihost/host.py
index e6c0db5..826372d 100644
--- a/pytest_multihost/host.py
+++ b/pytest_multihost/host.py
@@ -24,10 +24,13 @@ class BaseHost(object):
See README for an overview of the core classes.
"""
- transport_class = None
+ transport_class = transport.SSHTransport
+ command_prelude = ''
def __init__(self, domain, hostname, role, ip=None,
- external_hostname=None, username=None, password=None):
+ external_hostname=None, username=None, password=None,
+ test_dir=None, host_type=None):
+ self.host_type = host_type
self.domain = domain
self.role = str(role)
if username is None:
@@ -40,6 +43,10 @@ class BaseHost(object):
else:
self.ssh_key_filename = None
self.ssh_password = password
+ if test_dir is None:
+ self.test_dir = domain.config.test_dir
+ else:
+ self.test_dir = test_dir
shortname, dot, ext_domain = hostname.partition('.')
self.shortname = shortname
@@ -78,7 +85,7 @@ class BaseHost(object):
self.host_key = None
self.ssh_port = 22
- self.env_sh_path = os.path.join(domain.config.test_dir, 'env.sh')
+ self.env_sh_path = os.path.join(self.test_dir, 'env.sh')
self.log_collectors = []
@@ -118,20 +125,28 @@ class BaseHost(object):
username = dct.pop('username', None)
password = dct.pop('password', None)
+ host_type = dct.pop('host_type', 'default')
check_config_dict_empty(dct, 'host %s' % hostname)
- return cls(domain, hostname, role, ip, external_hostname,
- username, password)
+ return cls(domain, hostname, role,
+ ip=ip,
+ external_hostname=external_hostname,
+ username=username,
+ password=password,
+ host_type=host_type)
def to_dict(self):
"""Export info about this Host to a dict"""
- return {
+ result = {
'name': str(self.hostname),
'ip': self.ip,
'role': self.role,
'external_hostname': self.external_hostname,
}
+ if self.host_type != 'default':
+ result['host_type'] = self.host_type
+ return result
@property
def config(self):
@@ -204,28 +219,18 @@ class BaseHost(object):
does not exit with return code 0
:param cwd: The working directory for the command
"""
- raise NotImplementedError()
-
-
-class Host(BaseHost):
- """A Unix host"""
- transport_class = transport.SSHTransport
-
- def run_command(self, argv, set_env=True, stdin_text=None,
- log_stdout=True, raiseonerr=True,
- cwd=None):
- # This will give us a Bash shell
command = self.transport.start_shell(argv, log_stdout=log_stdout)
-
# Set working directory
if cwd is None:
- cwd = self.config.test_dir
+ cwd = self.test_dir
command.stdin.write('cd %s\n' % shell_quote(cwd))
# Set the environment
if set_env:
command.stdin.write('. %s\n' % shell_quote(self.env_sh_path))
- command.stdin.write('set -e\n')
+
+ if self.command_prelude:
+ command.stdin.write(self.command_prelude)
if isinstance(argv, basestring):
# Run a shell command given as a string
@@ -247,11 +252,17 @@ class Host(BaseHost):
return command
+class Host(BaseHost):
+ """A Unix host"""
+ command_prelude = 'set -e\n'
+
+
class WinHost(BaseHost):
"""
Representation of a remote Windows host.
-
- This is a stub; Windows hosts can't currently be interacted with.
"""
- pass
+ def __init__(self, domain, hostname, role, **kwargs):
+ # Set test_dir to the Windows directory, if not given explicitly
+ kwargs.setdefault('test_dir', domain.config.windows_test_dir)
+ super(WinHost, self).__init__(domain, hostname, role, **kwargs)
diff --git a/test_pytestmultihost/test_testconfig.py b/test_pytestmultihost/test_testconfig.py
index 8239a2c..b32fd38 100644
--- a/test_pytestmultihost/test_testconfig.py
+++ b/test_pytestmultihost/test_testconfig.py
@@ -116,7 +116,8 @@ class TestComplexConfig(CheckConfig):
dict(name='srv', ip='192.0.2.33', role='srv'),
]),
dict(name='adomain2.test', hosts=[
- dict(name='master.adomain2.test', ip='192.0.2.65'),
+ dict(name='master.adomain2.test', ip='192.0.2.65',
+ host_type='windows'),
]),
],
)
@@ -197,6 +198,7 @@ class TestComplexConfig(CheckConfig):
ip="192.0.2.65",
external_hostname="master.adomain2.test",
role="master",
+ host_type='windows',
),
],
),
@@ -228,3 +230,11 @@ class TestComplexConfig(CheckConfig):
ad_dom = conf.domains[1]
assert ad_dom.roles == ['srv']
assert ad_dom.extra_roles == ['srv']
+
+ assert conf.test_dir != conf.windows_test_dir
+
+ assert conf.domains[0].hosts[0].host_type == 'default'
+ assert conf.domains[0].hosts[0].test_dir == conf.test_dir
+
+ assert conf.domains[2].hosts[0].host_type == 'windows'
+ assert conf.domains[2].hosts[0].test_dir == conf.windows_test_dir
commit e97f3501df2d021ceb55c6ac106cedb7ff3b91e7
Author: Petr Viktorin <pviktori at redhat.com>
Date: Tue Mar 22 12:54:23 2016 +0100
Register as a Pytest plugin using the new PyPI Trove classifier
diff --git a/setup.py b/setup.py
index aceb2ce..a3d66ca 100644
--- a/setup.py
+++ b/setup.py
@@ -23,6 +23,7 @@ setup_args = dict(
'Development Status :: 4 - Beta',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Operating System :: POSIX',
+ 'Framework :: Pytest',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
More information about the Pkg-freeipa-devel
mailing list