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 ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y apt-utils && \ 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 dnf install -y python-pip
RUN mkdir /var/log/python-redfish RUN mkdir /var/log/python-redfish
RUN pip install python-redfish RUN pip install python-redfish --pre
CMD ["/bin/bash"] CMD ["/bin/bash"]

View File

@ -1,4 +1,4 @@
FROM fedora:23 FROM fedora:25
RUN dnf install -y python-pip && \ RUN dnf install -y python-pip && \
dnf install -y tar dnf install -y tar
COPY python-redfish.src.tar.gz /python-redfish.src.tar.gz 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 && \ RUN dnf install -y python3-pip && \
dnf install -y tar dnf install -y tar
COPY python-redfish.src.tar.gz /python-redfish.src.tar.gz COPY python-redfish.src.tar.gz /python-redfish.src.tar.gz

View File

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

View File

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

View File

@ -5,7 +5,9 @@
pytest>=2.6.4 pytest>=2.6.4
coverage>=3.6 coverage>=3.6
mock>=1.0.1 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 path.py>=5.2
testrepository>=0.0.20 testrepository>=0.0.20
flake8<2.6.0,>=2.5.4 # MIT flake8<2.6.0,>=2.5.4 # MIT