~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to deploy_stack.py

  • Committer: Aaron Bentley
  • Date: 2014-09-15 21:01:58 UTC
  • mto: This revision was merged to the branch mainline in revision 660.
  • Revision ID: aaron.bentley@canonical.com-20140915210158-if3c9afbg0f9c305
Start testing mixed environs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
        sleep(1)
102
102
 
103
103
 
104
 
def deploy_dummy_stack(env, charm_prefix):
105
 
    """"Deploy a dummy stack in the specified environment.
106
 
    """
107
 
    allowed_chars = string.ascii_uppercase + string.digits
108
 
    token=''.join(random.choice(allowed_chars) for n in range(20))
109
 
    env.deploy(charm_prefix + 'dummy-source')
110
 
    env.juju('set', 'dummy-source', 'token=%s' % token)
111
 
    env.deploy(charm_prefix + 'dummy-sink')
112
 
    env.juju('add-relation', 'dummy-source', 'dummy-sink')
113
 
    env.juju('expose', 'dummy-sink')
114
 
    if env.kvm:
115
 
        # A single virtual machine may need up to 30 minutes before
116
 
        # "apt-get update" and other initialisation steps are
117
 
        # finished; two machines initializing concurrently may
118
 
        # need even 40 minutes.
119
 
        env.wait_for_started(3600)
120
 
    else:
121
 
        env.wait_for_started()
 
104
def check_token(env, token):
122
105
    # Wait up to 120 seconds for token to be created.
123
106
    # Utopic is slower, maybe because the devel series gets more
124
107
    # package updates.
152
135
    if result != token:
153
136
        raise ValueError('Token is %r' % result)
154
137
 
 
138
def get_random_string():
 
139
    allowed_chars = string.ascii_uppercase + string.digits
 
140
    return ''.join(random.choice(allowed_chars) for n in range(20))
 
141
 
 
142
 
 
143
def deploy_dummy_stack(env, charm_prefix):
 
144
    """"Deploy a dummy stack in the specified environment.
 
145
    """
 
146
    env.deploy(charm_prefix + 'dummy-source')
 
147
    token = get_random_string()
 
148
    env.juju('set', 'dummy-source', 'token=%s' % token)
 
149
    env.deploy(charm_prefix + 'dummy-sink')
 
150
    env.juju('add-relation', 'dummy-source', 'dummy-sink')
 
151
    env.juju('expose', 'dummy-sink')
 
152
    if env.kvm:
 
153
        # A single virtual machine may need up to 30 minutes before
 
154
        # "apt-get update" and other initialisation steps are
 
155
        # finished; two machines initializing concurrently may
 
156
        # need even 40 minutes.
 
157
        env.wait_for_started(3600)
 
158
    else:
 
159
        env.wait_for_started()
 
160
    check_token(env, token)
 
161
 
155
162
 
156
163
def dump_env_logs(env, bootstrap_host, directory, host_id=None):
157
164
    machine_addrs = get_machines_for_logs(env, bootstrap_host)