def parse_output(container_id):
    d = Docker()
    raw_logs = d.logs(container_id)

    run_output = raw_logs.splitlines()

    # The final 2 lines we care about have some specific strings
    # search for them and determine if it was actually a successful run

    # Time taken for tests: 27.048s
    # Time per container: 535.584ms [mean] | 1252.565ms [90th] | 2002.064ms [99th]  # noqa

    parsed = run_output[-1].replace('Time per container: ', '').split('|')

    mean = parsed[0].replace('ms [mean] ', '')
    ninety = parsed[1].replace('ms [90th] ', '')
    ninetynine = parsed[2].replace('ms [99th] ', '')

    total_parsed = run_output[-2].replace('Time taken for tests: ', '')
    total_time = total_parsed.replace('s', '')

    action_set("results.total-time", {'value': total_time, 'units': 's'})

    action_set("results.mean-time", {'value': mean, 'units': 'ms'})

    action_set("results.90th-percentile", {'value': ninety, 'units': 'ms'})

    action_set("results.99th-percentile", {'value': ninetynine, 'units': 'ms'})

    Benchmark.set_composite_score(total_time, 'sec', 'desc')
Пример #2
0
def run_ems():
    # authenticate to private docker repository
    d = Docker()
    cfg = config()
    d.login(cfg['distribution-user'], cfg['distribution-pass'],
            cfg['distribution-email'])

    # Render the template
    render('docker-compose.yml', 'files/ems/docker-compose.yml', cfg)

    comp = Compose('files/ems')
    comp.up()
Пример #3
0
    def healthcheck(self):
        """
        Healthcheck is used to poll the Docker health state. A health test
        command need to be specified in the Compose manifest or in the
        Dockerfile.

        If the Docker container is not healthy a
        :class:`DockerComponentUnhealthy` is raised. If not, the container is
        currently considered healthy by the test command.

        :raises DockerComponentUnhealthy: The containers healthcheck failed
        :raises DockerComponentStarting: The container is starting up
        """
        hookenv.log("Healthchecking {}".format(self.name), level=hookenv.DEBUG)

        health = Docker().healthcheck(self.name, verbose=True)

        if not health:
            raise DockerComponentUnhealthy(self)

        if health["Status"] == "starting":
            raise DockerComponentStarting(self)

        if health["Status"] != "healthy":
            raise DockerComponentUnhealthy(self)
Пример #4
0
def dockerhost_connected(dockerhost):
    """
    Transmits the docker url to any subordinates requiring it.

    :return: None
    """
    dockerhost.configure(Docker().socket)
Пример #5
0
def publish_config():
    endpoint = endpoint_from_flag("endpoint.docker.joined")
    endpoint.set_config(
        socket=Docker().socket,
        runtime="docker",
        nvidia_enabled=is_state("nvidia-docker.supported"),
    )
def parse_output(container_id):
    d = Docker()
    raw_logs = d.logs(container_id)

    run_output = raw_logs.splitlines()

    # The final 2 lines we care about have some specific strings
    # search for them and determine if it was actually a successful run

    # Time taken for tests: 27.048s
    # Time per container: 535.584ms [mean] | 1252.565ms [90th] | 2002.064ms [99th]  # noqa

    parsed = run_output[-1].replace('Time per container: ', '').split('|')

    mean = parsed[0].replace('ms [mean] ', '')
    ninety = parsed[1].replace('ms [90th] ', '')
    ninetynine = parsed[2].replace('ms [99th] ', '')

    total_parsed = run_output[-2].replace('Time taken for tests: ', '')
    total_time = total_parsed.replace('s', '')

    action_set(
        "results.total-time",
        {'value': total_time, 'units': 's'}
    )

    action_set(
        "results.mean-time",
        {'value': mean, 'units': 'ms'}
    )

    action_set(
        "results.90th-percentile",
        {'value': ninety, 'units': 'ms'}
    )

    action_set(
        "results.99th-percentile",
        {'value': ninetynine, 'units': 'ms'}
    )

    Benchmark.set_composite_score(
        total_time,
        'sec',
        'desc'
    )
Пример #7
0
def publish_config():
    endpoint = endpoint_from_flag('endpoint.docker.joined')
    endpoint.set_config(socket=Docker().socket,
                        runtime='docker',
                        nvidia_enabled=is_state('nvidia-docker.supported'))
Пример #8
0
def dockerhost_connected(dockerhost):
    '''Transmits the docker url to any subordinates requiring it'''
    dockerhost.configure(Docker().socket)
Пример #9
0
def logspout_to_the_rescue():
    status_set('maintenance', 'Pulling logspout container image')
    d = Docker()
    d.pull(config('container-image'))
    set_state('logstash.pulled')
    status_set('waiting', 'Logspout image pulled')
Пример #10
0
 def docker(self):
     return Docker()
Пример #11
0
 def test_docker_init_workspace(self):
     devel = Docker(workspace="files/tmp")
     assert "{}".format(devel.workspace) == "files/tmp"
Пример #12
0
 def test_docker_init_socket(self):
     docker = Docker(socket="tcp://127.0.0.1:2357")
     assert docker.socket == "tcp://127.0.0.1:2357"
Пример #13
0
 def bootstrap(self):
     return Docker(socket="unix:///var/run/docker-bootstrap.sock")