def app(request):
    i = S2IDockerImage(image_name, tag=image_tag)
    app_name = os.path.basename(request.param)
    app = i.extend(request.param, app_name)
    yield app
    pass
    app.rmi()
Exemple #2
0
def test_usage():
    i = S2IDockerImage(image_name)
    c = i.run_via_binary()
    try:
        c.wait()
        logs = c.logs().decode("utf-8").strip()
        usage = i.usage()
        # FIXME: workaround: `docker logs` can't handle logs like these: '\n\n\n'
        assert logs.replace("\n", "") == usage.replace("\n", "")
    finally:
        c.delete()
Exemple #3
0
def test_s2i_extending(tmpdir):
    t = str(tmpdir)
    exec_path = os.path.join(t, "secret-executable")
    secret_message = "Can I have a cup of cocoa?"
    with open(exec_path, "w") as fd:
        fd.write("""\
        #!/bin/bash
        echo "%s"
        """ % secret_message)
    os.chmod(exec_path, 0o755)
    i = S2IDockerImage(S2I_IMAGE)
    ei = i.extend(t, "extended-punchbag")
    c = ei.run_via_binary()
    c.wait()
    assert c.logs_unicode() == secret_message + '\n'
    def test_usage(self):
        i = S2IDockerImage(image_name, tag=image_tag)
        c = i.run_via_binary()

        def logs_received():
            return len(list(c.logs())) > 0

        try:
            c.wait()
            # even after waiting there is still a race in journal logging driver
            Probe(timeout=10, pause=0.05, count=20, fnc=logs_received).run()
            logs = [x.decode("utf-8") for x in c.logs()]
            logs = "\n".join(logs).strip()
            usage = i.usage()
            # FIXME: workaround: `docker logs` can't handle logs like these: '\n\n\n'
            assert logs.replace("\n", "") == usage.replace("\n", "")
        finally:
            c.delete()
Exemple #5
0
def test_s2i_extending(app_path):
    i = S2IDockerImage(image_name)
    app_name = os.path.basename(app_path)
    app = i.extend(app_path, app_name)
    try:
        c = app.run_via_binary()
        try:
            c.wait_for_port(8080)
            assert c.is_port_open(8080)
            response = c.http_request("/", port="8080")
            assert response.ok
        finally:
            c.stop()
            c.wait()
            # debugging
            print(c.logs())
            c.delete()
    finally:
        app.rmi()
Exemple #6
0
def test_s2i_usage():
    i = S2IDockerImage(S2I_IMAGE)
    assert i.usage() == """\
Exemple #7
0
# -*- coding: utf-8 -*-
#
# Copyright Contributors to the Conu project.
# SPDX-License-Identifier: MIT
#

from conu import S2IDockerImage, DockerBackend

# to make sure that temporary directory is cleaned
with DockerBackend():
    source = 'https://github.com/dbarnett/python-helloworld'
    image = S2IDockerImage("centos/python-35-centos7")
    extended_image = image.extend(source, "myapp")
    container = image.run_via_binary()

    container.stop()
    container.delete()