From 66cb53df4ec0c8df5a577c4018951767af814d87 Mon Sep 17 00:00:00 2001 From: Uggla Date: Sat, 5 Mar 2016 18:54:34 +0100 Subject: [PATCH] Add tests to validate python-redfish is working with python3 - Update setuptools within dockerfiles to support requirements.txt syntax. - Check that tests can be run with Python2 and 3. --- redfish-client/tests/Dockerfile.debian | 3 +++ redfish-client/tests/Dockerfile.fedora | 1 - redfish-client/tests/Dockerfile.fedorap3 | 11 +++++++++++ redfish-client/tests/Dockerfile.fedorapip | 3 +-- redfish-client/tests/Dockerfile.ubuntu | 3 +++ redfish-client/tests/test_client.py | 16 ++++++++++------ redfish/__init__.py | 3 ++- 7 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 redfish-client/tests/Dockerfile.fedorap3 diff --git a/redfish-client/tests/Dockerfile.debian b/redfish-client/tests/Dockerfile.debian index bb09658..e5c01fc 100644 --- a/redfish-client/tests/Dockerfile.debian +++ b/redfish-client/tests/Dockerfile.debian @@ -6,6 +6,9 @@ apt-get install -y python-pip COPY python-redfish.src.tar.gz /python-redfish.src.tar.gz RUN mkdir /var/log/python-redfish RUN tar xvvf python-redfish.src.tar.gz +# Need a really recent version of setuptools to support +# configparser>=3.3.0; python_version < '3' in requirements.txt +RUN pip install --upgrade setuptools RUN cd python-redfish* && \ pip install -r requirements.txt && \ python setup.py install diff --git a/redfish-client/tests/Dockerfile.fedora b/redfish-client/tests/Dockerfile.fedora index 4770d9f..b28b8dd 100644 --- a/redfish-client/tests/Dockerfile.fedora +++ b/redfish-client/tests/Dockerfile.fedora @@ -1,6 +1,5 @@ FROM fedora:23 RUN dnf install -y python-pip && \ -dnf install -y git && \ dnf install -y tar COPY python-redfish.src.tar.gz /python-redfish.src.tar.gz RUN mkdir /var/log/python-redfish diff --git a/redfish-client/tests/Dockerfile.fedorap3 b/redfish-client/tests/Dockerfile.fedorap3 new file mode 100644 index 0000000..f2fbc89 --- /dev/null +++ b/redfish-client/tests/Dockerfile.fedorap3 @@ -0,0 +1,11 @@ +FROM fedora:23 +RUN dnf install -y python3-pip && \ +dnf install -y tar +COPY python-redfish.src.tar.gz /python-redfish.src.tar.gz +RUN mkdir /var/log/python-redfish +RUN tar xvvf python-redfish.src.tar.gz +RUN cd python-redfish* && \ +pip3 install -r requirements.txt && \ +python3 setup.py install +CMD ["/bin/bash"] + diff --git a/redfish-client/tests/Dockerfile.fedorapip b/redfish-client/tests/Dockerfile.fedorapip index dfb0cad..4d29b63 100644 --- a/redfish-client/tests/Dockerfile.fedorapip +++ b/redfish-client/tests/Dockerfile.fedorapip @@ -1,6 +1,5 @@ FROM fedora:23 -RUN dnf install -y python-pip && \ -dnf install -y git +RUN dnf install -y python-pip RUN mkdir /var/log/python-redfish RUN pip install python-redfish CMD ["/bin/bash"] diff --git a/redfish-client/tests/Dockerfile.ubuntu b/redfish-client/tests/Dockerfile.ubuntu index c77091c..1b9e542 100644 --- a/redfish-client/tests/Dockerfile.ubuntu +++ b/redfish-client/tests/Dockerfile.ubuntu @@ -6,6 +6,9 @@ apt-get install -y python-pip COPY python-redfish.src.tar.gz /python-redfish.src.tar.gz RUN mkdir /var/log/python-redfish RUN tar xvvf python-redfish.src.tar.gz +# Need a really recent version of setuptools to support +# configparser>=3.3.0; python_version < '3' in requirements.txt +RUN pip install --upgrade setuptools RUN cd python-redfish* && \ pip install -r requirements.txt && \ python setup.py install diff --git a/redfish-client/tests/test_client.py b/redfish-client/tests/test_client.py index 428bb1d..1f41752 100644 --- a/redfish-client/tests/test_client.py +++ b/redfish-client/tests/test_client.py @@ -37,7 +37,7 @@ class DockerTest(object): self.cli.wait(container=container.get('Id')) response = self.cli.logs(container=container.get('Id'), stdout=True) - return(response) + return(response.decode('utf8')) def test_dockersocket(): @@ -56,7 +56,7 @@ def test_docker(): def test_sources(): output = subprocess.check_output(["python", "setup.py", "sdist"]) - search = re.search(r"removing '(\S+)'", output) + search = re.search(r"removing '(\S+)'", str(output)) filename = Path('dist/' + search.group(1) + '.tar.gz') filename.copy('redfish-client/tests/python-redfish.src.tar.gz') assert Path('redfish-client/tests/python-redfish.src.tar.gz').isfile() @@ -64,20 +64,23 @@ def test_sources(): def test_dockerbuild(): docker = DockerTest() + # Warning : Image tag is derived from file name, do not use uppercase !!! dockerfiles = ('redfish-client/tests/Dockerfile.ubuntu', 'redfish-client/tests/Dockerfile.debian', 'redfish-client/tests/Dockerfile.fedora', + 'redfish-client/tests/Dockerfile.fedorap3', 'redfish-client/tests/Dockerfile.fedorapip') for dockerfile in dockerfiles: print('Testing : {}'.format(dockerfile)) response = docker.build(dockerfile) - status = response.pop() + status = str(response.pop()) assert 'Successfully built' in status def test_install(): docker = DockerTest() - images = ('rfubuntu', 'rfdebian', 'rffedora', 'rffedorapip') + images = ('rfubuntu', 'rfdebian', + 'rffedora', 'rffedorap3', 'rffedorapip') for img in images: print('Testing : {}'.format(img)) response = docker.run(img, 'redfish-client config showall') @@ -87,10 +90,11 @@ def test_install(): def test_versionformat(): docker = DockerTest() - images = ('rfubuntu', 'rfdebian', 'rffedora', 'rffedorapip') + images = ('rfubuntu', 'rfdebian', + 'rffedora', 'rffedorap3', 'rffedorapip') for img in images: print('Testing : {}'.format(img)) response = docker.run(img, 'redfish-client --version') print(response) - assert (re.match('redfish-client \d+\.\d+', response)) + assert (re.match(r'redfish-client \d+\.\d+', response)) diff --git a/redfish/__init__.py b/redfish/__init__.py index abe39c8..2b57f55 100644 --- a/redfish/__init__.py +++ b/redfish/__init__.py @@ -25,7 +25,8 @@ from redfish.main import * try: __version__ = pbr.version.VersionInfo('redfish').release_string() except Exception as e: - if "Versioning for this project requires either an sdist tarball" in e.message: + if "Versioning for this project requires either an sdist tarball" \ + in e.args[0]: pass else: raise