From 19416e321dcedcbdb7f004d2fafa56cab4d659d6 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Fri, 18 Jan 2019 18:40:43 +0100 Subject: [PATCH] Adding tests for CI Signed-off-by: Clement Verna --- tests/integration/runtest.sh | 3 +++ tests/integration/test_container.py | 34 +++++++++++++++++++++++++++++ tests/inventory | 2 ++ tests/tests.yml | 13 +++++++++++ 4 files changed, 52 insertions(+) create mode 100755 tests/integration/runtest.sh create mode 100644 tests/integration/test_container.py create mode 100644 tests/inventory create mode 100644 tests/tests.yml diff --git a/tests/integration/runtest.sh b/tests/integration/runtest.sh new file mode 100755 index 0000000..3a56327 --- /dev/null +++ b/tests/integration/runtest.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +pytest-3 -vv ./test_container.py diff --git a/tests/integration/test_container.py b/tests/integration/test_container.py new file mode 100644 index 0000000..8a7ebec --- /dev/null +++ b/tests/integration/test_container.py @@ -0,0 +1,34 @@ +#!/usr/bin/python3 + +import logging +import os + +import conu + +import pytest + + +IMAGE = os.environ.get("IMAGE_NAME", "registry.fedoraproject.org/fedora") +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) + container = im.run_via_binary(b) + yield container + container.stop() + container.delete() + + +class TestContainer: + def test_running(self, container): + assert container.is_running() + + def test_python3(self, container): + container.execute(["python3", "-V"]) + + +if __name__ == '__main__': + pytest.main() diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..df8b5f6 --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +[all] +localhost ansible_connection=local diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..bc0cd18 --- /dev/null +++ b/tests/tests.yml @@ -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