~benji/charms/precise/juju-gui/remove-default-view-mode-config

« back to all changes in this revision

Viewing changes to tests/deploy.py

  • Committer: Francesco Banconi
  • Date: 2013-11-28 17:58:28 UTC
  • mfrom: (139.2.4 ftests-bootstrap-node)
  • Revision ID: francesco.banconi@canonical.com-20131128175828-hey77fo5aqf1er7u
Deploy the GUI to machine 0 in functional tests.

Also added guiserver info checks, and fixed the
deploy module so that the previous behavior of
"make deploy" is restored and the resulting
service name is not random generated.

Removed test_local_release: that scenario is
already tested in TestBuiltinServerLocalRelease.

Moved test_nrpe_check_available to 
TestBuiltinServerLocalRelease.

Tests: assuming ec2 is the name of your ec2
environment, run the following:
`time make ftest JUJU_ENV="ec2"`
Tests should pass and take ~25-30 minutes.

R=gary.poster, matthew.scott, jeff.pihach
CC=
https://codereview.appspot.com/34130043

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
 
22
22
import json
 
23
import logging
23
24
import os
24
 
import random
25
 
import string
26
25
import tempfile
27
26
 
28
27
from charmhelpers import make_charm_config_file
53
52
    return repo
54
53
 
55
54
 
56
 
SERVICE_NAME_PREFIX = 'service-'
57
 
 
58
 
 
59
 
def make_service_name():
60
 
    """Generate a long, random service name."""
61
 
    characters = string.ascii_lowercase
62
 
    suffix = ''.join([random.choice(characters) for x in xrange(20)])
63
 
    return SERVICE_NAME_PREFIX + suffix
64
 
 
65
 
 
66
55
def juju_deploy(
67
 
        charm, options=None, force_machine=None, charm_source=None,
68
 
        series='precise'):
 
56
        charm_name, service_name=None, options=None, force_machine=None,
 
57
        charm_source=None, series='precise'):
69
58
    """Deploy and expose the charm. Return the first unit's public address.
70
59
 
71
60
    Also wait until the service is exposed and the first unit started.
 
61
 
 
62
    If service_name is None, use the name of the charm.
72
63
    If options are provided, they will be used when deploying the charm.
73
64
    If force_machine is not None, create the unit in the specified machine.
74
65
    If charm_source is None, dynamically retrieve the charm source directory.
75
66
    """
 
67
    # Note: this function is used by both the functional tests and
 
68
    # "make deploy": see the "if main" section below.
76
69
    if charm_source is None:
77
70
        # Dynamically retrieve the charm source based on the path of this file.
78
71
        charm_source = os.path.join(os.path.dirname(__file__), '..')
79
 
    repo = setup_repository(charm, charm_source, series=series)
 
72
    logging.debug('setting up the charms repository')
 
73
    repo = setup_repository(charm_name, charm_source, series=series)
80
74
    args = ['deploy', '--repository', repo]
81
 
    service_name = make_service_name()
 
75
    if service_name is None:
 
76
        service_name = charm_name
82
77
    if options is not None:
83
78
        config_file = make_charm_config_file({service_name: options})
84
79
        args.extend(['--config', config_file.name])
85
80
    if force_machine is not None:
86
81
        args.extend(['--to', str(force_machine)])
87
 
    args.append('local:{}/{}'.format(series, charm))
 
82
    charm_url = 'local:{}/{}'.format(series, charm_name)
 
83
    args.append(charm_url)
88
84
    args.append(service_name)
 
85
    logging.debug('deploying {} from the repository in {}'.format(
 
86
        charm_url, repo))
89
87
    juju(*args)
 
88
    logging.debug('exposing {}'.format(service_name))
90
89
    juju('expose', service_name)
91
 
    return wait_for_unit(service_name), service_name
 
90
    logging.debug('waiting for the unit to be ready')
 
91
    return wait_for_unit(service_name)
92
92
 
93
93
 
94
94
if __name__ == '__main__':
 
95
    logging.getLogger().setLevel(logging.DEBUG)
95
96
    unit = juju_deploy('juju-gui')
96
97
    print(json.dumps(unit, indent=2))