Add a support for Fedora CI tests
Signed-off-by: Clement Verna <cverna@tutanota.com>
This commit is contained in:
parent
45869ebb41
commit
1d5be706eb
4 changed files with 97 additions and 0 deletions
3
tests/integration/runtest.sh
Normal file
3
tests/integration/runtest.sh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
pytest-3 -vv ./test_container.py
|
||||
79
tests/integration/test_container.py
Normal file
79
tests/integration/test_container.py
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
import conu
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
IMAGE = os.environ.get("IMAGE_NAME", "registry.fedoraproject.org/f27/tools")
|
||||
TAG = os.environ.get("IMAGE_TAG", "latest")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def container(request):
|
||||
with conu.DockerBackend(logging_level=logging.DEBUG) as backend:
|
||||
im = backend.ImageClass(IMAGE, tag=TAG)
|
||||
b = conu.DockerRunBuilder(command=["sleep", "infinity"])
|
||||
b.options += [
|
||||
"--net", "host",
|
||||
"--pid=host",
|
||||
"--ipc", "host",
|
||||
"-it",
|
||||
"--privileged",
|
||||
"-v", "/run:/run",
|
||||
"-v", "/:/host",
|
||||
"-v", "/var/log:/var/log",
|
||||
]
|
||||
machine_id_path = "/etc/machine-id"
|
||||
if os.path.exists(machine_id_path):
|
||||
b.options += [
|
||||
"-v", "%s:%s" % (machine_id_path, machine_id_path)
|
||||
]
|
||||
localtime_path = "/etc/localtime"
|
||||
if os.path.exists(localtime_path):
|
||||
b.options += [
|
||||
"-v", "%s:%s" % (localtime_path, localtime_path)
|
||||
]
|
||||
container = im.run_via_binary(b)
|
||||
yield container
|
||||
container.stop()
|
||||
container.delete()
|
||||
|
||||
|
||||
class TestContainer:
|
||||
def test_ethtool(self, container):
|
||||
# with self.container.mount() as fs:
|
||||
# networks_devices = os.listdir(fs.p("/sys/class/net"))
|
||||
networks_devices = ["lo"]
|
||||
for device in networks_devices:
|
||||
container.execute(["ethtool", device])
|
||||
with pytest.raises(conu.ConuException):
|
||||
container.execute(["ethtool", "quantum-teleport"])
|
||||
|
||||
def test_netstat(self, container):
|
||||
container.execute(["netstat"])
|
||||
|
||||
def test_ss(self, container):
|
||||
container.execute(["ss"])
|
||||
|
||||
def test_pstack(self, container):
|
||||
container.execute(["pstack", "1"])
|
||||
|
||||
def test_nstat(self, container):
|
||||
container.execute(["nstat"])
|
||||
|
||||
def test_numastat(self, container):
|
||||
container.execute(["numastat"])
|
||||
|
||||
def test_pmap(self, container):
|
||||
container.execute(["pmap", "1"])
|
||||
|
||||
def test_strace(self, container):
|
||||
container.execute(["strace", "-V"])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pytest.main()
|
||||
2
tests/inventory
Normal file
2
tests/inventory
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[all]
|
||||
localhost ansible_connection=local
|
||||
13
tests/tests.yml
Normal file
13
tests/tests.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
- hosts: localhost
|
||||
roles:
|
||||
- role: standard-test-basic
|
||||
tags:
|
||||
- container
|
||||
tests:
|
||||
- integration
|
||||
required_packages:
|
||||
- python3-conu
|
||||
- python3-pytest
|
||||
- docker
|
||||
required_services:
|
||||
- docker
|
||||
Loading…
Add table
Add a link
Reference in a new issue