Re enable redfish-client tests

- Check if local docker is available, if not skip the tests.
  So this should allow gerrit tests to pass.
- Stick to docker-py 1.x, because 2.0 has lot of naming changes.
- Use Fedora 25 instead of 23.
- Use Ubuntu 16.04 instead of 14.04.
- Use pip --pre parameter. Allowing to test dev release (pre).
- Rename Dockerfiles to get more consistency using a new naming
  convention.
- Naming convention that I hope will make Bruno happy ! ;)

Change-Id: I3cbd51f201c4805ba58ebcabb023237624d4dfc8
This commit is contained in:
Uggla 2017-02-05 23:26:14 +01:00
parent 9d6ec64daf
commit edf25cb299
8 changed files with 52 additions and 26 deletions

View File

@ -1,4 +1,4 @@
FROM ubuntu:wily
FROM debian:8
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install -y apt-utils && \

View File

@ -1,6 +1,6 @@
FROM fedora:23
FROM fedora:25
RUN dnf install -y python-pip
RUN mkdir /var/log/python-redfish
RUN pip install python-redfish
RUN pip install python-redfish --pre
CMD ["/bin/bash"]

View File

@ -1,4 +1,4 @@
FROM fedora:23
FROM fedora:25
RUN dnf install -y python-pip && \
dnf install -y tar
COPY python-redfish.src.tar.gz /python-redfish.src.tar.gz

View File

@ -1,4 +1,4 @@
FROM fedora:23
FROM fedora:25
RUN dnf install -y python3-pip && \
dnf install -y tar
COPY python-redfish.src.tar.gz /python-redfish.src.tar.gz

View File

@ -10,6 +10,7 @@ import os
import stat
import subprocess
import re
import pytest
from docker import Client
from path import Path
standard_library.install_aliases()
@ -21,7 +22,7 @@ class DockerTest(object):
def build(self, dockerfile):
dockerfile = Path(dockerfile)
tag = 'rf' + dockerfile.basename().replace('Dockerfile.', '')
tag = 'rf-' + dockerfile.basename().replace('.dkf', '')
dockerfile.copy('redfish-client/tests/Dockerfile')
response = [line for line in self.cli.build(
path='redfish-client/tests',
@ -42,20 +43,31 @@ class DockerTest(object):
return(response.decode('utf8'))
def test_dockersocket():
mode = os.stat('/var/run/docker.sock').st_mode
def local_docker_available():
try:
mode = os.stat('/var/run/docker.sock').st_mode
except OSError:
return False
isSocket = stat.S_ISSOCK(mode)
assert isSocket, 'Make sure docker services are running'
if not isSocket:
print('Make sure docker services are running')
return False
def test_docker():
cli = Client(base_url='unix://var/run/docker.sock')
response = cli.containers()
assert isinstance(response, list), 'Ensure you have sufficiant' + \
'credentials to use docker with' + \
'your current user'
if not isinstance(response, list):
print('Ensure you have sufficiant' +
'credentials to use docker with' +
'your current user')
return False
return True
local_docker = pytest.mark.skipif(
not local_docker_available(), reason="Docker is not available locally")
@local_docker
def test_sources():
output = subprocess.check_output(["python", "setup.py", "sdist"])
search = re.search(r"removing '(\S+)'", str(output))
@ -64,15 +76,17 @@ def test_sources():
assert Path('redfish-client/tests/python-redfish.src.tar.gz').isfile()
@local_docker
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.centos',
'redfish-client/tests/Dockerfile.fedora',
'redfish-client/tests/Dockerfile.fedorap3',
'redfish-client/tests/Dockerfile.fedorapip')
# because docker image tags can not use uppercase so far.
dockerfiles = ('redfish-client/tests/ubuntu-16.04-src-p2.dkf',
'redfish-client/tests/debian-8-src-p2.dkf',
'redfish-client/tests/centos-7-src-p2.dkf',
'redfish-client/tests/fedora-25-src-p2.dkf',
'redfish-client/tests/fedora-25-src-p3.dkf',
'redfish-client/tests/fedora-25-pip-p2.dkf',)
for dockerfile in dockerfiles:
print('Testing : {}'.format(dockerfile))
response = docker.build(dockerfile)
@ -80,10 +94,15 @@ def test_dockerbuild():
assert 'Successfully built' in status
@local_docker
def test_install():
docker = DockerTest()
images = ('rfubuntu', 'rfdebian', 'rfcentos',
'rffedora', 'rffedorap3', 'rffedorapip')
images = ('rf-ubuntu-16.04-src-p2',
'rf-debian-8-src-p2',
'rf-centos-7-src-p2',
'rf-fedora-25-src-p2',
'rf-fedora-25-src-p3',
'rf-fedora-25-pip-p2')
for img in images:
print('Testing : {}'.format(img))
response = docker.run(img, 'redfish-client config showall')
@ -91,10 +110,15 @@ def test_install():
assert ('Managers configured' in response and 'None' in response)
@local_docker
def test_versionformat():
docker = DockerTest()
images = ('rfubuntu', 'rfdebian', 'rfcentos',
'rffedora', 'rffedorap3', 'rffedorapip')
images = ('rf-ubuntu-16.04-src-p2',
'rf-debian-8-src-p2',
'rf-centos-7-src-p2',
'rf-fedora-25-src-p2',
'rf-fedora-25-src-p3',
'rf-fedora-25-pip-p2')
for img in images:
print('Testing : {}'.format(img))
response = docker.run(img, 'redfish-client --version')

View File

@ -1,4 +1,4 @@
FROM debian:jessie
FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install -y apt-utils && \

View File

@ -5,7 +5,9 @@
pytest>=2.6.4
coverage>=3.6
mock>=1.0.1
docker-py>=1.1.0
# docker-py has a lot of naming changes coming with 2.0 so stick with 1.x
# the library 2.0 will be called docker instead of docker-py
docker-py>=1.8.1 # Apache-2.0
path.py>=5.2
testrepository>=0.0.20
flake8<2.6.0,>=2.5.4 # MIT