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.
This commit is contained in:
Uggla 2016-03-05 18:54:34 +01:00
parent d09a63a4c6
commit 66cb53df4e
7 changed files with 30 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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"]

View File

@ -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"]

View File

@ -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

View File

@ -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))

View File

@ -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