~viswesn/juju-ci-tools/aws_boto3

« back to all changes in this revision

Viewing changes to assess_multimodel.py

  • Committer: Curtis Hovey
  • Date: 2017-01-25 02:32:29 UTC
  • mfrom: (1855 trunk)
  • mto: This revision was merged to the branch mainline in revision 1865.
  • Revision ID: curtis@canonical.com-20170125023229-g7c6bzt0cqe1j8g3
Merged trunk and resolved conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
 
2
"""Assess multimodel support."""
2
3
 
3
4
from argparse import ArgumentParser
4
5
from contextlib import contextmanager
22
23
    add_basic_testing_arguments,
23
24
    ensure_dir,
24
25
    print_now,
25
 
)
26
 
 
27
 
 
28
 
def test_jes_deploy(client, charm_series, log_dir, base_env):
 
26
    )
 
27
 
 
28
 
 
29
def assess_multimodel_deploy(client, charm_series, log_dir, base_env):
29
30
    """Deploy the dummy stack in two hosted environments."""
30
31
    # deploy into system env
31
32
    deploy_dummy_stack(client, charm_series)
41
42
            check_services(env2_client)
42
43
 
43
44
 
 
45
def assess_destroy_current(client):
 
46
    model_name = client.model_name
 
47
    new_model = client.add_model('delete-me')
 
48
    new_model.switch('delete-me')
 
49
    new_model.destroy_model()
 
50
    new_model.show_controller()
 
51
    client.switch(model_name)
 
52
 
 
53
 
44
54
@contextmanager
45
 
def jes_setup(args):
 
55
def multimodel_setup(args):
46
56
    """
47
57
    Sets up the juju client and its environment.
48
58
 
81
91
@contextmanager
82
92
def hosted_environment(system_client, log_dir, suffix):
83
93
    env_name = '{}-{}'.format(system_client.env.environment, suffix)
84
 
    client = system_client.add_model(system_client.env.clone(env_name))
 
94
    client = system_client.add_model(env_name)
85
95
    try:
86
96
        yield client
87
97
    except:
104
114
    check_token(client, token)
105
115
 
106
116
 
107
 
def main():
 
117
def parse_args(argv=None):
 
118
    """Parse all arguments."""
108
119
    parser = ArgumentParser()
109
120
    add_basic_testing_arguments(parser, using_jes=True, deadline=True)
110
 
    args = parser.parse_args()
111
 
    with jes_setup(args) as (client, charm_series, base_env):
112
 
        test_jes_deploy(client, charm_series, args.logs, base_env)
 
121
    return parser.parse_args(argv)
 
122
 
 
123
 
 
124
def main():
 
125
    args = parse_args()
 
126
    with multimodel_setup(args) as (client, charm_series, base_env):
 
127
        assess_multimodel_deploy(client, charm_series, args.logs, base_env)
 
128
        assess_destroy_current(client)
113
129
 
114
130
 
115
131
if __name__ == '__main__':